[DO-971] ffmpeg recipe with requirements (!9)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/9
This commit is contained in:
27
recipes/xz_utils/all/conandata.yml
Normal file
27
recipes/xz_utils/all/conandata.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
sources:
|
||||
"5.4.5":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/xz"
|
||||
branch: "v5.4.5"
|
||||
"5.4.4":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/xz"
|
||||
branch: "v5.4.4"
|
||||
"5.4.2":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/xz"
|
||||
branch: "v5.4.2"
|
||||
"5.4.0":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/xz"
|
||||
branch: "v5.4.0"
|
||||
"5.2.10":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/xz"
|
||||
branch: "v5.2.10"
|
||||
"5.2.5":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/xz"
|
||||
branch: "v5.2.5"
|
||||
"5.2.4":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/xz"
|
||||
branch: "v5.2.4"
|
||||
patches:
|
||||
"5.2.4":
|
||||
- patch_file: "patches/0001-relax_windows-sdk-restriction.patch"
|
||||
patch_description: "Relax Windows SDK restriction"
|
||||
patch_type: "conan"
|
||||
230
recipes/xz_utils/all/conanfile.py
Normal file
230
recipes/xz_utils/all/conanfile.py
Normal file
@@ -0,0 +1,230 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.apple import fix_apple_shared_install_name
|
||||
from conan.tools.build import cross_building
|
||||
from conan.tools.env import VirtualBuildEnv
|
||||
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, replace_in_file, rm, rmdir, save, chdir
|
||||
from conan.tools.gnu import Autotools, AutotoolsToolchain
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, MSBuild, MSBuildToolchain
|
||||
from conan.tools.scm import Version, Git
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
required_conan_version = ">=1.54.0"
|
||||
|
||||
|
||||
class XZUtilsConan(ConanFile):
|
||||
name = "xz_utils"
|
||||
description = (
|
||||
"XZ Utils is free general-purpose data compression software with a high "
|
||||
"compression ratio. XZ Utils were written for POSIX-like systems, but also "
|
||||
"work on some not-so-POSIX systems. XZ Utils are the successor to LZMA Utils."
|
||||
)
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://tukaani.org/xz"
|
||||
topics = ("lzma", "xz", "compression")
|
||||
license = "Unlicense", "LGPL-2.1-or-later", "GPL-2.0-or-later", "GPL-3.0-or-later"
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
}
|
||||
|
||||
@property
|
||||
def _settings_build(self):
|
||||
return getattr(self, "settings_build", self.settings)
|
||||
|
||||
@property
|
||||
def _effective_msbuild_type(self):
|
||||
# treat "RelWithDebInfo" and "MinSizeRel" as "Release"
|
||||
# there is no DebugMT configuration in upstream vcxproj, we patch Debug configuration afterwards
|
||||
return "{}{}".format(
|
||||
"Debug" if self.settings.build_type == "Debug" else "Release",
|
||||
"MT" if is_msvc_static_runtime(self) and self.settings.build_type != "Debug" else "",
|
||||
)
|
||||
|
||||
@property
|
||||
def _msbuild_target(self):
|
||||
return "liblzma_dll" if self.options.shared else "liblzma"
|
||||
|
||||
@property
|
||||
def _use_msbuild(self):
|
||||
assume_clang_cl = (self.settings.os == "Windows"
|
||||
and self.settings.compiler == "clang"
|
||||
and self.settings.get_safe("compiler.runtime") is not None)
|
||||
return is_msvc(self) or assume_clang_cl
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def build_requirements(self):
|
||||
if self._settings_build.os == "Windows" and not self._use_msbuild:
|
||||
self.win_bash = True
|
||||
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
|
||||
self.tool_requires("msys2/cci.latest")
|
||||
|
||||
def source(self):
|
||||
#get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
git = Git(self)
|
||||
sources = self.conan_data["sources"][self.version]
|
||||
clone_args = ['--depth', '1', '--branch', sources["branch"]]
|
||||
git.clone(url=sources["url"], target=self.source_folder, args=clone_args)
|
||||
|
||||
def generate(self):
|
||||
if self._use_msbuild:
|
||||
tc = MSBuildToolchain(self)
|
||||
tc.configuration = self._effective_msbuild_type
|
||||
tc.generate()
|
||||
else:
|
||||
env = VirtualBuildEnv(self)
|
||||
env.generate()
|
||||
tc = AutotoolsToolchain(self)
|
||||
tc.configure_args.append("--disable-doc")
|
||||
if self.settings.build_type == "Debug":
|
||||
tc.configure_args.append("--enable-debug")
|
||||
if cross_building(self) and self.settings.os == "Windows":
|
||||
tc.configure_args.append("--disable-dependency-tracking")
|
||||
tc.configure_args.append("--disable-nls")
|
||||
tc.configure_args.append("--disable-scripts")
|
||||
tc.configure_args.append("--disable-threads")
|
||||
tc.configure_args.append("--enable-small")
|
||||
tc.configure_args.append("CFLAGS=-march=x86-64 -mtune=generic")
|
||||
tc.generate()
|
||||
|
||||
@property
|
||||
def _msvc_sln_folder(self):
|
||||
if (str(self.settings.compiler) == "Visual Studio" and Version(self.settings.compiler) >= "15") or \
|
||||
(str(self.settings.compiler) == "msvc" and Version(self.settings.compiler) >= "191"):
|
||||
return "vs2017"
|
||||
return "vs2013"
|
||||
|
||||
def _build_msvc(self):
|
||||
build_script_folder = os.path.join(self.source_folder, "windows", self._msvc_sln_folder)
|
||||
|
||||
#==============================
|
||||
# TODO: to remove once https://github.com/conan-io/conan/pull/12817 available in conan client.
|
||||
vcxproj_files = [
|
||||
os.path.join(build_script_folder, "liblzma.vcxproj"),
|
||||
os.path.join(build_script_folder, "liblzma_dll.vcxproj"),
|
||||
]
|
||||
if (str(self.settings.compiler) == "Visual Studio" and Version(self.settings.compiler) >= "15") or \
|
||||
(str(self.settings.compiler) == "msvc" and Version(self.settings.compiler) >= "191"):
|
||||
old_toolset = "v141"
|
||||
else:
|
||||
old_toolset = "v120"
|
||||
new_toolset = MSBuildToolchain(self).toolset
|
||||
conantoolchain_props = os.path.join(self.generators_folder, MSBuildToolchain.filename)
|
||||
for vcxproj_file in vcxproj_files:
|
||||
replace_in_file(
|
||||
self, vcxproj_file,
|
||||
f"<PlatformToolset>{old_toolset}</PlatformToolset>",
|
||||
f"<PlatformToolset>{new_toolset}</PlatformToolset>",
|
||||
)
|
||||
replace_in_file(
|
||||
self, vcxproj_file,
|
||||
"<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />",
|
||||
f"<Import Project=\"{conantoolchain_props}\" /><Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />",
|
||||
)
|
||||
|
||||
if self.settings.arch == "armv8":
|
||||
replace_in_file(self, vcxproj_file, "x64", "ARM64")
|
||||
|
||||
solution_file = os.path.join(build_script_folder, "xz_win.sln")
|
||||
if self.settings.arch == "armv8":
|
||||
replace_in_file(self, solution_file, "x64", "ARM64")
|
||||
|
||||
#==============================
|
||||
|
||||
msbuild = MSBuild(self)
|
||||
msbuild.build_type = self._effective_msbuild_type
|
||||
msbuild.platform = "Win32" if self.settings.arch == "x86" else msbuild.platform
|
||||
msbuild.build(os.path.join(build_script_folder, solution_file), targets=[self._msbuild_target])
|
||||
|
||||
def build(self):
|
||||
apply_conandata_patches(self)
|
||||
if self._use_msbuild:
|
||||
self._build_msvc()
|
||||
else:
|
||||
with chdir(self, self.source_folder):
|
||||
self.run("./autogen.sh --no-po4a --no-doxygen")
|
||||
autotools = Autotools(self)
|
||||
autotools.configure()
|
||||
autotools.make()
|
||||
|
||||
def package(self):
|
||||
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
if self._use_msbuild:
|
||||
inc_dir = os.path.join(self.source_folder, "src", "liblzma", "api")
|
||||
copy(self, "*.h", src=inc_dir, dst=os.path.join(self.package_folder, "include"))
|
||||
output_dir = os.path.join(self.source_folder, "windows")
|
||||
copy(self, "*.lib", src=output_dir, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
|
||||
copy(self, "*.dll", src=output_dir, dst=os.path.join(self.package_folder, "bin"), keep_path=False)
|
||||
rename(self, os.path.join(self.package_folder, "lib", "liblzma.lib"),
|
||||
os.path.join(self.package_folder, "lib", "lzma.lib"))
|
||||
else:
|
||||
autotools = Autotools(self)
|
||||
autotools.install()
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
rmdir(self, os.path.join(self.package_folder, "share"))
|
||||
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
|
||||
fix_apple_shared_install_name(self)
|
||||
|
||||
self._create_cmake_module_variables(
|
||||
os.path.join(self.package_folder, self._module_file_rel_path),
|
||||
)
|
||||
|
||||
def _create_cmake_module_variables(self, module_file):
|
||||
# TODO: also add LIBLZMA_HAS_AUTO_DECODER, LIBLZMA_HAS_EASY_ENCODER & LIBLZMA_HAS_LZMA_PRESET
|
||||
content = textwrap.dedent(f"""\
|
||||
set(LIBLZMA_FOUND TRUE)
|
||||
if(DEFINED LibLZMA_INCLUDE_DIRS)
|
||||
set(LIBLZMA_INCLUDE_DIRS ${{LibLZMA_INCLUDE_DIRS}})
|
||||
endif()
|
||||
if(DEFINED LibLZMA_LIBRARIES)
|
||||
set(LIBLZMA_LIBRARIES ${{LibLZMA_LIBRARIES}})
|
||||
endif()
|
||||
set(LIBLZMA_VERSION_MAJOR {Version(self.version).major})
|
||||
set(LIBLZMA_VERSION_MINOR {Version(self.version).minor})
|
||||
set(LIBLZMA_VERSION_PATCH {Version(self.version).patch})
|
||||
set(LIBLZMA_VERSION_STRING "{self.version}")
|
||||
""")
|
||||
save(self, module_file, content)
|
||||
|
||||
@property
|
||||
def _module_file_rel_path(self):
|
||||
return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake")
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
self.cpp_info.set_property("cmake_file_name", "LibLZMA")
|
||||
self.cpp_info.set_property("cmake_target_name", "LibLZMA::LibLZMA")
|
||||
self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path])
|
||||
self.cpp_info.set_property("pkg_config_name", "liblzma")
|
||||
self.cpp_info.libs = ["lzma"]
|
||||
if not self.options.shared:
|
||||
self.cpp_info.defines.append("LZMA_API_STATIC")
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.system_libs.append("pthread")
|
||||
|
||||
# TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed
|
||||
self.cpp_info.names["cmake_find_package"] = "LibLZMA"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "LibLZMA"
|
||||
self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path]
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/windows/vs2017/liblzma.vcxproj
|
||||
+++ b/windows/vs2017/liblzma.vcxproj
|
||||
@@ -29,7 +29,6 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{12728250-16EC-4DC6-94D7-E21DD88947F8}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
- <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
--- a/windows/vs2017/liblzma_dll.vcxproj
|
||||
+++ b/windows/vs2017/liblzma_dll.vcxproj
|
||||
@@ -29,7 +29,6 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{E0F247DB-EF12-4755-8DF9-F74BCD1348F7}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
- <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
26
recipes/xz_utils/all/test_package/CMakeLists.txt
Normal file
26
recipes/xz_utils/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(LibLZMA REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE LibLZMA::LibLZMA)
|
||||
|
||||
# Test whether variables from https://cmake.org/cmake/help/latest/module/FindLibLZMA.html
|
||||
# are properly defined in conan generators
|
||||
set(_custom_vars
|
||||
LIBLZMA_FOUND
|
||||
LIBLZMA_INCLUDE_DIRS
|
||||
LIBLZMA_LIBRARIES
|
||||
LIBLZMA_VERSION_MAJOR
|
||||
LIBLZMA_VERSION_MINOR
|
||||
LIBLZMA_VERSION_PATCH
|
||||
LIBLZMA_VERSION_STRING
|
||||
)
|
||||
foreach(_custom_var ${_custom_vars})
|
||||
if(DEFINED ${_custom_var})
|
||||
message(STATUS "${_custom_var}: ${${_custom_var}}")
|
||||
else()
|
||||
message(FATAL_ERROR "${_custom_var} not defined")
|
||||
endif()
|
||||
endforeach()
|
||||
26
recipes/xz_utils/all/test_package/conanfile.py
Normal file
26
recipes/xz_utils/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import CMake, cmake_layout
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
||||
8
recipes/xz_utils/all/test_package/test_package.c
Normal file
8
recipes/xz_utils/all/test_package/test_package.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <lzma.h>
|
||||
|
||||
int main() {
|
||||
printf("LZMA version %s\n", lzma_version_string());
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
8
recipes/xz_utils/all/test_v1_package/CMakeLists.txt
Normal file
8
recipes/xz_utils/all/test_v1_package/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test_package)
|
||||
17
recipes/xz_utils/all/test_v1_package/conanfile.py
Normal file
17
recipes/xz_utils/all/test_v1_package/conanfile.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake", "cmake_find_package"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if not tools.cross_building(self):
|
||||
bin_path = os.path.join("bin", "test_package")
|
||||
self.run(bin_path, run_environment=True)
|
||||
15
recipes/xz_utils/config.yml
Normal file
15
recipes/xz_utils/config.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
versions:
|
||||
"5.4.5":
|
||||
folder: all
|
||||
"5.4.4":
|
||||
folder: all
|
||||
"5.4.2":
|
||||
folder: all
|
||||
"5.4.0":
|
||||
folder: all
|
||||
"5.2.10":
|
||||
folder: all
|
||||
"5.2.5":
|
||||
folder: all
|
||||
"5.2.4":
|
||||
folder: all
|
||||
Reference in New Issue
Block a user