def __init__(self, options): self.dumpXmlPath = os.path.abspath(options.dumpXml) self.hostBuildDir = os.path.abspath(options.hostBuildDir) self.hostStagingDir = os.path.abspath(options.hostStagingDir) self.buildDir = os.path.abspath(options.buildDir) self.stagingDir = os.path.abspath(options.stagingDir) outDirOrArchive = os.path.abspath(options.outDirOrArchive) if outDirOrArchive.endswith(".tar.gz"): self.tarFile = tarfile.open(outDirOrArchive, "w:gz") self.outDir = "sdk" elif outDirOrArchive.endswith(".tar.bz2"): self.tarFile = tarfile.open(outDirOrArchive, "w:bz2") self.outDir = "sdk" elif outDirOrArchive.endswith(".tar"): self.tarFile = tarfile.open(outDirOrArchive, "w") self.outDir = "sdk" else: self.tarFile = None self.outDir = outDirOrArchive self.sdkDirs = [] self.headerLibs = [] self.files = {} # Load modules from xml logging.info("Loading xml '%s'", self.dumpXmlPath) try: self.moduledb = moduledb.loadXml(self.dumpXmlPath) except xml.parsers.expat.ExpatError as ex: sys.stderr.write("Error while loading '%s':\n" % self.dumpXmlPath) sys.stderr.write(" %s\n" % ex) sys.exit(1) self.atom = StringIO() self.atom.write("# GENERATED FILE, DO NOT EDIT\n\n") self.atom.write("LOCAL_PATH := $(call my-dir)\n\n") self.setup = StringIO() self.setup.write("# GENERATED FILE, DO NOT EDIT\n\n") self.setup.write("LOCAL_PATH := $(call my-dir)\n\n") if "OS_FLAVOUR" in self.moduledb.targetVars and \ self.moduledb.targetVars["OS_FLAVOUR"] == "android": self.android = StringIO() self.android.write("# GENERATED FILE, DO NOT EDIT\n\n") self.android.write("LOCAL_PATH := $(call my-dir)\n\n") else: self.android = None
def main(): (options, args) = parseArgs() # Load modules from xml try: modules = moduledb.loadXml(args[0]) except xml.parsers.expat.ExpatError as ex: sys.stderr.write("Error while loading '%s':\n" % args[0]) sys.stderr.write(" %s\n" % ex) sys.exit(1) for name in args[1:]: if name not in modules: sys.stderr.write("Error module '%s' not found:\n" % name) else: Project(name, modules, options).generate(options)
def main(): options = parseArgs() # -f imply -d if options.linkdeps_full: options.linkdeps = True # Load modules from xml try: modules = moduledb.loadXml(options.dumpXml) except xml.parsers.expat.ExpatError as ex: sys.stderr.write("Error while loading '%s':\n" % options.dumpXml) sys.stderr.write(" %s\n" % ex) sys.exit(1) for name in options.modules: if name not in modules: sys.stderr.write("Error module '%s' not found:\n" % name) else: Project(name, modules, options).generate(options)
def main(): (options, args) = parseArgs() # Load modules from xml try: modules = moduledb.loadXml(args[0]) except xml.parsers.expat.ExpatError as ex: sys.stderr.write("Error while loading '%s':\n" % args[0]) sys.stderr.write(" %s\n" % ex) sys.exit(1) for name in args[1:]: if os.path.exists(name): for module in modules: if os.path.abspath(module.fields["PATH"]) == os.path.abspath(name): if module.build: Project(module.name, modules, options).generate(options) elif name not in modules: sys.stderr.write("Error module '%s' not found:\n" % name) else: Project(name, modules, options).generate(options)
def main(): (options, args) = parseArgs() setupLog(options) # Extract arguments ctx = Context(args) # Load modules from xml logging.info("Loading xml '%s'", ctx.dumpXmlPath) try: ctx.moduledb = moduledb.loadXml(ctx.dumpXmlPath) except xml.parsers.expat.ExpatError as ex: sys.stderr.write("Error while loading '%s':\n" % ctx.dumpXmlPath) sys.stderr.write(" %s\n" % ex) sys.exit(1) # List of previous sdk to merge with the new one ctx.sdkDirs = ctx.moduledb.targetVars.get("SDK_DIRS", "").split() # Setup output directory logging.info("Initializing output directory '%s'", ctx.outDir) if os.path.exists(ctx.outDir): shutil.rmtree(ctx.outDir) os.makedirs(ctx.outDir, mode=0755) # Copy content of host staging directory if os.path.exists(ctx.hostStagingDir): logging.info("Copying host staging directory") copyHostStaging(ctx.hostStagingDir, os.path.join(ctx.outDir, "host")) # Copy content of staging directory logging.info("Copying staging directory") copyStaging(ctx.stagingDir, ctx.outDir) # Copy content of previous sdk for srcDir in ctx.sdkDirs: copySdk(srcDir, ctx.outDir) # Add some TARGET_XXX variables checks to make sure that the sdk is used # in the correct environment target_elements = [ "OS", "OS_FLAVOUR", "ARCH", "CPU", "CROSS", "LIBC", "DEFAULT_ARM_MODE" ] for element_to_check in target_elements: checkTargetVar(ctx, element_to_check) # Save initial TARGET_SETUP_XXX variables as TARGET_XXX for var in ctx.moduledb.targetSetupVars.keys(): writeTargetSetupVars(ctx, var) # Process modules for module in ctx.moduledb: processModule(ctx, module) # Process modules not built but whose headers are required for lib in ctx.headerLibs: processModule(ctx, ctx.moduledb[lib], headersOnly=True) # Check symlinks checkSymlinks(ctx.outDir) # Process custom macros for macro in ctx.moduledb.customMacros.values(): ctx.atom.write("define %s\n" % macro.name) ctx.atom.write(macro.value) ctx.atom.write("\nendef\n") ctx.atom.write("$(call local-register-custom-macro,%s)\n" % macro.name) # Write the atom.mk with open(os.path.join(ctx.outDir, "atom.mk"), "w") as atomFile: atomFile.write("# GENERATED FILE, DO NOT EDIT\n\n") atomFile.write("LOCAL_PATH := $(call my-dir)\n\n") atomFile.write(ctx.atom.getvalue()) # Write the setup.mk with open(os.path.join(ctx.outDir, "setup.mk"), "w") as setupFile: setupFile.write("# GENERATED FILE, DO NOT EDIT\n\n") setupFile.write("LOCAL_PATH := $(call my-dir)\n\n") setupFile.write(ctx.setup.getvalue()) setupFile.write("\n")
def main(): # Load project specific packages for kind in _PROJECT_KINDS: _PROJECT_KINDS[kind] = importlib.import_module(kind) # Parse arguments options = parse_args() setup_log() # Load module db from xml try: db = moduledb.loadXml(options.dump_xml) except (OSError, xml.parsers.expat.ExpatError) as ex: logging.error("Error while loading '%s': %s", options.dump_xml, str(ex)) sys.exit(1) # Construct the list of modules to generate modules = [] for module_or_dir in options.modules_or_dirs: if os.path.exists(module_or_dir): dir_path = os.path.abspath(module_or_dir) for module in db.keys(): module_path = os.path.abspath(db[module].fields["PATH"]) if dir_path == module_path: if module not in modules: modules.append(module) elif options.recursive and module_path.startswith(dir_path + os.path.sep): if module not in modules: modules.append(module) elif module_or_dir in db: if module_or_dir not in modules: modules.append(module_or_dir) else: logging.error("Unknown module or directory: '%s'", module_or_dir) sys.exit(1) if len(modules) == 0: logging.warning("No module found") sys.exit(1) # Construct the list of projects to generate projects = [] if options.merge: # Use first module for name and path if none given explicitly if not options.name: options.name = modules[0] logging.warning("Using '%s' for project name", options.name) if not options.outdirpath: options.outdirpath = os.path.abspath(db[modules[0]].fields["PATH"]) logging.warning("Using '%s' for project output", options.outdirpath) projects.append(Project(options.name, modules, db, options.outdirpath, options)) else: if len(modules) > 1 and options.name: logging.warning("Ignoring name option '%s' " "when generating several projects", options.name) options.name = None if len(modules) > 1 and options.outdirpath: logging.warning("Ignoring output option '%s' " "when generating several projects", options.outdirpath) options.outdirpath = None for module in modules: name = options.name or module outdirpath = options.outdirpath or os.path.abspath(db[module].fields["PATH"]) projects.append(Project(name, modules, db, outdirpath, options)) for project in projects: if not os.path.exists(project.outdirpath): logging.error("%s: output directory '%s' does not exists", project.name, project.outdirpath) else: _PROJECT_KINDS[options.kind].generate(project)