def build_autotools(self): prefix = os.path.abspath(self.package_folder) win_bash = False rc = None host = None build = None if self.is_mingw or self.is_msvc: prefix = prefix.replace('\\', '/') win_bash = True build = False if self.settings.arch == "x86": host = "i686-w64-mingw32" rc = "windres --target=pe-i386" elif self.settings.arch == "x86_64": host = "x86_64-w64-mingw32" rc = "windres --target=pe-x86-64" env_build = AutoToolsBuildEnvironment(self, win_bash=win_bash) if self.settings.os != "Windows": env_build.fpic = self.options.fPIC configure_args = ['--prefix=%s' % prefix] if self.options.shared: configure_args.extend(['--disable-static', '--enable-shared']) else: configure_args.extend(['--enable-static', '--disable-shared']) env_vars = {} if self.is_mingw: configure_args.extend(['CPPFLAGS=-I%s/include' % prefix, 'LDFLAGS=-L%s/lib' % prefix, 'RANLIB=:']) if self.is_msvc: runtime = str(self.settings.compiler.runtime) configure_args.extend(['CC=$PWD/build-aux/compile cl -nologo', 'CFLAGS=-%s' % runtime, 'CXX=$PWD/build-aux/compile cl -nologo', 'CXXFLAGS=-%s' % runtime, 'CPPFLAGS=-D_WIN32_WINNT=0x0600 -I%s/include' % prefix, 'LDFLAGS=-L%s/lib' % prefix, 'LD=link', 'NM=dumpbin -symbols', 'STRIP=:', 'AR=$PWD/build-aux/ar-lib lib', 'RANLIB=:']) env_vars['win32_target'] = '_WIN32_WINNT_VISTA' with tools.chdir(self.archive_name): tools.run_in_windows_bash(self, 'chmod +x build-aux/ar-lib build-aux/compile') if rc: configure_args.extend(['RC=%s' % rc, 'WINDRES=%s' % rc]) with tools.chdir(self.archive_name): with tools.environment_append(env_vars): env_build.configure(args=configure_args, host=host, build=build) env_build.make() env_build.make(args=["install"])
def run_in_bash_test(self): if platform.system() != "Windows": return class MockConanfile(object): def __init__(self): self.command = "" self.output = namedtuple("output", "info")(lambda x: None) self.env = {} def run(self, command, win_bash=False): self.command = command conanfile = MockConanfile() tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin") self.assertIn("bash", conanfile.command) self.assertIn("--login -c", conanfile.command) self.assertIn("^&^& a_command.bat ^", conanfile.command) with tools.environment_append( {"CONAN_BASH_PATH": "path\\to\\mybash.exe"}): tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin") self.assertIn("path\\to\\mybash.exe --login -c", conanfile.command)
def package(self): self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) if self._is_mingw_windows: package_folder = tools.unix_path( os.path.join(self.package_folder, "bin")) tools.run_in_windows_bash( self, "cp $(which libwinpthread-1.dll) {}".format(package_folder))
def run_in_bash_test(self): if platform.system() != "Windows": return class MockConanfile(object): def __init__(self): self.output = namedtuple("output", "info")(lambda x: None) # @UnusedVariable self.env = {"PATH": "/path/to/somewhere"} class MyRun(object): def __call__(self, command, output, log_filepath=None, cwd=None, subprocess=False): # @UnusedVariable self.command = command self._runner = MyRun() conanfile = MockConanfile() tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin") self.assertIn("bash", conanfile._runner.command) self.assertIn("--login -c", conanfile._runner.command) self.assertIn("^&^& a_command.bat ^", conanfile._runner.command) with tools.environment_append({"CONAN_BASH_PATH": "path\\to\\mybash.exe"}): tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin") self.assertIn('path\\to\\mybash.exe --login -c', conanfile._runner.command) with tools.environment_append({"CONAN_BASH_PATH": "path with spaces\\to\\mybash.exe"}): tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin") self.assertIn('"path with spaces\\to\\mybash.exe" --login -c', conanfile._runner.command) # try to append more env vars conanfile = MockConanfile() tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin", env={"PATH": "/other/path", "MYVAR": "34"}) self.assertIn('^&^& PATH=\\^"/cygdrive/other/path:/cygdrive/path/to/somewhere:$PATH\\^" ' '^&^& MYVAR=34 ^&^& a_command.bat ^', conanfile._runner.command)
def run_in_bash_test(self): if platform.system() != "Windows": return class MockConanfile(object): def __init__(self): self.output = namedtuple("output", "info")(lambda x: None) # @UnusedVariable self.env = {"PATH": "/path/to/somewhere"} class MyRun(object): def __call__(self, command, output, log_filepath=None, cwd=None, subprocess=False): # @UnusedVariable self.command = command self._runner = MyRun() conanfile = MockConanfile() tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin") self.assertIn("bash", conanfile._runner.command) self.assertIn("--login -c", conanfile._runner.command) self.assertIn("^&^& a_command.bat ^", conanfile._runner.command) with tools.environment_append({"CONAN_BASH_PATH": "path\\to\\mybash.exe"}): tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin") self.assertIn('path\\to\\mybash.exe --login -c', conanfile._runner.command) with tools.environment_append({"CONAN_BASH_PATH": "path with spaces\\to\\mybash.exe"}): tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin") self.assertIn('"path with spaces\\to\\mybash.exe" --login -c', conanfile._runner.command) # try to append more env vars conanfile = MockConanfile() tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin", env={"PATH": "/other/path", "MYVAR": "34"}) self.assertIn('^&^& PATH=\\^"/cygdrive/other/path:/cygdrive/path/to/somewhere:$PATH\\^" ' '^&^& MYVAR=34 ^&^& a_command.bat ^', conanfile._runner.command)
def mingw_build(self, config_options_string): # https://netix.dl.sourceforge.net/project/msys2/Base/x86_64/msys2-x86_64-20161025.exe config_options_string = tools.unix_path(config_options_string) if self.settings.build_type == "Debug": config_options_string = "-g " + config_options_string if self.settings.arch == "x86": config_line = "./Configure mingw %s" % config_options_string else: config_line = "./Configure mingw64 %s" % config_options_string self.output.warn(config_line) with tools.chdir(self.subfolder): tools.run_in_windows_bash(self, config_line) self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) # tools.run_in_windows_bash(self, "make depend") tools.run_in_windows_bash(self, "make")
def build(self): compiler_str = { "clang": "clang", "gcc": "" }.get(str(self.settings.compiler)) toolchain = "%s-linux-%s-%s%s" % (self.arch_id_str, self.android_id_str, compiler_str, self.settings.compiler.version) # Command available in android-ndk package # --stl => gnustl, libc++, stlport pre_path = (self.ndk_path + "/") if self.options.ndk_path else "" stl = { "libstdc++": "gnustl", "libstdc++11": "gnustl", "libc++": "libc++" }.get(str(self.settings.compiler.libcxx)) command = "%smake-standalone-toolchain.sh --toolchain=%s --platform=android-%s " \ "--install-dir=%s --stl=%s" % (pre_path, toolchain, self.settings.os.api_level, self.package_folder, stl) self.output.warn(command) # self.run("make-standalone-toolchain.sh --help") if platform.system != "Windows": self.run(command) else: tools.run_in_windows_bash(self, command) if self.options.use_system_python: if os.path.exists( os.path.join(self.package_folder, "bin", "python")): os.unlink(os.path.join(self.package_folder, "bin", "python")) if platform.system( ) == "Windows": # Create clang.exe to make CMake happy dest_cc_compiler = os.path.join(self.package_folder, "bin", "clang.exe") dest_cxx_compiler = os.path.join(self.package_folder, "bin", "clang++.exe") src_cc_compiler = os.path.join(self.package_folder, "bin", "clang38.exe") src_cxx_compiler = os.path.join(self.package_folder, "bin", "clang38++.exe") shutil.copy(src_cc_compiler, dest_cc_compiler) shutil.copy(src_cxx_compiler, dest_cxx_compiler) if not os.path.exists(os.path.join(self.package_folder, "bin")): raise Exception( "Invalid toolchain, try a higher api_level or different architecture: %s-%s" % (self.settings.arch, self.settings.os.api_level))
def _run(): if not win_bash: return self._conan_runner(command, output, os.path.abspath(RUN_LOG_NAME), cwd) # FIXME: run in windows bash is not using output return tools.run_in_windows_bash(self, bashcmd=command, cwd=cwd, subsystem=subsystem, msys_mingw=msys_mingw)
def mingw_build(self, config_options_string): if tools.os_info.is_windows: config_options_string = tools.unix_path(config_options_string) if self.settings.build_type == "Debug": config_options_string = "-g " + config_options_string if self.settings.arch == "x86": config_line = "./Configure mingw %s" % config_options_string else: config_line = "./Configure mingw64 %s" % config_options_string self.output.warn(config_line) with tools.chdir(self.subfolder): if tools.os_info.is_windows: tools.run_in_windows_bash(self, config_line) self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) # tools.run_in_windows_bash(self, "make depend") tools.run_in_windows_bash(self, "make") else: self.run(config_line) self.output.warn("----------MAKE OPENSSL %s-------------" % self.version) self.run("make")
def run(self, command, output=True, cwd=None, win_bash=False, subsystem=None, msys_mingw=True): if not win_bash: retcode = self._runner(command, output, os.path.abspath(RUN_LOG_NAME), cwd) else: retcode = tools.run_in_windows_bash(self, bashcmd=command, cwd=cwd, subsystem=subsystem, msys_mingw=msys_mingw) if retcode != 0: raise ConanException("Error %d while executing %s" % (retcode, command)) return retcode
def run_in_bash_test(self): if platform.system() != "Windows": return class MockConanfile(object): def __init__(self): self.command = "" self.output = namedtuple("output", "info")(lambda x: None) def run(self, command): self.command = command conanfile = MockConanfile() tools.run_in_windows_bash(conanfile, "a_command.bat") self.assertIn("bash --login -c", conanfile.command) self.assertIn("^&^& a_command.bat ^", conanfile.command) with tools.environment_append({"CONAN_BASH_PATH": "path\\to\\mybash.exe"}): tools.run_in_windows_bash(conanfile, "a_command.bat") self.assertIn("path\\to\\mybash.exe --login -c", conanfile.command)
def build(self): compiler_str = {"clang": "clang"}.get(str(self.settings.compiler)) toolchain = "%s-linux-%s-%s%s" % (self.arch_id_str, self.android_id_str, compiler_str, self.settings.compiler.version) pre_path = (self.ndk_path + "/") if self.options.ndk_path else "" command = "%smake_standalone_toolchain.py --arch %s --api %s " \ "--install-dir %s" % (pre_path, self.arch_standalone_name, self.settings.os.api_level, self.package_folder) self.output.warn(command) self.output.warn(self.package_folder) # self.run("make-standalone-toolchain.sh --help") if platform.system != "Windows": self.run(command) else: tools.run_in_windows_bash(self, command) if self.options.use_system_python: if os.path.exists( os.path.join(self.package_folder, "bin", "python")): os.unlink(os.path.join(self.package_folder, "bin", "python")) if platform.system( ) == "Windows": # Create clang.exe to make CMake happy dest_cc_compiler = os.path.join(self.package_folder, "bin", "clang.exe") dest_cxx_compiler = os.path.join(self.package_folder, "bin", "clang++.exe") src_cc_compiler = os.path.join(self.package_folder, "bin", "clang60.exe") src_cxx_compiler = os.path.join(self.package_folder, "bin", "clang60++.exe") shutil.copy(src_cc_compiler, dest_cc_compiler) shutil.copy(src_cxx_compiler, dest_cxx_compiler) if not os.path.exists(os.path.join(self.package_folder, "bin")): raise Exception( "Invalid toolchain, try a higher api_level or different architecture: %s-%s" % (self.settings.arch, self.settings.os.api_level))
def build(self): if self.settings.compiler == "Visual Studio": env = VisualStudioBuildEnvironment(self) with tools.environment_append(env.vars): with tools.chdir(os.path.join(self.source_subfolder, "win32", "VS2015")): vcvars = tools.vcvars_command(self.settings) btype = "%s%s%s" % (self.settings.build_type, "DLL" if self.options.shared else "", "_fixed" if self.options.shared and self.options.fixed_point else "") # Instead of using "replace" here below, would we could add the "arch" parameter, but it doesn't work when we are also # using the build_type parameter on conan 0.29.2 (conan bug?) build_command = tools.build_sln_command(self.settings, "opus.sln", build_type = btype).replace("x86", "Win32") self.output.info("Build command: %s" % build_command) self.run("%s && %s" % (vcvars, build_command)) else: env = AutoToolsBuildEnvironment(self) if self.settings.os != "Windows": env.fpic = self.options.fPIC with tools.environment_append(env.vars): with tools.chdir(self.source_subfolder): if self.settings.os == "Macos": tools.replace_in_file("configure", r"-install_name \$rpath/", "-install_name ") if self.settings.os == "Windows": tools.run_in_windows_bash(self, "./configure%s" % (" --enable-fixed-point" if self.options.fixed_point else "")) tools.run_in_windows_bash(self, "make") else: configure_options = " --prefix=%s" % os.path.join(self.build_folder, self.install_subfolder) if self.options.fixed_point: configure_options += " --enable-fixed-point" if self.options.shared: configure_options += " --disable-static --enable-shared" else: configure_options += " --disable-shared --enable-static" self.run("chmod +x configure") self.run("./configure%s" % configure_options) self.run("make") self.run("make install")
def _build_autotools(self): prefix = os.path.abspath(self.package_folder) rc = None host = None build = None if self._is_mingw_windows or self._is_msvc: prefix = prefix.replace('\\', '/') build = False if self.settings.arch == "x86": host = "i686-w64-mingw32" rc = "windres --target=pe-i386" elif self.settings.arch == "x86_64": host = "x86_64-w64-mingw32" rc = "windres --target=pe-x86-64" # # If you pass --build when building for iPhoneSimulator, the configure script halts. # So, disable passing --build by setting it to False. # if self.settings.os == "iOS" and self.settings.arch == "x86_64": build = False env_build = AutoToolsBuildEnvironment( self, win_bash=tools.os_info.is_windows) if self.settings.os != "Windows": env_build.fpic = self.options.fPIC configure_args = ['--prefix=%s' % prefix] if self.options.shared: configure_args.extend(['--disable-static', '--enable-shared']) else: configure_args.extend(['--enable-static', '--disable-shared']) env_vars = {} if self._is_mingw_windows: configure_args.extend([ 'CPPFLAGS=-I%s/include' % prefix, 'LDFLAGS=-L%s/lib' % prefix, 'RANLIB=:' ]) if self._is_msvc: runtime = str(self.settings.compiler.runtime) configure_args.extend([ 'CC=$PWD/build-aux/compile cl -nologo', 'CFLAGS=-%s' % runtime, 'CXX=$PWD/build-aux/compile cl -nologo', 'CXXFLAGS=-%s' % runtime, 'CPPFLAGS=-D_WIN32_WINNT=0x0600 -I%s/include' % prefix, 'LDFLAGS=-L%s/lib' % prefix, 'LD=link', 'NM=dumpbin -symbols', 'STRIP=:', 'AR=$PWD/build-aux/ar-lib lib', 'RANLIB=:' ]) env_vars['win32_target'] = '_WIN32_WINNT_VISTA' with tools.chdir(self._source_subfolder): tools.run_in_windows_bash( self, 'chmod +x build-aux/ar-lib build-aux/compile') if rc: configure_args.extend(['RC=%s' % rc, 'WINDRES=%s' % rc]) with tools.chdir(self._source_subfolder): with tools.environment_append(env_vars): env_build.configure(args=configure_args, host=host, build=build) env_build.make() env_build.install()
def build_configure(self): with tools.chdir('sources'): prefix = tools.unix_path( self.package_folder ) if self.settings.os == 'Windows' else self.package_folder args = [ '--prefix=%s' % prefix, '--disable-doc', '--disable-programs' ] if self.options.shared: args.extend(['--disable-static', '--enable-shared']) else: args.extend(['--disable-shared', '--enable-static']) args.append('--pkg-config-flags=--static') if self.settings.build_type == 'Debug': args.extend([ '--disable-optimizations', '--disable-mmx', '--disable-stripping', '--enable-debug' ]) if self.is_msvc: args.append('--toolchain=msvc') args.append('--extra-cflags=-%s' % self.settings.compiler.runtime) if int(str(self.settings.compiler.version)) <= 12: # Visual Studio 2013 (and earlier) doesn't support "inline" keyword for C (only for C++) args.append('--extra-cflags=-Dinline=__inline' % self.settings.compiler.runtime) if self.settings.arch == 'x86': args.append('--arch=x86') args.append('--enable-postproc' if self.options. postproc else '--disable-postproc') args.append( '--enable-pic' if self.options.fPIC else '--disable-pic') args.append( '--enable-zlib' if self.options.zlib else '--disable-zlib') args.append( '--enable-bzlib' if self.options.bzlib else '--disable-bzlib') args.append( '--enable-lzma' if self.options.lzma else '--disable-lzma') args.append( '--enable-iconv' if self.options.iconv else '--disable-iconv') args.append('--enable-libfreetype' if self.options. freetype else '--disable-libfreetype') args.append('--enable-libopenjpeg' if self.options. openjpeg else '--disable-libopenjpeg') args.append('--enable-libopenh264' if self.options. openh264 else '--disable-libopenh264') args.append('--enable-libvorbis' if self.options. vorbis else '--disable-libvorbis') args.append('--enable-libopus' if self.options. opus else '--disable-libopus') args.append( '--enable-libzmq' if self.options.zmq else '--disable-libzmq') args.append( '--enable-sdl2' if self.options.sdl2 else '--disable-sdl2') args.append('--enable-libx264' if self.options. x264 else '--disable-libx264') args.append('--enable-libx265' if self.options. x265 else '--disable-libx265') args.append( '--enable-libvpx' if self.options.vpx else '--disable-libvpx') args.append('--enable-libmp3lame' if self.options. mp3lame else '--disable-libmp3lame') args.append('--enable-libfdk-aac' if self.options. fdk_aac else '--disable-libfdk-aac') args.append('--enable-libwebp' if self.options. webp else '--disable-libwebp') args.append( '--enable-nvenc' if self.options.nvenc else '--disable-nvenc') if self.options.x264 or self.options.x265 or self.options.postproc: args.append('--enable-gpl') if self.options.fdk_aac: args.append('--enable-nonfree') if self.settings.os == "Linux": args.append( '--enable-alsa' if self.options.alsa else '--disable-alsa') args.append('--enable-libpulse' if self.options. pulse else '--disable-libpulse') args.append('--enable-vaapi' if self.options. vaapi else '--disable-vaapi') args.append('--enable-vdpau' if self.options. vdpau else '--disable-vdpau') if self.options.xcb: args.extend([ '--enable-libxcb', '--enable-libxcb-shm', '--enable-libxcb-shape', '--enable-libxcb-xfixes' ]) else: args.extend([ '--disable-libxcb', '--disable-libxcb-shm', '--disable-libxcb-shape', '--disable-libxcb-xfixes' ]) if self.settings.os == "Macos": args.append('--enable-appkit' if self.options. appkit else '--disable-appkit') args.append('--enable-avfoundation' if self.options. avfoundation else '--disable-avfoundation') args.append('--enable-coreimage' if self.options. avfoundation else '--disable-coreimage') args.append('--enable-audiotoolbox' if self.options. audiotoolbox else '--disable-audiotoolbox') args.append('--enable-videotoolbox' if self.options. videotoolbox else '--disable-videotoolbox') args.append('--enable-securetransport' if self.options. securetransport else '--disable-securetransport') if self.settings.os == "Windows": args.append('--enable-libmfx' if self.options. qsv else '--disable-libmfx') # FIXME disable CUDA and CUVID by default, revisit later if not self.options.nvenc: args.extend(['--disable-cuda', '--disable-cuvid']) os.makedirs('pkgconfig') if self.options.freetype: self.copy_pkg_config('freetype') self.copy_pkg_config('libpng') if self.options.opus: self.copy_pkg_config('opus') if self.options.vorbis: self.copy_pkg_config('ogg') self.copy_pkg_config('vorbis') if self.options.zmq: self.copy_pkg_config('zmq') if self.options.sdl2: self.copy_pkg_config('sdl2') if self.options.x264: self.copy_pkg_config('libx264') if self.options.x265: self.copy_pkg_config('libx265') if self.options.vpx: self.copy_pkg_config('libvpx') if self.options.fdk_aac: self.copy_pkg_config('libfdk_aac') if self.options.openh264: self.copy_pkg_config('openh264') if self.options.openjpeg: self.copy_pkg_config('openjpeg') if self.options.webp: self.copy_pkg_config('libwebp') if self.options.nvenc: self.copy_pkg_config('ffmpeg-nv-codec-headers') pkg_config_path = os.path.abspath('pkgconfig') pkg_config_path = tools.unix_path( pkg_config_path ) if self.settings.os == 'Windows' else pkg_config_path try: if self.is_msvc or self.is_mingw_windows: # hack for MSYS2 which doesn't inherit PKG_CONFIG_PATH for filename in ['.bashrc', '.bash_profile', '.profile']: tools.run_in_windows_bash( self, 'cp ~/%s ~/%s.bak' % (filename, filename)) command = 'echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:%s" >> ~/%s'\ % (pkg_config_path, filename) tools.run_in_windows_bash(self, command) env_build = AutoToolsBuildEnvironment( self, win_bash=self.is_mingw_windows or self.is_msvc) # ffmpeg's configure is not actually from autotools, so it doesn't understand standard options like # --host, --build, --target env_build.configure(args=args, build=False, host=False, target=False, pkg_config_paths=[pkg_config_path]) env_build.make() env_build.make(args=['install']) finally: if self.is_msvc or self.is_mingw_windows: for filename in ['.bashrc', '.bash_profile', '.profile']: tools.run_in_windows_bash( self, 'cp ~/%s.bak ~/%s' % (filename, filename)) tools.run_in_windows_bash(self, 'rm -f ~/%s.bak' % filename)
def build_configure(self): with tools.chdir(self._source_subfolder): prefix = tools.unix_path( self.package_folder ) if self.settings.os == 'Windows' else self.package_folder args = [ '--prefix=%s' % prefix, '--disable-doc', '--disable-programs' ] if self.options.shared: args.extend(['--disable-static', '--enable-shared']) else: args.extend(['--disable-shared', '--enable-static']) args.append('--pkg-config-flags=--static') if self.settings.build_type == 'Debug': args.extend([ '--disable-optimizations', '--disable-mmx', '--disable-stripping', '--enable-debug' ]) if self._is_msvc: args.append('--toolchain=msvc') args.append('--extra-cflags=-%s' % self.settings.compiler.runtime) if int(str(self.settings.compiler.version)) <= 12: # Visual Studio 2013 (and earlier) doesn't support "inline" keyword for C (only for C++) args.append('--extra-cflags=-Dinline=__inline' % self.settings.compiler.runtime) if self.settings.arch == 'x86': args.append('--arch=x86') if self.settings.os != "Windows": args.append( '--enable-pic' if self.options.fPIC else '--disable-pic') args.append('--enable-postproc' if self.options. postproc else '--disable-postproc') args.append( '--enable-zlib' if self.options.zlib else '--disable-zlib') args.append( '--enable-bzlib' if self.options.bzlib else '--disable-bzlib') args.append( '--enable-lzma' if self.options.lzma else '--disable-lzma') args.append( '--enable-iconv' if self.options.iconv else '--disable-iconv') args.append('--enable-libfreetype' if self.options. freetype else '--disable-libfreetype') args.append('--enable-libopenjpeg' if self.options. openjpeg else '--disable-libopenjpeg') args.append('--enable-libopenh264' if self.options. openh264 else '--disable-libopenh264') args.append('--enable-libvorbis' if self.options. vorbis else '--disable-libvorbis') args.append('--enable-libopus' if self.options. opus else '--disable-libopus') args.append( '--enable-libzmq' if self.options.zmq else '--disable-libzmq') args.append( '--enable-sdl2' if self.options.sdl2 else '--disable-sdl2') args.append('--enable-libx264' if self.options. x264 else '--disable-libx264') args.append('--enable-libx265' if self.options. x265 else '--disable-libx265') args.append( '--enable-libvpx' if self.options.vpx else '--disable-libvpx') args.append('--enable-libmp3lame' if self.options. mp3lame else '--disable-libmp3lame') args.append('--enable-libfdk-aac' if self.options. fdk_aac else '--disable-libfdk-aac') args.append('--enable-libwebp' if self.options. webp else '--disable-libwebp') args.append('--enable-openssl' if self.options. openssl else '--disable-openssl') #if self.options.x264 or self.options.x265 or self.options.postproc: # args.append('--enable-gpl') assert not (self.options.x264 or self.options.x265 or self.options.postproc) args.append('--disable-gpl') # NOTE(a.kamyshev): Commented out lines are wrong, fdk_aac with lgpl does not require nonfree, it does so only for gpl license, # see https://www.ffmpeg.org/general.html#toc-OpenCORE_002c-VisualOn_002c-and-Fraunhofer-libraries #if self.options.fdk_aac: # args.append('--enable-nonfree') args.append('--disable-nonfree') if self.settings.os == "Linux": # there is no option associated with alsa in ffmpeg 3.3.1 # args.append('--enable-alsa' if self.options.alsa else '--disable-alsa') args.append('--enable-libpulse' if self.options. pulse else '--disable-libpulse') args.append('--enable-vaapi' if self.options. vaapi else '--disable-vaapi') args.append('--enable-vdpau' if self.options. vdpau else '--disable-vdpau') if self.options.xcb: args.extend([ '--enable-libxcb', '--enable-libxcb-shm', '--enable-libxcb-shape', '--enable-libxcb-xfixes' ]) else: args.extend([ '--disable-libxcb', '--disable-libxcb-shm', '--disable-libxcb-shape', '--disable-libxcb-xfixes' ]) if self.settings.os == "Macos" and False: # v.looze: ffmpeg 3.3.1 does not support these config options args.append('--enable-appkit' if self.options. appkit else '--disable-appkit') args.append('--enable-avfoundation' if self.options. avfoundation else '--disable-avfoundation') args.append('--enable-coreimage' if self.options. avfoundation else '--disable-coreimage') args.append('--enable-audiotoolbox' if self.options. audiotoolbox else '--disable-audiotoolbox') args.append('--enable-videotoolbox' if self.options. videotoolbox else '--disable-videotoolbox') args.append('--enable-securetransport' if self.options. securetransport else '--disable-securetransport') if self.settings.os == "Windows": args.append('--enable-libmfx' if self.options. qsv else '--disable-libmfx') # FIXME disable CUDA and CUVID by default, revisit later args.extend(['--disable-cuda', '--disable-cuvid']) # thanks to generators = "pkg_config", we will have all dependency # *.pc files in build folder, so pointing pkg-config there is enough pkg_config_path = os.path.abspath(self.build_folder) print("pkg_config_path or build_folder: " + pkg_config_path) pkg_config_path = tools.unix_path( pkg_config_path ) if self.settings.os == 'Windows' else pkg_config_path try: if self._is_msvc or self._is_mingw_windows: # hack for MSYS2 which doesn't inherit PKG_CONFIG_PATH for filename in ['.bashrc', '.bash_profile', '.profile']: tools.run_in_windows_bash( self, 'cp ~/%s ~/%s.bak' % (filename, filename)) command = 'echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:%s" >> ~/%s'\ % (pkg_config_path, filename) tools.run_in_windows_bash(self, command) # looks like msys2 package has pkg-config preinstalled, # but we need to install it ourselves in case the msys in CONAN_MSYS_PATH does not have it pkg_config_find_or_install_command = "pacman -Qs pkg-config || pacman -S --noconfirm pkg-config" tools.run_in_windows_bash( self, pkg_config_find_or_install_command) # intel_media_sdk.pc contains info on a package libmfx, but ffmpeg's configure script doesn't recognize it tools.run_in_windows_bash( self, 'mv %s/intel_media_sdk.pc %s/libmfx.pc' % (pkg_config_path, pkg_config_path)) env_build = AutoToolsBuildEnvironment( self, win_bash=self._is_mingw_windows or self._is_msvc) if self.settings.os == "Windows" and self.settings.build_type == "Debug": # see https://trac.ffmpeg.org/ticket/6429 (ffmpeg does not build without compiler optimizations) env_build.flags = ["-Zi", "-O2"] # ffmpeg's configure is not actually from autotools, so it doesn't understand standard options like # --host, --build, --target env_build.configure(args=args, build=False, host=False, target=False, pkg_config_paths=[pkg_config_path]) env_build.make() env_build.make(args=['install']) finally: if self._is_msvc or self._is_mingw_windows: for filename in ['.bashrc', '.bash_profile', '.profile']: tools.run_in_windows_bash( self, 'cp ~/%s.bak ~/%s' % (filename, filename)) tools.run_in_windows_bash(self, 'rm -f ~/%s.bak' % filename)
def build(self): if self.settings.compiler == "Visual Studio": env = VisualStudioBuildEnvironment(self) with tools.environment_append(env.vars): if self.options.shared: vs_suffix = "_dynamic" else: vs_suffix = "_static" libdirs = "<AdditionalLibraryDirectories>" libdirs_ext = "<AdditionalLibraryDirectories>$(LIB);" if self.options.shared: replace_in_file( "%s\\%s\\win32\\VS2010\\libvorbis\\libvorbis%s.vcxproj" % (self.conanfile_directory, self.sources_folder, vs_suffix), libdirs, libdirs_ext) replace_in_file( "%s\\%s\\win32\\VS2010\\libvorbis\\libvorbis%s.vcxproj" % (self.conanfile_directory, self.sources_folder, vs_suffix), "libogg.lib", "ogg.lib") if self.options.shared: replace_in_file( "%s\\%s\\win32\\VS2010\\libvorbisfile\\libvorbisfile%s.vcxproj" % (self.conanfile_directory, self.sources_folder, vs_suffix), libdirs, libdirs_ext) replace_in_file( "%s\\%s\\win32\\VS2010\\libvorbisfile\\libvorbisfile%s.vcxproj" % (self.conanfile_directory, self.sources_folder, vs_suffix), "libogg.lib", "ogg.lib") replace_in_file( "%s\\%s\\win32\\VS2010\\vorbisdec\\vorbisdec%s.vcxproj" % (self.conanfile_directory, self.sources_folder, vs_suffix), libdirs, libdirs_ext) if self.options.shared: replace_in_file( "%s\\%s\\win32\\VS2010\\vorbisdec\\vorbisdec%s.vcxproj" % (self.conanfile_directory, self.sources_folder, vs_suffix), "libogg.lib", "ogg.lib") else: replace_in_file( "%s\\%s\\win32\\VS2010\\vorbisdec\\vorbisdec%s.vcxproj" % (self.conanfile_directory, self.sources_folder, vs_suffix), "libogg_static.lib", "ogg.lib") replace_in_file( "%s\\%s\\win32\\VS2010\\vorbisenc\\vorbisenc%s.vcxproj" % (self.conanfile_directory, self.sources_folder, vs_suffix), libdirs, libdirs_ext) if self.options.shared: replace_in_file( "%s\\%s\\win32\\VS2010\\vorbisenc\\vorbisenc%s.vcxproj" % (self.conanfile_directory, self.sources_folder, vs_suffix), "libogg.lib", "ogg.lib") else: replace_in_file( "%s\\%s\\win32\\VS2010\\vorbisenc\\vorbisenc%s.vcxproj" % (self.conanfile_directory, self.sources_folder, vs_suffix), "libogg_static.lib", "ogg.lib") vcvars = tools.vcvars_command(self.settings) cd_build = "cd %s\\%s\\win32\\VS2010" % ( self.conanfile_directory, self.sources_folder) build_command = build_sln_command(self.settings, "vorbis%s.sln" % vs_suffix) self.run( "%s && %s && %s" % (vcvars, cd_build, build_command.replace("x86", "Win32"))) else: base_path = ("%s/" % self.conanfile_directory ) if self.settings.os != "Windows" else "" cd_build = "cd %s%s" % (base_path, self.sources_folder) env = AutoToolsBuildEnvironment(self) if self.settings.os != "Windows": env.fpic = self.options.fPIC with tools.environment_append(env.vars): if self.settings.os == "Macos": old_str = '-install_name \\$rpath/\\$soname' new_str = '-install_name \\$soname' replace_in_file( "%s/%s/configure" % (self.conanfile_directory, self.sources_folder), old_str, new_str) if self.settings.os == "Windows": run_in_windows_bash(self, "%s && ./configure" % cd_build) run_in_windows_bash(self, "%s && make" % cd_build) else: configure_options = " --prefix=%s" % self.package_folder if self.options.shared: configure_options += " --disable-static --enable-shared" else: configure_options += " --disable-shared --enable-static" self.run("%s && chmod +x ./configure" % cd_build) self.run("%s && chmod +x ./install-sh" % cd_build) self.run("%s && ./configure%s" % (cd_build, configure_options)) self.run("%s && make" % cd_build) self.run("%s && make install" % cd_build)
def sh_run(self, command): return tools.run_in_windows_bash(self.conan_file, command)
def run_bash(self, cmd): if self.settings.os == "Windows": tools.run_in_windows_bash(self, cmd) else: self.run(cmd)
def windows_build(self): # this overrides pre-configured environments (such as Appveyor's) if "VisualStudioVersion" in os.environ: del os.environ["VisualStudioVersion"] compiler_cxx = compiler_cc = '$PWD/ragel-%s/compile cl -nologo' % self.version self.autotools = AutoToolsBuildEnvironment(self, win_bash=True) with tools.chdir("{0}-{1}".format('ragel', self.version)): tools.run_in_windows_bash( self, 'pacman -S automake-wrapper autoconf --noconfirm --needed') makefile_am = os.path.join('ragel', 'Makefile.am').replace('\\', '/') self.output.info("Patching: %s" % makefile_am) tools.replace_in_file(makefile_am, 'INCLUDES = -I$(top_srcdir)/aapl', 'AM_CPPFLAGS = -I$(top_srcdir)/aapl') main_cpp = os.path.join('ragel', 'main.cpp').replace('\\', '/') self.output.info("Patching: %s" % main_cpp) tools.replace_in_file(main_cpp, '#include <unistd.h>', '') tools.run_in_windows_bash(self, 'aclocal') tools.run_in_windows_bash(self, 'autoheader') tools.run_in_windows_bash( self, 'automake --foreign --add-missing --force-missing') tools.run_in_windows_bash(self, 'autoconf') with tools.vcvars(self.settings): compiler_options = '-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE ' \ '-D_CRT_NONSTDC_NO_WARNINGS -WL -W2 -WX- -Gy -DNDEBUG ' \ '-diagnostics:classic -DWIN32 -D_WINDOWS -O2 -Ob2 ' compiler_options += '-wd4577 -wd5026 -wd5027 -wd4710 -wd4711 -wd4626 -wd4250 -wd4365 ' \ '-wd4625 -wd4774 -wd4530 -wd4100 -wd4706 -wd4512 -wd4800 -wd4702 ' \ '-wd4819 -wd4355 -wd4091 -wd4267 -wd4365 -wd4625 -wd4774 -wd4820' linker_options = '/MACHINE:X{0}'.format( '86' if self.settings.arch_build == 'x86' else '64') runtime = '-%s' % str(self.settings.compiler.runtime) prefix = tools.unix_path(os.path.abspath(self.package_folder), tools.MSYS2) flags = '{compiler_options} {runtime} -I{prefix}/include'.format( compiler_options=compiler_options, runtime=runtime, prefix=prefix) ldflags = '-L{prefix}/lib {linker_options}'.format( linker_options=linker_options, prefix=prefix) configure_args = [ 'CC={compiler_cc}'.format(compiler_cc=compiler_cc), 'CXX={compiler_cxx}'.format(compiler_cxx=compiler_cxx), 'CFLAGS={flags}'.format(flags=flags), 'CXXFLAGS={flags}'.format(flags=flags), 'CPPFLAGS={flags}'.format(flags=flags), 'LDFLAGS={ldflags}'.format(ldflags=ldflags), 'LD=link', 'NM=dumpbin -symbols', 'STRIP=:', 'RANLIB=:' ] self.autotools.configure(configure_dir="ragel-%s" % self.version, args=configure_args) self.autotools.make()