def build(self): config = "dev" if self.settings.build_type == "Debug" else "release" if self.settings.os == "Windows": env_vars = tools.vcvars_dict(self) with tools.vcvars(self.settings): self.run("bash {} {} {} {} {} '{}' '{}' {}".format( self._build_script, self._source_subfolder, self._ospl_platform + "-" + config, tools.cpu_count(), "msvc" if self.settings.compiler == "Visual Studio" else "", env_vars["VSINSTALLDIR"], env_vars["WindowsSdkDir"], "yes" if self.options.include_cs else "no"), win_bash=True, subsystem="cygwin") elif self.settings.os == "Android": # Need to build for host first. self.run("bash {} {} x86_64.linux-tools {}".format( self._build_script, self._source_subfolder, tools.cpu_count())) # Hack to ensure that %idl.STAMP is run tools.replace_in_file( os.path.join(self._source_subfolder, 'src', 'osplcore', 'makefile.mak'), 'idl | build_tools_stage_idlpp', 'idl ') self.run( "bash {} {} {} {} $CC $CXX $RANLIB $AR $SYSROOT $ANDROID_ABI". format(self._build_android, self._source_subfolder, self._ospl_platform + "-" + config, tools.cpu_count()), run_environment=True) else: self.run("bash {} {} {} {} {}".format( self._build_script, self._source_subfolder, self._ospl_platform + "-" + config, tools.cpu_count(), ""))
def build(self): outdir = self.build_folder includedir = outdir + self.include_install_path() mkspecsdir = outdir + '/mkspecs' libdir = outdir + '/lib' env_vars = tools.vcvars_dict(self.settings) env_vars['_CL_'] = '/utf-8' with tools.environment_append(env_vars): command = 'qmake -r' command += ' VERSION=%s' % self.version # command += ' CONFIG-=debug_and_release' # command += ' CONFIG-=debug_and_release_target' command += ' CONFIG+=release' command += ' PREFIX=%s' % outdir command += ' LIB_INSTALL_DIR=%s' % libdir command += ' INCLUDE_INSTALL_DIR=%s' % includedir command += ' MKSPECS_INSTALL_DIR=%s' % mkspecsdir command += ' DTK_STATIC_LIB=YES' command += ' DTK_STATIC_TRANSLATION=YES' command += ' DTK_NO_MULTIMEDIA=YES' command += ' %s' % self.source_folder self.run(command) self.run('jom clean') self.run('jom') self.run('jom install')
def package(self): meson = Meson(self) meson.install(build_dir="meson") if self.settings.os == "Linux": pass if self.settings.os == "Windows": bin_dir = os.path.join(self.package_folder, 'bin') vars_dict = tools.vcvars_dict(self.settings) windows_sdk_dir = vars_dict['WindowsSdkDir'] windows_sdk_version = vars_dict['WindowsSDKVersion'] ucrt_redist_dir = os.path.join(windows_sdk_dir, 'Redist', windows_sdk_version, 'ucrt', 'DLLs', 'x64') if not os.path.exists(ucrt_redist_dir): raise ConanInvalidConfiguration( "ucrt redist dir does not exist: %s" % (ucrt_redist_dir)) self.copy('*.dll', dst=bin_dir, src=ucrt_redist_dir) vctoolsredist_dir = vars_dict['VCToolsRedistDir'] vcredist_dir = os.path.join(vctoolsredist_dir, 'x64', 'Microsoft.VC142.CRT') if not os.path.exists(vcredist_dir): raise ConanInvalidConfiguration( "ucrt redist dir does not exist: %s" % (ucrt_redist_dir)) self.copy('*.dll', dst=bin_dir, src=vcredist_dir) qt_path_bin = self._get_qt_bin_paths() with tools.environment_append({"PATH": qt_path_bin}): with tools.chdir(bin_dir): qml_dir = os.path.join(self.source_folder, 'fubble', 'app') # dont do -no-widgets # widgets is needed for svg self.run( 'windeployqt.exe fubble.exe --no-compiler-runtime --qmldir "%s"' % (qml_dir))
def _create_auto_tools_environment(self, autotools): extra_env_vars = {} if self.settings.compiler == "Visual Studio": self.package_folder = tools.unix_path(self.package_folder) msvcc = tools.unix_path(os.path.join(self.source_folder, self._source_subfolder, "msvcc.sh")) msvcc.replace("\\", "/") msvcc_args = [] autotools.defines.append("FFI_BUILDING") if not self.options.shared: autotools.defines.append("FFI_STATIC") if "MT" in self.settings.compiler.runtime: autotools.defines.append("USE_STATIC_RTL") if "d" in self.settings.compiler.runtime: autotools.defines.append("USE_DEBUG_RTL") if self.settings.arch == "x86_64": msvcc_args.append("-m64") elif self.settings.arch == "x86": msvcc_args.append("-m32") if msvcc_args: msvcc = "{} {}".format(msvcc, " ".join(msvcc_args)) extra_env_vars.update(tools.vcvars_dict(self.settings)) extra_env_vars.update({ "INSTALL": tools.unix_path(os.path.join(self.source_folder, self._source_subfolder, "install-sh")), "LIBTOOL": tools.unix_path(os.path.join(self.source_folder, self._source_subfolder, "ltmain.sh")), "CC": msvcc, "CXX": msvcc, "LD": "link", "CPP": "cl -nologo -EP", "CXXCPP": "cl -nologo -EP", }) with tools.environment_append(extra_env_vars): yield
def package_info(self): allvars = tools.vcvars_dict(self.settings) path = allvars["PATH"].split(os.pathsep) def relevant_path(path): return "Visual" in path or "Microsoft" in path or "MS" in path path = [entry for entry in path if relevant_path(entry)] # very weak self.env_info.PATH = path
def get_build_environment(self): env = {} if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio": env = tools.vcvars_dict(self.settings, filter_known_paths=False) toolset = str(self.settings.compiler.get_safe("toolset")) if toolset.endswith("_xp"): import find_sdk_winxp env = find_sdk_winxp.dict_append(self.settings.arch, env=env) return env
def __init__(self, conanfile): super(VirtualBuildEnvGenerator, self).__init__(conanfile) self.venv_name = "conanbuildenv" compiler = conanfile.settings.get_safe("compiler") if compiler == "Visual Studio": self.env = VisualStudioBuildEnvironment(conanfile).vars_dict self.env.update(vcvars_dict(conanfile.settings)) else: self.env = AutoToolsBuildEnvironment(conanfile).vars_dict
def build(self): cmake = CMake(self) if self.settings.os_build == "Windows": vcvars = tools.vcvars_dict(self.settings) cmake.definitions["VSINSTALLDIR"] = vcvars["VSINSTALLDIR"].rstrip( '\\') cmake.configure(source_folder=self._source_dir) cmake.build()
def _run(self, command): def _build(): self._conanfile.run(command) if self._vcvars_needed: vcvars_dict = tools.vcvars_dict(self._settings, output=self._conanfile.output) with _environment_add(vcvars_dict, post=self._append_vcvars): _build() else: _build()
def build(self): environment = {} if self.settings.compiler == "Visual Studio": environment.update(tools.vcvars_dict(self.settings)) with tools.environment_append(environment): cxx = tools.get_env("CXX") self.run("{cxx} {src} -o example".format(cxx=cxx, src=os.path.join( self.source_folder, "example.cpp")), win_bash=self.settings.os is "Windows")
def build(self): """Build the elements to package.""" qmake = "qmake" environment = {} if self.settings.os == "Windows": environment = tools.vcvars_dict(self) environment["CMAKE_GENERATOR"] = "Visual Studio 14 2015 Win64" qmake += ".exe" environment["PYSIDE_DISABLE_INTERNAL_QT_CONF"] = "1" # There may be a DLL conflict. Put Qt and libClang DLLs in front of the PATH. if self.settings.os == "Windows": if not "PATH" in environment: environment["PATH"] = [] environment["PATH"].insert(0, self.deps_cpp_info["qt"].bin_paths[0]) if not "LLVM_INSTALL_DIR" in os.environ: clang_path = os.path.join(self.source_folder, "libclang") environment["PATH"].insert(0, (os.path.join(clang_path, "bin"))) environment["LLVM_INSTALL_DIR"] = clang_path arguments = [ "--qmake=\"%s\"" % os.path.join(self.deps_cpp_info["qt"].rootpath, "bin", qmake), #"--skip-modules=QtNetwork,QtOpenGLFunctions,QtQuick,QtQuickWidgets,QtQml", "--skip-docs", "--prefix=%s" % self.package_folder, "--parallel=%s" % tools.cpu_count(), "--openssl=\"%s\"" % os.path.join(self.deps_cpp_info["OpenSSL"].rootpath, "bin"), "--ignore-git", ] if self.settings.build_type == "Debug": arguments.append("--debug") if self.settings.os == "Windows": arguments.append("--jom") setup = os.path.join(self.source_folder, self._source_subfolder, "setup.py") with tools.environment_append(environment): with tools.chdir(self._source_subfolder): if self.settings.os == "Windows": python_exe = "python_d.exe" if self.settings.build_type == "Debug" else "python.exe" else: python_exe = "python" self.run(python_exe + " %s install %s" % (setup, " ".join(arguments)))
def _build_msbuild(self): msbuild = MSBuild(self) with tools.chdir(self._source_subfolder): tools.replace_in_file("msvc\\libhunspell.vcxproj", "v140_xp", "v140") env_vars = tools.vcvars_dict(self.settings) winsdkver = env_vars["WindowsSDKVersion"].replace("\\", "") self.output.info('Using Windows SDK Version %s' % winsdkver) tools.replace_in_file("msvc\\libhunspell.vcxproj", "<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>", "<WindowsTargetPlatformVersion>%s</WindowsTargetPlatformVersion>" % winsdkver) if (self.options.shared): msbuild.build("msvc\\libhunspell.vcxproj") else: msbuild.build("msvc\\libhunspell.vcxproj", definitions={"HUNSPELL_STATIC": None})
def build(self): output_name = "jscript" if self.settings.os == "Windows": output_name += { "x86": "32", "x86_64": "64" }.get(str(self.settings.arch)) if self.settings.build_type == "Debug": output_name += "d" # flags = [ #"--ninja", "--shared", "--dest-os=%s" % { "Windows": "win", "Linux": "linux" }.get(str(self.settings.os)), "--dest-cpu=%s" % { "x86": "ia32", "x86_64": "x64" }.get(str(self.settings.arch)), "--node_core_target_name=%s" % output_name ] # if self.settings.build_type == "Debug": flags.append("--debug") # Run build env = {} if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio": env = tools.vcvars_dict(self.settings) env["GYP_MSVS_VERSION"] = { "14": "2015", "15": "2017" }.get(str(self.settings.compiler.version)) self.run("python --version") with tools.chdir("src"), tools.environment_append(env): self.run("python configure %s" % " ".join(flags)) if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio": build_type = str(self.settings.build_type) arch = { "x86": "Win32", "x86_64": "x64" }.get(str(self.settings.arch)) self.run( "msbuild node.sln /m /t:Build /p:Configuration=%s /p:Platform=%s" % (build_type, arch)) else: self.run("make -j %s" % tools.cpu_count())
def get_build_environment(self): env = {} if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio": if tools.get_env("VisualStudioVersion") is not None: self.output.warn("vcvars already set, skip") # self.output.warn("Shift Cygwin path to end") path_lst = os.environ["PATH"].split(os.pathsep) cygwin_path = self.deps_env_info["cygwin_installer"].path[0] path_lst.remove(cygwin_path) path_lst.append(cygwin_path) os.environ["PATH"] = os.pathsep.join(path_lst) else: env = tools.vcvars_dict(self.settings, filter_known_paths=False, force=True) return env
def vcvars_dict_test(self): # https://github.com/conan-io/conan/issues/2904 output_with_newline_and_spaces = """__BEGINS__ PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 9, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=9e09 set nl=^ env_var= without_equals_sign ProgramFiles(x86)=C:\Program Files (x86) """.encode("utf-8") def vcvars_command_mock(settings, arch, compiler_version, force, vcvars_ver, winsdk_version): # @UnusedVariable return "unused command" def subprocess_check_output_mock(cmd, shell): self.assertIn("unused command", cmd) return output_with_newline_and_spaces with mock.patch('conans.client.tools.win.vcvars_command', new=vcvars_command_mock): with mock.patch('subprocess.check_output', new=subprocess_check_output_mock): vars = tools.vcvars_dict(None, only_diff=False) self.assertEqual(vars["PROCESSOR_ARCHITECTURE"], "AMD64") self.assertEqual( vars["PROCESSOR_IDENTIFIER"], "Intel64 Family 6 Model 158 Stepping 9, GenuineIntel") self.assertEqual(vars["PROCESSOR_LEVEL"], "6") self.assertEqual(vars["PROCESSOR_REVISION"], "9e09") self.assertEqual(vars["ProgramFiles(x86)"], "C:\Program Files (x86)")
def _build_msvc(self): arch_ext = "{}".format(32 if self.settings.arch == "x86" else 64) vcbuild_folder = os.path.join(self.build_folder, self._source_subfolder, "vcbuild") libmpdec_folder = os.path.join(self.build_folder, self._source_subfolder, "libmpdec") dist_folder = os.path.join(vcbuild_folder, "dist{}".format(arch_ext)) os.mkdir(dist_folder) makefile_vc_original = os.path.join(libmpdec_folder, "Makefile.vc") for msvcrt in ("MDd", "MTd", "MD", "MT"): tools.replace_in_file(makefile_vc_original, msvcrt, str(self.settings.compiler.runtime)) shutil.copy(os.path.join(libmpdec_folder, "Makefile.vc"), os.path.join(libmpdec_folder, "Makefile")) with tools.chdir(libmpdec_folder): with tools.environment_append(tools.vcvars_dict(self.settings)): self.run("nmake clean") self.run("nmake MACHINE={machine} DLL={dll}".format( machine="ppro" if self.settings.arch == "x86" else "x64", dll="1" if self.options.shared else "0")) shutil.copy("mpdecimal.h", dist_folder) if self.options.shared: shutil.copy( "libmpdec-{}.dll".format(self.version), os.path.join(dist_folder, "libmpdec-{}.dll".format(self.version))) shutil.copy( "libmpdec-{}.dll.exp".format(self.version), os.path.join(dist_folder, "libmpdec-{}.exp".format(self.version))) shutil.copy( "libmpdec-{}.dll.lib".format(self.version), os.path.join(dist_folder, "libmpdec-{}.lib".format(self.version))) else: shutil.copy("libmpdec-{}.lib".format(self.version), dist_folder)
def build(self): out_dir_path="out" if self.settings.os == "Windows": build_env = tools.vcvars_dict(self.settings) else: # GNU binutils's ld and gold don't support Darwin (macOS) # Use the default provided linker build_env = dict() if self.settings.os == "Linux": if self.options.use_gold_linker: build_env["LDFLAGS"] = "-fuse-ld=gold" with tools.environment_append(build_env): with tools.chdir('%s/gn' % (self.source_folder)): python_executable = sys.executable self.run("{python} build/gen.py"\ .format(python=python_executable)) self.run("ninja -j {cpu_nb} -C {build_dir}"\ .format(cpu_nb=tools.cpu_count()-1, build_dir=out_dir_path)) if self.options.tests: self.run("{build_dir}/gn_unittests".format(build_dir=out_dir_path))
def build(self): outdir = self.build_folder env_vars = tools.vcvars_dict(self.settings) env_vars['_CL_'] = '/utf-8' with tools.environment_append(env_vars): command = 'qmake -r' command += ' VERSION=%s' % self.version # command += ' CONFIG-=debug_and_release' # command += ' CONFIG-=debug_and_release_target' command += ' CONFIG+=release' command += ' PREFIX=%s' % outdir command += ' DEFINES+=DTK_STATIC_LIB' command += ' DTK_STATIC_TRANSLATION=YES' command += ' DTK_NO_MULTIMEDIA=YES' command += ' %s' % self.source_folder self.run(command) # self.run('jom clean') self.run('jom') self.run('jom install')
def msvc_build(self, build_options): configure_cmd = "perl " + os.path.join(self.source_folder, "src", "Configure") build_options.append( "-D_WIN32_WINNT=0x0601" ) # Windows 7 and Windows Server 2008 R2 minimal target target = { "x86": "VC-WIN32", "x86_64": "VC-WIN64A" }.get(str(self.settings.arch)) env = tools.vcvars_dict(self.settings) env["LINK"] = "/subsystem:console,6.01" # Windows 7 and Windows Server 2008 R2 minimal target # Run build with tools.environment_append(env): self.run("perl --version") self.run("%s %s %s" % (configure_cmd, " ".join(build_options), target)) self.run("nmake") if self.options.with_unit_tests: self.run("nmake test")
def _build_context(self): extra_env_vars = {} if tools.os_info.is_windows and (self._is_msvc or self.settings.compiler == "clang"): msvcc = tools.unix_path( os.path.join(self.source_folder, self._source_subfolder, "msvcc.sh")) msvcc_args = [] if self._is_msvc: if self.settings.arch == "x86_64": msvcc_args.append("-m64") elif self.settings.arch == "x86": msvcc_args.append("-m32") elif self.settings.compiler == "clang": msvcc_args.append("-clang-cl") if msvcc_args: msvcc = "{} {}".format(msvcc, " ".join(msvcc_args)) extra_env_vars.update(tools.vcvars_dict(self.settings)) extra_env_vars.update({ "INSTALL": tools.unix_path( os.path.join(self.source_folder, self._source_subfolder, "install-sh")), "LIBTOOL": tools.unix_path( os.path.join(self.source_folder, self._source_subfolder, "ltmain.sh")), "CC": msvcc, "CXX": msvcc, "LD": "link", "CPP": "cl -nologo -EP", "CXXCPP": "cl -nologo -EP", }) with tools.environment_append(extra_env_vars): yield
def _build_msvc(self): self._fix_msvc_sources() libmpdec_folder = os.path.join(self.build_folder, self._source_subfolder, "libmpdec") vcbuild_folder = os.path.join(self.build_folder, self._source_subfolder, "vcbuild") arch_ext = "{}".format(32 if self.settings.arch == "x86" else 64) main_version, _ = self.version.split(".", 1) dist_folder = os.path.join(vcbuild_folder, "dist{}".format(arch_ext)) os.mkdir(dist_folder) shutil.copy(os.path.join(libmpdec_folder, "Makefile.vc"), os.path.join(libmpdec_folder, "Makefile")) with tools.chdir(libmpdec_folder): with tools.environment_append(tools.vcvars_dict(self.settings)): # self.run("nmake /nologo clean") self.run("nmake /nologo MACHINE={machine} DLL={dll}".format( machine="ppro" if self.settings.arch == "x86" else "x64", dll="1" if self.options.shared else "0")) shutil.copy("mpdecimal.h", dist_folder) if self.options.shared: shutil.copy( "libmpdec-{}.dll".format(main_version), os.path.join(dist_folder, "libmpdec-{}.dll".format(main_version))) shutil.copy( "libmpdec-{}.dll.exp".format(main_version), os.path.join(dist_folder, "libmpdec-{}.exp".format(main_version))) shutil.copy( "libmpdec-{}.dll.lib".format(main_version), os.path.join(dist_folder, "libmpdec-{}.lib".format(main_version))) else: shutil.copy("libmpdec-{}.lib".format(main_version), dist_folder)
def build(self): with tools.chdir(self.source_dir): build_dir = path.join(self.build_folder, "build-dir") if self.settings.os == "Windows": python_executable = "C:\\Python27\\python.exe" build_env = tools.vcvars_dict(self.settings) else: python_executable = "python3" # GNU binutils's ld and gold don't support Darwin (macOS) # Use the default provided linker build_env = dict() if self.settings.os == "Linux": build_env["LDFLAGS"] = "-fuse-ld=gold" with tools.environment_append(build_env): self.run("{python} build/gen.py --out-path={build_dir}"\ .format(python=python_executable, build_dir=build_dir)) self.run("ninja -j {cpu_nb} -C {build_dir}"\ .format(cpu_nb=tools.cpu_count()-1, build_dir=build_dir)) if self.options.tests: self.run( "{build_dir}/gn_unittests".format(build_dir=build_dir))
def package(self): if self.options.debian_packaging: shutil.rmtree(self.package_folder) self.copy("OrbitService", src="bin/", dst="{}-{}/opt/developer/tools/".format(self.name, self._version())) self.copy("liborbit.so", src="lib/", dst="{}-{}/opt/developer/tools/".format(self.name, self._version())) self.copy("NOTICE", dst="{}-{}/usr/share/doc/{}/".format(self.name, self._version(), self.name)) self.copy("LICENSE", dst="{}-{}/usr/share/doc/{}/".format(self.name, self._version(), self.name)) basedir = "{}/{}-{}".format(self.package_folder, self.name, self._version()) os.makedirs("{}/DEBIAN".format(basedir), exist_ok=True) tools.save("{}/DEBIAN/control".format(basedir), """Package: orbitprofiler Version: {} Section: development Priority: optional Architecture: amd64 Maintainer: Google, Inc <*****@*****.**> Description: Orbit is a C/C++ profiler for Windows, Linux and the Stadia Platform. Homepage: https://github.com/google/orbit Installed-Size: `du -ks usr/ | cut -f 1` """.format(self._version())) tools.save("{}/DEBIAN/postinst".format(basedir), """ #!/bin/bash # Setting the setuid-bit for OrbitService chmod -v 4775 /opt/developer/tools/OrbitService """) self.run("chmod +x {}/DEBIAN/postinst".format(basedir)) self.run("chmod g-s {}/DEBIAN".format(basedir)) self.run("chmod g-s {}/".format(basedir)) self.run("dpkg-deb -b --root-owner-group {}".format(basedir)) self.run("dpkg --contents {}.deb".format(basedir)) shutil.rmtree(basedir) self.copy("*", src="bin/fonts", dst="bin/fonts", symlinks=True) self.copy("*", src="bin/shaders", dst="bin/shaders", symlinks=True) self.copy("*.pdb", src="bin/", dst="bin") self.copy("Orbit", src="bin/", dst="bin") self.copy("Orbit.exe", src="bin/", dst="bin") self.copy("Orbit.debug", src="bin/", dst="bin") self.copy("OrbitService", src="bin/", dst="bin") self.copy("OrbitService.exe", src="bin/", dst="bin") self.copy("OrbitService.debug", src="bin/", dst="bin") self.copy("OrbitClientGgp", src="bin/", dst="bin") self.copy("OrbitClientGgp.exe", src="bin/", dst="bin") self.copy("OrbitClientGgp.debug", src="bin/", dst="bin") self.copy("crashpad_handler.exe", src="bin/", dst="bin") self.copy("NOTICE") self.copy("NOTICE.Chromium") self.copy("NOTICE.Chromium.csv") self.copy("LICENSE") self.copy("liborbit.so", src="lib/", dst="lib") self.copy("libOrbitVulkanLayer.so", src="lib/", dst="lib") self.copy("VkLayer_Orbit_implicit.json", src="lib/", dst="lib") self.copy("LinuxTracingIntegrationTests", src="bin/", dst="bin") self.copy("LinuxTracingIntegrationTests.debug", src="bin/", dst="bin") self.copy("libLinuxTracingIntegrationTestPuppetSharedObject.so", src="lib/", dst="lib") self.copy("libLinuxTracingIntegrationTestPuppetSharedObject.so.debug", src="lib/", dst="lib") self.copy("OrbitFakeClient", src="bin/", dst="bin") self.copy("OrbitFakeClient.debug", src="bin/", dst="bin") self.copy("opengl32sw.dll", src="bin/", dst="bin") if not self.options.system_qt: orbit_executable = "Orbit.exe" if self.settings.os == "Windows" else "Orbit" self.run("windeployqt --pdb {}".format(orbit_executable), cwd=os.path.join(self.package_folder, "bin"), run_environment=True) # Package Visual C++ and C Runtime vcvars = tools.vcvars_dict(self) if 'VCToolsRedistDir' in vcvars: arch = 'x64' if self.settings.arch == 'x86_64' else 'x86' src_path = os.path.join(vcvars['VCToolsRedistDir'], arch, 'Microsoft.VC142.CRT') self.copy("*.dll", src=src_path, dst="bin")