def cross_platform_msg_test(self): bad_os = "Linux" if platform.system() != "Linux" else "Macos" message = "Cross-platform from '%s' to '%s'" % (detected_os(), bad_os) self._create("Hello0", "0.1") self.client.run("install Hello0/0.1@lasote/stable -s os=%s" % bad_os, ignore_error=True) self.assertIn(message, self.client.user_io.out)
def cross_platform_msg_test(self): # Explicit with os_build and os_arch settings message = "Cross-build from 'Linux:x86_64' to 'Windows:x86_64'" self._create("Hello0", "0.1", settings='"os_build", "os", "arch_build", "arch", "compiler"') self.client.run("install Hello0/0.1@lasote/stable -s os_build=Linux -s os=Windows", ignore_error=True) self.assertIn(message, self.client.user_io.out) # Implicit detection when not available (retrocompatibility) bad_os = "Linux" if platform.system() != "Linux" else "Macos" message = "Cross-build from '%s:x86_64' to '%s:x86_64'" % (detected_os(), bad_os) self._create("Hello0", "0.1") self.client.run("install Hello0/0.1@lasote/stable -s os=%s" % bad_os, ignore_error=True) self.assertIn(message, self.client.user_io.out)
def install(self, reference, install_folder, profile, remote=None, build_modes=None, filename=None, update=False, manifest_folder=None, manifest_verify=False, manifest_interactive=False, generators=None, no_imports=False, inject_require=None, cwd=None, install_reference=False): """ Fetch and build all dependencies for the given reference @param reference: ConanFileReference or path to user space conanfile @param install_folder: where the output files will be saved @param remote: install only from that remote @param profile: Profile object with both the -s introduced options and profile read values @param build_modes: List of build_modes specified @param filename: Optional filename of the conanfile @param update: Check for updated in the upstream remotes (and update) @param manifest_folder: Folder to install the manifests @param manifest_verify: Verify dependencies manifests against stored ones @param manifest_interactive: Install deps manifests in folder for later verify, asking user for confirmation @param generators: List of generators from command line. If False, no generator will be written @param no_imports: Install specified packages but avoid running imports @param inject_require: Reference to add as a requirement to the conanfile @param cwd: Only used in case of reference, to get a conanfile_directory to a virtual SMELL """ if generators is not False: generators = set(generators) if generators else set() generators.add("txt") # Add txt generator by default manifest_manager = ManifestManager( manifest_folder, user_io=self._user_io, client_cache=self._client_cache, verify=manifest_verify, interactive=manifest_interactive) if manifest_folder else None remote_proxy = ConanProxy(self._client_cache, self._user_io, self._remote_manager, remote, update=update, manifest_manager=manifest_manager) loader = self.get_loader(profile) if not install_reference and isinstance( reference, ConanFileReference): # is a create loader.dev_reference = reference conanfile = self._load_install_conanfile(loader, reference, filename, cwd=cwd) if inject_require: self._inject_require(conanfile, inject_require) graph_builder = self._get_graph_builder(loader, update, remote_proxy) deps_graph = graph_builder.load(conanfile) # This line is so the conaninfo stores the correct complete info conanfile.info.scope = profile.scopes registry = RemoteRegistry(self._client_cache.registry, self._user_io.out) if inject_require: output = ScopedOutput("%s test package" % str(inject_require), self._user_io.out) output.info("Installing dependencies") else: if not isinstance(reference, ConanFileReference): output = ScopedOutput("PROJECT", self._user_io.out) output.highlight("Installing %s" % reference) else: output = ScopedOutput(str(reference), self._user_io.out) output.highlight("Installing package") Printer(self._user_io.out).print_graph(deps_graph, registry) try: if loader._settings.os and detected_os() != loader._settings.os: message = "Cross-platform from '%s' to '%s'" % ( detected_os(), loader._settings.os) self._user_io.out.writeln(message, Color.BRIGHT_MAGENTA) except ConanException: # Setting os doesn't exist pass build_mode = BuildMode(build_modes, self._user_io.out) build_requires = BuildRequires(loader, graph_builder, registry, output, profile.build_requires) installer = ConanInstaller(self._client_cache, output, remote_proxy, build_mode, build_requires) # Apply build_requires to consumer conanfile if not isinstance(reference, ConanFileReference): build_requires.install("", conanfile, installer) installer.install(deps_graph) build_mode.report_matches() if install_folder: # Write generators if generators is not False: tmp = list(conanfile.generators ) # Add the command line specified generators tmp.extend([g for g in generators if g not in tmp]) conanfile.generators = tmp write_generators(conanfile, install_folder, output) if not isinstance(reference, ConanFileReference): # Write conaninfo content = normalize(conanfile.info.dumps()) save(os.path.join(install_folder, CONANINFO), content) output.info("Generated %s" % CONANINFO) if not no_imports: run_imports(conanfile, install_folder, output) call_system_requirements(conanfile, output) if install_reference: # The conanfile loaded is really a virtual one. The one with the deploy is the first level one deploy_conanfile = deps_graph.inverse_levels()[1][0].conanfile if hasattr(deploy_conanfile, "deploy") and callable( deploy_conanfile.deploy): run_deploy(deploy_conanfile, install_folder, output) if manifest_manager: manifest_manager.print_log()