def compileflags(self, what): from mozbuild.util import resolve_target_to_make from mozbuild.compilation import util if not util.check_top_objdir(self.topobjdir): return 1 path_arg = self._wrap_path_argument(what) make_dir, make_target = resolve_target_to_make(self.topobjdir, path_arg.relpath()) if make_dir is None and make_target is None: return 1 build_vars = util.get_build_vars(make_dir, self) if what.endswith('.c'): cc = 'CC' name = 'COMPILE_CFLAGS' else: cc = 'CXX' name = 'COMPILE_CXXFLAGS' if name not in build_vars: return # Drop the first flag since that is the pathname of the compiler. flags = (shell_split(build_vars[cc]) + shell_split(build_vars[name]))[1:] print(' '.join(shell_quote(arg) for arg in util.sanitize_cflags(flags)))
def compileflags(self, what): from mozbuild.util import resolve_target_to_make from mozbuild.compilation import util if not util.check_top_objdir(self.topobjdir): return 1 path_arg = self._wrap_path_argument(what) make_dir, make_target = resolve_target_to_make(self.topobjdir, path_arg.relpath()) if make_dir is None and make_target is None: return 1 build_vars = util.get_build_vars(make_dir, self) if what.endswith(".c"): cc = "CC" name = "COMPILE_CFLAGS" else: cc = "CXX" name = "COMPILE_CXXFLAGS" if name not in build_vars: return # Drop the first flag since that is the pathname of the compiler. flags = (shell_split(build_vars[cc]) + shell_split(build_vars[name]))[1:] print(" ".join(shell_quote(arg) for arg in util.sanitize_cflags(flags)))
def compileflags(command_context, what): from mozbuild.util import resolve_target_to_make from mozbuild.compilation import util if not util.check_top_objdir(command_context.topobjdir): return 1 path_arg = command_context._wrap_path_argument(what) make_dir, make_target = resolve_target_to_make(command_context.topobjdir, path_arg.relpath()) if make_dir is None and make_target is None: return 1 build_vars = util.get_build_vars(make_dir, command_context) if what.endswith(".c"): cc = "CC" name = "COMPILE_CFLAGS" else: cc = "CXX" name = "COMPILE_CXXFLAGS" if name not in build_vars: return # Drop the first flag since that is the pathname of the compiler. flags = (shell_split(build_vars[cc]) + shell_split(build_vars[name]))[1:] print(" ".join(shell_quote(arg) for arg in util.sanitize_cflags(flags)))
def compileflags(self, what): from mozbuild.util import resolve_target_to_make from mozbuild.compilation import util if not util.check_top_objdir(self.topobjdir): return 1 path_arg = self._wrap_path_argument(what) make_dir, make_target = resolve_target_to_make(self.topobjdir, path_arg.relpath()) if make_dir is None and make_target is None: return 1 build_vars = util.get_build_vars(make_dir, self) if what.endswith('.c'): name = 'COMPILE_CFLAGS' else: name = 'COMPILE_CXXFLAGS' if name not in build_vars: return print(' '.join(shell_quote(arg) for arg in shell_split(build_vars[name])))
def gradle(self, args): # Avoid logging the command self.log_manager.terminal_handler.setLevel(logging.CRITICAL) # In automation, JAVA_HOME is set via mozconfig, which needs # to be specially handled in each mach command. This turns # $JAVA_HOME/bin/java into $JAVA_HOME. java_home = os.path.dirname(os.path.dirname(self.substs['JAVA'])) gradle_flags = shell_split(self.substs.get('GRADLE_FLAGS', '')) # We force the Gradle JVM to run with the UTF-8 encoding, since we # filter strings.xml, which is really UTF-8; the ellipsis character is # replaced with ??? in some encodings (including ASCII). It's not yet # possible to filter with encodings in Gradle # (https://github.com/gradle/gradle/pull/520) and it's challenging to # do our filtering with Gradle's Ant support. Moreover, all of the # Android tools expect UTF-8: see # http://tools.android.com/knownissues/encoding. See # http://stackoverflow.com/a/21267635 for discussion of this approach. return self.run_process([self.substs['GRADLE']] + gradle_flags + args, append_env={ 'GRADLE_OPTS': '-Dfile.encoding=utf-8', 'JAVA_HOME': java_home, }, pass_thru=True, # Allow user to run gradle interactively. ensure_exit_code=False, # Don't throw on non-zero exit code. cwd=mozpath.join(self.topsrcdir))
def _get_dir_flags(self, directory): if directory in self._flags: return self._flags[directory] from mozbuild.util import resolve_target_to_make make_dir, make_target = resolve_target_to_make( self.environment.topobjdir, directory) if make_dir is None and make_target is None: raise Exception('Cannot figure out the make dir and target for ' + directory) build_vars = util.get_build_vars(directory, self._cmd) # We only care about the following build variables. for name in ('COMPILE_CFLAGS', 'COMPILE_CXXFLAGS', 'COMPILE_CMFLAGS', 'COMPILE_CMMFLAGS'): if name not in build_vars: continue build_vars[name] = util.sanitize_cflags( shell_split(build_vars[name])) self._flags[directory] = build_vars return self._flags[directory]
def gradle(self, args, verbose=False): if not verbose: # Avoid logging the command self.log_manager.terminal_handler.setLevel(logging.CRITICAL) # In automation, JAVA_HOME is set via mozconfig, which needs # to be specially handled in each mach command. This turns # $JAVA_HOME/bin/java into $JAVA_HOME. java_home = os.path.dirname(os.path.dirname(self.substs["JAVA"])) gradle_flags = self.substs.get("GRADLE_FLAGS", "") or os.environ.get( "GRADLE_FLAGS", "" ) gradle_flags = shell_split(gradle_flags) # We force the Gradle JVM to run with the UTF-8 encoding, since we # filter strings.xml, which is really UTF-8; the ellipsis character is # replaced with ??? in some encodings (including ASCII). It's not yet # possible to filter with encodings in Gradle # (https://github.com/gradle/gradle/pull/520) and it's challenging to # do our filtering with Gradle's Ant support. Moreover, all of the # Android tools expect UTF-8: see # http://tools.android.com/knownissues/encoding. See # http://stackoverflow.com/a/21267635 for discussion of this approach. # # It's not even enough to set the encoding just for Gradle; it # needs to be for JVMs spawned by Gradle as well. This # happens during the maven deployment generating the GeckoView # documents; this works around "error: unmappable character # for encoding ASCII" in exoplayer2. See # https://discuss.gradle.org/t/unmappable-character-for-encoding-ascii-when-building-a-utf-8-project/10692/11 # NOQA: E501 # and especially https://stackoverflow.com/a/21755671. if self.substs.get("MOZ_AUTOMATION"): gradle_flags += ["--console=plain"] env = os.environ.copy() env.update( { "GRADLE_OPTS": "-Dfile.encoding=utf-8", "JAVA_HOME": java_home, "JAVA_TOOL_OPTIONS": "-Dfile.encoding=utf-8", } ) # Set ANDROID_SDK_ROOT if --with-android-sdk was set. # See https://bugzilla.mozilla.org/show_bug.cgi?id=1576471 android_sdk_root = self.substs.get("ANDROID_SDK_ROOT", "") if android_sdk_root: env["ANDROID_SDK_ROOT"] = android_sdk_root return self.run_process( [self.substs["GRADLE"]] + gradle_flags + args, explicit_env=env, pass_thru=True, # Allow user to run gradle interactively. ensure_exit_code=False, # Don't throw on non-zero exit code. cwd=mozpath.join(self.topsrcdir), )
def gradle(self, args, verbose=False): if not verbose: # Avoid logging the command self.log_manager.terminal_handler.setLevel(logging.CRITICAL) # In automation, JAVA_HOME is set via mozconfig, which needs # to be specially handled in each mach command. This turns # $JAVA_HOME/bin/java into $JAVA_HOME. java_home = os.path.dirname(os.path.dirname(self.substs['JAVA'])) gradle_flags = self.substs.get('GRADLE_FLAGS', '') or \ os.environ.get('GRADLE_FLAGS', '') gradle_flags = shell_split(gradle_flags) # We force the Gradle JVM to run with the UTF-8 encoding, since we # filter strings.xml, which is really UTF-8; the ellipsis character is # replaced with ??? in some encodings (including ASCII). It's not yet # possible to filter with encodings in Gradle # (https://github.com/gradle/gradle/pull/520) and it's challenging to # do our filtering with Gradle's Ant support. Moreover, all of the # Android tools expect UTF-8: see # http://tools.android.com/knownissues/encoding. See # http://stackoverflow.com/a/21267635 for discussion of this approach. # # It's not even enough to set the encoding just for Gradle; it # needs to be for JVMs spawned by Gradle as well. This # happens during the maven deployment generating the GeckoView # documents; this works around "error: unmappable character # for encoding ASCII" in exoplayer2. See # https://discuss.gradle.org/t/unmappable-character-for-encoding-ascii-when-building-a-utf-8-project/10692/11 # NOQA: E501 # and especially https://stackoverflow.com/a/21755671. return self.run_process( [self.substs['GRADLE']] + gradle_flags + ['--console=plain'] + args, append_env={ 'GRADLE_OPTS': '-Dfile.encoding=utf-8', 'JAVA_HOME': java_home, 'JAVA_TOOL_OPTIONS': '-Dfile.encoding=utf-8', }, pass_thru=True, # Allow user to run gradle interactively. ensure_exit_code=False, # Don't throw on non-zero exit code. cwd=mozpath.join(self.topsrcdir))
def gradle(self, args, verbose=False): if not verbose: # Avoid logging the command self.log_manager.terminal_handler.setLevel(logging.CRITICAL) # In automation, JAVA_HOME is set via mozconfig, which needs # to be specially handled in each mach command. This turns # $JAVA_HOME/bin/java into $JAVA_HOME. java_home = os.path.dirname(os.path.dirname(self.substs['JAVA'])) gradle_flags = self.substs.get('GRADLE_FLAGS', '') or \ os.environ.get('GRADLE_FLAGS', '') gradle_flags = shell_split(gradle_flags) # We force the Gradle JVM to run with the UTF-8 encoding, since we # filter strings.xml, which is really UTF-8; the ellipsis character is # replaced with ??? in some encodings (including ASCII). It's not yet # possible to filter with encodings in Gradle # (https://github.com/gradle/gradle/pull/520) and it's challenging to # do our filtering with Gradle's Ant support. Moreover, all of the # Android tools expect UTF-8: see # http://tools.android.com/knownissues/encoding. See # http://stackoverflow.com/a/21267635 for discussion of this approach. # # It's not even enough to set the encoding just for Gradle; it # needs to be for JVMs spawned by Gradle as well. This # happens during the maven deployment generating the GeckoView # documents; this works around "error: unmappable character # for encoding ASCII" in exoplayer2. See # https://discuss.gradle.org/t/unmappable-character-for-encoding-ascii-when-building-a-utf-8-project/10692/11 # and especially https://stackoverflow.com/a/21755671. return self.run_process([self.substs['GRADLE']] + gradle_flags + ['--console=plain'] + args, append_env={ 'GRADLE_OPTS': '-Dfile.encoding=utf-8', 'JAVA_HOME': java_home, 'JAVA_TOOL_OPTIONS': '-Dfile.encoding=utf-8', }, pass_thru=True, # Allow user to run gradle interactively. ensure_exit_code=False, # Don't throw on non-zero exit code. cwd=mozpath.join(self.topsrcdir))
def _get_dir_flags(self, directory): if directory in self._flags: return self._flags[directory] from mozbuild.util import resolve_target_to_make make_dir, make_target = resolve_target_to_make(self.environment.topobjdir, directory) if make_dir is None and make_target is None: raise Exception('Cannot figure out the make dir and target for ' + directory) build_vars = util.get_build_vars(directory, self._cmd) # We only care about the following build variables. for name in ('COMPILE_CFLAGS', 'COMPILE_CXXFLAGS', 'COMPILE_CMFLAGS', 'COMPILE_CMMFLAGS'): if name not in build_vars: continue build_vars[name] = util.sanitize_cflags(shell_split(build_vars[name])) self._flags[directory] = build_vars return self._flags[directory]