def _generate_aggregated_env(conanfile): from conan.tools.microsoft import unix_path for group, env_scripts in conanfile.env_scripts.items(): bats = [] shs = [] for env_script in env_scripts: path = os.path.join(conanfile.generators_folder, env_script) if env_script.endswith(".bat"): bats.append(path) elif env_script.endswith(".sh"): shs.append(unix_path(conanfile, path)) if shs: sh_content = ". " + " && . ".join('"{}"'.format(s) for s in shs) save( os.path.join(conanfile.generators_folder, "conan{}.sh".format(group)), sh_content) if bats: lines = "\r\n".join('call "{}"'.format(b) for b in bats) bat_content = textwrap.dedent("""\ @echo off {} """.format(lines)) save( os.path.join(conanfile.generators_folder, "conan{}.bat".format(group)), bat_content)
def _adjust_path(self, path): if self._base_compiler == 'Visual Studio': path = path.replace('/', '\\') else: path = path.replace('\\', '/') path = unix_path(self._conanfile, path) return '"%s"' % path if ' ' in path else path
def test_unix_path(subsystem, expected_path): c = ConfDefinition() c.loads( textwrap.dedent("""\ tools.microsoft.bash:subsystem={} """.format(subsystem))) settings = MockSettings({"os": "Windows"}) conanfile = ConanFileMock() conanfile.conf = c.get_conanfile_conf(None) conanfile.settings = settings conanfile.settings_build = settings conanfile.win_bash = True path = unix_path(conanfile, "c:/path/to/stuff") assert expected_path == path
def configure(self, build_script_folder=None): """ http://jingfenghanmax.blogspot.com.es/2010/09/configure-with-host-target-and-build.html https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html """ # FIXME: Conan 2.0 Are we keeping the "should_XXX" properties??? if not self._conanfile.should_configure: return source = self._conanfile.source_folder if build_script_folder: source = os.path.join(self._conanfile.source_folder, build_script_folder) configure_cmd = "{}/configure".format(source) configure_cmd = unix_path(self._conanfile, configure_cmd) cmd = "{} {}".format(configure_cmd, self._configure_args) self._conanfile.output.info("Calling:\n > %s" % cmd) self._conanfile.run(cmd)