diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index fc7cd14e222c..6e008a6c357b 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -705,9 +705,6 @@ def determine_linker_and_stdlib_args(self, target: build.BuildTarget) -> T.Tuple If we're building a static library, there is only one static linker. Otherwise, we query the target for the dynamic linker. ''' - print("determine_linker_and_stdlib_args()") - print("\ttarget:", target) - print("\ttarget.for_machine:", target.for_machine) if isinstance(target, build.StaticLibrary): return self.build.static_linker[target.for_machine], [] l, stdlib_args = target.get_clink_dynamic_linker_and_stdlibs() diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index b312c34f10a4..aed40f2aa2a6 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -834,8 +834,6 @@ def create_target_linker_introspection(self, target: build.Target, linker: T.Uni tgt[lnk_hash] = lnk_block def generate_target(self, target): - print("generate_target():", target) - print("\tfor_machine:", target.for_machine) try: if isinstance(target, build.BuildTarget): os.makedirs(self.get_target_private_dir_abs(target)) @@ -1042,9 +1040,6 @@ def generate_target(self, target): final_obj_list = self.generate_prelink(target, obj_list) else: final_obj_list = obj_list - print("calling generate_link()") - print("\tlinker:", linker) - print("\tlinker.for_machine:", linker.for_machine) elem = self.generate_link(target, outname, final_obj_list, linker, pch_objects, stdlib_args=stdlib_args) self.generate_dependency_scan_target(target, compiled_sources, source2object, generated_source_files, fortran_order_deps) self.add_build(elem) @@ -2842,10 +2837,7 @@ def _generate_single_compile_target_args(self, target: build.BuildTarget, compil # Include dirs from internal deps should override include dirs from # external deps and must maintain the order in which they are specified. # Hence, we must reverse the list so that the order is preserved. - print("_generate_single_compile_target_args()", target) - print(">>>") for i in reversed(target.get_include_dirs()): - print("i:", i) basedir = i.get_curdir() # We should iterate include dirs in reversed orders because # -Ipath will add to begin of array. And without reverse @@ -2857,7 +2849,6 @@ def _generate_single_compile_target_args(self, target: build.BuildTarget, compil commands += includeargs for d in i.get_extra_build_dirs(): commands += compiler.get_include_args(d, i.is_system) - print("<<<") # Add per-target compile args, f.ex, `c_args : ['-DFOO']`. We set these # near the end since these are supposed to override everything else. commands += self.escape_extra_args(target.get_extra_args(compiler.get_language())) @@ -3332,10 +3323,6 @@ def guess_external_link_dependencies(self, linker, target, commands, internal): try: static_patterns = linker.get_library_naming(self.environment, LibType.STATIC, strict=True) shared_patterns = linker.get_library_naming(self.environment, LibType.SHARED, strict=True) - print("calling linker.get_library_dirs()") - print("\tlinker:", linker) - print("\ttarget:", target) - print("\ttarget.for_machine:", target.for_machine) search_dirs = tuple(search_dirs) + tuple(linker.get_library_dirs(self.environment)) for libname in libs: # be conservative and record most likely shared and static resolution, because we don't know exactly diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 42c379f61e09..1a5868af976e 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -306,12 +306,6 @@ def copy_to_native(self) -> Build: other.searched_programs = set() other.dependency_overrides = PerMachineDefaultable.default(False, self.dependency_overrides.build, {}) - import pprint - print("\n=== POTATO A:") - pprint.pp(other.dependency_overrides.build.keys()) - print("\n=== POTATO B:") - pprint.pp(other.dependency_overrides.host.keys()) - print("") other.devenv = [] other.modules = [] @@ -327,20 +321,18 @@ def _copy_to(self, other: Build) -> None: other.__dict__[k] = v def merge(self, other: Build) -> None: - is_native_clone = other.environment.coredata.is_native_clone + is_native_cross = other.environment.coredata.is_native_cross() for k, v in other.__dict__.items(): if k == 'environment': continue - if is_native_clone and k == 'dependency_overrides': - print("ZKIPPING") + if is_native_cross and k == 'dependency_overrides': continue self.__dict__[k] = v - if is_native_clone: + if is_native_cross: + # XXX: Should we merge dependency_overrides? self.environment.coredata.merge_from_native_cross(other.environment.coredata) - print("TODOOOO") - pass def ensure_static_linker(self, compiler: Compiler) -> None: if self.static_linker[compiler.for_machine] is None and compiler.needs_static_linker(): @@ -687,7 +679,7 @@ def get_id(self) -> str: self.subdir, name, self.type_suffix(), '@native' if self.is_native_cross() else '') def is_native_cross(self): - return self.environment.coredata.is_native_clone + return self.environment.coredata.is_native_cross() def process_kwargs_base(self, kwargs: T.Dict[str, T.Any]) -> None: if 'build_by_default' in kwargs: @@ -1038,18 +1030,12 @@ def process_compilers(self) -> T.List[str]: # are expected to be able to add arbitrary non-source files to the # sources list for s in sources: - print(">>>>>>>>") for lang, compiler in self.all_compilers.items(): - print("lang:", lang, "compiler:", compiler) if compiler.can_compile(s): - print("\tcan_compile? yes") if lang not in self.compilers: self.compilers[lang] = compiler break - else: - print("\tcan_compile? nope") else: - print("<<<<<<<< nope!") if is_known_suffix(s): path = pathlib.Path(str(s)).as_posix() m = f'No {self.for_machine.get_lower_case_name()} machine compiler for {path!r}' @@ -1650,7 +1636,6 @@ def get_clink_dynamic_linker_and_stdlibs(self) -> T.Tuple['Compiler', T.List[str ''' # If the user set the link_language, just return that. if self.link_language: - print("get_clink_dynamic_linker_and_stdlibs(): A") comp = self.all_compilers[self.link_language] return comp, comp.language_stdlib_only_link_flags(self.environment) @@ -1658,22 +1643,10 @@ def get_clink_dynamic_linker_and_stdlibs(self) -> T.Tuple['Compiler', T.List[str # languages we don't have in self.all_compilers. Use the global list of # all compilers here. all_compilers = self.environment.coredata.compilers[self.for_machine] - print("get_clink_dynamic_linker_and_stdlibs(): B") - print("\tself.for_machine:", self.for_machine) # Languages used by dependencies dep_langs = self.get_langs_used_by_deps() - import pprint - print("\tself.compilers:") - print("\tvvv") - pprint.pp(self.compilers) - print("\t^^^") - print("\tall_compilers:") - print("\tvvv") - pprint.pp(all_compilers) - print("\t^^^") - # Pick a compiler based on the language priority-order for l in clink_langs: if l in self.compilers or l in dep_langs: @@ -1684,16 +1657,11 @@ def get_clink_dynamic_linker_and_stdlibs(self) -> T.Tuple['Compiler', T.List[str f'Could not get a dynamic linker for build target {self.name!r}. ' f'Requires a linker for language "{l}", but that is not ' 'a project language.') - print("\textracted linker:") - print(linker) - print("\twhich has for_machine:", linker.for_machine) stdlib_args: T.List[str] = self.get_used_stdlib_args(linker.language) # Type of var 'linker' is Compiler. # Pretty hard to fix because the return value is passed everywhere return linker, stdlib_args - print("get_clink_dynamic_linker_and_stdlibs(): C") - # None of our compilers can do clink, this happens for example if the # target only has ASM sources. Pick the first capable compiler. for l in clink_langs: diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 48d3d3e48ad4..1e3e0811aa9c 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -389,10 +389,6 @@ def _get_basic_compiler_args(self, env: 'Environment', mode: CompileCheckMode) - pass # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS and CPPFLAGS from the env - print("calling env.coredata.get_external_args()") - print("\tself:", self) - print("\tfor_machine:", self.for_machine) - print("\tself.language:", self.language) sys_args = env.coredata.get_external_args(self.for_machine, self.language) if isinstance(sys_args, str): sys_args = [sys_args] diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index dedd1e0e7037..b7e6de27b357 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -586,7 +586,7 @@ def __init__(self, options: argparse.Namespace, scratch_dir: str, meson_command: self.builtin_options_libdir_cross_fixup() self.init_builtins('') - self.is_native_clone = False + self._is_native_clone = False def copy_to_native(self) -> CoreData: other = CoreData.__new__(CoreData) @@ -606,7 +606,7 @@ def copy_to_native(self) -> CoreData: build=self.deps.build, host=self.deps.host) - other.is_native_clone = True + other._is_native_clone = True return other @@ -935,6 +935,9 @@ def is_cross_build(self, when_building_for: MachineChoice = MachineChoice.HOST) return False return len(self.cross_files) > 0 + def is_native_cross(self) -> bool: + return self._is_native_clone + def copy_build_options_from_regular_ones(self) -> bool: dirty = False assert not self.is_cross_build() diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index abe82af947b3..cbfddef0bf5d 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -871,7 +871,7 @@ def get_build_dir(self) -> str: return self.build_dir def build_output_rpath(self, subdir: str, *parts: T.Sequence[str]) -> str: - if self.coredata.is_native_clone: + if self.coredata.is_native_cross(): assert subdir.startswith('subprojects') result = 'subprojects-native' + subdir[11:] else: diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index a1d168eba0e9..081724a52298 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -854,7 +854,8 @@ def run_command_impl(self, return RunProcess(cmd, expanded_args, env, srcdir, builddir, self.subdir, self.environment.get_build_command() + ['introspect'], - in_builddir=in_builddir, is_native_cross=self.coredata.is_native_clone, + in_builddir=in_builddir, + is_native_cross=self.coredata.is_native_cross(), check=check, capture=capture) def func_option(self, nodes, args, kwargs): @@ -878,17 +879,10 @@ def func_subproject(self, nodes: mparser.BaseNode, args: T.Tuple[str], kwargs: k return self.do_subproject(args[0], kw) def find_subproject(self, subp_name: str, native: bool) -> T.Optional[SubprojectHolder]: - print(f"\t\t\tfind_subproject() subp_name='{subp_name}' native={native}") - print("vvv") - import pprint - pprint.pp(self.subprojects, indent=16) - print("^^^") - x = self.subprojects.get(self._make_subproject_id(subp_name, native)) - print(f"\t\t\t\t=> {x}") - return x + return self.subprojects.get(self._make_subproject_id(subp_name, native)) def _make_subproject_id(self, subp_name: str, native: bool) -> T.Tuple[str, MachineChoice]: - if self.coredata.is_native_clone: + if self.coredata.is_native_cross(): for_machine = MachineChoice.BUILD else: for_machine = MachineChoice.BUILD if native else MachineChoice.HOST @@ -1003,7 +997,7 @@ def _do_subproject_meson(self, subp_name: str, subp_id: str, subdir: str, mlog.log('Generated Meson AST:', meson_filename) mlog.cmd_ci_include(meson_filename) - is_native_cross_boundary = native and self.coredata.is_cross_build() and not self.coredata.is_native_clone + is_native_cross_boundary = native and self.coredata.is_cross_build() and not self.coredata.is_native_cross() if is_native_cross_boundary: new_build = self.build.copy_to_native() default_options = {k.as_build(): v for k, v in default_options.items()} @@ -1375,16 +1369,12 @@ def func_add_languages(self, node: mparser.FunctionNode, args: T.Tuple[T.List[st for lang in sorted(langs, key=compilers.sort_clink): mlog.log('Compiler for language', mlog.bold(lang), 'skipped: feature', mlog.bold(feature), 'disabled') return False - if self.coredata.is_native_clone: - print("add_langauges() XXX") + if self.coredata.is_native_cross(): return self.add_languages(langs, required, MachineChoice.BUILD) if native is not None: - print("add_langauges() A") - print("using machine:", self.machine_from_native_kwarg(kwargs)) for_machine = self.machine_from_native_kwarg(kwargs) return self.add_languages(langs, required, for_machine) else: - print("add_langauges() B") # absent 'native' means 'both' for backwards compatibility tv = FeatureNew.get_target_version(self.subproject) if FeatureNew.check_version(tv, '0.54.0'): @@ -2464,7 +2454,7 @@ def func_subdir(self, node: mparser.BaseNode, args: T.Tuple[str], kwargs: 'kwtyp self.processed_buildfiles.add(build_file) self.subdir = subdir os.makedirs(os.path.join(self.environment.build_dir, - compute_build_subdir(subdir, self.coredata.is_native_clone)), + compute_build_subdir(subdir, self.coredata.is_native_cross())), exist_ok=True) buildfilename = os.path.join(self.subdir, environment.build_filename) self.build_def_files.add(buildfilename) @@ -2705,8 +2695,6 @@ def func_configure_file(self, node: mparser.BaseNode, args: T.List[TYPE_var], ofile_abs = os.path.join(self.environment.build_dir, ofile_path, ofile_fname) output_subdir = self.environment.build_output_rpath(self.subdir) - print("=== configure_file()") - print("output_subdir:", output_subdir) # Perform the appropriate action if kwargs['configuration'] is not None: @@ -2894,7 +2882,7 @@ def build_incdir_object(self, incdir_strings: T.List[str], is_system: bool = Fal absdir_build = os.path.join(absbase_build, a) if not os.path.isdir(absdir_src) and not os.path.isdir(absdir_build): raise InvalidArguments(f'Include dir {a} does not exist.') - i = build.IncludeDirs(self.subdir, incdir_strings, is_system, self.coredata.is_native_clone) + i = build.IncludeDirs(self.subdir, incdir_strings, is_system, self.coredata.is_native_cross()) return i @typed_pos_args('add_test_setup', str) @@ -3365,7 +3353,7 @@ def build_target(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargs targetclass: T.Type[T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]] ) -> T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]: name, sources = args - if self.coredata.is_native_clone: + if self.coredata.is_native_cross(): for_machine = MachineChoice.BUILD kwargs['install'] = False else: @@ -3489,7 +3477,7 @@ def build_target(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargs return target def kwarg_options_to_machine(self, kwargs: kwtypes.FuncWithNativeArg) -> MachineChoice: - if self.coredata.is_native_clone: + if self.coredata.is_native_cross(): return MachineChoice.BUILD return kwargs['native'] diff --git a/mesonbuild/interpreter/interpreterobjects.py b/mesonbuild/interpreter/interpreterobjects.py index ad27ea5d9681..9a20eb7b98df 100644 --- a/mesonbuild/interpreter/interpreterobjects.py +++ b/mesonbuild/interpreter/interpreterobjects.py @@ -242,12 +242,9 @@ def run_command(self, 'MESONINTROSPECT': ' '.join([shlex.quote(x) for x in mesonintrospect]), } if in_builddir: - print("XXX: A, subdir:", subdir) cwd = os.path.join(build_dir, compute_build_subdir(subdir, is_native_cross)) else: - print("XXX: B, subdir:", subdir) cwd = os.path.join(source_dir, subdir) - print("XXX: cwd:", cwd) child_env = os.environ.copy() child_env.update(menv) child_env = env.get_env(child_env) @@ -898,7 +895,7 @@ def found_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> bool: @noPosargs @noKwargs def private_dir_include_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> build.IncludeDirs: - return build.IncludeDirs('', [], False, self.interpreter.coredata.is_native_clone, + return build.IncludeDirs('', [], False, self.interpreter.coredata.is_native_cross(), [self.interpreter.backend.get_target_private_dir(self._target_object)]) @noPosargs diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index 21cf0ac0f0fd..df34a60bf85f 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -54,7 +54,7 @@ def __init__(self, interpreter: 'Interpreter') -> None: self.current_node = interpreter.current_node def is_native_cross(self) -> bool: - return self._interpreter.coredata.is_native_clone + return self._interpreter.coredata.is_native_cross() def get_include_args(self, include_dirs: T.Iterable[T.Union[str, build.IncludeDirs]], prefix: str = '-I') -> T.List[str]: if not include_dirs: