def source(self): tools.get("%s/archive/v%s.zip" % (self.homepage, self.version)) os.rename("docopt.cpp-%s" % self.version, "sources") tools.replace_in_file("sources/CMakeLists.txt", "include(GNUInstallDirs)", """include(GNUInstallDirs) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() """)
def build(self): if self.settings.os == "Linux" or self.settings.os == "Macos": env_build = AutoToolsBuildEnvironment(self) env_vars = env_build.vars.copy() # Configure script creates conftest that cannot execute without shared openssl binaries. # Ways to solve the problem: # 1. set *LD_LIBRARY_PATH (works with Linux but does not work on OS X 10.11 with SIP) # 2. copying dylib's to the build directory (fortunately works on OS X) # 3. set rpath (dangerous) imported_libs = [] if self.options.with_openssl and self.options.shared: if self.settings.os == "Macos": imported_libs = os.listdir(self.deps_cpp_info['OpenSSL'].lib_paths[0]) for imported_lib in imported_libs: shutil.copy(self.deps_cpp_info['OpenSSL'].lib_paths[0] + '/' + imported_lib, self.FOLDER_NAME) self.output.warn("Copying OpenSSL libraries to fix conftest") if self.settings.os == "Linux": if 'LD_LIBRARY_PATH' in env_vars: env_vars['LD_LIBRARY_PATH'] = ':'.join([env_vars['LD_LIBRARY_PATH']] + self.deps_cpp_info.libdirs) else: env_vars['LD_LIBRARY_PATH'] = ':'.join(self.deps_cpp_info.libdirs) # required to correctly find static libssl on Linux if self.options.with_openssl and self.settings.os == "Linux": env_vars['OPENSSL_LIBADD'] = '-ldl' # disable rpath build old_str = "-install_name \$rpath/" new_str = "-install_name " replace_in_file("%s/configure" % self.FOLDER_NAME, old_str, new_str) # compose configure options suffix = '' if not self.options.shared: suffix += " --disable-shared " if self.options.with_openssl: suffix += "--enable-openssl " else: suffix += "--disable-openssl " if self.options.disable_threads: suffix += "--disable-thread-support " self.output.warn('Using env vars: ' + repr(env_vars)) with environment_append(env_vars): cmd = 'cd %s && ./configure %s' % (self.FOLDER_NAME, suffix) self.output.warn('Running: ' + cmd) self.run(cmd) cmd = 'cd %s && make' % (self.FOLDER_NAME) self.output.warn('Running: ' + cmd) self.run(cmd) # now clean imported libs if imported_libs: for imported_lib in imported_libs: os.unlink(self.FOLDER_NAME + '/' + imported_lib)
def build(self): cmake = CMake(self.settings) self.run("mkdir _build") conan_magic_lines = ''' # project name project(SFML) cmake_minimum_required(VERSION 2.8.3) include(../conanbuildinfo.cmake) CONAN_BASIC_SETUP() ''' replace_in_file("%s/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "project(SFML)", "") replace_in_file("%s/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "cmake_minimum_required(VERSION 2.8.3)", conan_magic_lines) # put frameworks in ~/Library/Frameworks, else we get permission denied # for SFML to work, you'll probably have to copy the sfml extlibs # frameworks manually into /Library/Frameworks self.run('cd _build && cmake ../%s -DBUILD_SHARED_LIBS=%s %s' % (self.ZIP_FOLDER_NAME, "ON" if self.options.shared else "OFF", cmake.command_line) ) if self.settings.os == "Windows": self.run("cd _build && cmake --build . %s --target install --config %s" % (cmake.build_config, self.settings.build_type)) else: self.run("cd _build && cmake --build . %s -- -j2" % cmake.build_config)
def build(self): """ Define your project building. You decide the way of building it to reuse it later in any other project. """ if self.settings.os == "Linux" or self.settings.os == "Macos": if self.settings.os == "Macos": old_str = 'install_name \$rpath/\$soname' new_str = 'install_name \$soname' replace_in_file("./%s/configure" % self.ZIP_FOLDER_NAME, old_str, new_str) env = ConfigureEnvironment(self.deps_cpp_info, self.settings) if self.options.fPIC: env_line = env.command_line.replace('CFLAGS="', 'CFLAGS="-fPIC ') else: env_line = env.command_line self.run("cd %s && %s ./configure" % (self.ZIP_FOLDER_NAME, env_line)) self.run("cd %s && %s make" % (self.ZIP_FOLDER_NAME, env_line)) else: cmake = CMake(self.settings) self.run("cd %s && mkdir _build" % self.ZIP_FOLDER_NAME) cd_build = "cd %s/_build" % self.ZIP_FOLDER_NAME self.output.warn('%s && cmake .. %s' % (cd_build, cmake.command_line)) shared_line = "-DBUILD_SHARED_LIBS=ON" if self.options.shared else "" self.run('%s && cmake .. %s %s' % (cd_build, cmake.command_line, shared_line)) self.output.warn("%s && cmake --build . %s" % (cd_build, cmake.build_config)) self.run("%s && cmake --build . %s" % (cd_build, cmake.build_config))
def build(self): """ Define your project building. You decide the way of building it to reuse it later in any other project. """ if self.settings.os == "Linux" or self.settings.os == "Macos": env = ConfigureEnvironment(self.deps_cpp_info, self.settings) env_line = env.command_line.replace('CFLAGS="', 'CFLAGS="-fPIC ') if self.settings.arch == "x86" or self.settings.arch == "x86_64": env_line = env_line.replace('CFLAGS="', 'CFLAGS="-mstackrealign ') self.output.warn(env_line) if self.settings.os == "Macos": old_str = '-install_name $libdir/$SHAREDLIBM' new_str = '-install_name $SHAREDLIBM' replace_in_file("./%s/configure" % self.ZIP_FOLDER_NAME, old_str, new_str) self.run("cd %s && %s ./configure" % (self.ZIP_FOLDER_NAME, env_line)) #self.run("cd %s && %s make check" % (self.ZIP_FOLDER_NAME, env.command_line)) self.run("cd %s && %s make" % (self.ZIP_FOLDER_NAME, env_line)) else: cmake = CMake(self.settings) if self.settings.os == "Windows": self.run("IF not exist _build mkdir _build") else: self.run("mkdir _build") cd_build = "cd _build" self.output.warn('%s && cmake .. %s' % (cd_build, cmake.command_line)) self.run('%s && cmake .. %s' % (cd_build, cmake.command_line)) self.output.warn("%s && cmake --build . %s" % (cd_build, cmake.build_config)) self.run("%s && cmake --build . %s" % (cd_build, cmake.build_config))
def build(self): """ Define your project building. You decide the way of building it to reuse it later in any other project. """ if self.settings.os == "Linux" or self.settings.os == "Macos": shared_options = "--enable-shared" if self.options.shared else "--enable-static" arch = "-m32 " if self.settings.arch == "x86" else "" if self.settings.os == "Macos": old_str = 'install_name \$rpath/\$soname' new_str = 'install_name \$soname' replace_in_file("./%s/configure" % self.ZIP_FOLDER_NAME, old_str, new_str) self.run("cd %s && CFLAGS='%s -mstackrealign -fPIC -O3' ./configure %s" % (self.ZIP_FOLDER_NAME, arch, shared_options)) self.run("cd %s && make" % self.ZIP_FOLDER_NAME) elif self.settings.os == "Windows": runtimes = {"MD": "MultiThreadedDLL", "MDd": "MultiThreadedDebugDLL", "MT": "MultiThreaded", "MTd": "MultiThreadedDebug"} runtime = runtimes[str(self.settings.compiler.runtime)] file_path = "%s/contrib/windows/libhwloc.vcxproj" % self.ZIP_FOLDER_NAME # Adjust runtime in project solution replace_in_file(file_path, "MultiThreadedDLL", runtime) platform, configuration = self.visual_platform_and_config() msbuild = 'Msbuild.exe hwloc.sln /m /t:libhwloc /p:Configuration=%s;Platform="%s"' % (configuration, platform) self.output.info(msbuild) self.run("cd %s/contrib/windows/ && %s" % (self.ZIP_FOLDER_NAME, msbuild))
def build(self): if self.settings.os == "Linux" or self.settings.os == "Macos": env = ConfigureEnvironment(self.deps_cpp_info, self.settings) if self.options.fPIC: env_line = env.command_line.replace('CFLAGS="', 'CFLAGS="-fPIC ') else: env_line = env.command_line if self.settings.os == "Macos": old_str = '-install_name \$rpath/\$soname' new_str = '-install_name \$soname' replace_in_file("./%s/configure" % self.ZIP_FOLDER_NAME, old_str, new_str) self.output.warn(env_line) self.run("cd %s && %s ./configure" % (self.ZIP_FOLDER_NAME, env_line)) self.run("cd %s && %s make -j6 check" % (self.ZIP_FOLDER_NAME, env_line)) else: cmake = CMake(self.settings) os.mkdir(os.path.join(self.ZIP_FOLDER_NAME, "_build")) cd_build = "cd %s/_build" % self.ZIP_FOLDER_NAME lite = "-DCAPNP_LITE=1" if self.settings.compiler == "Visual Studio" else "" cmake_1 = '%s && cmake .. %s %s -DEXTERNAL_CAPNP=0 -DBUILD_TESTING=0' % (cd_build, cmake.command_line, lite) self.output.warn(cmake_1) self.run(cmake_1) cmake_2 = "%s && cmake --build . %s" % (cd_build, cmake.build_config) self.output.warn(cmake_2) self.run(cmake_2)
def build(self): cmake = CMake(self.settings) print("Compiler: %s %s" % (self.settings.compiler, self.settings.compiler.version)) print("Arch: %s" % self.settings.arch) lib_opt = "-DCMAKE_DEBUG_POSTFIX:STRING={0} -DCMAKE_RELEASE_POSTFIX:STRING={0}".format("r" if self.settings.build_type == "Release" else "d") replace_lines = '''cmake_minimum_required(VERSION 2.8) include(../conanbuildinfo.cmake) conan_basic_setup() ''' replace_in_file("nana/CMakeLists.txt", "cmake_minimum_required(VERSION 2.8)", replace_lines) # process options if self.options.enable_audio: lib_opt += " -DENABLE_AUDIO:BOOL=ON" else: # Disable audio processing in nana replace_in_file("nana/include/nana/config.hpp", "#define NANA_ENABLE_AUDIO", "//#define NANA_ENABLE_AUDIO") if self.options.enable_png: lib_opt += " -DENABLE_PNG:BOOL=ON" if self.options.enable_jpeg: lib_opt += " -DENABLE_JPEG:BOOL=ON" self.run('cmake %s/nana %s %s' % (self.conanfile_directory, cmake.command_line, lib_opt)) self.run("cmake --build . %s" % cmake.build_config)
def build_windows(self): iconv_headers_paths = self.deps_cpp_info["winiconv"].include_paths[0] iconv_lib_paths= " ".join(['lib="%s"' % lib for lib in self.deps_cpp_info["winiconv"].lib_paths]) env = ConfigureEnvironment(self.deps_cpp_info, self.settings) env_variables = env.command_line compiler = "msvc" if self.settings.compiler == "Visual Studio" else self.settings.compiler == "gcc" debug = "yes" if self.settings.build_type == "Debug" else "no" configure_command = "cd %s/win32 && %s && cscript configure.js " \ "zlib=1 compiler=%s cruntime=/%s debug=%s include=\"%s\" %s" % (self.ZIP_FOLDER_NAME, env_variables, compiler, self.settings.compiler.runtime, debug, iconv_headers_paths, iconv_lib_paths) self.output.warn(configure_command) self.run(configure_command) makefile_path = os.path.join(self.ZIP_FOLDER_NAME, "win32", "Makefile.msvc") # Zlib library name is not zlib.lib always, it depends on configuration replace_in_file(makefile_path, "LIBS = $(LIBS) zlib.lib", "LIBS = $(LIBS) %s.lib" % self.deps_cpp_info["zlib"].libs[0]) make_command = "nmake /f Makefile.msvc" if self.settings.compiler == "Visual Studio" else "make -f Makefile.mingw" make_command = "cd %s/win32 && %s && %s" % (self.ZIP_FOLDER_NAME, env_variables, make_command) self.output.warn(make_command) self.run(make_command)
def unix_make(config_options_string): self.output.warn("----------CONFIGURING OPENSSL %s-------------" % self.version) m32_suff = " -m32" if self.settings.arch == "x86" else "" if self.settings.os == "Linux": if self.settings.build_type == "Debug": config_options_string = "-d " + config_options_string m32_pref = "setarch i386 " if self.settings.arch == "x86" else "" run_in_src("%s ./config %s %s" % (m32_pref, config_options_string, m32_suff)) run_in_src("make depend") self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) run_in_src("make") elif self.settings.os == "Macos": if self.settings.arch == "x86_64": command = "./Configure darwin64-x86_64-cc %s" % config_options_string else: command = "./config %s %s" % (config_options_string, m32_suff) run_in_src(command) # REPLACE -install_name FOR FOLLOW THE CONAN RULES, # DYNLIBS IDS AND OTHER DYNLIB DEPS WITHOUT PATH, JUST THE LIBRARY NAME old_str = 'SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$' new_str = 'SHAREDFLAGS="$$SHAREDFLAGS -install_name $$SHLIB$' replace_in_file("./openssl-%s/Makefile.shared" % self.version, old_str, new_str) self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) run_in_src("make")
def build(self): if self.settings.os == "Windows" and self.version == "master": raise ConanException("Trunk builds are not supported on Windows (cannot build directly from master git repository).") if self.settings.compiler == "Visual Studio": env = VisualStudioBuildEnvironment(self) with tools.environment_append(env.vars): version = min(12, int(self.settings.compiler.version.value)) version = 10 if version == 11 else version cd_build = "cd %s\\%s\\build\\vc%s" % (self.conanfile_directory, self.source_directory, version) build_command = build_sln_command(self.settings, "glew.sln") vcvars = vcvars_command(self.settings) self.run("%s && %s && %s" % (vcvars, cd_build, build_command.replace("x86", "Win32"))) else: if self.settings.os == "Windows": replace_in_file("%s/build/cmake/CMakeLists.txt" % self.source_directory, \ "if(WIN32 AND (NOT MSVC_VERSION LESS 1600)", \ "if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600)") if self.version == "master": self.run("make extensions") cmake = CMake(self) cmake.configure(source_dir="%s/build/cmake" % self.source_directory, defs={"BUILD_UTILS": "OFF"}) cmake.build()
def build(self): if self.settings.os == "Linux" or self.settings.os == "Macos": env = ConfigureEnvironment(self.deps_cpp_info, self.settings) if self.options.fPIC: env_line = env.command_line.replace('CFLAGS="', 'CFLAGS="-fPIC ') else: env_line = env.command_line self.run("cd %s && %s ./autogen.sh" % (self.ZIP_FOLDER_NAME, env_line)) self.run("chmod +x ./%s/configure" % self.ZIP_FOLDER_NAME) if self.settings.os == "Macos": old_str = '-install_name \$rpath/\$soname' new_str = '-install_name \$soname' replace_in_file("./%s/configure" % self.ZIP_FOLDER_NAME, old_str, new_str) self.run("cd %s && %s ./configure" % (self.ZIP_FOLDER_NAME, env_line)) self.run("cd %s && %s make" % (self.ZIP_FOLDER_NAME, env_line)) else: cmake = CMake(self.settings) self.run("cd %s && mkdir _build" % self.ZIP_FOLDER_NAME) cd_build = "cd %s/_build" % self.ZIP_FOLDER_NAME self.output.warn('%s && cmake .. %s' % (cd_build, cmake.command_line)) self.run('%s && cmake .. %s' % (cd_build, cmake.command_line)) self.output.warn("%s && cmake --build . %s" % (cd_build, cmake.build_config)) self.run("%s && cmake --build . %s" % (cd_build, cmake.build_config))
def source(self): self.run("git clone https://github.com/fmtlib/fmt") self.run("cd fmt && git checkout 3.0.0") # This small hack might be useful to guarantee proper /MT /MD linkage in MSVC # if the packaged project doesn't have variables to set it properly tools.replace_in_file("fmt/CMakeLists.txt", "project(FMT)", '''project(FMT) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup()''')
def source(self): self.run("git clone https://github.com/ebostijancic/pulsar_cpp") # self.run("cd hello && git checkout static_shared") # This small hack might be useful to guarantee proper /MT /MD linkage in MSVC # if the packaged project doesn't have variables to set it properly tools.replace_in_file("pulsar_cpp/CMakeLists.txt", "PROJECT(pulsar_cpp)", '''PROJECT(pulsar_cpp) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup()''')
def build(self): tools.replace_in_file(file_path="CMakeLists.txt", search="project (civetweb)", replace="""project (civetweb) include(conanbuildinfo.cmake) conan_basic_setup()""") cmake = self._configure_cmake() cmake.build()
def _inject_magic_lines(self): """Inject Conan setup in cmake file to solve exteral dependencies. """ conan_magic_lines = '''project(FlatBuffers) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() ''' tools.replace_in_file("CMakeLists.txt", "project(FlatBuffers)", conan_magic_lines)
def source( self ): zip_name = "glfw-3.2.zip" tools.download("https://github.com/glfw/glfw/releases/download/3.2/glfw-3.2.zip", zip_name) tools.unzip(zip_name) os.unlink(zip_name) tools.replace_in_file("glfw-3.2/CMakeLists.txt", "project(GLFW C)", """project(GLFW C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() """)
def prepare_for_package(the_client): the_client.save({"src/header.h": "contents"}, clean_first=True) the_client.run("new lib/1.0 -s") # don't need build method tools.replace_in_file(os.path.join(client.current_folder, "conanfile.py"), "def build", "def skip_build") the_client.run("install . --install-folder build") mkdir(os.path.join(client.current_folder, "build2"))
def source(self): # This small hack might be useful to guarantee proper /MT /MD linkage # in MSVC if the packaged project doesn't have variables to set it # properly tools.replace_in_file("CMakeLists.txt", "project(brotli C)", '''project(brotli C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup()''') # log2 is not available for some platform, see FastLog2 tools.replace_in_file("CMakeLists.txt", 'message(FATAL_ERROR "log2() not found")', 'message(WARNING "log2() not found")')
def test_replace_in_file(self): replace_in_file(self.win_file, "nis", "nus") replace_in_file(self.bytes_file, "nis", "nus") content = tools.load(self.win_file) self.assertNotIn("nis", content) self.assertIn("nus", content) content = tools.load(self.bytes_file) self.assertNotIn("nis", content) self.assertIn("nus", content)
def source(self): self.run("git clone https://github.com/zeromq/libzmq.git") self.run("cd libzmq && git checkout v4.2.0") tools.replace_in_file( "libzmq/CMakeLists.txt", "project(ZeroMQ)", """project(ZeroMQ) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() """, )
def source(self): tools.get("{0}/archive/v{1}.tar.gz".format(self.homepage, self.version)) extracted_dir = self.name + "-" + self.version os.rename(extracted_dir, self._source_subfolder) # This small hack might be useful to guarantee proper /MT /MD linkage # in MSVC if the packaged project doesn't have variables to set it # properly tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), "project(Fruit)", '''PROJECT(Myfruit) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup()''')
def build_with_configure(self): env = ConfigureEnvironment(self.deps_cpp_info, self.settings) env_line = env.command_line.replace('CFLAGS="', 'CFLAGS="-fPIC ') if self.settings.os == "Macos": old_str = '-install_name \$rpath/\$soname' new_str = '-install_name \$soname' replace_in_file("./%s/configure" % self.ZIP_FOLDER_NAME, old_str, new_str) self.run("cd %s && %s ./configure --with-python=no" % (self.ZIP_FOLDER_NAME, env.command_line)) #self.run("cd %s && %s make check" % (self.ZIP_FOLDER_NAME, env.command_line)) self.run("cd %s && %s make" % (self.ZIP_FOLDER_NAME, env.command_line))
def test_replace_in_file(self): replace_in_file(self.win_file, "nis", "nus") replace_in_file(self.bytes_file, "nis", "nus") with open(self.win_file, "rt") as handler: content = handler.read() self.assertNotIn("nis", content) self.assertIn("nus", content) with open(self.bytes_file, "rt") as handler: content = handler.read() self.assertNotIn("nis", content) self.assertIn("nus", content)
def build(self): env = ConfigureEnvironment(self.deps_cpp_info, self.settings) #env_line = env.command_line.replace('CFLAGS="', 'CFLAGS="-fPIC ') if self.settings.os == "Macos": old_str = '-install_name \$rpath/\$soname' new_str = '-install_name \$soname' replace_in_file("./%s/configure" % self.ZIP_FOLDER_NAME, old_str, new_str) # current workaround zlib = "--with-zlib=%s" % self.deps_cpp_info["zlib"].rootpath self.run("cd %s && %s ./configure %s" % (self.ZIP_FOLDER_NAME, env.command_line, zlib)) #self.run("cd %s && %s ./configure" % (self.ZIP_FOLDER_NAME, env.command_line)) self.run("cd %s && %s make" % (self.ZIP_FOLDER_NAME, env.command_line))
def build(self): os.mkdir("build") tools.replace_in_file("CMakeLists.txt", "project(blosc)", '''project(blosc) include(${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake) conan_basic_setup(NO_OUTPUT_DIRS)''') cmake = CMake(self) cmake.definitions["BUILD_TESTS"] = "ON" if self.run_tests else "OFF" cmake.definitions["BUILD_BENCHMARKS"] = "ON" if self.run_tests else "OFF" cmake.definitions["BUILD_SHARED"] = "ON" if (self.options.shared or self.run_tests) else "OFF" cmake.definitions["BUILD_STATIC"] = "OFF" if self.options.shared else "ON" cmake.configure(build_folder="build") cmake.build() if self.run_tests: self.output.warn("Running tests!!") self.launch_tests()
def build_local_different_folders_test(self): # Real build, needed to ensure that the generator is put in the correct place and # cmake finds it, using an install_folder different from build_folder client = TestClient() client.run("new lib/1.0") client.run("source . --source-folder src") # Patch the CMakeLists to include the generator file from a different folder install_dir = os.path.join(client.current_folder, "install_x86") tools.replace_in_file(os.path.join(client.current_folder, "src", "hello", "CMakeLists.txt"), "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake", '"%s/conanbuildinfo.cmake"' % install_dir) client.run("install . --install-folder install_x86 -s arch=x86") client.run("build . --build-folder build_x86 --install-folder '%s' " "--source-folder src" % install_dir) self.assertTrue(os.path.exists(os.path.join(client.current_folder, "build_x86", "lib")))
def patch_config_paths(self): """ changes references to the absolute path of the installed package in exported cmake config files to the appropriate conan variable. This makes most (sensible) cmake config files portable. For example, if a package foo installs a file called "fooConfig.cmake" to be used by cmake's find_package method, normally this file will contain absolute paths to the installed package folder, for example it will contain a line such as: SET(Foo_INSTALL_DIR /home/developer/.conan/data/Foo/1.0.0/...) This will cause cmake find_package() method to fail when someone else installs the package via conan. This function will replace such mentions to SET(Foo_INSTALL_DIR ${CONAN_FOO_ROOT}) which is a variable that is set by conanbuildinfo.cmake, so that find_package() now correctly works on this conan package. If the install() method of the CMake object in the conan file is used, this function should be called _after_ that invocation. For example: def build(self): cmake = CMake(self) cmake.configure() cmake.build() cmake.install() cmake.patch_config_paths() """ if not self._conanfile.should_install: return if not self._conanfile.name: raise ConanException("cmake.patch_config_paths() can't work without package name. " "Define name in your recipe") pf = self.definitions.get("CMAKE_INSTALL_PREFIX") replstr = "${CONAN_%s_ROOT}" % self._conanfile.name.upper() allwalk = chain(os.walk(self._conanfile.build_folder), os.walk(self._conanfile.package_folder)) for root, _, files in allwalk: for f in files: if f.endswith(".cmake"): tools.replace_in_file(os.path.join(root, f), pf, replstr, strict=False)
def build(self): """ Define your project building. You decide the way of building it to reuse it later in any other project. """ env = ConfigureEnvironment(self.deps_cpp_info, self.settings) if self.settings.os == "Linux" or self.settings.os == "Macos": suffix = "" if self.options.with_openssl: if self.settings.os == "Macos": suffix += "--with-darwinssl" else: suffix += "--with-ssl " else: suffix += "--without-ssl" if not self.options.shared: suffix += " --disable-shared" if self.options.disable_threads: suffix += " --disable-thread" if not self.options.with_ldap: suffix += " --disable-ldap" suffix += ' --with-ca-bundle=cacert.pem' # Hack for configure, don't know why fails because it's not able to find libefence.so command_line = env.command_line.replace("-lefence", "") configure = "cd %s && %s ./configure %s" % (self.ZIP_FOLDER_NAME, command_line, suffix) self.output.warn(configure) self.run(configure) self.run("cd %s && %s make" % (self.ZIP_FOLDER_NAME, env.command_line)) else: # Do not compile curl tool, just library conan_magic_lines = '''project(CURL) cmake_minimum_required(VERSION 3.0) include(../conanbuildinfo.cmake) CONAN_BASIC_SETUP() ''' replace_in_file("%s/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "cmake_minimum_required(VERSION 2.8 FATAL_ERROR)", conan_magic_lines) replace_in_file("%s/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "project( CURL C )", "") replace_in_file("%s/src/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "add_executable(", "IF(0)\n add_executable(") replace_in_file("%s/src/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "install(TARGETS ${EXE_NAME} DESTINATION bin)", "ENDIF()") # EOF cmake = CMake(self.settings) static = "-DBUILD_SHARED_LIBS=ON -DCURL_STATICLIB=OFF" if self.options.shared else "-DBUILD_SHARED_LIBS=OFF -DCURL_STATICLIB=ON" self.run("cd %s && mkdir _build" % self.ZIP_FOLDER_NAME) cd_build = "cd %s/_build" % self.ZIP_FOLDER_NAME self.run('%s && cmake .. %s %s' % (cd_build, cmake.command_line, static)) self.run("%s && cmake --build . %s" % (cd_build, cmake.build_config))
def build(self): if self.settings.os == "Linux" or self.settings.os == "Macos": autotools = AutoToolsBuildEnvironment(self) env_vars = autotools.vars.copy() # required to correctly find static libssl on Linux if self.options.with_openssl and self.settings.os == "Linux": env_vars['OPENSSL_LIBADD'] = '-ldl' # disable rpath build tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), r"-install_name \$rpath/", "-install_name ") # compose configure options configure_args = [] if not self.options.shared: configure_args.append("--disable-shared") configure_args.append("--enable-openssl" if self.options.with_openssl else "--disable-openssl") if self.options.disable_threads: configure_args.append("--disable-thread-support") with tools.environment_append(env_vars): with tools.chdir(self._source_subfolder): # set LD_LIBRARY_PATH with tools.environment_append(RunEnvironment(self).vars): autotools.configure(args=configure_args) autotools.make() elif self.settings.os == "Windows": vcvars = tools.vcvars_command(self.settings) suffix = '' if self.options.with_openssl: suffix = "OPENSSL_DIR=" + self.deps_cpp_info['OpenSSL'].rootpath # add runtime directives to runtime-unaware nmakefile tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.nmake"), 'LIBFLAGS=/nologo', 'LIBFLAGS=/nologo\n' 'CFLAGS=$(CFLAGS) /%s' % str(self.settings.compiler.runtime)) # do not build tests. static_libs is the only target, no shared libs at all make_command = "nmake %s -f Makefile.nmake static_libs" % suffix with tools.chdir(self._source_subfolder): self.run("%s && %s" % (vcvars, make_command))
def build(self): for f in glob.glob("*.cmake"): tools.replace_in_file( f, "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:>", "", strict=False) tools.replace_in_file( f, "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:>", "", strict=False) tools.replace_in_file( f, "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:>", "", strict=False) tools.replace_in_file( f, "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:-Wl,--export-dynamic>", "", strict=False) tools.replace_in_file( f, "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:-Wl,--export-dynamic>", "", strict=False) with tools.vcvars( self.settings ) if self.settings.compiler == "Visual Studio" else tools.no_op(): # next lines force cmake package to be in PATH before the one provided by visual studio (vcvars) build_env = tools.RunEnvironment( self ).vars if self.settings.compiler == "Visual Studio" else {} build_env["MAKEFLAGS"] = "j%d" % tools.cpu_count() build_env["PKG_CONFIG_PATH"] = [self.build_folder] if self.settings.os == "Windows": if not "PATH" in build_env: build_env["PATH"] = [] build_env["PATH"].append( os.path.join(self.source_folder, "qt6", "gnuwin32", "bin")) if self.settings.compiler == "Visual Studio": # this avoids cmake using gcc from strawberryperl build_env["CC"] = "cl" build_env["CXX"] = "cl" with tools.environment_append(build_env): if tools.os_info.is_macos: open(".qmake.stash", "w").close() open(".qmake.super", "w").close() cmake = self._configure_cmake() if tools.os_info.is_macos: with open("bash_env", "w") as f: f.write('export DYLD_LIBRARY_PATH="%s"' % ":".join( RunEnvironment(self).vars["DYLD_LIBRARY_PATH"])) with tools.environment_append( {"BASH_ENV": os.path.abspath("bash_env") }) if tools.os_info.is_macos else tools.no_op(): with tools.run_environment(self): cmake.build()
def source(self): source_url = "https://github.com/guangie88/rustfp" tools.get("{0}/archive/v{1}.tar.gz".format(source_url, self.version)) extracted_dir = self.name + "-" + self.version # Work to remove 'deps' directory (conan will handle them) shutil.rmtree(os.path.join(extracted_dir, "deps")) tools.replace_in_file(os.path.join(extracted_dir, "CMakeLists.txt"), "add_subdirectory(deps/optional-lite)", "") tools.replace_in_file(os.path.join(extracted_dir, "CMakeLists.txt"), "add_subdirectory(deps/variant)", "") tools.replace_in_file(os.path.join(extracted_dir, "CMakeLists.txt"), "install(DIRECTORY deps/optional-lite/include/nonstd DESTINATION include)", "") tools.replace_in_file(os.path.join(extracted_dir, "CMakeLists.txt"), "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/optional-lite/include>", "") tools.replace_in_file(os.path.join(extracted_dir, "CMakeLists.txt"), ''' target_include_directories(rustfp_unit_test PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/Catch2/single_include>) ''', ''' target_include_directories(rustfp_unit_test PRIVATE) ''') tools.replace_in_file(os.path.join(extracted_dir, "CMakeLists.txt"), ''' target_link_libraries(rustfp INTERFACE mpark_variant) ''', ''' target_link_libraries(rustfp INTERFACE) ''') #Rename to "source_subfolder" is a convention to simplify later steps os.rename(extracted_dir, self.source_subfolder)
def _patch_sources(self): tools.replace_in_file( os.path.join(self._source_subfolder, "CMakeLists.txt"), "set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1)", "")
def _replace_in_nmake_opt(self, str1, str2): tools.replace_in_file( os.path.join(self.build_folder, self._source_subfolder, "nmake.opt"), str1, str2)
def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) # Provide relocatable protobuf::protoc target and Protobuf_PROTOC_EXECUTABLE cache variable # TODO: some of the following logic might be disabled when conan will # allow to create executable imported targets in package_info() protobuf_config_cmake = os.path.join(self._source_subfolder, "cmake", "protobuf-config.cmake.in") tools.replace_in_file( protobuf_config_cmake, "@_protobuf_FIND_ZLIB@", "# BEGIN CONAN PATCH\n#_protobuf_FIND_ZLIB@\n# END CONAN PATCH") exe_ext = ".exe" if self.settings.os == "Windows" else "" protoc_filename = "protoc" + exe_ext module_folder_depth = len( os.path.normpath(self._cmake_install_base_path).split(os.path.sep)) protoc_rel_path = "{}bin/{}".format( "".join(["../"] * module_folder_depth), protoc_filename) protoc_target = textwrap.dedent("""\ if(NOT TARGET protobuf::protoc) if(CMAKE_CROSSCOMPILING) find_program(PROTOC_PROGRAM protoc PATHS ENV PATH NO_DEFAULT_PATH) endif() if(NOT PROTOC_PROGRAM) set(PROTOC_PROGRAM \"${{CMAKE_CURRENT_LIST_DIR}}/{protoc_rel_path}\") endif() get_filename_component(PROTOC_PROGRAM \"${{PROTOC_PROGRAM}}\" ABSOLUTE) set(Protobuf_PROTOC_EXECUTABLE ${{PROTOC_PROGRAM}} CACHE FILEPATH \"The protoc compiler\") add_executable(protobuf::protoc IMPORTED) set_property(TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION ${{Protobuf_PROTOC_EXECUTABLE}}) endif() """.format(protoc_rel_path=protoc_rel_path)) tools.replace_in_file( protobuf_config_cmake, "include(\"${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake\")", protoc_target) # Set DYLD_LIBRARY_PATH in command line to avoid issues with shared protobuf # (even with virtualrunenv, this fix might be required due to SIP) # Only works with cmake, cmake_find_package or cmake_find_package_multi generators if tools.is_apple_os(self.settings.os): tools.replace_in_file( protobuf_config_cmake, "add_custom_command(", ("set(CUSTOM_DYLD_LIBRARY_PATH ${CONAN_LIB_DIRS} ${Protobuf_LIB_DIRS} ${Protobuf_LIB_DIRS_RELEASE} ${Protobuf_LIB_DIRS_DEBUG} ${Protobuf_LIB_DIRS_RELWITHDEBINFO} ${Protobuf_LIB_DIRS_MINSIZEREL})\n" "string(REPLACE \";\" \":\" CUSTOM_DYLD_LIBRARY_PATH \"${CUSTOM_DYLD_LIBRARY_PATH}\")\n" "add_custom_command(")) tools.replace_in_file( protobuf_config_cmake, "COMMAND protobuf::protoc", "COMMAND ${CMAKE_COMMAND} -E env \"DYLD_LIBRARY_PATH=${CUSTOM_DYLD_LIBRARY_PATH}\" $<TARGET_FILE:protobuf::protoc>" ) # Disable a potential warning in protobuf-module.cmake.in # TODO: remove this patch? Is it really useful? protobuf_module_cmake = os.path.join(self._source_subfolder, "cmake", "protobuf-module.cmake.in") tools.replace_in_file( protobuf_module_cmake, "if(DEFINED Protobuf_SRC_ROOT_FOLDER)", "if(0)\nif(DEFINED Protobuf_SRC_ROOT_FOLDER)", ) tools.replace_in_file( protobuf_module_cmake, "# Define upper case versions of output variables", "endif()", )
def _patch_configure(self): # since _patch_makefile_org will replace binutils variables # use a more restricted regular expresion to prevent that Configure script trying to do it again configure = os.path.join(self._source_subfolder, "Configure") tools.replace_in_file(configure, r"s/^AR=\s*ar/AR= $ar/;", r"s/^AR=\s*ar\b/AR= $ar/;")
def build(self): # https://github.com/opencv/opencv/issues/8010 if str(self.settings.compiler) == 'clang' and str(self.settings.compiler.version) == '3.9': tools.replace_in_file(os.path.join(self._source_subfolder, 'modules', 'imgproc', 'CMakeLists.txt'), 'ocv_define_module(imgproc opencv_core WRAP java python js)', 'ocv_define_module(imgproc opencv_core WRAP java python js)\n' 'set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/src/' 'imgwarp.cpp PROPERTIES COMPILE_FLAGS "-O0")') # allow to find conan-supplied OpenEXR if self.options.openexr: find_openexr = os.path.join(self._source_subfolder, 'cmake', 'OpenCVFindOpenEXR.cmake') tools.replace_in_file(find_openexr, r'SET(OPENEXR_ROOT "C:/Deploy" CACHE STRING "Path to the OpenEXR \"Deploy\" folder")', '') tools.replace_in_file(find_openexr, r'set(OPENEXR_ROOT "")', '') tools.replace_in_file(find_openexr, 'SET(OPENEXR_LIBSEARCH_SUFFIXES x64/Release x64 x64/Debug)', '') tools.replace_in_file(find_openexr, 'SET(OPENEXR_LIBSEARCH_SUFFIXES Win32/Release Win32 Win32/Debug)', '') def openexr_library_names(name): # OpenEXR library may have different names, depends on namespace versioning, static, debug, etc. reference = str(self.requires["openexr"]) version_name = reference.split("@")[0] version = version_name.split("/")[1] version_tokens = version.split('.') major, minor = version_tokens[0], version_tokens[1] suffix = '%s_%s' % (major, minor) names = ['%s-%s' % (name, suffix), '%s-%s_s' % (name, suffix), '%s-%s_d' % (name, suffix), '%s-%s_s_d' % (name, suffix), '%s' % name, '%s_s' % name, '%s_d' % name, '%s_s_d' % name] return ' '.join(names) for lib in ['Half', 'Iex', 'Imath', 'IlmImf', 'IlmThread']: tools.replace_in_file(find_openexr, 'NAMES %s' % lib, 'NAMES %s' % openexr_library_names(lib)) cmake = self._configure_cmake() cmake.build()
def _patch_sources(self): # Fix dependency of IlmBase tools.replace_in_file( os.path.join(self._source_subfolder, "IlmBase", "Half", "CMakeLists.txt"), "ADD_LIBRARY ( Half_static STATIC\n half.cpp", "ADD_LIBRARY ( Half_static STATIC\n half.cpp \"${CMAKE_CURRENT_BINARY_DIR}/eLut.h\" \"${CMAKE_CURRENT_BINARY_DIR}/toFloat.h\"" ) tools.replace_in_file( os.path.join(self._source_subfolder, "IlmBase", "Half", "CMakeLists.txt"), "ADD_LIBRARY ( Half SHARED\n half.cpp", "ADD_LIBRARY ( Half SHARED\n half.cpp \"${CMAKE_CURRENT_BINARY_DIR}/eLut.h\" \"${CMAKE_CURRENT_BINARY_DIR}/toFloat.h\"" ) # Don't let the build script override static/shared of IlmBase tools.replace_in_file( os.path.join(self._source_subfolder, "CMakeLists.txt"), "set(BUILD_ILMBASE_STATIC ON)", "set(BUILD_ILMBASE_STATIC {})".format(not self.options.shared)) if self.options.shared: tools.replace_in_file( os.path.join(self._source_subfolder, "OpenEXR", "IlmImf", "CMakeLists.txt"), "IlmBase::Half_static", "IlmBase::Half${OPENEXR_TARGET_SUFFIX}") tools.replace_in_file( os.path.join(self._source_subfolder, "OpenEXR", "IlmImf", "CMakeLists.txt"), "IlmBase::IlmThread_static", "IlmBase::IlmThread${OPENEXR_TARGET_SUFFIX}") tools.replace_in_file( os.path.join(self._source_subfolder, "OpenEXR", "IlmImf", "CMakeLists.txt"), "IlmBase::Iex_static", "IlmBase::Iex${OPENEXR_TARGET_SUFFIX}") # Do not override RUNTIME_DIR in IlmImf tools.replace_in_file( os.path.join(self._source_subfolder, "OpenEXR", "IlmImf", "CMakeLists.txt"), "SET(RUNTIME_DIR", "# SET(RUNTIME_DIR")
def windows_make(config_options_string): self.output.warn( "----------CONFIGURING OPENSSL FOR WINDOWS. %s-------------" % self.version) debug = "debug-" if self.settings.build_type == "Debug" else "" arch = "32" if self.settings.arch == "x86" else "64A" configure_type = debug + "VC-WIN" + arch # Will output binaries to ./binaries config_command = "perl Configure %s no-asm --prefix=../binaries" % configure_type whole_command = "%s %s" % (config_command, config_options_string) self.output.warn(whole_command) run_in_src(whole_command) if self.options.no_asm: run_in_src(os.path.join("ms", "do_nasm")) if arch == "64A": run_in_src(os.path.join("ms", "do_win64a")) else: run_in_src(os.path.join("ms", "do_ms")) runtime = self.settings.compiler.runtime # Replace runtime in ntdll.mak and nt.mak rootDir = os.path.join(self.build_folder, "openssl-" + str(self.version)) runtimeStr = "/" + str(runtime) + " " replace_in_file(os.path.join(rootDir, "ms", "nt.mak"), "/MT ", runtimeStr, False) replace_in_file(os.path.join(rootDir, "ms", "nt.mak"), "/MTd ", runtimeStr, False) replace_in_file(os.path.join(rootDir, "ms", "ntdll.mak"), "/MD ", runtimeStr, False) replace_in_file(os.path.join(rootDir, "ms", "ntdll.mak"), "/MDd ", runtimeStr, False) self.output.warn(os.curdir) make_command = "" if self.settings.compiler == "Visual Studio": make_command = tools.vcvars_command(self.settings) + " && " make_command += "nmake -f " + os.path.join( "ms", "ntdll.mak" ) if self.options.shared else "nmake -f " + os.path.join( rootDir, "ms", "nt.mak") self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) run_in_src(make_command) run_in_src("%s install" % make_command) # Rename libs with the arch renames = { "./binaries/lib/libeay32.lib": "./binaries/lib/libeay32%s.lib" % runtime, "./binaries/lib/ssleay32.lib": "./binaries/lib/ssleay32%s.lib" % runtime } for old, new in renames.items(): if os.path.exists(old): os.rename(old, new)
def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "FindVulkanHeaders.cmake"), "HINTS ${VULKAN_HEADERS_INSTALL_DIR}/share/vulkan/registry", "HINTS ${VULKAN_HEADERS_INSTALL_DIR}/res/vulkan/registry")
def build(self): tools.replace_in_file(os.path.join(self._source_subfolder, "bzip2.c"), r"<sys\stat.h>", "<sys/stat.h>") cmake = self._configure_cmake() cmake.build()
def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt") cmakelists_src = os.path.join(self._source_subfolder, "src", "CMakeLists.txt") cmake_configure = os.path.join(self._source_subfolder, "cmake", "Configure.cmake") # Fix installation tools.replace_in_file(cmakelists_src, "${CMAKE_BINARY_DIR}", "${PROJECT_BINARY_DIR}") # Honor options and inject dependencies definitions # TODO: submit a patch upstream ## zlib tools.replace_in_file(cmakelists_src, "${ZLIB_LIBRARIES}", "ZLIB::ZLIB") if not self.options.with_zlib: tools.replace_in_file(cmakelists_src, "if (ZLIB_LIBRARIES)", "if(0)") tools.replace_in_file(cmake_configure, "if (ZLIB_FOUND)", "if(0)") ## giflib tools.replace_in_file(cmakelists_src, "${GIF_LIBRARIES}", "GIF::GIF") if not self.options.with_gif: tools.replace_in_file(cmakelists_src, "if (GIF_LIBRARIES)", "if(0)") tools.replace_in_file(cmake_configure, "if (GIF_FOUND)", "if(0)") ## libjpeg tools.replace_in_file(cmakelists_src, "${JPEG_LIBRARIES}", "JPEG::JPEG") if not self.options.with_jpeg: tools.replace_in_file(cmakelists_src, "if (JPEG_LIBRARIES)", "if(0)") tools.replace_in_file(cmake_configure, "if (JPEG_FOUND)", "if(0)") ## libpng tools.replace_in_file(cmakelists_src, "${PNG_LIBRARIES}", "PNG::PNG") if not self.options.with_png: tools.replace_in_file(cmakelists_src, "if (PNG_LIBRARIES)", "if(0)") tools.replace_in_file(cmake_configure, "if (PNG_FOUND)", "if(0)") ## libtiff tools.replace_in_file(cmakelists_src, "${TIFF_LIBRARIES}", "TIFF::TIFF") if not self.options.with_tiff: tools.replace_in_file(cmakelists_src, "if (TIFF_LIBRARIES)", "if(0)") tools.replace_in_file(cmake_configure, "if (TIFF_FOUND)", "if(0)") ## We have to be more aggressive with dependencies found with pkgconfig ## Injection of libdirs is ensured by conan_basic_setup() ## openjpeg tools.replace_in_file(cmakelists, "if(NOT JP2K)", "if(0)") tools.replace_in_file( cmakelists_src, "if (JP2K_FOUND)", "if (JP2K_FOUND)\n" "target_compile_definitions(leptonica PRIVATE ${JP2K_CFLAGS_OTHER})" ) if not self.options.with_openjpeg: tools.replace_in_file(cmakelists_src, "if (JP2K_FOUND)", "if(0)") tools.replace_in_file(cmake_configure, "if (JP2K_FOUND)", "if(0)") ## libwebp tools.replace_in_file(cmakelists, "if(NOT WEBP)", "if(0)") tools.replace_in_file( cmakelists_src, "if (WEBP_FOUND)", "if (WEBP_FOUND)\n" "target_compile_definitions(leptonica PRIVATE ${WEBP_CFLAGS_OTHER} ${WEBPMUX_CFLAGS_OTHER})" ) tools.replace_in_file(cmakelists_src, "${WEBP_LIBRARIES}", "${WEBP_LIBRARIES} ${WEBPMUX_LIBRARIES}") if tools.Version(self.version) >= "1.79.0": tools.replace_in_file(cmakelists, "if(NOT WEBPMUX)", "if(0)") if not self.options.with_webp: tools.replace_in_file(cmakelists_src, "if (WEBP_FOUND)", "if(0)") tools.replace_in_file(cmake_configure, "if (WEBP_FOUND)", "if(0)") # Remove detection of fmemopen() on macOS < 10.13 # CheckFunctionExists will find it in the link library. # There's no error because it's not including the header with the # deprecation macros. if self.settings.os == "Macos" and self.settings.os.version: if tools.Version(self.settings.os.version) < "10.13": tools.replace_in_file( cmake_configure, "set(functions_list\n " "fmemopen\n fstatat\n)", "set(functions_list\n " "fstatat\n)")
def visual_build(self, config_options_string): self.run_in_src("perl --version") self.output.warn( "----------CONFIGURING OPENSSL FOR WINDOWS. %s-------------" % self.version) debug = "debug-" if self.settings.build_type == "Debug" else "" arch = "32" if self.settings.arch == "x86" else "64A" configure_type = debug + "VC-WIN" + arch no_asm = "no-asm" if self.options.no_asm else "" # Will output binaries to ./binaries with tools.vcvars(self.settings, filter_known_paths=False): config_command = "perl Configure %s %s --prefix=../binaries" % ( configure_type, no_asm) whole_command = "%s %s" % (config_command, config_options_string) self.output.warn(whole_command) self.run_in_src(whole_command) if not self.options.no_asm and self.settings.arch == "x86": # The 64 bits builds do not require the do_nasm # http://p-nand-q.com/programming/windows/building_openssl_with_visual_studio_2013.html self.run_in_src(r"ms\do_nasm") else: if arch == "64A": self.run_in_src(r"ms\do_win64a") else: self.run_in_src(r"ms\do_ms") runtime = self.settings.compiler.runtime # Replace runtime in ntdll.mak and nt.mak def replace_runtime_in_file(filename): runtimes = ["MDd", "MTd", "MD", "MT"] for e in runtimes: try: tools.replace_in_file(filename, "/%s" % e, "/%s" % runtime) self.output.warn("replace vs runtime %s in %s" % ("/%s" % e, filename)) return # we found a runtime argument in the file, so we can exit the function except: pass raise Exception("Could not find any vs runtime in file") replace_runtime_in_file("./%s/ms/ntdll.mak" % self.subfolder) replace_runtime_in_file("./%s/ms/nt.mak" % self.subfolder) if self.settings.arch == "x86": # Do not consider warning as errors, 1.0.2n error with x86 builds tools.replace_in_file("./%s/ms/nt.mak" % self.subfolder, "-WX", "") tools.replace_in_file("./%s/ms/ntdll.mak" % self.subfolder, "-WX", "") make_command = "nmake -f ms\\ntdll.mak" if self.options.shared else "nmake -f ms\\nt.mak " self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) self.run_in_src(make_command) self.run_in_src("%s install" % make_command) # Rename libs with the arch renames = { "./binaries/lib/libeay32.lib": "./binaries/lib/libeay32%s.lib" % runtime, "./binaries/lib/ssleay32.lib": "./binaries/lib/ssleay32%s.lib" % runtime } for old, new in renames.items(): if os.path.exists(old): os.rename(old, new)
def _patch_compiler(self, cc, cxx): tools.replace_in_file(os.path.join(self._source_subfolder, "build", "gmake.{}".format(self._os), "genie.make"), "CC = gcc", "CC = {}".format(cc)) tools.replace_in_file(os.path.join(self._source_subfolder, "build", "gmake.{}".format(self._os), "genie.make"), "CXX = g++", "CXX = {}".format(cxx))
def build(self): with tools.vcvars(self.settings): tools.patch(os.path.join(self._source_subfolder, "build"), "platform-android.mk.patch") with tools.chdir(self._source_subfolder): prefix = os.path.abspath(self.package_folder) if tools.os_info.is_windows: prefix = tools.unix_path(prefix) tools.replace_in_file('Makefile', 'PREFIX=/usr/local', 'PREFIX=%s' % prefix) if self.settings.os == "Android": arch = str(self.settings.arch) arch = {"armv7": "arm", "armv8": "arm64"}.get(arch, arch) else: if self.settings.arch == 'x86': arch = 'i386' elif self.settings.arch == 'x86_64': arch = 'x86_64' else: arch = self.settings.arch args = ['ARCH=%s' % arch] env_build = AutoToolsBuildEnvironment(self) if self.settings.compiler == 'Visual Studio': tools.replace_in_file( os.path.join('build', 'platform-msvc.mk'), 'CFLAGS_OPT += -MT', 'CFLAGS_OPT += -%s' % str(self.settings.compiler.runtime)) tools.replace_in_file( os.path.join('build', 'platform-msvc.mk'), 'CFLAGS_DEBUG += -MTd -Gm', 'CFLAGS_DEBUG += -%s -Gm' % str(self.settings.compiler.runtime)) args.append('OS=msvc') env_build.flags.append('-FS') else: if tools.os_info.is_windows: args.append('OS=mingw_nt') if self.settings.compiler == 'clang' and self.settings.compiler.libcxx == 'libc++': tools.replace_in_file( 'Makefile', 'STATIC_LDFLAGS=-lstdc++', 'STATIC_LDFLAGS=-lc++\nLDFLAGS+=-lc++') if self.settings.os == "Android": args.append("NDKLEVEL=%s" % str(self.settings.os.api_level)) libcxx = str(self.settings.compiler.libcxx) args.append("STL_LIB=" + ( "$(NDKROOT)/sources/cxx-stl/llvm-libc++/libs/$(APP_ABI)/lib%s " % "c++_static.a" if libcxx == "c++_static" else "c++_shared.so" ) + "$(NDKROOT)/sources/cxx-stl/llvm-libc++/libs/$(APP_ABI)/libc++abi.a" ) args.append('OS=android') ndk_home = os.environ["ANDROID_NDK_HOME"] args.append('NDKROOT=%s' % ndk_home) # not NDK_ROOT here target = "android-%s" % str(self.settings.os.api_level) args.append('TARGET=%s' % target) tools.replace_in_file( os.path.join("codec", "build", "android", "dec", "jni", "Application.mk"), "APP_STL := stlport_shared", "APP_STL := %s" % str(self.settings.compiler.libcxx)) tools.replace_in_file( os.path.join("codec", "build", "android", "dec", "jni", "Application.mk"), "APP_PLATFORM := android-12", "APP_PLATFORM := %s" % target) args.append("CCASFLAGS=$(CFLAGS) -fno-integrated-as") env_build.make(args=args, target="libraries") args.append('install-' + ( 'shared' if self.options.shared else 'static-lib')) env_build.make(args=args)
def _patch_makefile_org(self): # https://wiki.openssl.org/index.php/Compilation_and_Installation#Modifying_Build_Settings # its often easier to modify Configure and Makefile.org rather than trying to add targets to the configure scripts makefile_org = os.path.join(self._source_subfolder, "Makefile.org") env_build = self._get_env_build() with tools.environment_append(env_build.vars): cc = os.environ.get("CC", "cc") tools.replace_in_file(makefile_org, "CC= cc", "CC= %s %s" % (cc, os.environ["CFLAGS"])) if "AR" in os.environ: tools.replace_in_file(makefile_org, "AR=ar", "AR=%s" % os.environ["AR"]) if "RANLIB" in os.environ: tools.replace_in_file(makefile_org, "RANLIB= ranlib", "RANLIB= %s" % os.environ["RANLIB"]) rc = os.environ.get("WINDRES", os.environ.get("RC")) if rc: tools.replace_in_file(makefile_org, "RC= windres", "RC= %s" % rc) if "NM" in os.environ: tools.replace_in_file(makefile_org, "NM= nm", "NM= %s" % os.environ["NM"]) if "AS" in os.environ: tools.replace_in_file(makefile_org, "AS=$(CC) -c", "AS=%s" % os.environ["AS"])
def _patch_sources(self): tools.replace_in_file( os.path.join(self._source_subfolder, "src", "CMakeLists.txt"), "box2d STATIC", "box2d")
def source(self): tools.replace_in_file("{}/CMakeLists.txt".format(self._source_dir), "CURL::libcurl", "CURL::CURL")
def build(self): ''' For Visual Studio (tried with 2010) compiling need: - perl: http://www.activestate.com/activeperl/downloads - nasm: http://www.nasm.us/ Put perl and nasm bin folder in USER PATH (not system path, so the visual 2010 command system symbol can find it) Open the visual 2010 command system symbol and run conan. Here are good page explaining it: http://hostagebrain.blogspot.com.es/2015/04/build-openssl-on-windows.html ''' self.output.info("") self.output.info("---------- build ----------") self.output.info("") self.output.info("os : " + str(self.settings.os)) self.output.info("arch : " + str(self.settings.arch)) self.output.info("build_type: " + str(self.settings.build_type)) if self.settings.compiler == "Visual Studio": self.output.info("runtime : " + str(self.settings.compiler.runtime)) if self.settings.os == "Linux" and self.settings.compiler == "gcc" and self.settings.arch == "armv7hf" and not re.match( "arm.*", platform.machine()): self.output.warn( "The tool makedepend is needed to build. Please enter sudo password if requested..." ) self.run("sudo apt-get install -y xutils-dev") config_options_string = "" if self.deps_cpp_info.include_paths: include_path = self.deps_cpp_info["zlib"].include_paths[0] if self.settings.os == "Windows": lib_path = self.deps_cpp_info["zlib"].lib_paths[ 0] + "/" + self.deps_cpp_info["zlib"].libs[ 0] + ".lib" # Concrete lib file else: lib_path = self.deps_cpp_info["zlib"].lib_paths[ 0] # Just path, linux will find the right file config_options_string += ' --with-zlib-include="%s"' % include_path config_options_string += ' --with-zlib-lib="%s"' % lib_path # EFENCE LINK if "electric-fence" in self.requires: libs = " ".join([ "-l%s" % lib for lib in self.deps_cpp_info["electric-fence"].libs ]) config_options_string += ' -L"%s" -I"%s" %s' % ( self.deps_cpp_info["electric-fence"].lib_paths[0], self.deps_cpp_info["electric-fence"].include_paths[0], libs) else: replace_in_file("./openssl-%s/Configure" % self.version, "::-lefence::", "::") replace_in_file("./openssl-%s/Configure" % self.version, "::-lefence ", "::") self.output.warn("=====> Options: %s" % config_options_string) for option_name in self.options.values.fields: activated = getattr(self.options, option_name) if activated: self.output.info("Activated option! %s" % option_name) config_options_string += " %s" % option_name.replace("_", "-") def run_in_src(command, show_output=False): if not show_output and self.settings.os != "Windows": command += ' | while read line; do echo -n "."; done' with tools.chdir( os.path.join(self.build_folder, "openssl-" + str(self.version))): self.run(command) self.output.writeln(" ") def unix_make(config_options_string): self.output.warn("----------CONFIGURING OPENSSL %s-------------" % self.version) m32_suff = " -m32" if self.settings.arch == "x86" else "" if self.settings.os == "Linux": if self.settings.build_type == "Debug": config_options_string = "-d " + config_options_string m32_pref = "setarch i386 " if self.settings.arch == "x86" else "" run_in_src("%s ./config %s %s" % (m32_pref, config_options_string, m32_suff)) run_in_src("make depend") self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) run_in_src("make") elif self.settings.os == "Macos": if self.settings.arch == "x86_64": command = "./Configure darwin64-x86_64-cc %s" % config_options_string else: command = "./config %s %s" % (config_options_string, m32_suff) run_in_src(command) # REPLACE -install_name FOR FOLLOW THE CONAN RULES, # DYNLIBS IDS AND OTHER DYNLIB DEPS WITHOUT PATH, JUST THE LIBRARY NAME old_str = 'SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$' new_str = 'SHAREDFLAGS="$$SHAREDFLAGS -install_name $$SHLIB$' replace_in_file("./openssl-%s/Makefile.shared" % self.version, old_str, new_str) self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) run_in_src("make") def arm_make(config_options_string): if not "CXX" in os.environ: raise Exception( "failed to extract compiler from environment variable \"CXX\" (variable is not set)" ) result = re.search(r"(.*)g\+\+$", os.environ.get("CXX"), re.M | re.I) if not result: raise Exception( "Failed to extract compiler from environment variable \"CXX\". Variable value \"" + os.environ.get("CXX") + "\" does not end with \"g++\", e.g. \"arm-linux-gnueabihf-g++\"." ) verbose = False self.output.warn("----------CONFIGURING OPENSSL %s-------------" % self.version) # CAUTION: We intentionally set CC and CXX in order to satisfy the Configure script!!! command = "CC=gcc CXX=g++ CROSS_COMPILE=" + result.group( 1 ) + " ./Configure linux-armv4 -march=armv7-a %s" % config_options_string self.output.info("command: %s" % command) run_in_src(command, show_output=verbose) # run_in_src("printenv", show_output=True) # test CC and CXX having original values run_in_src("make depend", show_output=verbose) self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) run_in_src("make", show_output=verbose) def windows_make(config_options_string): self.output.warn( "----------CONFIGURING OPENSSL FOR WINDOWS. %s-------------" % self.version) debug = "debug-" if self.settings.build_type == "Debug" else "" arch = "32" if self.settings.arch == "x86" else "64A" configure_type = debug + "VC-WIN" + arch # Will output binaries to ./binaries config_command = "perl Configure %s no-asm --prefix=../binaries" % configure_type whole_command = "%s %s" % (config_command, config_options_string) self.output.warn(whole_command) run_in_src(whole_command) if self.options.no_asm: run_in_src(os.path.join("ms", "do_nasm")) if arch == "64A": run_in_src(os.path.join("ms", "do_win64a")) else: run_in_src(os.path.join("ms", "do_ms")) runtime = self.settings.compiler.runtime # Replace runtime in ntdll.mak and nt.mak rootDir = os.path.join(self.build_folder, "openssl-" + str(self.version)) runtimeStr = "/" + str(runtime) + " " replace_in_file(os.path.join(rootDir, "ms", "nt.mak"), "/MT ", runtimeStr, False) replace_in_file(os.path.join(rootDir, "ms", "nt.mak"), "/MTd ", runtimeStr, False) replace_in_file(os.path.join(rootDir, "ms", "ntdll.mak"), "/MD ", runtimeStr, False) replace_in_file(os.path.join(rootDir, "ms", "ntdll.mak"), "/MDd ", runtimeStr, False) self.output.warn(os.curdir) make_command = "" if self.settings.compiler == "Visual Studio": make_command = tools.vcvars_command(self.settings) + " && " make_command += "nmake -f " + os.path.join( "ms", "ntdll.mak" ) if self.options.shared else "nmake -f " + os.path.join( rootDir, "ms", "nt.mak") self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) run_in_src(make_command) run_in_src("%s install" % make_command) # Rename libs with the arch renames = { "./binaries/lib/libeay32.lib": "./binaries/lib/libeay32%s.lib" % runtime, "./binaries/lib/ssleay32.lib": "./binaries/lib/ssleay32%s.lib" % runtime } for old, new in renames.items(): if os.path.exists(old): os.rename(old, new) if self.settings.os == "Linux" or self.settings.os == "Macos": if self.settings.compiler == "gcc" and self.settings.arch == "armv7hf" and not re.match( "arm.*", platform.machine()): arm_make(config_options_string) else: unix_make(config_options_string) elif self.settings.os == "Windows": windows_make(config_options_string) self.output.info("----------BUILD END-------------")
def _patch_sources(self): if not self.options.with_snappy: tools.replace_in_file( os.path.join(self._source_subfolder, "CMakeLists.txt"), ('''check_library_exists(snappy snappy_compress ''' '''"" HAVE_SNAPPY)'''), "")
def build(self): tools.replace_in_file( os.path.join(self._source_subfolder, 'meson.build'), "subdir('tests')", "#subdir('tests')") meson = self._configure_meson() meson.build()
def build(self): """ Define your project building. You decide the way of building it to reuse it later in any other project. """ if self.settings.os == "Linux" or self.settings.os == "Macos": suffix = " --without-libidn " if not self.options.with_libidn else "--with-libidn" suffix += " --without-librtmp " if not self.options.with_librtmp else "--with-librtmp" suffix += " --without-libmetalink " if not self.options.with_libmetalink else "--with-libmetalink" if self.options.with_openssl: if self.settings.os == "Macos" and self.options.darwin_ssl: suffix += "--with-darwinssl " else: suffix += "--with-ssl " else: suffix += "--without-ssl " if self.options.with_libssh2: suffix += "--with-libssh2=%s " % self.deps_cpp_info[ "libssh2"].lib_paths[0] else: suffix += " --without-libssh2 " suffix += "--with-zlib=%s " % self.deps_cpp_info["zlib"].lib_paths[ 0] if not self.options.shared: suffix += " --disable-shared" if self.options.disable_threads: suffix += " --disable-thread" if not self.options.with_ldap: suffix += " --disable-ldap" if self.options.custom_cacert: suffix += ' --with-ca-bundle=cacert.pem' env_build = AutoToolsBuildEnvironment(self) with environment_append(env_build.vars): # Hack for configure, don't know why fails because it's not able to find libefence.so # TODO better to remove it from depends if 'efence' in env_build.libs: env_build.libs.remove('efence') old_str = "-install_name \$rpath/" new_str = "-install_name " replace_in_file("%s/configure" % self.ZIP_FOLDER_NAME, old_str, new_str) configure = "cd %s && %s ./configure %s" % ( self.ZIP_FOLDER_NAME, '', suffix) self.output.warn(configure) # BUG: https://github.com/curl/curl/commit/bd742adb6f13dc668ffadb2e97a40776a86dc124 replace_in_file( "%s/configure" % self.ZIP_FOLDER_NAME, 'LDFLAGS="`$PKGCONFIG --libs-only-L zlib` $LDFLAGS"', 'LDFLAGS="$LDFLAGS `$PKGCONFIG --libs-only-L zlib`"') self.output.warn(configure) self.run(configure) if self.settings.os == "Macos": make_suffix = "CFLAGS=-Wno-unguarded-availability" else: make_suffix = '' self.run("cd %s && make %s" % (self.ZIP_FOLDER_NAME, make_suffix)) else: # Do not compile curl tool, just library conan_magic_lines = '''project(CURL) cmake_minimum_required(VERSION 3.0) include(../conanbuildinfo.cmake) CONAN_BASIC_SETUP() ''' replace_in_file("%s/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "cmake_minimum_required(VERSION 2.8 FATAL_ERROR)", conan_magic_lines) replace_in_file("%s/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "project( CURL C )", "") replace_in_file("%s/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "include(CurlSymbolHiding)", "") replace_in_file("%s/src/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "add_executable(", "IF(0)\n add_executable(") replace_in_file("%s/src/CMakeLists.txt" % self.ZIP_FOLDER_NAME, "install(TARGETS ${EXE_NAME} DESTINATION bin)", "ENDIF()") # EOF cmake = CMake(self.settings) static = "-DBUILD_SHARED_LIBS=ON -DCURL_STATICLIB=OFF" if self.options.shared else "-DBUILD_SHARED_LIBS=OFF -DCURL_STATICLIB=ON" ldap = "-DCURL_DISABLE_LDAP=ON" if not self.options.with_ldap else "-DCURL_DISABLE_LDAP=OFF" self.run("cd %s && mkdir _build" % self.ZIP_FOLDER_NAME) cd_build = "cd %s/_build" % self.ZIP_FOLDER_NAME self.run('%s && cmake .. %s -DBUILD_TESTING=OFF %s %s' % (cd_build, cmake.command_line, ldap, static)) self.run("%s && cmake --build . %s" % (cd_build, cmake.build_config))
def build(self): # Before building we need to make some edits to the premake file to build using conan dependencies rather than local/bundled # Generate the list of dependency include and library paths as strings include_path_str = ', '.join( '"{0}"'.format(p) for p in self.deps_cpp_info["libsodium"].include_paths + self.deps_cpp_info["mbedtls"].include_paths) lib_path_str = ', '.join( '"{0}"'.format(p) for p in self.deps_cpp_info["libsodium"].lib_paths + self.deps_cpp_info["mbedtls"].lib_paths) premake_path = os.path.join(self._source_subfolder, "premake5.lua") if self.settings.os == "Windows": # Replace Windows directory seperator include_path_str = include_path_str.replace("\\", "/") lib_path_str = lib_path_str.replace("\\", "/") # Edit the premake script to use conan rather than bundled dependencies tools.replace_in_file(premake_path, "includedirs { \".\", \"./windows\"", "includedirs { \".\", %s" % include_path_str, strict=True) tools.replace_in_file(premake_path, "libdirs { \"./windows\" }", "libdirs { %s }" % lib_path_str, strict=True) # Edit the premake script to change the name of libsodium tools.replace_in_file(premake_path, "\"sodium\"", "\"libsodium\"", strict=True) else: # Edit the premake script to use conan rather than local dependencies tools.replace_in_file(premake_path, "\"/usr/local/include\"", include_path_str, strict=True) # Build using premake if self.settings.compiler == "Visual Studio": generator = "vs" + { "16": "2019", "15": "2017", "14": "2015", "12": "2013", "11": "2012", "10": "2010", "9": "2008", "8": "2005" }.get(str(self.settings.compiler.version)) else: generator = "gmake2" with tools.chdir(self._source_subfolder): self.run("premake5 %s" % generator) if self.settings.compiler == "Visual Studio": msbuild = MSBuild(self) msbuild.build("Yojimbo.sln") else: config = "debug" if self.settings.build_type == "Debug" else "release" config += "_x64" env_build = AutoToolsBuildEnvironment(self) env_build.make(args=["config=%s" % config])
def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"), 'set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})', "") # Get rid of cmake_dependent_option, it can activate features when we try to disable them, # let the Conan user decide what to use and what not. with open(os.path.join(self._source_subfolder, "CMakeLists.txt"), 'r+') as f: text = f.read() text = re.sub('cmake_dependent_option\(([0-9A-Z_]+) .*\)', r'option(\1 "Option \1 disabled by Conan" OFF)', text) f.seek(0) f.write(text) f.truncate() # GLFW naming tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), "find_package(GLFW)", "find_package(glfw3)") tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), "GLFW_FOUND", "glfw3_FOUND") tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), "GLFW::GLFW", "glfw::glfw") # EGL naming tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), "find_package(EGL)", "find_package(egl_system)") tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), "EGL_FOUND", "egl_system_FOUND") tools.replace_in_file(os.path.join(self._source_subfolder, "src", "Magnum", "Platform", "CMakeLists.txt"), "EGL::EGL", "egl::egl")
def source(self): git = tools.Git(folder=self.name) git.clone("https://github.com/cisco/openh264.git", branch="master") git.checkout(self.git_hash) tools.replace_in_file("{}/meson.build".format(self.name), "version : '1.8.0'", "version : '2.0.0'")
def build(self): cmake = CMake(self) cmake.definitions["ENABLE_LIB_ONLY"] = True cmake.definitions["CMAKE_INSTALL_PREFIX"] = self.package_folder cmake.definitions["CMAKE_BUILD_SHARED_LIBS"] = self.options.shared for option in _FIND_PACKAGES: if not getattr(self.options, option): tools.replace_in_file('sources/CMakeLists.txt', _FIND_PACKAGES[option], '') tools.replace_in_file( 'sources/lib/CMakeLists.txt', 'DESTINATION "${CMAKE_INSTALL_LIBDIR}"', 'RUNTIME DESTINATION "bin" LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib"') tools.replace_in_file( 'sources/lib/CMakeLists.txt', 'add_library(nghttp2 SHARED ${NGHTTP2_SOURCES} ${NGHTTP2_RES})', 'add_library(nghttp2 ${NGHTTP2_SOURCES} ${NGHTTP2_RES})') tools.replace_in_file( 'sources/src/CMakeLists.txt', 'DESTINATION "${CMAKE_INSTALL_LIBDIR}"', 'RUNTIME DESTINATION "bin" LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib"') tools.replace_in_file( 'sources/src/CMakeLists.txt', 'add_library(nghttp2_asio SHARED', 'add_library(nghttp2_asio') if self.options.with_asio: cmake.definitions["ENABLE_ASIO_LIB"] = True tools.replace_in_file( 'sources/CMakeLists.txt', 'find_package(Boost 1.54.0 REQUIRED system thread)', '') if not self.options.shared: tools.replace_in_file( 'sources/lib/includes/nghttp2/nghttp2.h', '#define NGHTTP2_EXTERN __declspec(dllimport)', '#define NGHTTP2_EXTERN') cmake.configure() cmake.build() cmake.install()
def _patch_files(self): # - fontconfig requires libtool version number, change it for the corresponding freetype one tools.replace_in_file( os.path.join(self._source_subfolder, 'configure'), '21.0.15', '2.8.1')
def _patch_sources(self): tools.replace_in_file( os.path.join(self._source_subfolder, "meson.build"), "subdir('tests')", "#subdir('tests')")
def _patch_makefile_org(self): # https://wiki.openssl.org/index.php/Compilation_and_Installation#Modifying_Build_Settings # its often easier to modify Configure and Makefile.org rather than trying to add targets to the configure scripts def adjust_path(path): return path.replace("\\", "/") if tools.os_info.is_windows else path makefile_org = os.path.join(self._source_subfolder, "Makefile.org") env_build = self._get_env_build() with tools.environment_append(env_build.vars): if not "CROSS_COMPILE" in os.environ: cc = os.environ.get("CC", "cc") tools.replace_in_file(makefile_org, "CC= cc\n", "CC= %s %s\n" % (adjust_path(cc), os.environ["CFLAGS"])) if "AR" in os.environ: tools.replace_in_file(makefile_org, "AR=ar $(ARFLAGS) r\n", "AR=%s $(ARFLAGS) r\n" % adjust_path(os.environ["AR"])) if "RANLIB" in os.environ: tools.replace_in_file(makefile_org, "RANLIB= ranlib\n", "RANLIB= %s\n" % adjust_path(os.environ["RANLIB"])) rc = os.environ.get("WINDRES", os.environ.get("RC")) if rc: tools.replace_in_file(makefile_org, "RC= windres\n", "RC= %s\n" % adjust_path(rc)) if "NM" in os.environ: tools.replace_in_file(makefile_org, "NM= nm\n", "NM= %s\n" % adjust_path(os.environ["NM"])) if "AS" in os.environ: tools.replace_in_file(makefile_org, "AS=$(CC) -c\n", "AS=%s\n" % adjust_path(os.environ["AS"]))
def _replace_runtime_in_file(self, filename): for e in ["MDd", "MTd", "MD", "MT"]: tools.replace_in_file(filename, "/%s " % e, "/%s " % self.settings.compiler.runtime, strict=False)