def buildComponent(component, componentDir=None): """ Build the component. Return a pair of paths (pathToBinary, pathToXPTFile)""" logger = build_util.getLogger('build_components') # Save current working directory to set it back later prevDir = os.getcwd() # Component Directory if componentDir is None: componentDir = os.path.join(Settings.prefs.src_dir, "components", component) os.chdir(componentDir) logger.info("Making build and bin dirs for component %s"%component) buildDir = os.path.join(componentDir, "build") binDir = os.path.join(componentDir, "bin") for dir in [buildDir, binDir]: try: os.mkdir(dir) except OSError, err: if err.errno == errno.EEXIST: logger.warning("Couldn't make %s because it exists."%dir) logger.warning("Deleting %s"%dir) shutil.rmtree(dir) logger.warning("Trying to make %s again"%dir) os.mkdir(dir) else: raise
def buildInstaller(): """ Build the installer""" logger = build_util.getLogger('build_Installer') makensis = os.path.normpath(Settings.config.get("env","NSIS")) nsi_file = os.path.normpath(os.path.join(module_path, "installer", "kylo.nsi")) version = build_util.VersionFormat() nsis_defs = { "APP_DIR": Settings.prefs.kylo_build_dir, "BUILD_ID": Settings.config.get("App", "BuildID"), "WIN_VERSION": version.win, "FULL_VERSION": version.full, "FILENAME_VERSION": version.full.replace(".","_"), "VERSION_MAJOR": version.ints[0], "VERSION_MINOR": version.ints[1], "DISPLAY_VERSION": version.display, "OUT_FILE_DIR": Settings.prefs.dist_dir, "LOCALE": "en-US", } # Create dist_dir if it doesn't exist if not os.path.exists(Settings.prefs.dist_dir): logger.info("Creating dist directory: %s", Settings.prefs.dist_dir) os.makedirs(Settings.prefs.dist_dir) args= [makensis] + ["/D%s=%s" % (k,v) for (k,v) in nsis_defs.iteritems()] + [nsi_file] logger.debug("Running: **" + " ".join(args)) build_util.runSubprocess(args, logger)
def buildInstaller(): """ Build the installer""" logger = build_util.getLogger('build_Installer') makensis = os.path.normpath(Settings.config.get("env", "NSIS")) nsi_file = os.path.normpath( os.path.join(module_path, "installer", "kylo.nsi")) version = build_util.VersionFormat() locale = "en-US" filename_version = version.full.replace(".", "_") if locale == "en-US": exe_name = "kylo-setup-%s.exe" % filename_version else: exe_name = "kylo-setup-%s-%s.exe" % (locale, filename_version) installer_exe = os.path.normpath( os.path.join(Settings.prefs.dist_dir, exe_name)) nsis_defs = { "APP_DIR": Settings.prefs.kylo_build_dir, "BUILD_ID": Settings.config.get("App", "BuildID"), "WIN_VERSION": version.win, "FULL_VERSION": version.full, "VERSION_MAJOR": version.ints[0], "VERSION_MINOR": version.ints[1], "DISPLAY_VERSION": version.display, "OUT_FILE_NAME": installer_exe, "LOCALE": locale } # Create dist_dir if it doesn't exist if not os.path.exists(Settings.prefs.dist_dir): logger.info("Creating dist directory: %s", Settings.prefs.dist_dir) os.makedirs(Settings.prefs.dist_dir) args = [makensis ] + ["/D%s=%s" % (k, v) for (k, v) in nsis_defs.iteritems()] + [nsi_file] logger.debug("Running: **" + " ".join(args)) build_util.runSubprocess(args, logger) assert os.path.exists(installer_exe), "Installer not at expected location" logger.info("Attempt to sign installer...") build_util.signExe(installer_exe, logger)
def buildInstaller(): """ Build the installer""" logger = build_util.getLogger('build_Installer') makensis = os.path.normpath(Settings.config.get("env","NSIS")) nsi_file = os.path.normpath(os.path.join(module_path, "installer", "kylo.nsi")) version = build_util.VersionFormat() locale = "en-US" filename_version = version.full.replace(".","_") if locale == "en-US": exe_name = "kylo-setup-%s.exe" % filename_version else: exe_name = "kylo-setup-%s-%s.exe" % (locale, filename_version) installer_exe = os.path.normpath(os.path.join(Settings.prefs.dist_dir, exe_name)) nsis_defs = { "APP_DIR": Settings.prefs.kylo_build_dir, "BUILD_ID": Settings.config.get("App", "BuildID"), "WIN_VERSION": version.win, "FULL_VERSION": version.full, "VERSION_MAJOR": version.ints[0], "VERSION_MINOR": version.ints[1], "DISPLAY_VERSION": version.display, "OUT_FILE_NAME": installer_exe, "LOCALE": locale } # Create dist_dir if it doesn't exist if not os.path.exists(Settings.prefs.dist_dir): logger.info("Creating dist directory: %s", Settings.prefs.dist_dir) os.makedirs(Settings.prefs.dist_dir) args= [makensis] + ["/D%s=%s" % (k,v) for (k,v) in nsis_defs.iteritems()] + [nsi_file] logger.debug("Running: **" + " ".join(args)) build_util.runSubprocess(args, logger) assert os.path.exists(installer_exe), "Installer not at expected location" logger.info("Attempt to sign installer...") build_util.signExe(installer_exe, logger)
def cleanComponent(component, componentDir=None): logger = build_util.getLogger('build_components') logger.info("Cleaning component %s"%component) if componentDir is None: componentDir = os.path.join(Settings.prefs.src_dir, "components", component) buildDir = os.path.join(componentDir, "build") binDir = os.path.join(componentDir, "bin") # Delete the xpt and auto-gen header and cmake header rule file for ext in ['xpt', 'h', 'h.rule']: delPath = os.path.join(componentDir, 'I%s.%s'%(component, ext)) logger.info("Removing %s"%delPath) try: os.remove(delPath) except OSError, err: if err.errno != errno.ENOENT: raise
def getLogger(): global _logger if _logger is None: _logger = build_util.getLogger("build_kylo") return _logger
def init(args=None): usage = "Build The Kylo Browser.\n"\ "\tusage: %prog [options] configfile [configfile [configfile...]]" parser = OptionParser(usage=usage) # Log defaults parser.set_defaults(verbosity="info") parser.set_defaults(logfile=None) # Clean defaults parser.set_defaults(clean=False) parser.set_defaults(clean_dist=False) # Build defaults parser.set_defaults(update=True) parser.set_defaults(omnify=True) parser.set_defaults(compile=[]) parser.set_defaults(buildapp=False) parser.set_defaults(installer=False) # Path defaults ROOT_DIR = os.path.abspath("../..") parser.set_defaults(root_dir=ROOT_DIR) parser.set_defaults(src_dir=os.path.abspath(os.path.join(ROOT_DIR, "src"))) parser.set_defaults( build_dir=os.path.abspath(os.path.join(ROOT_DIR, "build"))) parser.set_defaults( dist_dir=os.path.abspath(os.path.join(ROOT_DIR, "dist"))) parser.set_defaults(bin_dir=os.path.abspath(os.path.join(ROOT_DIR, "bin"))) parser.set_defaults(moz_dir=os.path.abspath(os.path.join(ROOT_DIR, "src"))) # Identity defaults (set to None - defaults come from config files) parser.set_defaults(version=None) parser.set_defaults(buildid=None) parser.set_defaults(prodid=None) parser.set_defaults(gecko=None) parser.set_defaults(revision=None) # TODO: Handle language packs #parser.set_defaults(langs=[]) # --------------------- # Verbosity options parser.add_option("-v", "--verbose", action="store_const", dest="verbosity", const="debug", help="Print lots of information while building. " + \ "Equivalent to --verbosity=debug") parser.add_option("-q", "--quiet", action="store_const", dest="verbosity", const="critical", help="Disable informational messages while building. " + \ "Equivalent to --verbosity=critical") parser.add_option("--verbosity", dest="verbosity", choices=["debug", "info", "warning", "error", "critical"], help="Set level of informational messages to print. " + \ "One of 'debug','info','warning','error','critical'. " + \ "Default is 'info'") parser.add_option( "--logfile", dest="logfile", type="string", help="Output the log to a specific file. Logs to stdout if not set.") # --------------------- # Directory options (root, build, src, bin, dist, moz) parser.add_option("--root-dir", dest="root_dir", type="string", metavar="ROOT_DIR", help="Use sources from ROOT_DIR. " + \ "(ROOT_DIR contains src, build, dist, bin). " + \ "Default is '..'") parser.add_option("--build-dir", dest="build_dir", type="string", metavar="BUILD_DIR", help="Use BUILD_DIR as staging directory for builds. " + \ "Default is '../build'") parser.add_option("--src-dir", dest="src_dir", type="string", metavar="SRC_DIR", help="SRC_DIR contains source code for Kylo, extensions and components. " + \ "Default is '../src'") parser.add_option("--dist-dir", type="string", dest="dist_dir", metavar="DIST_DIR", help="Put executable or installer in DIST_DIR. " + \ "Default is '../dist'") parser.add_option("--moz-dir", type="string", dest="moz_dir", metavar="MOZ_DIR", help="Parent directory of 'xulrunner' and 'xulrunner-sdk'. " + \ "Default is '../src'") # --------------------- # Clean options parser.add_option("--clean", dest="clean", action="store_true", help="Deletes existing build and bin" + \ "directories, exits build process.") parser.add_option("--clean-dist", dest="clean_dist", action="store_true", help="Deletes files within DIST_DIR. If not specified, " + \ "DIST_DIR is excluded from normal clean up process.") # --------------------- # Build options (skip-update, skip-omni, compile, app, installer) parser.add_option("--skip-update", dest="update", action="store_false", help="If the BUILD_DIR already contains files copied from the SRC_DIR " + \ "this will prevent them from being copied over with latest.") parser.add_option( "--skip-omni", dest="omnify", action="store_false", help= "Prevents application source being compressed into a single omni.jar file." ) parser.add_option("-c", "--compile", action="store_const", dest="compile", const=["ext", "com"], help="Compile all XPCOM components in the 'components' and 'extensions' directories. " + \ "NOTE: skipping this option may " + \ "produce errors if pre-compiled libraries " + \ "do not already exist in their appropriate bin directories") parser.add_option( "--compile-ext", action="append_const", dest="compile", const="ext", help="Compile XPCOM components in the 'extensions' directory ONLY.") parser.add_option( "--compile-com", action="append_const", dest="compile", const="com", help="Compile XPCOM components in the 'components' directory ONLY.") parser.add_option("--app", dest="buildapp", action="store_true", help="Create the Kylo executable (.exe, .app, etc.)") parser.add_option( "-i", "--installer", action="store_true", dest="installer", help="Create the installer file (NSIS on Windows, DMG on OS X).") # --------------------- # Identity options (build id, product id, version) parser.add_option("-B", "--build-id", dest="buildid", type="string", help="Build Number. Overrides the 'BuildID' value, under 'App', " + \ "in the config file.") parser.add_option("-P", "--product-id", type="string", dest="prodid", help="Product id. Default is 'kylo'. Can be alphanumeric string, " + \ "no spaces. Overrides the ProdID value, under App, in the config file.") parser.add_option("-V", "--version", dest="version", type="string", help="The version of Kylo that is being built. Overrides the " + \ "'Version' value, under 'App', in the config file.") parser.add_option("-G", "--gecko-version", type="string", dest="gecko", help="Version of the XUL SDK to compile against. Overrides the " + \ "'gecko' value, under 'Build', in the config file.") parser.add_option("-R", "--revision", type="string", dest="revision", help="Revision number - tacked on as the last value in the version string. " + \ "Like 1.0.1[.123456]. Should be a changelist number.") (options, args) = parser.parse_args(args=args) Settings.prefs = options if len(args) < 1: parser.error("Incorrect number of arguments") # Save the platform in a convenient string if sys.platform == "win32": Settings.platform = "win32" elif sys.platform == "darwin": Settings.platform = "osx" elif sys.platform.startswith("linux"): Settings.platform = "linux" else: Settings.platform = sys.platform # New config parser, allows options without values and forces case-sensitive options conf = ConfigParser(allow_no_value=True) conf.optionxform = str # Grab platform config platformConf = os.path.join(Settings.platform, "%s.platform.conf" % Settings.platform) if os.path.isfile(platformConf): conf.readfp(open(platformConf)) # Suck in application.ini file as config appini = os.path.normpath( os.path.join(Settings.prefs.src_dir, "kylo", "application.ini")) if os.path.isfile(appini): conf.readfp(open(appini)) # Read the first config file passed in as argument conf.readfp(open(os.path.abspath(args[0]))) # Loop through other config file arguments if len(args) > 1: cfgs = [os.path.abspath(cfg) for cfg in args[1:]] conf.read(cfgs) Settings.config = conf # Set some overrides if Settings.prefs.prodid: Settings.config.set("App", "ProdID", Settings.prefs.prodid) if Settings.prefs.buildid: Settings.config.set("App", "BuildID", Settings.prefs.buildid) else: # Default build id is current time stamp Settings.config.set("App", "BuildID", datetime.now().strftime("%Y%m%d%H%M%S")) if Settings.prefs.version: Settings.config.set("App", "Version", Settings.prefs.version) if Settings.prefs.gecko: Settings.config.set("Build", "gecko", Settings.prefs.gecko) # Tack on the revision number (if provided) if Settings.prefs.revision: v = Settings.config.get("App", "Version") Settings.config.set("App", "Version", "%s.%s" % (v, Settings.prefs.revision)) # If we're cleaning, skip other options automatically if Settings.prefs.clean: Settings.prefs.compile = () Settings.prefs.update = False Settings.prefs.omnify = False Settings.prefs.buildapp = False Settings.prefs.installer = False global logger logger = build_util.getLogger("build_kylo") sys.stdout = build_util.StreamLogger(sys.stdout, logger, prefix='[stdout] ') sys.stderr = build_util.StreamLogger(sys.stderr, logger, prefix='[stderr] ') logger.info('=' * 72) logger.info(' Making a %s %s build' % (Settings.platform, Settings.config.get("App", "ProdID"))) logger.info(' source dir: %s' % Settings.prefs.src_dir) logger.info(' build dir: %s' % Settings.prefs.build_dir) logger.info(' dist dir: %s' % Settings.prefs.dist_dir) logger.info(' moz dir: %s' % Settings.prefs.moz_dir) logger.info('=' * 72)
def makejar(delete_files=True): logger = build_util.getLogger("omnify") # ---------------------- # We need to grab the chrome.manifest file because we're going to modify it chrome_mfst_path = os.path.join(Settings.prefs.kylo_build_dir, "chrome.manifest") try: chrome_mfst = open(chrome_mfst_path, 'r+') except IOError as e: logger.error("chrome.manifest missing! Can't create omni.jar") # Binary components stay in the main chrome.manifest, everything else goes in a copy in the omni.jar bin_mfst = [] jar_mfst = [] for line in chrome_mfst: if line.startswith("binary-component"): bin_mfst.append(line) else: jar_mfst.append(line) chrome_mfst.close() chrome_mfst = open(chrome_mfst_path, 'w+') chrome_mfst.writelines(jar_mfst) chrome_mfst.close() # ---------------------- # Create the jar file # omni.jar was renamed to omni.ja in Gecko 10 gecko = Settings.config.get("Build", "gecko") m = re.search(r"^(\d+)\.",gecko) gecko_major_ver = int(m.group(1)) if gecko_major_ver <= 9: omni_filename = "omni.jar" else: omni_filename = "omni.ja" omni_path = os.path.abspath(os.path.join(Settings.prefs.kylo_build_dir, omni_filename)) omni_jar = zipfile.ZipFile(omni_path, 'w', compression=zipfile.ZIP_STORED) # Here's what's going into the omni.jar # /chrome # /components (- *.dll, *.so, *.dylib) # /defaults # chrome.manifest chrome_path = os.path.join(Settings.prefs.kylo_build_dir, "chrome") components_path = os.path.join(Settings.prefs.kylo_build_dir, "components") defaults_path = os.path.join(Settings.prefs.kylo_build_dir, "defaults") addToZip(omni_jar, omni_path, chrome_path) addToZip(omni_jar, omni_path, components_path, exclude=[r'.*\.dll$', r'.*\.so$', r'.*\.dylib$', r'.*\.xpt$', r'.*binary\.manifest$']) addToZip(omni_jar, omni_path, defaults_path) addToZip(omni_jar, omni_path, chrome_mfst_path) omni_jar.close() # Need to optimize the jar optimize_log = open('omni.jar.log', 'w+') optimize_log.write('') optimize_log.close() optimizejars.optimizejar(omni_path, omni_path, 'omni.jar.log') # Delete files we've jarred if delete_files: for f in omni_jar.namelist(): os.remove(os.path.abspath(os.path.join(os.path.split(omni_path)[0], f))) shutil.rmtree(chrome_path) shutil.rmtree(defaults_path) if len(os.listdir(components_path)) < 1: os.rmdir(components_path) else: # Still need to delete original chrome.manifest os.remove(chrome_mfst_path)
def init(args=None): usage = "Build The Kylo Browser.\n" "\tusage: %prog [options] configfile [configfile [configfile...]]" parser = OptionParser(usage=usage) # Log defaults parser.set_defaults(verbosity="info") parser.set_defaults(logfile=None) # Clean defaults parser.set_defaults(clean=False) parser.set_defaults(clean_dist=False) # Build defaults parser.set_defaults(update=True) parser.set_defaults(omnify=True) parser.set_defaults(compile=[]) parser.set_defaults(buildapp=False) parser.set_defaults(installer=False) # Path defaults ROOT_DIR = os.path.abspath("../..") parser.set_defaults(root_dir=ROOT_DIR) parser.set_defaults(src_dir=os.path.abspath(os.path.join(ROOT_DIR, "src"))) parser.set_defaults(build_dir=os.path.abspath(os.path.join(ROOT_DIR, "build"))) parser.set_defaults(dist_dir=os.path.abspath(os.path.join(ROOT_DIR, "dist"))) parser.set_defaults(bin_dir=os.path.abspath(os.path.join(ROOT_DIR, "bin"))) parser.set_defaults(moz_dir=os.path.abspath(os.path.join(ROOT_DIR, "src"))) # Identity defaults (set to None - defaults come from config files) parser.set_defaults(version=None) parser.set_defaults(buildid=None) parser.set_defaults(prodid=None) parser.set_defaults(gecko=None) parser.set_defaults(revision=None) # TODO: Handle language packs # parser.set_defaults(langs=[]) # --------------------- # Verbosity options parser.add_option( "-v", "--verbose", action="store_const", dest="verbosity", const="debug", help="Print lots of information while building. " + "Equivalent to --verbosity=debug", ) parser.add_option( "-q", "--quiet", action="store_const", dest="verbosity", const="critical", help="Disable informational messages while building. " + "Equivalent to --verbosity=critical", ) parser.add_option( "--verbosity", dest="verbosity", choices=["debug", "info", "warning", "error", "critical"], help="Set level of informational messages to print. " + "One of 'debug','info','warning','error','critical'. " + "Default is 'info'", ) parser.add_option( "--logfile", dest="logfile", type="string", help="Output the log to a specific file. Logs to stdout if not set." ) # --------------------- # Directory options (root, build, src, bin, dist, moz) parser.add_option( "--root-dir", dest="root_dir", type="string", metavar="ROOT_DIR", help="Use sources from ROOT_DIR. " + "(ROOT_DIR contains src, build, dist, bin). " + "Default is '..'", ) parser.add_option( "--build-dir", dest="build_dir", type="string", metavar="BUILD_DIR", help="Use BUILD_DIR as staging directory for builds. " + "Default is '../build'", ) parser.add_option( "--src-dir", dest="src_dir", type="string", metavar="SRC_DIR", help="SRC_DIR contains source code for Kylo, extensions and components. " + "Default is '../src'", ) parser.add_option( "--dist-dir", type="string", dest="dist_dir", metavar="DIST_DIR", help="Put executable or installer in DIST_DIR. " + "Default is '../dist'", ) parser.add_option( "--moz-dir", type="string", dest="moz_dir", metavar="MOZ_DIR", help="Parent directory of 'xulrunner' and 'xulrunner-sdk'. " + "Default is '../src'", ) # --------------------- # Clean options parser.add_option( "--clean", dest="clean", action="store_true", help="Deletes existing build and bin" + "directories, exits build process.", ) parser.add_option( "--clean-dist", dest="clean_dist", action="store_true", help="Deletes files within DIST_DIR. If not specified, " + "DIST_DIR is excluded from normal clean up process.", ) # --------------------- # Build options (skip-update, skip-omni, compile, app, installer) parser.add_option( "--skip-update", dest="update", action="store_false", help="If the BUILD_DIR already contains files copied from the SRC_DIR " + "this will prevent them from being copied over with latest.", ) parser.add_option( "--skip-omni", dest="omnify", action="store_false", help="Prevents application source being compressed into a single omni.jar file.", ) parser.add_option( "-c", "--compile", action="store_const", dest="compile", const=["ext", "com"], help="Compile all XPCOM components in the 'components' and 'extensions' directories. " + "NOTE: skipping this option may " + "produce errors if pre-compiled libraries " + "do not already exist in their appropriate bin directories", ) parser.add_option( "--compile-ext", action="append_const", dest="compile", const="ext", help="Compile XPCOM components in the 'extensions' directory ONLY.", ) parser.add_option( "--compile-com", action="append_const", dest="compile", const="com", help="Compile XPCOM components in the 'components' directory ONLY.", ) parser.add_option( "--app", dest="buildapp", action="store_true", help="Create the Kylo executable (.exe, .app, etc.)" ) parser.add_option( "-i", "--installer", action="store_true", dest="installer", help="Create the installer file (NSIS on Windows, DMG on OS X).", ) # --------------------- # Identity options (build id, product id, version) parser.add_option( "-B", "--build-id", dest="buildid", type="string", help="Build Number. Overrides the 'BuildID' value, under 'App', " + "in the config file.", ) parser.add_option( "-P", "--product-id", type="string", dest="prodid", help="Product id. Default is 'kylo'. Can be alphanumeric string, " + "no spaces. Overrides the ProdID value, under App, in the config file.", ) parser.add_option( "-V", "--version", dest="version", type="string", help="The version of Kylo that is being built. Overrides the " + "'Version' value, under 'App', in the config file.", ) parser.add_option( "-G", "--gecko-version", type="string", dest="gecko", help="Version of the XUL SDK to compile against. Overrides the " + "'gecko' value, under 'Build', in the config file.", ) parser.add_option( "-R", "--revision", type="string", dest="revision", help="Revision number - tacked on as the last value in the version string. " + "Like 1.0.1[.123456]. Should be a changelist number.", ) (options, args) = parser.parse_args(args=args) Settings.prefs = options if len(args) < 1: parser.error("Incorrect number of arguments") # Save the platform in a convenient string if sys.platform == "win32": Settings.platform = "win32" elif sys.platform == "darwin": Settings.platform = "osx" elif sys.platform.startswith("linux"): Settings.platform = "linux" else: Settings.platform = sys.platform # New config parser, allows options without values and forces case-sensitive options conf = ConfigParser(allow_no_value=True) conf.optionxform = str # Grab platform config platformConf = os.path.join(Settings.platform, "%s.platform.conf" % Settings.platform) if os.path.isfile(platformConf): conf.readfp(open(platformConf)) # Suck in application.ini file as config appini = os.path.normpath(os.path.join(Settings.prefs.src_dir, "kylo", "application.ini")) if os.path.isfile(appini): conf.readfp(open(appini)) # Read the first config file passed in as argument conf.readfp(open(os.path.abspath(args[0]))) # Loop through other config file arguments if len(args) > 1: cfgs = [os.path.abspath(cfg) for cfg in args[1:]] conf.read(cfgs) Settings.config = conf # Set some overrides if Settings.prefs.prodid: Settings.config.set("App", "ProdID", Settings.prefs.prodid) if Settings.prefs.buildid: Settings.config.set("App", "BuildID", Settings.prefs.buildid) else: # Default build id is current time stamp Settings.config.set("App", "BuildID", datetime.now().strftime("%Y%m%d%H%M%S")) if Settings.prefs.version: Settings.config.set("App", "Version", Settings.prefs.version) if Settings.prefs.gecko: Settings.config.set("Build", "gecko", Settings.prefs.gecko) # Tack on the revision number (if provided) if Settings.prefs.revision: v = Settings.config.get("App", "Version") Settings.config.set("App", "Version", "%s.%s" % (v, Settings.prefs.revision)) # If we're cleaning, skip other options automatically if Settings.prefs.clean: Settings.prefs.compile = () Settings.prefs.update = False Settings.prefs.omnify = False Settings.prefs.buildapp = False Settings.prefs.installer = False global logger logger = build_util.getLogger("build_kylo") sys.stdout = build_util.StreamLogger(sys.stdout, logger, prefix="[stdout] ") sys.stderr = build_util.StreamLogger(sys.stderr, logger, prefix="[stderr] ") logger.info("=" * 72) logger.info(" Making a %s %s build" % (Settings.platform, Settings.config.get("App", "ProdID"))) logger.info(" source dir: %s" % Settings.prefs.src_dir) logger.info(" build dir: %s" % Settings.prefs.build_dir) logger.info(" dist dir: %s" % Settings.prefs.dist_dir) logger.info("=" * 72)
def makejar(delete_files=True): logger = build_util.getLogger("omnify") # ---------------------- # We need to grab the chrome.manifest file because we're going to modify it chrome_mfst_path = os.path.join(Settings.prefs.kylo_build_dir, "chrome.manifest") try: chrome_mfst = open(chrome_mfst_path, 'r+') except IOError as e: logger.error("%s missing! Can't create omni.jar" % chrome_mfst_path) sys.exit() # Binary components stay in the main chrome.manifest, everything else goes in a copy in the omni.jar bin_mfst = [] jar_mfst = [] for line in chrome_mfst: if line.startswith("binary-component"): bin_mfst.append(line) else: jar_mfst.append(line) chrome_mfst.close() chrome_mfst = open(chrome_mfst_path, 'w+') chrome_mfst.writelines(jar_mfst) chrome_mfst.close() # ---------------------- # Create the jar file # omni.jar was renamed to omni.ja in Gecko 10 gecko = Settings.config.get("Build", "gecko") m = re.search(r"^(\d+)\.", gecko) gecko_major_ver = int(m.group(1)) if gecko_major_ver <= 9: omni_filename = "omni.jar" else: omni_filename = "omni.ja" omni_path = os.path.abspath( os.path.join(Settings.prefs.kylo_build_dir, omni_filename)) omni_jar = zipfile.ZipFile(omni_path, 'w', compression=zipfile.ZIP_STORED) # Here's what's going into the omni.jar # /chrome # /components (- *.dll, *.so, *.dylib) # /defaults # chrome.manifest chrome_path = os.path.join(Settings.prefs.kylo_build_dir, "chrome") components_path = os.path.join(Settings.prefs.kylo_build_dir, "components") defaults_path = os.path.join(Settings.prefs.kylo_build_dir, "defaults") addToZip(omni_jar, omni_path, chrome_path) addToZip(omni_jar, omni_path, components_path, exclude=[ r'.*\.dll$', r'.*\.so$', r'.*\.dylib$', r'.*\.xpt$', r'.*binary\.manifest$' ]) addToZip(omni_jar, omni_path, defaults_path) addToZip(omni_jar, omni_path, chrome_mfst_path) omni_jar.close() # Need to optimize the jar optimize_log = open('omni.jar.log', 'w+') optimize_log.write('') optimize_log.close() optimizejars.optimizejar(omni_path, omni_path, 'omni.jar.log') # Delete files we've jarred if delete_files: for f in omni_jar.namelist(): os.remove( os.path.abspath(os.path.join(os.path.split(omni_path)[0], f))) shutil.rmtree(chrome_path) shutil.rmtree(defaults_path) if len(os.listdir(components_path)) < 1: os.rmdir(components_path) else: # Still need to delete original chrome.manifest os.remove(chrome_mfst_path)