def package(self): cmake = self._configure_cmake() cmake.install() self.copy("licence.txt", dst="licenses", src=self._source_subfolder) tools.mkdir( os.path.join(self.package_folder, self._new_mfast_config_dir)) self._extract_fasttypegentarget_macro() tools.rmdir( os.path.join(self.package_folder, self._old_mfast_config_dir)) tools.rmdir(os.path.join(self.package_folder, "share")) if self.options.shared: tools.remove_files_by_mask( os.path.join(self.package_folder, "lib"), "*_static*" if self.settings.os == "Windows" else "*.a") # TODO: several CMake variables should also be emulated (casing issues): # [ ] MFAST_INCLUDE_DIR - include directories for mFAST # [ ] MFAST_LIBRARY_DIRS - library directories for mFAST # [ ] MFAST_LIBRARIES - libraries to link against # [ ] MFAST_COMPONENTS - installed components # [ ] MFAST_<component>_LIBRARY - particular component library # [x] MFAST_EXECUTABLE - the fast_type_gen executable => done in _prepend_exec_target_in_fasttypegentarget() self._prepend_exec_target_in_fasttypegentarget() self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._lib_targets_module_file), { values["target"]: "mFAST::{}".format(values["target"]) for values in self._mfast_lib_components.values() })
def _build_autotools(self): """ Test autotools integration """ # Copy autotools directory to build folder shutil.copytree(os.path.join(self.source_folder, "autotools"), os.path.join(self.build_folder, "autotools")) with tools.chdir("autotools"): self.run("{} --install --verbose -Wall".format( os.environ["AUTORECONF"]), win_bash=tools.os_info.is_windows) tools.mkdir(self._package_folder) conf_args = [ "--prefix={}".format(tools.unix_path(self._package_folder)), "--enable-shared", "--enable-static", ] os.mkdir("bin_autotools") with tools.chdir("bin_autotools"): with self._build_context(): autotools = AutoToolsBuildEnvironment( self, win_bash=tools.os_info.is_windows) autotools.libs = [] autotools.configure(args=conf_args, configure_dir=os.path.join( self.build_folder, "autotools")) autotools.make(args=["V=1", "-j1"]) autotools.install()
def build(self): tools.mkdir(self.build_dir) with tools.chdir(self.build_dir): cmake = CMake(self) cmake.definitions['ASSIMP_BUILD_ASSIMP_TOOLS'] = False cmake.definitions['ASSIMP_BUILD_SAMPLES'] = False cmake.definitions['ASSIMP_BUILD_STATIC_LIB'] = False cmake.definitions['ASSIMP_BUILD_TESTS'] = False cmake.definitions['ASSIMP_NO_EXPORT'] = True cmake.definitions['BUILD_SHARED_LIBS'] = True cmake.definitions['CMAKE_BUILD_TYPE'] = 'Release' cmake.definitions['CMAKE_COMPILER_IS_GNUCC'] = True cmake.definitions['CMAKE_CXX_COMPILER'] = self.deps_cpp_info[ 'llvm'].rootpath + '/bin/clang++' cmake.definitions['CMAKE_C_COMPILER'] = self.deps_cpp_info[ 'llvm'].rootpath + '/bin/clang' cmake.definitions['CMAKE_C_FLAGS'] = cmake.definitions[ 'CMAKE_CXX_FLAGS'] = '-Oz -DNDEBUG' cmake.definitions[ 'CMAKE_CXX_FLAGS'] += ' -stdlib=libc++ -I' + ' -I'.join( self.deps_cpp_info['llvm'].include_paths) cmake.definitions['CMAKE_INSTALL_NAME_DIR'] = '@rpath' cmake.definitions['CMAKE_INSTALL_PREFIX'] = '%s/../%s' % ( os.getcwd(), self.install_dir) if platform.system() == 'Darwin': cmake.definitions['CMAKE_OSX_ARCHITECTURES'] = 'x86_64;arm64' cmake.definitions['CMAKE_OSX_DEPLOYMENT_TARGET'] = '10.11' cmake.definitions['CMAKE_OSX_SYSROOT'] = self.deps_cpp_info[ 'macos-sdk'].rootpath cmake.configure(source_dir='../%s' % self.source_dir, build_dir='.') cmake.build() cmake.install()
def _build_install_binutils(self, target): autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) conf_args = [ "--prefix={}".format(os.path.join(self.package_folder, target).replace("\\", "/")), "--disable-build-warnings", "--target={}".format(target), ] autotools.flags.extend(["-DSTDC_HEADERS", "-D_FORTIFY_SOURCE=0"]) host = tools.get_gnu_triplet(str(self.settings.os), str(self.settings.arch), str(self.settings.compiler)) build = tools.get_gnu_triplet(tools.detected_os(), tools.detected_architecture(), "gcc") if tools.os_info.is_windows: build = "{}-w64-mingw32".format({ "x86": "i686", }.get(str(tools.detected_architecture()), str(tools.detected_architecture()))) if self.settings.os == "Windows": host = "{}-w64-mingw32".format({ "x86": "i686", }.get(str(self.settings.arch), str(self.settings.arch))) build_folder = os.path.join("build_binutils_{}".format(target)) tools.mkdir(build_folder) with tools.chdir(build_folder): self.output.info("Building binutils for target={}".format(target)) autotools.configure(args=conf_args, configure_dir=os.path.join(self.source_folder, "binutils"), build=build, host=host) autotools.make() autotools.install()
def build(self): cmake = CMake(self) cmake.definitions['CONAN_DISABLE_CHECK_COMPILER'] = True cmake.definitions['CMAKE_CXX_FLAGS'] = '-Oz -std=c++11 -stdlib=libc++' cmake.definitions['CMAKE_CXX_COMPILER'] = self.deps_cpp_info['llvm'].rootpath + '/bin/clang++' cmake.definitions['CMAKE_SHARED_LINKER_FLAGS'] = cmake.definitions['CMAKE_EXE_LINKER_FLAGS'] = '-stdlib=libc++' cmake.definitions['CMAKE_INSTALL_PREFIX'] = '%s/%s' % (os.getcwd(), self.install_dir) if platform.system() == 'Darwin': cmake.definitions['CMAKE_OSX_ARCHITECTURES'] = 'x86_64;arm64' cmake.definitions['CMAKE_OSX_DEPLOYMENT_TARGET'] = '10.11' cmake.definitions['CMAKE_OSX_SYSROOT'] = self.deps_cpp_info['macos-sdk'].rootpath tools.mkdir(self.build_dir) with tools.chdir(self.build_dir): cmake.configure(source_dir='../%s' % self.source_dir, build_dir='.', args=['-Wno-dev', '--no-warn-unused-cli']) cmake.build() cmake.install() with tools.chdir(self.install_dir): if platform.system() == 'Darwin': self.run('install_name_tool -id @rpath/libz.dylib lib/libz.dylib') elif platform.system() == 'Linux': patchelf = self.deps_cpp_info['patchelf'].rootpath + '/bin/patchelf' self.run('%s --set-soname libz.so lib/libz.so' % patchelf)
def test(self): if tools.cross_building(self.settings): return tools.mkdir("libs") tools.save("Jamroot", "") with tools.environment_append({"BOOST_ROOT": self.build_folder}): self.run("boostdep --list-modules", run_environment=True)
def imports(self): if not os.path.exists("src/3space-studio/logo.ico"): tools.download( f"https://openclipart.org/image/400px/svg_to_png/97921/rubik-3D-colored.png", "src/3space-studio/logo.png") filename = "src/3space-studio/logo.png" img = Image.open(filename) img.save("src/3space-studio/logo.ico") registry_url = "https://www.khronos.org/registry" if not os.path.exists("packages/include/KHR/khrplatform.h"): tools.download(f"{registry_url}/EGL/api/KHR/khrplatform.h", "packages/include/KHR/khrplatform.h") tools.download(f"{registry_url}/OpenGL/api/GL/glext.h", "packages/include/GL/glext.h") tools.download(f"{registry_url}/OpenGL/api/GL/glxext.h", "packages/include/GL/glxext.h") tools.download(f"{registry_url}/OpenGL/api/GL/wgl.h", "packages/include/GL/wgl.h") tools.download(f"{registry_url}/OpenGL/api/GL/wglext.h", "packages/include/GL/wglext.h") tools.download(f"{registry_url}/OpenGL/api/GL/glcorearb.h", "packages/include/GL/glcorearb.h") tools.rmdir("cmake") tools.mkdir("cmake") [tools.rename(file, f"cmake/{file}") for file in glob.glob("*.cmake")]
def _package_mingw(self): with self._mingw_build_environment(): tools.mkdir(os.path.join(self.package_folder, "include", "libxml2")) self.run("mingw32-make -f Makefile.mingw install-libs") if self.options.include_utils: self.run("mingw32-make -f Makefile.mingw install-dist")
def build(self): tools.mkdir("qmake_folder") with tools.chdir("qmake_folder"): self.output.info("Building with qmake") def qmakeBuild(self): self.run("qmake %s" % self.source_folder, run_environment=True) if tools.os_info.is_windows: if self.settings.compiler == "Visual Studio": self.run("jom") else: self.run("mingw32-make") else: self.run("make") if self.settings.compiler == "Visual Studio": with tools.vcvars(self.settings): qmakeBuild(self) else: qmakeBuild(self) if not self.options["Qt"].shared: self.output.info( "disabled cmake test with static Qt, because of https://bugreports.qt.io/browse/QTBUG-38913" ) else: self.output.info("Building with CMake") cmake = CMake(self) cmake.configure(build_folder="cmake_folder") cmake.build()
def package(self): self.copy(pattern="BSD.txt", dst="licenses", src=self._source_subfolder) self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) if self.settings.compiler == "Visual Studio": arch = { "x86": "Win32", "x86_64": "x64", }[str(self.settings.arch)] tools.mkdir(os.path.join(self.package_folder, "bin")) shutil.copy( os.path.join(self._msvc_subfolder, arch, str(self.settings.build_type), "yasm.exe"), os.path.join(self.package_folder, "bin", "yasm.exe")) self.copy(pattern="yasm.exe*", src=self._source_subfolder, dst="bin", keep_path=False) else: autotools = self._configure_autotools() autotools.install() tools.rmdir(os.path.join(self.package_folder, "share"))
def package(self): cmake = self._configure_cmake() cmake.install() self.copy("LICENSE", src=self._source_subfolder, dst="licenses") tools.rmdir(os.path.join(self.package_folder, "share")) tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) if self.options.toml_config: tools.mkdir(os.path.join(self.package_folder, "res")) tools.rename(os.path.join(self.package_folder, "etc", "roudi_config_example.toml"), os.path.join(self.package_folder, "res", "roudi_config.toml")) tools.rmdir(os.path.join(self.package_folder, "etc")) # bring to default package structure if (tools.Version(self.version) >= "2.0.0"): include_paths = ["iceoryx_binding_c", "iceoryx_hoofs", "iceoryx_posh", "iceoryx_versions.hpp"] for include_path in include_paths: tools.rename( os.path.join(self.package_folder, "include", "iceoryx", "v{}".format(self.version), include_path), os.path.join(self.package_folder, "include", include_path)) # TODO: to remove in conan v2 once cmake_find_package* generators removed if (tools.Version(self.version) >= "2.0.0"): self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {v["target"]: "iceoryx::{}".format(k) for k, v in self._iceoryx_components["2.0.0"].items()}) else: self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {v["target"]: "iceoryx::{}".format(k) for k, v in self._iceoryx_components["1.0.X"].items()})
def package(self): self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) if self.options.header_only: header_dir = os.path.join(self._source_subfolder, "include", "flatbuffers") dst_dir = os.path.join("include", "flatbuffers") self.copy("*.h", dst=dst_dir, src=header_dir) else: cmake = self._configure_cmake() cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) if self.settings.os == "Windows" and self.options.shared: if self.settings.compiler == "Visual Studio": tools.mkdir(os.path.join(self.package_folder, "bin")) shutil.move( os.path.join(self.package_folder, "lib", "%s.dll" % self.name), os.path.join(self.package_folder, "bin", "%s.dll" % self.name)) elif self.settings.compiler == "gcc": shutil.move( os.path.join(self.package_folder, "lib", "lib%s.dll" % self.name), os.path.join(self.package_folder, "bin", "lib%s.dll" % self.name))
def package(self): self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder) # Run cmake if there is anything to build if (self.options.flatbuffers and not self._header_only) or self.options.flatc: cmake = self._configure_cmake() cmake.install() tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) if self.options.flatbuffers: self.copy(pattern="BuildFlatBuffers.cmake", dst="bin/cmake", src=os.path.join(self._source_subfolder, "CMake")) if self._header_only: header_dir = os.path.join(self._source_subfolder, "include", "flatbuffers") dst_dir = os.path.join("include", "flatbuffers") self.copy("*.h", dst=dst_dir, src=header_dir) if not self._header_only: if self.settings.os == "Windows" and self.options.shared: tools.mkdir(os.path.join(self.package_folder, "bin")) for dll_path in glob.glob( os.path.join(self.package_folder, "lib", "*.dll")): shutil.move( dll_path, os.path.join(self.package_folder, "bin", os.path.basename(dll_path))) elif self.options.flatc: tools.rmdir(os.path.join(self.package_folder, "include"))
def _build_zlib(self): with tools.chdir(self._source_subfolder): # https://github.com/madler/zlib/issues/268 tools.replace_in_file( 'gzguts.h', '#if defined(_WIN32) || defined(__CYGWIN__)', '#if defined(_WIN32) || defined(__MINGW32__)') if self.settings.os == "iOS": tools.replace_in_file( "gzguts.h", '#ifdef _LARGEFILE64_SOURCE', '#include <unistd.h>\n\n#ifdef _LARGEFILE64_SOURCE') for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']: tools.replace_in_file( filename, '#ifdef HAVE_UNISTD_H ' '/* may be set to #if 1 by ./configure */', '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)') tools.replace_in_file( filename, '#ifdef HAVE_STDARG_H ' '/* may be set to #if 1 by ./configure */', '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)') tools.mkdir("_build") with tools.chdir("_build"): if self._use_autotools: self._build_zlib_autotools() else: self._build_zlib_cmake()
def _patch_gn_build_system(self, source_file, dest_folder): if os.path.exists(os.path.join(dest_folder, "BUILD.gn")): return False tools.mkdir(dest_folder) shutil.copy(os.path.join(self.source_folder, source_file), os.path.join(dest_folder, "BUILD.gn")) return True
def package(self): self.copy("*LICENSE", src=self._source_subfolder, dst="licenses", keep_path=False) if self.settings.compiler == "Visual Studio": self.copy("*.h", src=os.path.join(self._source_subfolder, "include"), dst="include") self.copy("*.dll", src=os.path.join(self._source_subfolder, "vs2015", "build"), dst="bin") self.copy("*.lib", src=os.path.join(self._source_subfolder, "vs2015", "build"), dst="lib") os.rename(os.path.join(self.package_folder, "lib", "Argon2OptDll.lib"), os.path.join(self.package_folder, "lib", "argon2.lib")) else: autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) with tools.chdir(self._source_subfolder): with tools.environment_append(autotools.vars): autotools.install(args=self._make_args) # drop unneeded dirs tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) tools.rmdir(os.path.join(self.package_folder, "bin")) if self.settings.os == "Windows" and self.options.shared: os.unlink(os.path.join(self.package_folder, "lib", "libargon2.a")) self.copy("libargon2.dll.a", src=self._source_subfolder, dst="lib") tools.mkdir(os.path.join(self.package_folder, "bin")) os.rename(os.path.join(self.package_folder, "lib", "libargon2.dll"), os.path.join(self.package_folder, "bin", "libargon2.dll")) # drop unneeded libs if self.options.shared: if self.settings.os != "Windows": tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.a*") else: tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.dll") tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.so") tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.so.*") tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.dylib")
def package(self): self.copy("LICENSE", src=self._source_subfolder, dst="licenses") with tools.chdir(self._source_subfolder): with self._build_context(): self.run("scons install -Y \"{}\"".format(os.path.join(self.source_folder, self._source_subfolder)), run_environment=True) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) if self.settings.os == "Windows": for file in glob.glob(os.path.join(self.package_folder, "lib", "*.exp")): os.unlink(file) for file in glob.glob(os.path.join(self.package_folder, "lib", "*.pdb")): os.unlink(file) if self.options.shared: for file in glob.glob(os.path.join(self.package_folder, "lib", "serf-{}.*".format(self._version_major))): os.unlink(file) tools.mkdir(os.path.join(self.package_folder, "bin")) os.rename(os.path.join(self.package_folder, "lib", "libserf-{}.dll".format(self._version_major)), os.path.join(self.package_folder, "bin", "libserf-{}.dll".format(self._version_major))) else: for file in glob.glob(os.path.join(self.package_folder, "lib", "libserf-{}.*".format(self._version_major))): os.unlink(file) else: ext_to_remove = self._static_ext if self.options.shared else self._shared_ext for fn in os.listdir(os.path.join(self.package_folder, "lib")): if any(re.finditer("\\.{}(\.?|$)".format(ext_to_remove), fn)): os.unlink(os.path.join(self.package_folder, "lib", fn))
def test(self): test_env_dir = "test_env" tools.mkdir(test_env_dir) bin_path = os.path.join("bin", "test_package") handler_exe = "crashpad_handler.exe" if self.settings.os == "Windows" else "crashpad_handler" handler_bin_path = os.path.join(self.deps_cpp_info['crashpad'].rootpath, "bin", handler_exe) self.run("%s %s/db %s" % (bin_path, test_env_dir, handler_bin_path), run_environment=True)
def _build_zlib(self): for patch in self.conan_data["patches"][self.version]: tools.patch(**patch) with tools.chdir(self._source_subfolder): # https://github.com/madler/zlib/issues/268 tools.replace_in_file( 'gzguts.h', '#if defined(_WIN32) || defined(__CYGWIN__)', '#if defined(_WIN32) || defined(__MINGW32__)') is_apple_clang12 = self.settings.compiler == "apple-clang" and tools.Version( self.settings.compiler.version) >= "12.0" if not is_apple_clang12: for filename in ['zconf.h', 'zconf.h.cmakein', 'zconf.h.in']: tools.replace_in_file( filename, '#ifdef HAVE_UNISTD_H ' '/* may be set to #if 1 by ./configure */', '#if defined(HAVE_UNISTD_H) && (1-HAVE_UNISTD_H-1 != 0)' ) tools.replace_in_file( filename, '#ifdef HAVE_STDARG_H ' '/* may be set to #if 1 by ./configure */', '#if defined(HAVE_STDARG_H) && (1-HAVE_STDARG_H-1 != 0)' ) tools.mkdir("_build") with tools.chdir("_build"): self._build_zlib_cmake()
def build(self): cmake = CMake(self) cmake.definitions['BUILD_SHARED_LIBS'] = True cmake.definitions['ENABLE_OPENMP'] = False cmake.definitions['ENABLE_SAMPLES'] = False cmake.definitions['CONAN_DISABLE_CHECK_COMPILER'] = True cmake.definitions['CMAKE_BUILD_TYPE'] = 'Release' cmake.definitions['CMAKE_C_COMPILER'] = self.deps_cpp_info['llvm'].rootpath + '/bin/clang' cmake.definitions['CMAKE_C_FLAGS'] = cmake.definitions['CMAKE_CXX_FLAGS'] = '-Oz' cmake.definitions['CMAKE_INSTALL_PREFIX'] = '%s/%s' % (os.getcwd(), self.install_dir) if platform.system() == 'Darwin': cmake.definitions['CMAKE_OSX_ARCHITECTURES'] = 'x86_64;arm64' cmake.definitions['CMAKE_OSX_DEPLOYMENT_TARGET'] = '10.11' cmake.definitions['CMAKE_OSX_SYSROOT'] = self.deps_cpp_info['macos-sdk'].rootpath cmake.definitions['CMAKE_CXX_COMPILER'] = self.deps_cpp_info['llvm'].rootpath + '/bin/clang++' tools.mkdir(self.build_dir) with tools.chdir(self.build_dir): cmake.configure(source_dir='../%s' % self.source_dir, build_dir='.') cmake.build() cmake.install() with tools.chdir(self.install_dir): if platform.system() == 'Darwin': self.run('install_name_tool -id @rpath/libmuparser.dylib lib/libmuparser.dylib') elif platform.system() == 'Linux': patchelf = self.deps_cpp_info['patchelf'].rootpath + '/bin/patchelf' self.run('%s --set-soname libmuparser.so lib/libmuparser.so' % patchelf)
def _build_with_qmake(self): tools.mkdir("qmake_folder") with tools.chdir("qmake_folder"): self.output.info("Building with qmake") with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op(): args = [self.source_folder, "DESTDIR=bin"] def _getenvpath(var): val = os.getenv(var) if val and tools.os_info.is_windows: val = val.replace("\\", "/") os.environ[var] = val return val value = _getenvpath('CC') if value: args += ['QMAKE_CC=' + value, 'QMAKE_LINK_C=' + value, 'QMAKE_LINK_C_SHLIB=' + value] value = _getenvpath('CXX') if value: args += ['QMAKE_CXX=' + value, 'QMAKE_LINK=' + value, 'QMAKE_LINK_SHLIB=' + value] self.run("qmake %s" % " ".join(args), run_environment=True) if tools.os_info.is_windows: if self.settings.compiler == "Visual Studio": self.run("jom", run_environment=True) else: self.run("mingw32-make", run_environment=True) else: self.run("make", run_environment=True)
def _build_with_qmake(self): tools.mkdir("qmake_folder") with tools.chdir("qmake_folder"): self.output.info("Building with qmake") def _qmakebuild(): args = [self.source_folder] value = os.getenv('CC') if value: args += ['QMAKE_CC=' + value, 'QMAKE_LINK_C=' + value, 'QMAKE_LINK_C_SHLIB=' + value] value = os.getenv('CXX') if value: args += ['QMAKE_CXX=' + value, 'QMAKE_LINK=' + value, 'QMAKE_LINK_SHLIB=' + value] self.run("qmake %s" % " ".join(args), run_environment=True) if tools.os_info.is_windows: if self.settings.compiler == "Visual Studio": self.run("jom") else: self.run("mingw32-make") else: self.run("make") if self.settings.compiler == "Visual Studio": with tools.vcvars(self.settings): _qmakebuild() else: _qmakebuild()
def package(self): self.copy("LICENSE", dst="licenses", src=os.path.join(self.source_folder, self._source_subfolder)) env_build = self._configure_autotools() build_dir = os.path.join(self.build_folder, self._source_subfolder, "build") with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): with tools.environment_append(env_build.vars): with tools.chdir(build_dir): command = "{make} {silent} install".format( make=self._make_tool, silent=self._silent) self.run(command, win_bash=tools.os_info.is_windows) self._install_name_tool() for dll in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")): shutil.move(dll, os.path.join(self.package_folder, "bin")) if self.settings.os != "Windows" and self.options.data_packaging in [ "files", "archive" ]: tools.mkdir(os.path.join(self.package_folder, "res")) shutil.move(self._data_path, os.path.join(self.package_folder, "res")) tools.rmdir(os.path.join(self.package_folder, "lib", "icu")) tools.rmdir(os.path.join(self.package_folder, "lib", "man")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) tools.rmdir(os.path.join(self.package_folder, "share"))
def build(self): if not tools.cross_building(self): if not os.path.isfile(self._test_package_assembly_source): self.output.warn(f"Missing {self._test_package_assembly_source}.\ntest_package does not support this target os/arch. Please consider adding it. (It's a great learning experience)") else: tools.mkdir(os.path.join(self.build_folder, "bin")) tools.mkdir(os.path.join(self.build_folder, "lib")) gas = self._append_gnu_triplet("as") ld = self._append_gnu_triplet("ld") extension = "" if self._target_os == "Windows": extension = ".exe" # Create minimum import library for kernel32.dll dlltool = f"{self.deps_user_info['binutils'].gnu_triplet}-dlltool" dlltool_args = [dlltool, "--input-def", f"{self.source_folder}/Windows-kernel32.def", "--output-lib", f"{self.build_folder}/lib/libkernel32.a"] self.run(" ".join(dlltool_args)) assembler_args = [gas, self._test_package_assembly_source, "-o", f"{self.build_folder}/object.o"] linker_args = [ld, f"{self.build_folder}/object.o", "-o", f"{self.build_folder}/bin/test_package{extension}"] + self._test_linker_args self.run(" ".join(assembler_args)) self.run(" ".join(linker_args))
def package(self): toolchain = "mxe/usr" self.copy("%s-*" % self.target_tuple(), src=os.path.join(toolchain, "bin"), dst="bin", symlinks=False) self.copy("*.dll", src=os.path.join(toolchain, self.target_tuple(), "bin"), dst="bin", symlinks=False) self.copy("*", src=os.path.join(toolchain, "include"), dst="include", symlinks=False) self.copy("*", src=os.path.join(toolchain, self.target_tuple(), "include"), dst=os.path.join(self.target_tuple(), "include"), symlinks=False) self.copy("*", src=os.path.join(toolchain, self.target_tuple(), "lib"), dst=os.path.join(self.target_tuple(), "lib"), symlinks=False) self.copy("*", src=os.path.join(toolchain, "lib"), dst="lib", symlinks=False) self.copy("*", src=os.path.join(toolchain, "libexec"), dst="libexec", symlinks=False) self.copy("*", src=os.path.join(toolchain, self.target_tuple()), dst=self.target_tuple(), symlinks=False) # MXE is generally not relocatable (https://github.com/mxe/mxe/issues/1700, https://github.com/mxe/mxe/issues/1902), # but we can get around this for the toolchain by relying on the fact that e.g. `gcc` will look for `as` # so we'll just create symlinks to the right binaries on the same directory and add that directory to bindirs. # This symlinks folder will only be added to the PATH using a profile, so that other MXE-based package # can depend on this one without inadvertently using the mingw64 gcc and therefore build Windows binaries instead of Linux ones. with tools.chdir(os.path.join(self.package_folder, "bin")): symlink_path = "symlinks" tools.mkdir(symlink_path) for target in glob.iglob("%s-*" % self.target_tuple()): link_name = target.replace("%s-" % self.target_tuple(), "", 1) if link_name == "ld": target = "{0}-{1}".format(self.target_tuple(), link_name) link_name = "real-ld" link_path = os.path.join(symlink_path, link_name) if not os.path.exists(link_path) and not link_name in [ "cmake", "cpack" ]: os.symlink(os.path.join("..", target), link_path) if link_name == "real-ld" and not os.path.exists( os.path.join(symlink_path, "collect2")): os.symlink( os.path.join("../../libexec/gcc", self.target_tuple(), MXEGCCVERSION, "collect2"), os.path.join(symlink_path, "collect2"))
def build(self): if not tools.cross_building(self, skip_x64_x86=True): command = "{} --version".format(self.deps_user_info["cpython"].python) buffer = StringIO() self.run(command, output=buffer, ignore_errors=True, run_environment=True) self.output.info("output: %s" % buffer.getvalue()) self.run(command, run_environment=True) cmake = CMake(self) py_major = self.deps_cpp_info["cpython"].version.split(".")[0] cmake.definitions["BUILD_MODULE"] = self._supports_modules cmake.definitions["PY_VERSION_MAJOR"] = py_major cmake.definitions["PY_VERSION_MAJOR_MINOR"] = ".".join(self._py_version.split(".")[:2]) cmake.definitions["PY_FULL_VERSION"] = self.deps_cpp_info["cpython"].version cmake.definitions["PY_VERSION"] = self._py_version cmake.definitions["PY_VERSION_SUFFIX"] = self._cmake_abi.suffix cmake.definitions["PYTHON_EXECUTABLE"] = self.deps_user_info["cpython"].python cmake.definitions["USE_FINDPYTHON_X".format(py_major)] = self._cmake_try_FindPythonX cmake.definitions["Python{}_EXECUTABLE".format(py_major)] = self.deps_user_info["cpython"].python cmake.definitions["Python{}_ROOT_DIR".format(py_major)] = self.deps_cpp_info["cpython"].rootpath cmake.definitions["Python{}_USE_STATIC_LIBS".format(py_major)] = not self.options["cpython"].shared cmake.definitions["Python{}_FIND_FRAMEWORK".format(py_major)] = "NEVER" cmake.definitions["Python{}_FIND_REGISTRY".format(py_major)] = "NEVER" cmake.definitions["Python{}_FIND_IMPLEMENTATIONS".format(py_major)] = "CPython" cmake.definitions["Python{}_FIND_STRATEGY".format(py_major)] = "LOCATION" if self.settings.compiler != "Visual Studio": if tools.Version(self._py_version) < tools.Version("3.8"): cmake.definitions["Python{}_FIND_ABI".format(py_major)] = self._cmake_abi.cmake_arg with tools.environment_append(RunEnvironment(self).vars): cmake.configure() cmake.build() if not tools.cross_building(self, skip_x64_x86=True): if self._supports_modules: with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op(): modsrcfolder = "py2" if tools.Version(self.deps_cpp_info["cpython"].version).major < "3" else "py3" tools.mkdir(os.path.join(self.build_folder, modsrcfolder)) for fn in os.listdir(os.path.join(self.source_folder, modsrcfolder)): shutil.copy(os.path.join(self.source_folder, modsrcfolder, fn), os.path.join(self.build_folder, modsrcfolder, fn)) shutil.copy(os.path.join(self.source_folder, "setup.py"), os.path.join(self.build_folder, "setup.py")) env = { "DISTUTILS_USE_SDK": "1", "MSSdk": "1" } env.update(**AutoToolsBuildEnvironment(self).vars) with tools.environment_append(env): setup_args = [ "{}/setup.py".format(self.source_folder), # "conan", # "--install-folder", self.build_folder, "build", "--build-base", self.build_folder, "--build-platlib", os.path.join(self.build_folder, "lib_setuptools"), ] if self.settings.build_type == "Debug": setup_args.append("--debug") self.run("{} {}".format(self.deps_user_info["cpython"].python, " ".join("\"{}\"".format(a) for a in setup_args)), run_environment=True)
def package(self): self.copy(pattern="LICENSE", src=self._source_subfolder, dst="licenses") cmake = self._configure_cmake() cmake.install() if self.settings.os == "Windows" and self.options.shared: tools.mkdir(os.path.join(self.package_folder, "bin")) for dll_path in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")): shutil.move(dll_path, os.path.join(self.package_folder, "bin", os.path.basename(dll_path)))
def _build_with_meson(self): if self.options["qtbase"].shared and not tools.cross_building(self.settings): self.output.info("Building with Meson") tools.mkdir("meson_folder") with tools.environment_append(RunEnvironment(self).vars): meson = Meson(self) meson.configure(build_folder="meson_folder", defs={"cpp_std": "c++11"}) meson.build()
def test(self): if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") input_file = os.path.join(self.source_folder, "DCMTK_JPEGExt_12Bits.dcm") test_dir = "test_dir" tools.mkdir(test_dir) output_file = os.path.join(test_dir, "output.dcm") self.run([bin_path, input_file, output_file], run_environment=True)
def build(self): tools.mkdir('build') meson = Meson(self) meson.configure( args=['--prefix='+self.package_folder], build_folder='build' ) meson.build(targets=['install'])