def generate_args(self): configure_args = [] configure_args.extend(self.configure_args) if self.default_configure_install_args: # If someone want arguments but not the defaults can pass them in args manually configure_args.extend([ "--prefix=%s" % self._conanfile.package_folder.replace("\\", "/"), "--bindir=${prefix}/bin", "--sbindir=${prefix}/bin", "--libdir=${prefix}/lib", "--includedir=${prefix}/include", "--oldincludedir=${prefix}/include", "--datarootdir=${prefix}/share" ]) user_args_str = args_to_string(self.configure_args) for flag, var in (("host", self._host), ("build", self._build), ("target", self._target)): if var and flag not in user_args_str: configure_args.append('--{}={}'.format(flag, var)) args = { "configure_args": args_to_string(configure_args), "make_args": args_to_string(self.make_args) } save_toolchain_args(args, namespace=self._namespace)
def _writebuild(self, toolchain_file): result = {} # TODO: Lets do it compatible with presets soon if self.generator is not None: result["cmake_generator"] = self.generator result["cmake_toolchain_file"] = toolchain_file or self.filename if result: save_toolchain_args(result, namespace=self._namespace)
def test_save_toolchain_args_full(): temp_folder = tempfile.mkdtemp() content = { 'win_path': r'my\win\path', 'command': r'conan --option "My Option"', 'my_regex': r'([A-Z])\w+' } save_toolchain_args(content, generators_folder=temp_folder) args = load(os.path.join(temp_folder, CONAN_TOOLCHAIN_ARGS_FILE)) assert "[%s]" % CONAN_TOOLCHAIN_ARGS_SECTION in args assert r'win_path = my\win\path' in args
def test_source_folder_works(): folder = temp_folder() os.chdir(folder) save_toolchain_args({"configure_args": "-foo bar", "make_args": ""}) conanfile = ConanFileMock() conanfile.folders.set_base_install(folder) sources = "/path/to/sources" conanfile.folders.set_base_source(sources) autotools = Autotools(conanfile) autotools.configure(build_script_folder="subfolder") assert conanfile.command.replace( "\\", "/") == "/path/to/sources/subfolder/configure -foo bar" autotools.configure() assert conanfile.command.replace( "\\", "/") == "/path/to/sources/configure -foo bar"
def test_configure_arguments(): tmp = temp_folder() os.chdir(tmp) save_toolchain_args({ "configure_args": "my_configure_args", "make_args": "my_make_args" }) runner = RunnerMock() conanfile = ConanFile(Mock(), runner=runner) conanfile.settings = MockSettings({}) conanfile.folders.set_base_install(tmp) conanfile.folders.set_base_source(tmp) conanfile.conf = Conf() conanfile.conf["tools.gnu:make_program"] = "my_make" conanfile.conf["tools.build:jobs"] = "23" ab = Autotools(conanfile) ab.configure() assert "configure my_configure_args" in runner.command_called ab = Autotools(conanfile) ab.make() assert "my_make my_make_args -j23" in runner.command_called
def generate(self): save_toolchain_args({ "bazel_config": self._conanfile.conf["tools.google.bazel:config"], "bazelrc_path": self._conanfile.conf["tools.google.bazel:bazelrc_path"] })
def test_save_toolchain_args_empty(): temp_folder = tempfile.mkdtemp() content = {} save_toolchain_args(content, generators_folder=temp_folder) args = load(os.path.join(temp_folder, CONAN_TOOLCHAIN_ARGS_FILE)) assert "[%s]" % CONAN_TOOLCHAIN_ARGS_SECTION in args