1 def mono_find_provides_and_requires(files, d):
5 import bb, os, commands
7 pathprefix = "export PATH=%s; export LANG=; export LC_ALL=; " % bb.data.getVar('PATH', d, 1)
9 if not filename.endswith(".dll") and not filename.endswith(".exe"):
11 if not os.path.isfile(filename) or os.path.islink(filename):
15 name, version = None, None
17 ret, result = commands.getstatusoutput("%smonodis --assembly '%s'" % (pathprefix, filename))
19 bb.error("raw_provides_and_requires: monodis --assembly '%s' failed, dependency information will be inaccurate" % filename)
21 for line in result.splitlines():
22 if not ":" in line: continue
23 key, value = line.split(":", 1)
24 if key.strip() == "Name":
26 elif key.strip() == "Version":
27 version = value.strip()
28 if name is not None and version is not None:
29 if (name, version) not in provides:
30 provides.append( (name, version) )
33 name, version = None, None
34 ret, result = commands.getstatusoutput("%smonodis --assemblyref '%s'" % (pathprefix, filename))
36 bb.error("raw_provides_and_requires: monodis --assemblyref '%s' failed, dependency information will be inaccurate" % filename)
38 for line in result.splitlines():
39 if not "=" in line: continue
40 key, value = line.split("=", 1)
41 if ":" in key and key.split(":",1)[1].strip() == "Version":
42 version = value.strip()
43 elif key.strip() == "Name":
45 if name is not None and version is not None:
46 if (name, version) not in requires:
47 requires.append( (name, version) )
48 name, version = None, None
50 # Remove everything from requires that's already in provides as it's not actually required
51 # to be provided externally
52 requires = [e for e in requires if not e in provides]
53 return provides, requires
55 CLILIBSDIR = "${STAGING_DIR_HOST}/clilibs"
57 python mono_do_clilibs() {
58 import bb, os, re, os.path
60 exclude_clilibs = bb.data.getVar('EXCLUDE_FROM_CLILIBS', d, 0)
62 bb.note("not generating clilibs")
65 lib_re = re.compile("^lib.*\.so")
66 libdir_re = re.compile(".*/lib$")
68 packages = bb.data.getVar('PACKAGES', d, 1)
70 workdir = bb.data.getVar('WORKDIR', d, 1)
72 bb.error("WORKDIR not defined")
75 pkgdest = bb.data.getVar('PKGDEST', d, 1)
77 clilibs_dir = bb.data.getVar('CLILIBSDIR', d, 1)
78 bb.mkdirhier(clilibs_dir)
80 provides, requires = {}, {}
81 private_libs = bb.data.getVar('PRIVATE_CLILIBS', d, 1)
82 for pkg in packages.split():
83 bb.debug(2, "calculating clilib provides for %s" % pkg)
86 top = os.path.join(pkgdest, pkg)
87 for root, dirs, files in os.walk(top):
89 path = os.path.join(root, file)
90 if file.endswith(".exe") or file.endswith(".dll"):
91 files_to_check.append( path )
92 provides[pkg], requires[pkg] = mono_find_provides_and_requires(files_to_check, d)
93 clilibs_file = os.path.join(clilibs_dir, pkg + ".list")
94 if os.path.exists(clilibs_file):
95 os.remove(clilibs_file)
96 if len(provides[pkg]) > 0:
97 fd = open(clilibs_file, 'w')
98 for s in provides[pkg]:
99 fd.write(" ".join(s) + '\n')
103 list_re = re.compile('^(.*)\.list$')
104 for file in os.listdir(clilibs_dir):
105 m = list_re.match(file)
108 fd = open(os.path.join(clilibs_dir, file))
109 lines = fd.readlines()
112 clilib_provider[tuple(l.rstrip().split())] = dep_pkg
114 for pkg in packages.split():
115 bb.debug(2, "calculating clilib requirements for %s" % pkg)
118 for n in requires[pkg]:
119 if n in clilib_provider.keys():
120 dep_pkg = clilib_provider[n]
125 if not dep_pkg in deps:
128 bb.note("Couldn't find CLI library provider for %s" % (n,))
130 deps_file = os.path.join(pkgdest, pkg + ".clilibdeps")
131 if os.path.exists(deps_file):
134 fd = open(deps_file, 'w')
141 if [ "${INHIBIT_MONO_STAGE}" = "1" ]
146 for package in ${PACKAGES}; do
147 if [ -d "${PKGDEST}/${package}/${libdir}" ]; then
148 cd "${PKGDEST}/${package}/${libdir}"
149 for file in `find . -iname "*.dll"`; do
150 cp --parent -fpPR "${file}" "${STAGING_LIBDIR}/"
155 addtask mono_stage after do_package before do_populate_sysroot
157 def mono_after_parse(d):
159 # Insert mono_do_clilibs into PACKAGEFUNCS
160 # Needs to be called after populate_packages, but before read_shlibdeps
161 PACKAGEFUNCS = bb.data.getVar("PACKAGEFUNCS", d, 1)
163 PACKAGEFUNCS = PACKAGEFUNCS.split()
164 if "read_shlibdeps" in PACKAGEFUNCS:
165 i = PACKAGEFUNCS.index("read_shlibdeps")
166 PACKAGEFUNCS.insert(i, "mono_do_clilibs")
167 elif "populate_packages" in PACKAGEFUNCS:
168 i = PACKAGEFUNCS.index("populate_packages")
169 PACKAGEFUNCS.insert(i+1, "mono_do_clilibs")
170 bb.data.setVar("PACKAGEFUNCS", " ".join(PACKAGEFUNCS), d)