def copy(self, dest, skip_if_older=True): ''' Invokes the preprocessor to create the destination file. ''' if isinstance(dest, six.string_types): dest = Dest(dest) else: assert isinstance(dest, Dest) # We have to account for the case where the destination exists and is a # symlink to something. Since we know the preprocessor is certainly not # going to create a symlink, we can just remove the existing one. If the # destination is not a symlink, we leave it alone, since we're going to # overwrite its contents anyway. # If symlinks aren't supported at all, we can skip this step. # See comment in AbsoluteSymlinkFile about Windows. if hasattr(os, 'symlink') and platform.system() != 'Windows': if os.path.islink(dest.path): os.remove(dest.path) pp_deps = set(self.extra_depends) # If a dependency file was specified, and it exists, add any # dependencies from that file to our list. if self.depfile and os.path.exists(self.depfile): target = mozpath.normpath(dest.name) with _open(self.depfile, 'rt') as fileobj: for rule in makeutil.read_dep_makefile(fileobj): if target in rule.targets(): pp_deps.update(rule.dependencies()) skip = False if dest.exists() and skip_if_older: # If a dependency file was specified, and it doesn't exist, # assume that the preprocessor needs to be rerun. That will # regenerate the dependency file. if self.depfile and not os.path.exists(self.depfile): skip = False else: skip = not BaseFile.any_newer(dest.path, pp_deps) if skip: return False deps_out = None if self.depfile: deps_out = FileAvoidWrite(self.depfile) pp = Preprocessor(defines=self.defines, marker=self.marker) pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings) with _open(self.path, 'rU') as input: pp.processFile(input=input, output=dest, depfile=deps_out) dest.close() if self.depfile: deps_out.close() return True
def copy(self, dest, skip_if_older=True): ''' Invokes the preprocessor to create the destination file. ''' if isinstance(dest, basestring): dest = Dest(dest) else: assert isinstance(dest, Dest) # We have to account for the case where the destination exists and is a # symlink to something. Since we know the preprocessor is certainly not # going to create a symlink, we can just remove the existing one. If the # destination is not a symlink, we leave it alone, since we're going to # overwrite its contents anyway. # If symlinks aren't supported at all, we can skip this step. if hasattr(os, 'symlink'): if os.path.islink(dest.path): os.remove(dest.path) pp_deps = set(self.extra_depends) # If a dependency file was specified, and it exists, add any # dependencies from that file to our list. if self.depfile and os.path.exists(self.depfile): target = mozpath.normpath(dest.name) with open(self.depfile, 'rb') as fileobj: for rule in makeutil.read_dep_makefile(fileobj): if target in rule.targets(): pp_deps.update(rule.dependencies()) skip = False if dest.exists() and skip_if_older: # If a dependency file was specified, and it doesn't exist, # assume that the preprocessor needs to be rerun. That will # regenerate the dependency file. if self.depfile and not os.path.exists(self.depfile): skip = False else: skip = not BaseFile.any_newer(dest.path, pp_deps) if skip: return False deps_out = None if self.depfile: deps_out = FileAvoidWrite(self.depfile) pp = Preprocessor(defines=self.defines, marker=self.marker) pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings) with open(self.path, 'rU') as input: pp.processFile(input=input, output=dest, depfile=deps_out) dest.close() if self.depfile: deps_out.close() return True
def inputs(self): pp = Preprocessor(defines=self.defines, marker=self.marker) pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings) with open(self.path, 'rU') as input: with open(os.devnull, 'w') as output: pp.processFile(input=input, output=output) # This always yields at least self.path. return pp.includes
def inputs(self): pp = Preprocessor(defines=self.defines, marker=self.marker) pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings) with open(self.path, 'rU') as input: with open(os.devnull, 'w') as output: pp.processFile(input=input, output=output) # This always yields at least self.path. return pp.includes
def process_package_overload(src, dst, version, app_buildid): ensureParentDir(dst) # First replace numeric version like '1.3' # Then replace with 'slashed' version like '1_4' # Finally set the full length addon version like 1.3.20131230 defines = { "NUM_VERSION": version, "SLASH_VERSION": version.replace(".", "_"), "FULL_VERSION": ("%s.%s" % (version, app_buildid)) } pp = Preprocessor(defines=defines) pp.do_filter("substitution") with open(dst, "w") as output: with open(src, "r") as input: pp.processFile(input=input, output=output)
def process_package_overload(src, dst, version, app_buildid): ensureParentDir(dst) # First replace numeric version like '1.3' # Then replace with 'slashed' version like '1_4' # Finally set the full length addon version like 1.3.20131230 defines = { "NUM_VERSION": version, "SLASH_VERSION": version.replace(".", "_"), "FULL_VERSION": ("%s.%s" % (version, app_buildid)) } pp = Preprocessor(defines=defines) pp.do_filter("substitution") with open(dst, "w") as output: with open(src, "r") as input: pp.processFile(input=input, output=output)
def preprocess_file(src, dst, version, app_buildid, update_url): ensureParentDir(dst) defines = { "ADDON_ID": "fxos_" + version.replace(".", "_") + "*****@*****.**", # (reduce the app build id to only the build date # as addon manager doesn't handle big ints in addon versions) "ADDON_VERSION": ("%s.%s" % (version, app_buildid[:8])), "ADDON_NAME": "Firefox OS " + version + " Simulator", "ADDON_DESCRIPTION": "a Firefox OS " + version + " simulator", "ADDON_UPDATE_URL": update_url } pp = Preprocessor(defines=defines) pp.do_filter("substitution") with open(dst, "w") as output: with open(src, "r") as input: pp.processFile(input=input, output=output)
def preprocess_file(src, dst, version, app_buildid, update_url): ensureParentDir(dst) defines = { "ADDON_ID": "fxos_" + version.replace(".", "_") + "*****@*****.**", # (reduce the app build id to only the build date # as addon manager doesn't handle big ints in addon versions) "ADDON_VERSION": ("%s.%s" % (version, app_buildid[:8])), "ADDON_NAME": "Firefox OS " + version + " Simulator", "ADDON_DESCRIPTION": "a Firefox OS " + version + " simulator", "ADDON_UPDATE_URL": update_url } pp = Preprocessor(defines=defines) pp.do_filter("substitution") with open(dst, "w") as output: with open(src, "r") as input: pp.processFile(input=input, output=output)
TINT_FOREGROUND_DRAWABLE=1), dict(VIEW_NAME_SUFFIX='LinearLayout', BASE_TYPE='android.widget.LinearLayout'), dict(VIEW_NAME_SUFFIX='RelativeLayout', BASE_TYPE='android.widget.RelativeLayout', STYLE_CONSTRUCTOR=1), dict(VIEW_NAME_SUFFIX='TextSwitcher', BASE_TYPE='android.widget.TextSwitcher'), dict(VIEW_NAME_SUFFIX='TextView', BASE_TYPE='android.widget.TextView', STYLE_CONSTRUCTOR=1), dict(VIEW_NAME_SUFFIX='View', BASE_TYPE='android.view.View', STYLE_CONSTRUCTOR=1), dict(VIEW_NAME_SUFFIX='ListView', BASE_TYPE='android.widget.ListView', STYLE_CONSTRUCTOR=1), dict(VIEW_NAME_SUFFIX='ProgressBar', BASE_TYPE='android.widget.ProgressBar', STYLE_CONSTRUCTOR=1), ] for view in views: pp = Preprocessor(defines=view, marker='//#') dest = os.path.join(__DIR__, dest_format_string % view) with open(template, 'rU') as input: with open(dest, 'wt') as output: pp.processFile(input=input, output=output) print('%s' % dest)
STYLE_CONSTRUCTOR=1, TINT_FOREGROUND_DRAWABLE=1, BOOKMARK_NO_TINT=1), dict(VIEW_NAME_SUFFIX='ImageView', BASE_TYPE='android.widget.ImageView', STYLE_CONSTRUCTOR=1, TINT_FOREGROUND_DRAWABLE=1), dict(VIEW_NAME_SUFFIX='LinearLayout', BASE_TYPE='android.widget.LinearLayout'), dict(VIEW_NAME_SUFFIX='RelativeLayout', BASE_TYPE='android.widget.RelativeLayout', STYLE_CONSTRUCTOR=1), dict(VIEW_NAME_SUFFIX='TextSwitcher', BASE_TYPE='android.widget.TextSwitcher'), dict(VIEW_NAME_SUFFIX='TextView', BASE_TYPE='android.widget.TextView', STYLE_CONSTRUCTOR=1), dict(VIEW_NAME_SUFFIX='View', BASE_TYPE='android.view.View', STYLE_CONSTRUCTOR=1), ] for view in views: pp = Preprocessor(defines=view, marker='//#') dest = os.path.join(__DIR__, dest_format_string % view) with open(template, 'rU') as input: with open(dest, 'wt') as output: pp.processFile(input=input, output=output) print('%s' % dest)
def main(output_file, input_filename): # input_filename is an absolute path, so there's no need to join with __DIR__. pp = Preprocessor(defines=buildconfig.defines, marker='//#') CONFIG = defaultdict(lambda: None) CONFIG.update(buildconfig.substs) DEFINES = {} for var in ('MOZ_ANDROID_ACTIVITY_STREAM' 'MOZ_ANDROID_ANR_REPORTER', 'MOZ_ANDROID_BEAM', 'MOZ_ANDROID_CUSTOM_TABS', 'MOZ_ANDROID_DOWNLOADS_INTEGRATION', 'MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE', 'MOZ_ANDROID_EXCLUDE_FONTS', 'MOZ_ANDROID_GCM', 'MOZ_ANDROID_MLS_STUMBLER', 'MOZ_ANDROID_SEARCH_ACTIVITY', 'MOZ_DEBUG', 'MOZ_INSTALL_TRACKING', 'MOZ_LOCALE_SWITCHER', 'MOZ_NATIVE_DEVICES', 'MOZ_SWITCHBOARD'): if CONFIG[var]: DEFINES[var] = 1 for var in ('MOZ_ANDROID_GCM_SENDERID', 'MOZ_PKG_SPECIAL', 'MOZ_UPDATER'): if CONFIG[var]: DEFINES[var] = CONFIG[var] for var in ('ANDROID_CPU_ARCH', 'ANDROID_PACKAGE_NAME', 'GRE_MILESTONE', 'MOZ_ANDROID_APPLICATION_CLASS', 'MOZ_ANDROID_BROWSER_INTENT_CLASS', 'MOZ_ANDROID_SEARCH_INTENT_CLASS', 'MOZ_APP_BASENAME', 'MOZ_APP_DISPLAYNAME', 'MOZ_APP_ID', 'MOZ_APP_NAME', 'MOZ_APP_UA_NAME', 'MOZ_APP_VENDOR', 'MOZ_APP_VERSION', 'MOZ_CHILD_PROCESS_NAME', 'MOZ_CRASHREPORTER', 'MOZ_MOZILLA_API_KEY', 'MOZ_UPDATE_CHANNEL', 'OMNIJAR_NAME', 'OS_TARGET', 'TARGET_XPCOM_ABI'): DEFINES[var] = CONFIG[var] # Mangle our package name to avoid Bug 750548. DEFINES['MANGLED_ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME'].replace('fennec', 'f3nn3c') DEFINES['MOZ_APP_ABI'] = CONFIG['TARGET_XPCOM_ABI'] if not CONFIG['COMPILE_ENVIRONMENT']: # These should really come from the included binaries, but that's not easy. DEFINES['MOZ_APP_ABI'] = 'arm-eabi-gcc3' DEFINES['TARGET_XPCOM_ABI'] = 'arm-eabi-gcc3' if '-march=armv7' in CONFIG['OS_CFLAGS']: DEFINES['MOZ_MIN_CPU_VERSION'] = 7 else: DEFINES['MOZ_MIN_CPU_VERSION'] = 5 # It's okay to use MOZ_ADJUST_SDK_KEY here because this doesn't # leak the value to build logs. if CONFIG['MOZ_INSTALL_TRACKING']: DEFINES['MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN'] = CONFIG['MOZ_ADJUST_SDK_KEY'] # TODO: mark buildid.h as a dependency? How about the buildconfig itself? DEFINES['MOZ_BUILDID'] = open(os.path.join(buildconfig.topobjdir, 'buildid.h')).readline().split()[2] pp.context.update(DEFINES) with open(input_filename, 'rU') as input: pp.processFile(input=input, output=output_file) return 0
def main(output_file, input_filename): # input_filename is an absolute path, so there's no need to join with __DIR__. pp = Preprocessor(defines=buildconfig.defines, marker='//#') CONFIG = defaultdict(lambda: None) CONFIG.update(buildconfig.substs) DEFINES = {} for var in ('MOZ_ANDROID_ACTIVITY_STREAM' 'MOZ_ANDROID_ANR_REPORTER', 'MOZ_ANDROID_BEAM', 'MOZ_ANDROID_CUSTOM_TABS', 'MOZ_ANDROID_DOWNLOADS_INTEGRATION', 'MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE', 'MOZ_ANDROID_EXCLUDE_FONTS', 'MOZ_ANDROID_GCM', 'MOZ_ANDROID_MLS_STUMBLER', 'MOZ_ANDROID_SEARCH_ACTIVITY', 'MOZ_DEBUG', 'MOZ_INSTALL_TRACKING', 'MOZ_LOCALE_SWITCHER', 'MOZ_NATIVE_DEVICES', 'MOZ_SWITCHBOARD'): if CONFIG[var]: DEFINES[var] = 1 for var in ('MOZ_ANDROID_GCM_SENDERID', 'MOZ_PKG_SPECIAL', 'MOZ_UPDATER'): if CONFIG[var]: DEFINES[var] = CONFIG[var] for var in ('ANDROID_CPU_ARCH', 'ANDROID_PACKAGE_NAME', 'GRE_MILESTONE', 'MOZ_ANDROID_APPLICATION_CLASS', 'MOZ_ANDROID_BROWSER_INTENT_CLASS', 'MOZ_ANDROID_SEARCH_INTENT_CLASS', 'MOZ_APP_BASENAME', 'MOZ_APP_DISPLAYNAME', 'MOZ_APP_ID', 'MOZ_APP_NAME', 'MOZ_APP_UA_NAME', 'MOZ_APP_VENDOR', 'MOZ_APP_VERSION', 'MOZ_CHILD_PROCESS_NAME', 'MOZ_CRASHREPORTER', 'MOZ_MOZILLA_API_KEY', 'MOZ_UPDATE_CHANNEL', 'OMNIJAR_NAME', 'OS_TARGET', 'TARGET_XPCOM_ABI'): DEFINES[var] = CONFIG[var] # Mangle our package name to avoid Bug 750548. DEFINES['MANGLED_ANDROID_PACKAGE_NAME'] = CONFIG[ 'ANDROID_PACKAGE_NAME'].replace('fennec', 'f3nn3c') DEFINES['MOZ_APP_ABI'] = CONFIG['TARGET_XPCOM_ABI'] if not CONFIG['COMPILE_ENVIRONMENT']: # These should really come from the included binaries, but that's not easy. DEFINES['MOZ_APP_ABI'] = 'arm-eabi-gcc3' DEFINES['TARGET_XPCOM_ABI'] = 'arm-eabi-gcc3' if '-march=armv7' in CONFIG['OS_CFLAGS']: DEFINES['MOZ_MIN_CPU_VERSION'] = 7 else: DEFINES['MOZ_MIN_CPU_VERSION'] = 5 # It's okay to use MOZ_ADJUST_SDK_KEY here because this doesn't # leak the value to build logs. if CONFIG['MOZ_INSTALL_TRACKING']: DEFINES['MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN'] = CONFIG[ 'MOZ_ADJUST_SDK_KEY'] # TODO: mark buildid.h as a dependency? How about the buildconfig itself? DEFINES['MOZ_BUILDID'] = open( os.path.join(buildconfig.topobjdir, 'buildid.h')).readline().split()[2] pp.context.update(DEFINES) with open(input_filename, 'rU') as input: pp.processFile(input=input, output=output_file) return 0