Initial Commit

This commit is contained in:
Yousef Khadadeh 2025-07-06 20:43:53 +03:00
commit 6088fc29ed
978 changed files with 353647 additions and 0 deletions

24
conan/conan-skia/LICENSE Normal file
View file

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>

View file

@ -0,0 +1,52 @@
# Conan 2.0 recipe for Skia
Conan 2.0 recipe for Skia graphics library.
## Usage
You can add this repository as [Local Recipes Index Repository](https://docs.conan.io/2/tutorial/conan_repositories/setup_local_recipes_index.html), or manually `conan create` the recipe at `recipes/skia/all`.
## Version
Currently supports following versions:
* `chrome/m130`
* `130.20241118.0`
* `chrome/m131`
* `131.20250131.0`
* `chrome/m132`
* `132.20250131.0`
* `chrome/m133`
* `133.20250327.0`
* `chrome/m134`
* `134.20250327.0`
Version numbers are formatted as `(chrome milestone version).(checkout date).0`
If you need other versions, please open new issue on Github.
## Requirements
* Since `chrome/m100` Skia requires C++17.
## OS
Tested on following OS (with default options):
| OS | shared | static |
| ------------- | ------ | ------ |
| Windows | ![build](https://github.com/mocabe/conan-skia/actions/workflows/windows-latest-shared.yml/badge.svg) | ![build](https://github.com/mocabe/conan-skia/actions/workflows/windows-latest-static.yml/badge.svg) |
| Macos | ![build](https://github.com/mocabe/conan-skia/actions/workflows/macos-latest-shared.yml/badge.svg) | ![build](https://github.com/mocabe/conan-skia/actions/workflows/macos-latest-static.yml/badge.svg) |
| iOS | ![build](https://github.com/mocabe/conan-skia/actions/workflows/ios-armv8-shared.yml/badge.svg) | ![build](https://github.com/mocabe/conan-skia/actions/workflows/ios-armv8-static.yml/badge.svg) |
| Linux | ![build](https://github.com/mocabe/conan-skia/actions/workflows/ubuntu-latest-shared.yml/badge.svg) | ![build](https://github.com/mocabe/conan-skia/actions/workflows/ubuntu-latest-static.yml/badge.svg) |
| Android/arm64 | ![build](https://github.com/mocabe/conan-skia/actions/workflows/android-armv8-shared.yml/badge.svg) | ![build](https://github.com/mocabe/conan-skia/actions/workflows/android-armv8-static.yml/badge.svg) |
| Android/arm32 | ![build](https://github.com/mocabe/conan-skia/actions/workflows/android-armv7-shared.yml/badge.svg) | ![build](https://github.com/mocabe/conan-skia/actions/workflows/android-armv7-static.yml/badge.svg) |
| Emscripten | | ![build](https://github.com/mocabe/conan-skia/actions/workflows/emscripten-static.yml/badge.svg) |
## Bug reports
Please open new issue on Github Issues.
## License
The Unlicense (Public Domain)

View file

@ -0,0 +1,14 @@
include(default)
[settings]
os=Android
os.api_level=28
arch=armv7
compiler=clang
compiler.version=12
compiler.libcxx=c++_static
compiler.cppstd=17
[tool_requires]
android-ndk/r26d
make/4.4.1

View file

@ -0,0 +1,14 @@
include(default)
[settings]
os=Android
os.api_level=28
arch=armv8
compiler=clang
compiler.version=12
compiler.libcxx=c++_static
compiler.cppstd=17
[tool_requires]
android-ndk/r26d
make/4.4.1

View file

@ -0,0 +1,12 @@
include(default)
[settings]
os=Emscripten
arch=wasm
compiler=clang
compiler.version=16
compiler.libcxx=libc++
compiler.cppstd=17
[tool_requires]
*: emsdk/3.1.50

View file

@ -0,0 +1,11 @@
include(default)
[settings]
os=iOS
os.version=17.5
os.sdk=iphoneos
os.sdk_version=17.5
arch=armv8.3
compiler=apple-clang
compiler.version=15.0
compiler.libcxx=libc++

View file

@ -0,0 +1,2 @@
[properties]
sys_root = ''

View file

@ -0,0 +1,37 @@
sources:
"126.20240526.0":
url:
- "https://github.com/google/skia/archive/69980ce8d04144b41adbc5cc194f29adbc12ceaa.zip"
sha256: "8096a1f4317cac42e6f868af6cf7c22c5f75cd79e5217ff4be768bae9218168e"
"127.20240803.0":
url:
- "https://github.com/google/skia/archive/1c8089adffdabe3790cc4ca4fb36e24c2f6ab792.zip"
sha256: "d00e9d3c00b23cb057ce9a3afccbe8cee15d85135def375265488f974b273290"
"128.20241118.0":
url:
- "https://github.com/google/skia/archive/5cc7e24d986e9c1ba3d44c4a36353b393305a79b.zip"
sha256: "bcaf85d84d96e25d3b03aa55a3835ac01c1d24df90982869d23db11706cd4794"
"129.20241118.0":
url:
- "https://github.com/google/skia/archive/80be572399d10cec68fd971a64984b2b0feb5f66.zip"
sha256: "1f8fdc4c78499d9b1daa0b832ddb99f06206ebfd2d472d66e75284d6310509eb"
"130.20241118.0":
url:
- "https://github.com/google/skia/archive/d41eba845cdb7ade07e68f20676675c25e2734fc.zip"
sha256: "9e0662def5a76c95b5c43b50be052dab965ae30188a40e8926f19823ae113d03"
"131.20250131.0":
url:
- "https://github.com/google/skia/archive/f14f6b1ab7cf544c0190074488d17821281cfa4d.zip"
sha256: "05cee9a0051af3f62cf72dcc9f19151ad17eef3e8e7bac46f8f539d04fce327f"
"132.20250131.0":
url:
- "https://github.com/google/skia/archive/ee9db7d1348f76780fd0184b9b0243d653e36411.zip"
sha256: "47285853c86a2a7a0f2ee6cede13043b79a71c0ba1302b70ef63e335d07e8192"
"133.20250327.0":
url:
- "https://github.com/google/skia/archive/ecebe831881cdf52c65df518777210071f7970dd.zip"
sha256: "3595d8e00f06b77b7636f3ef31b04ac5a2ca5bdba872528e460b9cfe80ef4433"
"134.20250327.0":
url:
- "https://github.com/google/skia/archive/aefbd9403c1b3032ad4cd0281ef312ed262c7125.zip"
sha256: "e10c67a96828b9f36364e2459cdee3e3b381a3875ff78db2b30e7b6fe69509bb"

View file

@ -0,0 +1,967 @@
from conan import ConanFile
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rename, mkdir, rmdir, save, replace_in_file
from conan.tools.build.flags import cppstd_flag
from conan.tools.build import check_min_cppstd
from conan.tools.microsoft import is_msvc
from conan.tools.microsoft.visual import msvc_runtime_flag
from conan.tools.apple import is_apple_os, XCRun
from conan.tools.gnu import AutotoolsToolchain
from conan.tools.env import VirtualBuildEnv
from conan.errors import ConanInvalidConfiguration
from os.path import join
import os
import re
import json
class ConanSkia(ConanFile):
name = "skia"
package_type = "library"
# Optional metadata
license = "<Put the package license here>"
author = "<Put your name here> <And your email here>"
url = "<Package recipe repository url here, for issues about the package>"
description = "<Description of skia package here>"
topics = ("<Put some tag here>", "<here>", "<and here>")
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
_skia_options = {
# configurable dependencies
"use_expat" : [True, False],
"use_freetype" : [True, False],
"use_harfbuzz" : [True, False],
"use_icu" : [True, False],
"use_libjpeg_turbo_encode" : [True, False],
"use_libjpeg_turbo_decode" : [True, False],
"use_libpng_encode" : [True, False],
"use_libpng_decode" : [True, False],
"use_libwebp_encode" : [True, False],
"use_libwebp_decode" : [True, False],
"use_zlib" : [True, False],
# system library options
"use_system_expat" : [True, False],
"use_system_freetype": [True, False],
"use_system_harfbuzz" : [True, False],
"use_system_icu" :[True, False],
"use_system_libjpeg_turbo" : [True, False],
"use_system_libpng" : [True, False],
"use_system_libwebp" : [True, False],
"use_system_zlib" : [True, False],
# conan library options
"use_conan_expat" : [True, False],
"use_conan_freetype": [True, False],
"use_conan_fontconfig": [True, False],
"use_conan_harfbuzz" : [True, False],
"use_conan_icu" :[True, False],
"use_conan_libjpeg_turbo" : [True, False],
"use_conan_libpng" : [True, False],
"use_conan_libwebp" : [True, False],
"use_conan_zlib" : [True, False],
# backend options
"use_angle" : [True, False],
"use_gl" : [True, False],
"use_vulkan" : [True, False],
"use_metal" : [True, False],
"use_webgl" : [True, False],
"use_webgpu" : [True, False],
"use_dawn" : [True, False],
"use_direct3d" :[True, False],
"use_piex" : [True, False],
"use_wuffs" : [True, False],
"use_libavif" : [True, False],
"use_libjxl_decode" : [True, False],
"use_ndk_images" : [True, False],
"use_x11" : [True, False],
"use_xps" : [True, False],
"use_dng_sdk" : [True, False],
"use_fontconfig" : [True, False],
"use_fonthost_mac" : [True, False],
"use_perfetto" : [True, False],
# backend toggles
"enable_ganesh" : [True, False],
"enable_graphite" : [True, False],
"enable_pdf" : [True, False],
"enable_winuwp" : [True, False],
"enable_fontmgr_android" : [True, False],
"enable_fontmgr_custom_directory" : [True, False],
"enable_fontmgr_custom_embedded" : [True, False],
"enable_fontmgr_custom_empty" : [True, False],
"enable_fontmgr_fontconfig" : [True, False],
"enable_fontmgr_win" : [True, False],
"enable_fontmgr_win_gdi" : [True, False],
"enable_fontmgr_FontConfigInterface" : [True, False],
# modules
"enable_svg" : [True, False],
"enable_skottie" : [True, False],
"enable_skunicode" : [True, False],
"enable_skshaper" : [True, False],
"enable_bentleyottmann" : [True, False],
"enable_skparagraph" : [True, False],
# canvaskit
"canvaskit_enable_alias_font" : [True, False],
"canvaskit_enable_canvas_bindings" : [True, False],
"canvaskit_enable_effects_deserialization" : [True, False],
"canvaskit_enable_embedded_font" : [True, False],
"canvaskit_enable_font" : [True, False],
"canvaskit_enable_matrix_helper" : [True, False],
"canvaskit_enable_pathops" : [True, False],
"canvaskit_enable_rt_shader" : [True, False],
"canvaskit_enable_skp_serialization" : [True, False],
"canvaskit_enable_sksl_trace" : [True, False],
"canvaskit_enable_paragraph" : [True, False],
"canvaskit_enable_webgpu" : [True, False],
"canvaskit_enable_webgl" : [True, False],
# other options
"enable_precompile" : [True, False],
"enable_optimize_size" : [True, False],
"enable_api_available_macro" : [True, False],
"gl_standard" : ["gl", "gles", "webgl", ""],
}
_skia_default_options = {
# configurable dependencies
"use_icu" : True,
"use_libjpeg_turbo_encode" : True,
"use_libjpeg_turbo_decode" : True,
"use_libpng_encode" : True,
"use_libpng_decode" : True,
"use_libwebp_encode" : True,
"use_libwebp_decode" : True,
"use_zlib" : True,
# system library options
"use_system_expat" : True,
"use_system_freetype": True,
"use_system_harfbuzz" : True,
"use_system_icu" : True,
"use_system_libjpeg_turbo" : True,
"use_system_libpng" : True,
"use_system_libwebp" : True,
"use_system_zlib" : True,
# conan library options
"use_conan_expat" : True,
"use_conan_freetype": True,
"use_conan_fontconfig": True,
"use_conan_harfbuzz" : True,
"use_conan_icu" : True,
"use_conan_libjpeg_turbo" : True,
"use_conan_libpng" : True,
"use_conan_libwebp" : True,
"use_conan_zlib" : True,
# backend options
"use_angle" : False,
"use_gl" : True,
"use_vulkan" : False,
"use_metal" : False,
"use_dawn" : False,
"use_direct3d" : False,
"use_xps" : True,
"use_wuffs" : True,
"use_libavif" : False,
"use_libjxl_decode" : False,
# backend toggles
"enable_ganesh" : True,
"enable_graphite" : False,
"enable_winuwp" : False,
# modules
"enable_skshaper" : True,
"enable_bentleyottmann" : True,
# canvaskit
"canvaskit_enable_alias_font" : True,
"canvaskit_enable_canvas_bindings" : True,
"canvaskit_enable_effects_deserialization" : True,
"canvaskit_enable_embedded_font" : True,
"canvaskit_enable_font" : True,
"canvaskit_enable_matrix_helper" : True,
"canvaskit_enable_pathops" : True,
"canvaskit_enable_rt_shader" : True,
"canvaskit_enable_skp_serialization" : True,
"canvaskit_enable_sksl_trace" : True,
"canvaskit_enable_webgpu " : False,
"canvaskit_enable_webgl " : False,
# other options
"enable_precompile" : True,
"enable_optimize_size" : False,
"enable_api_available_macro" : True,
}
options = {
"shared" : [True, False],
"fPIC" : [True, False],
} | _skia_options
default_options = {
"shared": False,
"fPIC": True,
} | _skia_default_options
def _is_ios_variant(self):
os = self.settings.os
return (os == "iOS" or os == "watchOS" or os == "tvOS" or os == "visionOS")
def _is_ios_variant_simulator(self):
os = self.settings.os
if os == "iOS" and os.sdk == "iphonesimulator":
return True
elif os == "watchOS" and os.sdk == "watchsimulator":
return True
elif os == "tvOS" and os.sdk == "appletvsimulator":
return True
elif os == "visionOS" and os.sdk == "xrsimulator":
return True
return False
def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, 17)
if self.settings.arch == "x86":
pass
elif self.settings.arch == "x86_64":
pass
elif self.settings.arch == "wasm":
pass
elif re.match(r'armv7.*', self.settings.arch.value):
pass
elif re.match(r'armv8.*', self.settings.arch.value):
pass
else:
raise ConanInvalidConfiguration("Unsupported settings.arch")
def configure(self):
os = self.settings.os
arch = self.settings.arch
if self.options.shared:
self.options.rm_safe("fPIC")
if self.options.use_harfbuzz == None:
# Disabled on Emscripten due to false-positive of HAVE_MPROTECT.
# Will revisit once 9.0.0 is added to conancenter.
enabled = (os != "Emscripten")
self.options.use_harfbuzz = enabled
if self.options.use_expat == None:
enabled = (arch != "wasm")
self.options.use_expat = enabled
if self.options.use_freetype == None:
enabled = (os == "Android" or os == "Linux" or arch == "wasm")
self.options.use_freetype = enabled
if self.options.use_webgl == None:
enabled = (arch == "wasm")
self.options.use_webgl = enabled
if self.options.use_webgpu == None:
enabled = (arch == "wasm")
self.options.use_webgpu = enabled
if self.options.use_x11 == None:
enabled = (os == "Linux")
self.options.use_x11 = enabled
if self.options.use_fontconfig == None:
enabled = (os == "Linux")
self.options.use_fontconfig = enabled
if self.options.use_fonthost_mac == None:
enabled = (os == "Macos" or self._is_ios_variant())
self.options.use_fonthost_mac = enabled
if self.options.use_perfetto == None:
enabled = (os == "Macos" or os == "Android" or os == "Linux")
self.options.use_perfetto = enabled
if self.options.enable_pdf == None:
enabled = arch != "wasm"
self.options.enable_pdf = enabled
if self.options.enable_fontmgr_android == None:
enabled = self.options.use_freetype and self.options.use_expat
self.options.enable_fontmgr_android = enabled
if self.options.enable_fontmgr_custom_directory == None:
enabled = self.options.use_freetype and arch != "wasm"
self.options.enable_fontmgr_custom_directory = enabled
if self.options.enable_fontmgr_custom_embedded == None:
enabled = self.options.use_freetype
self.options.enable_fontmgr_custom_embedded = enabled
if self.options.enable_fontmgr_custom_empty == None:
enabled = self.options.use_freetype
self.options.enable_fontmgr_custom_empty = enabled
if self.options.enable_fontmgr_fontconfig == None:
enabled = self.options.use_freetype and self.options.use_fontconfig
self.options.enable_fontmgr_fontconfig = enabled
if self.options.enable_fontmgr_win == None:
enabled = (os == "Windows")
self.options.enable_fontmgr_win = enabled
if self.options.enable_fontmgr_win_gdi == None:
enabled = (os == "Windows") and not self.options.enable_winuwp
self.options.enable_fontmgr_win_gdi = enabled
if self.options.enable_fontmgr_FontConfigInterface == None:
enabled = self.options.use_freetype and self.options.use_fontconfig
self.options.enable_fontmgr_FontConfigInterface = enabled
if self.options.use_piex == None:
enabled = os != "Windows" and arch != "wasm"
self.options.use_piex = enabled
if self.options.use_dng_sdk == None:
enabled = arch != "wasm" and self.options.use_libjpeg_turbo_decode and self.options.use_zlib
self.options.use_dng_sdk = enabled
if self.options.use_ndk_images == None:
enabled = os == "Android" and int(os.api_level.value) >= 30
self.options.use_ndk_images = enabled
if self.options.enable_svg == None:
enabled = not self.options.shared
self.options.enable_svg = enabled
if self.options.enable_skottie == None:
enabled = not self.options.shared
self.options.enable_skottie = enabled
if self.options.enable_skunicode == None:
enabled = self.options.use_icu
self.options.enable_skunicode = enabled
if self.options.enable_skparagraph == None:
enabled = self.options.enable_skshaper and self.options.enable_skunicode and self.options.use_harfbuzz
self.options.enable_skparagraph = enabled
if self.options.canvaskit_enable_paragraph == None:
enabled = self.options.enable_skparagraph
self.options.canvaskit_enable_paragraph = enabled
if self.options.gl_standard == None:
if os == "Macos":
self.options.gl_standard = "gl"
elif self._is_ios_variant():
self.options.gl_standard = "gles"
elif arch == "wasm":
self.options.gl_standard = "webgl"
else:
self.options.gl_standard = ""
# Remove unnecessary system library options.
if self.options.use_expat == False:
self.options.rm_safe("use_system_expat")
elif not self.options.use_system_expat:
self.options.rm_safe("use_conan_expat")
if self.options.use_freetype == False:
self.options.rm_safe("use_system_freetype")
elif not self.options.use_system_freetype:
self.options.rm_safe("use_conan_freetype")
if self.options.use_icu == False:
self.options.rm_safe("use_system_icu")
elif not self.options.use_system_icu:
self.options.rm_safe("use_conan_icu")
if self.options.use_harfbuzz == False:
self.options.rm_safe("use_system_harfbuzz")
elif not self.options.use_system_harfbuzz:
self.options.rm_safe("use_conan_harfbuzz")
if self.options.use_libjpeg_turbo_encode == False and self.options.use_libjpeg_turbo_decode == False:
self.options.rm_safe("use_system_libjpeg_turbo")
elif not self.options.use_system_libjpeg_turbo:
self.options.rm_safe("use_conan_libjpeg_turbo")
if self.options.use_libpng_encode == False and self.options.use_libpng_decode == False:
self.options.rm_safe("use_system_libpng")
elif not self.options.use_system_libpng:
self.options.rm_safe("use_conan_libpng")
if self.options.use_libwebp_encode == False and self.options.use_libwebp_decode == False:
self.options.rm_safe("use_system_libwebp")
elif not self.options.use_system_libwebp:
self.options.rm_safe("use_conan_libwebp")
if self.options.use_zlib == False:
self.options.rm_safe("use_system_zlib")
elif not self.options.use_system_zlib:
self.options.rm_safe("use_conan_zlib")
def export_sources(self):
export_conandata_patches(self)
def source(self):
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)
apply_conandata_patches(self)
def requirements(self):
self.tool_requires("depot_tools/[>=20200407]")
self.tool_requires("ninja/[>=1.11.0]")
if self.options.use_harfbuzz and self.options.use_system_harfbuzz and self.options.use_conan_harfbuzz:
self.requires("harfbuzz/[>=7.3.0]", options = {"with_subset":True, "with_glib":False})
if self.options.use_freetype and self.options.use_system_freetype and self.options.use_conan_freetype:
self.requires("freetype/[>=2.11.1]")
if self.options.use_fontconfig and self.options.use_conan_fontconfig:
self.requires("fontconfig/[>=2.14.2]")
if self.options.use_expat and self.options.use_system_expat and self.options.use_conan_expat:
self.requires("expat/[>=2.5.0]")
if self.options.use_icu and self.options.use_system_icu and self.options.use_conan_icu:
if self.settings.os == "Emscripten":
self.requires("icu/[74.2]")
else:
self.requires("icu/[>=74.2]")
if (self.options.use_libpng_decode or self.options.use_libpng_encode) and self.options.use_system_libpng and self.options.use_conan_libpng:
self.requires("libpng/[>=1.6.32]")
if (self.options.use_libjpeg_turbo_decode or self.options.use_libjpeg_turbo_encode) and self.options.use_system_libjpeg_turbo and self.options.use_conan_libjpeg_turbo:
self.requires("libjpeg-turbo/[>=3.0.0]")
if (self.options.use_libwebp_decode or self.options.use_libwebp_encode) and self.options.use_system_libwebp and self.options.use_conan_libwebp:
self.requires("libwebp/[>=1.2.4]", options = {"swap_16bit_csp":True})
if self.options.use_zlib and self.options.use_system_zlib and self.options.use_conan_zlib:
self.requires("zlib/[>=1.2.11]")
def layout(self):
src_folder = "src"
build_folder = src_folder
generators_folder = self.folders.generators or "conan"
subproject = self.folders.subproject
self.folders.source = src_folder if not subproject else join(subproject, src_folder)
self.folders.build = build_folder if not subproject else join(subproject, build_folder)
self.folders.generators = join(self.folders.build, generators_folder)
def _get_lower_bool_str(self, cond):
return "true" if cond else "false"
def _collect_link_libs(self, dependency, components):
libs = []
libs += dependency.cpp_info.libs
libs += dependency.cpp_info.system_libs
# The order of components affects link order.
# TODO: Sould we handle inter-component dependencies?
for component in components:
libs += dependency.cpp_info.components[component].libs
libs += dependency.cpp_info.components[component].system_libs
for transitiveDependency in dependency.dependencies.host.values():
libs += transitiveDependency.cpp_info.libs
libs += transitiveDependency.cpp_info.system_libs
# TODO: Is there proper way to determine link order of those components?
for dep in transitiveDependency.cpp_info.components.values():
libs += dep.libs
libs += dep.system_libs
return libs
def _collect_link_frameworks(self, dependency, components):
frameworks = []
frameworks += dependency.cpp_info.frameworks
for component in components:
frameworks += dependency.cpp_info.components[component].frameworks
for transitiveDependency in dependency.dependencies.host.values():
frameworks += transitiveDependency.cpp_info.frameworks
for dep in transitiveDependency.cpp_info.components.values():
frameworks += dep.frameworks
return frameworks
def _link_libs(self, name, components=[]):
libs = []
libs += self._collect_link_libs(self.dependencies[name], components)
ext = ""
if self.settings.os == "Windows":
ext = ".lib"
return [lib + ext for lib in libs]
def _link_frameworks(self, name, components=[]):
frameworks = self._collect_link_frameworks(self.dependencies[name], components)
return [fw + ".framework" for fw in frameworks]
def build(self):
# activate-emsdk fails on Windows for some reason.
os.environ["GIT_SYNC_DEPS_SKIP_EMSDK"] = "1"
self.run("python3 tools/git-sync-deps")
del os.environ["GIT_SYNC_DEPS_SKIP_EMSDK"]
if self.options.use_expat and self.options.use_system_expat and self.options.use_conan_expat:
replace_in_file(self, join(self.source_folder, "third_party", "expat", "BUILD.gn"),
"libs = [ \"expat\" ]", f"libs = {json.dumps(self._link_libs('expat'))}",
strict=False)
if self.options.use_harfbuzz and self.options.use_system_harfbuzz and self.options.use_conan_harfbuzz:
replace_in_file(self, join(self.source_folder, "third_party", "harfbuzz", "BUILD.gn"),
"libs = [ \"harfbuzz\" ]",
f"libs = {json.dumps(self._link_libs('harfbuzz'))}\n " +
f"frameworks = {json.dumps(self._link_frameworks('harfbuzz'))}",
strict=False)
replace_in_file(self, join(self.source_folder, "third_party", "harfbuzz", "BUILD.gn"),
"include_dirs = [ \"/usr/include/harfbuzz\" ]", "include_dirs = [ ]",
strict=False)
replace_in_file(self, join(self.source_folder, "third_party", "harfbuzz", "BUILD.gn"),
"libs += [ \"harfbuzz-subset\" ]", "libs += [ ]",
strict=False)
if self.options.use_freetype and self.options.use_system_freetype and self.options.use_conan_freetype:
replace_in_file(self, join(self.source_folder, "third_party", "freetype2", "BUILD.gn"),
"libs = [ skia_system_freetype2_lib ]", f"libs = {json.dumps(self._link_libs('freetype'))}",
strict=False)
replace_in_file(self, join(self.source_folder, "third_party", "freetype2", "BUILD.gn"),
"include_dirs = [ skia_system_freetype2_include_path ]", "include_dirs = [ ]",
strict=False)
if self.options.use_icu and self.options.use_system_icu and self.options.use_conan_icu:
replace_in_file(self, join(self.source_folder, "third_party", "icu", "BUILD.gn"),
# icu-data must come after other components, otherwise it leaves an undefined symbol in shared library.
"libs = [ \"icuuc\" ]", f"libs = {json.dumps(self._link_libs('icu', components=['icu-uc','icu-data']))}",
strict=False)
if (self.options.use_libjpeg_turbo_encode or self.options.use_libjpeg_turbo_decode) and self.options.use_system_libjpeg_turbo and self.options.use_conan_libjpeg_turbo:
replace_in_file(self, join(self.source_folder, "third_party", "libjpeg-turbo", "BUILD.gn"),
"libs = [ \"jpeg\" ]", f"libs = {json.dumps(self._link_libs('libjpeg-turbo', components=['jpeg']))}",
strict=False)
if (self.options.use_libpng_encode or self.options.use_libpng_decode) and self.options.use_system_libpng and self.options.use_conan_libpng:
replace_in_file(self, join(self.source_folder, "third_party", "libpng", "BUILD.gn"),
"libs = [ \"png\" ]", f"libs = {json.dumps(self._link_libs('libpng'))}",
strict=False)
if self.options.use_zlib and self.options.use_system_zlib and self.options.use_conan_zlib:
replace_in_file(self, join(self.source_folder, "third_party", "zlib", "BUILD.gn"),
"libs = [ \"z\" ]", f"libs = {json.dumps(self._link_libs('zlib'))}",
strict=False)
if (self.options.use_libwebp_decode or self.options.use_libwebp_encode) and self.options.use_system_libwebp and self.options.use_conan_libwebp:
replace_in_file(self, join(self.source_folder, "third_party", "libwebp", "BUILD.gn"),
" libs = [\n \"webp\",\n \"webpdemux\",\n \"webpmux\",\n ]",
f" libs = {json.dumps(self._link_libs('libwebp',components=['webp','webpmux','webpdemux','sharpyuv']))}",
strict=False)
if self._is_ios_variant():
if self.settings.arch == "armv8":
replace_in_file(self, join(self.source_folder, "gn", "skia", "BUILD.gn"),
"\"-arch\",\n \"arm64e\",",
"#\"-arch\",\n #\"arm64e\",",
strict=False)
elif self.settings.arch == "armv8.3":
replace_in_file(self, join(self.source_folder, "gn", "skia", "BUILD.gn"),
"\"-arch\",\n \"arm64\",",
"#\"-arch\",\n #\"arm64\",",
strict=False)
args = ""
args += "is_official_build=true\n"
args += f"is_component_build={self._get_lower_bool_str(self.options.shared)}\n"
buildenv = VirtualBuildEnv(self).vars()
if cc := buildenv.get("CC", default=None):
args += f"cc=\"{cc}\"\n"
if cxx := buildenv.get("CXX", default=None):
args += f"cxx=\"{cxx}\"\n"
if ar := buildenv.get("AR", default=None):
args += f"ar=\"{ar}\"\n"
if self.settings.os == "Emscripten":
if emsdk := buildenv.get("EMSDK", default=None):
args += f"skia_emsdk_dir=\"{emsdk}\"\n"
if self.settings.os == "Windows":
winsdk_version = self.conf.get("tools.microsoft:winsdk_version", default=None)
if winsdk_version != None:
args += f"win_sdk_version=\"{winsdk_version}\"\n"
if self.settings.os == "Android":
ndk_path = self.conf.get("tools.android:ndk_path", default=None)
if ndk_path != None:
args += f"ndk = \"{ndk_path}\"\n"
args += f"ndk_api = {self.settings.os.api_level}\n"
if self.settings.os == "iOS":
args += f"target_os = \"ios\"\n"
elif self.settings.os == "tvOS":
args += f"target_os = \"tvos\"\n"
elif self._is_ios_variant():
args += f"target_os = \"ios\"\n"
if self._is_ios_variant_simulator():
args += f"ios_use_simulator = true\n"
if self.settings.arch == "x86":
args += "target_cpu = \"x86\"\n"
elif self.settings.arch == "x86_64":
args += "target_cpu = \"x64\"\n"
elif self.settings.arch == "wasm":
args += "target_cpu = \"wasm\"\n"
elif self.settings.arch == "armv7":
args += "target_cpu = \"arm\"\n"
elif self.settings.arch == "armv8":
args += "target_cpu = \"arm64\"\n"
elif self._is_ios_variant() and self.settings.arch == "armv8.3":
args += "target_cpu = \"arm64\"\n"
else:
raise RuntimeError("Unexpected settings.arch")
cflags = []
ldflags = []
asmflags = []
for dep in self.dependencies.host.values():
cflags += [f"-I{dir}" for dir in dep.cpp_info.includedirs]
cflags += [f"-D{define}" for define in dep.cpp_info.defines]
if is_msvc(self):
ldflags += [f"/LIBPATH:{dir}" for dir in dep.cpp_info.libdirs]
else:
ldflags += [f"-L{dir}" for dir in dep.cpp_info.libdirs]
for component in dep.cpp_info.components.values():
cflags += [f"-I{dir}" for dir in component.includedirs]
cflags += [f"-D{define}" for define in component.defines]
if is_msvc(self):
ldflags += [f"/LIBPATH:{dir}" for dir in component.libdirs]
else:
ldflags += [f"-L{dir}" for dir in component.libdirs]
if is_msvc(self):
cflags += [f"/{msvc_runtime_flag(self)}"]
if not self.options.shared and self.settings.compiler != "msvc":
fpic = self.options.get_safe("fPIC")
if fpic != None:
cflags += ["-fPIC"]
if is_apple_os(self):
min_version_flag = AutotoolsToolchain(self).apple_min_version_flag
cflags += [min_version_flag]
ldflags += [min_version_flag]
asmflags += [min_version_flag]
cflags += [f"-D{define}" for define in self.conf.get("tools.build:defines", default=[], check_type=list)]
ldflags += self.conf.get("tools.build:sharedlinkflags", default=[], check_type=list)
ldflags += self.conf.get("tools.build:exelinkflags", default=[], check_type=list)
linker_scripts = self.conf.get("tools.build:linker_scripts", default=[], check_type=list)
ldflags += ["-T'" + linker_script + "'" for linker_script in linker_scripts]
cflags += self.conf.get("tools.build:cflags", default=[], check_type=list)
cflags_c = []
cflags_cc = self.conf.get("tools.build:cxxflags", default=[], check_type=list)
cflags_cc += [cppstd_flag(self)]
args += f"extra_cflags={json.dumps(cflags)}\n"
args += f"extra_cflags_c={json.dumps(cflags_c)}\n"
args += f"extra_cflags_cc={json.dumps(cflags_cc)}\n"
args += f"extra_ldflags={json.dumps(ldflags)}\n"
args += f"extra_asmflags={json.dumps(asmflags)}\n"
if self.settings.os == "Macos" or self._is_ios_variant():
sdk_path = self.conf.get("tools.apple:sdk_path", default=None)
if not sdk_path:
sdk_path = XCRun(self).sdk_path
if sdk_path:
args += f"xcode_sysroot=\"{sdk_path}\"\n"
if self._is_ios_variant():
args += f"skia_ios_use_signing = false\n"
for key in self._skia_options.keys():
value = self.options.get_safe(key)
if value != None and not key.startswith("use_conan"):
b = self._get_lower_bool_str(value)
k = "use_system_freetype2" if key == "use_system_freetype" else key
args += f"skia_{k}={b}\n"
rmdir(self, "out/conan")
mkdir(self, "out/conan")
save(self, "out/conan/args.gn", args)
if self.settings.os == "Windows":
self.run("bin\gn gen out/conan")
else:
self.run("bin/gn gen out/conan")
self.run("ninja -C out/conan")
def package(self):
source_folder_include = join(self.source_folder, "include")
source_folder_modules = join(self.source_folder, "modules")
package_folder_include = join(self.package_folder, "include")
package_folder_include_modules = join(package_folder_include, "modules")
package_folder_lib = join(self.package_folder, "lib")
package_folder_bin = join(self.package_folder, "bin")
build_folder_out = join(self.build_folder, "out", "conan")
# Skia headers have to be included relative to root of Skia repository (for example, #include <include/core/SkCanvas.h>).
# So we have to create another 'include' folder inside include directory...
# Include the entire skia root folder as an include (only copy includes)
copy(self, "*.h", self.source_folder, package_folder_include)
#copy(self, "*.h", source_folder_include, join(package_folder_include, "include"))
## removed sksg from this list
#for mod in ["skottie", "skresource", "sksg", "skshaper", "skunicode", "svg"]:
# copy(self, "*.h", join(source_folder_modules, mod, "include"), join(package_folder_include_modules, mod, "include"))
## skcms doesn't have include folder for some reason.
#copy(self, "*.h", join(source_folder_modules, "skcms"), join(package_folder_include_modules, "skcms"))
if self.settings.os == "Windows":
if self.options.shared:
copy(self, "*.dll", build_folder_out, package_folder_bin, keep_path=False)
copy(self, "*.dll.lib", build_folder_out, package_folder_lib, keep_path=False)
# rename: *.dll.lib -> *.lib
for filename in os.listdir(package_folder_lib):
if filename.endswith(".dll.lib"):
new_filename = filename.replace(".dll.lib", ".lib")
rename(self, join(package_folder_lib, filename), join(package_folder_lib, new_filename))
else:
copy(self, "*.lib", build_folder_out, package_folder_lib, keep_path=False)
else:
if self.options.shared:
copy(self, "*.so", build_folder_out, package_folder_lib, keep_path=False)
copy(self, "*.dylib", build_folder_out, package_folder_lib, keep_path=False)
else:
copy(self, "*.a", build_folder_out, package_folder_lib, keep_path=False)
if self.settings.os == "Emscripten" and self.settings.arch == "wasm":
copy(self, "canvaskit.js", build_folder_out, package_folder_bin)
copy(self, "canvaskit.wasm", build_folder_out, package_folder_bin)
def package_info(self):
# As of Conan 2.3.1, CMake generators cannot propagate transitive dependencies when you use components.
# So we have to put evetything into root cpp_info...
# https://github.com/conan-io/conan/issues/14888
# component: skia
self.cpp_info.defines += ["SK_CODEC_DEFINES_BMP"]
self.cpp_info.defines += ["SK_CODEC_DEFINES_WBMP"]
self.cpp_info.defines += ["SK_DISABLE_TRACING"] # assuming is_official_build
if self.options.use_gl:
self.cpp_info.defines += ["SK_GL"]
if self.options.use_dawn:
self.cpp_info.defines += ["SK_DAWN"]
if self.options.use_direct3d:
self.cpp_info.defines += ["SK_ENABLE_SPIRV_CROSS"]
self.cpp_info.defines += ["SK_DIRECT3D"]
self.cpp_info.system_libs += ["d3d12", "dxgi", "d3dcompiler"]
if self.options.use_vulkan:
self.cpp_info.defines += ["SK_VULKAN"]
if self.options.use_metal:
self.cpp_info.defines += ["SK_METAL"]
if self.options.shared:
self.cpp_info.defines += ["SKIA_DLL"]
if self.settings.os == "Linux":
self.cpp_info.defines += ["SK_R32_SHIFT=16"]
if self.settings.os == "Android":
self.cpp_info.system_libs += ["log"]
if self.options.enable_optimize_size:
self.cpp_info.defines += ["SK_ENABLE_OPTIMIZE_SIZE"]
if self.options.enable_precompile:
self.cpp_info.defines += ["SK_ENABLE_PRECOMPILE"]
if self.options.enable_ganesh:
self.cpp_info.defines += ["SK_GANESH"]
if self.options.enable_graphite:
self.cpp_info.defines += ["SK_GRAPHITE"]
if self.options.use_perfetto:
self.cpp_info.defines += ["SK_USE_PERFETTO"]
if self.settings.os == "Macos" or self._is_ios_variant():
if self.options.enable_api_available_macro:
self.cpp_info.defines += ["SK_ENABLE_API_AVAILABLE"]
else:
self.cpp_info.cflags += ["-Wno-unguarded-availability"]
if self.options.gl_standard == "gl":
self.cpp_info.defines += ["SKIA_ASSUME_GL=1"]
if self.options.gl_standard == "gles":
self.cpp_info.defines += ["SKIA_ASSUME_GL_ES=1"]
if self.options.gl_standard == "webgl":
self.cpp_info.defines += ["SKIA_ASSUME_WEBGL=1"]
if self.options.enable_pdf:
if self.options.use_zlib and self.options.use_libjpeg_turbo_decode and self.options.use_libjpeg_turbo_encode:
self.cpp_info.defines += ["SK_SUPPORT_PDF"]
if self.options.use_xps:
self.cpp_info.defines += ["SK_SUPPORT_XPS"]
if self.options.use_wuffs and not self.options.shared:
self.cpp_info.defines += ["SK_HAS_WUFFS_LIBRARY"]
self.cpp_info.defines += ["SK_CODEC_DECODES_GIF"]
self.cpp_info.libs += ["wuffs"]
if self.options.use_piex and not self.options.shared:
self.cpp_info.libs += ["piex"]
if self.options.use_dng_sdk and self.options.use_libjpeg_turbo_decode and self.options.use_piex and not self.options.shared:
self.cpp_info.defines += ["qDNGBigEndian=0"]
self.cpp_info.libs += ["dng_sdk"]
if self.options.use_libpng_decode:
self.cpp_info.defines += ["SK_CODEC_DECODES_ICO"]
self.cpp_info.defines += ["SK_CODEC_DECODES_PNG"]
if self.options.use_libpng_decode:
self.cpp_info.defines += ["SK_CODEC_DECODES_WEBP"]
if self.options.use_libavif:
self.cpp_info.defines += ["SK_CODEC_DECODES_AVIF"]
if self.options.use_libjpeg_turbo_decode:
self.cpp_info.defines += ["SK_CODEC_DECODES_JPEG"]
if self.options.use_libjxl_decode:
self.cpp_info.defines += ["SK_CODEC_DECODE_JPEGXL"]
if self.options.use_ndk_images:
self.cpp_info.defines += ["SK_ENABLE_NDK_IMAGES"]
if self.options.use_expat:
self.cpp_info.defines += ["SK_XML"]
if self.options.use_dng_sdk and self.options.use_libjpeg_turbo_decode and self.options.use_piex:
self.cpp_info.defines += ["SK_CODEC_DECODES_RAW"]
if self.options.use_fonthost_mac:
self.cpp_info.defines += ["SK_TYPEFACE_FACTORY_CORETEXT", "SK_FONTMGR_CORETEXT_AVAILABLE"]
if self.settings.os == "Macos":
self.cpp_info.frameworks += ["AppKit", "ApplicationServices"]
elif self._is_ios_variant():
self.cpp_info.frameworks += ["CoreFoundation", "CoreGraphics", "CoreText", "UIKit"]
if self.options.enable_fontmgr_android:
self.cpp_info.defines += ["SK_FONTMGR_ANDROID_AVAILABLE"]
if self.options.enable_fontmgr_custom_directory:
self.cpp_info.defines += ["SK_FONTMGR_FREETYPE_DIRECTORY_AVAILABLE"]
if self.options.enable_fontmgr_custom_embedded:
self.cpp_info.defines += ["SK_FONTMGR_FREETYPE_EMBEDDED_AVAILABLE"]
if self.options.enable_fontmgr_custom_empty:
self.cpp_info.defines += ["SK_FONTMGR_FREETYPE_EMPTY_AVAILABLE"]
if self.options.enable_fontmgr_fontconfig:
self.cpp_info.defines += ["SK_FONTMGR_FONTCONFIG_AVAILABLE"]
if self.options.enable_fontmgr_win:
self.cpp_info.defines += ["SK_TYPEFACE_FACTORY_DIRECTWRITE", "SK_FONTMGR_DIRECTWRITE_AVAILABLE"]
if self.options.enable_fontmgr_win_gdi:
self.cpp_info.defines += ["SK_FONTMGR_GDI_AVAILABLE"]
self.cpp_info.system_libs += ["gdi32"]
# component: pathkit
if not self.options.shared:
self.cpp_info.libs += ["pathkit"]
# component: skcms
if not self.options.shared:
self.cpp_info.libs += ["skcms"]
# component: sksg
# sksg doesn't exist in the program's build, so it'll be commented for now
# if not self.options.shared:
# self.cpp_info.libs += ["sksg"]
# component: svg
if self.options.enable_svg and self.options.use_expat:
self.cpp_info.defines += ["SK_SVG"]
self.cpp_info.libs += ["svg"]
# component: skresource
if not self.options.shared:
self.cpp_info.libs += ["skresources"]
self.cpp_info.libs += ["skia"] # Placed this after some components due to library order being important on some systems
# component: skunicode
if self.options.enable_skunicode:
self.cpp_info.defines += ["SK_UNICODE_AVAILABLE"]
self.cpp_info.defines += ["SK_UNICODE_ICU_IMPLEMENTATION"]
self.cpp_info.libs += ["skunicode_icu", "skunicode_core"] # Swapped order
# component: skparagraph
if self.options.enable_skparagraph:
if not (self.settings.os == "Windows" and self.options.shared):
self.cpp_info.libs += ["skparagraph"]
self.cpp_info.defines += ["SK_ENABLE_PARAGRAPH"]
# component: skshaper
if self.options.enable_skshaper:
self.cpp_info.libs += ["skshaper"]
self.cpp_info.defines += ["SK_SHAPER_PRIMITIVE_AVAILABLE"]
if self.options.use_fonthost_mac:
self.cpp_info.defines += ["SK_SHAPER_CORETEXT_AVAILABLE"]
if self.options.use_harfbuzz:
self.cpp_info.defines += ["SK_SHAPER_HARFBUZZ_AVAILABLE"]
if self.options.shared:
self.cpp_info.defines += ["SK_SHAPER_UNICODE_AVAILABLE"]
# component: skottie
if self.options.enable_skottie:
self.cpp_info.libs += ["skottie"]
self.cpp_info.defines += ["SK_ENABLE_SKOTTIE", "SK_ENABLE_SKSLEFFECT"]
# component: bentleyottmann
if self.options.enable_bentleyottmann:
if not (self.settings.os == "Windows" and self.options.shared):
self.cpp_info.libs += ["bentleyottmann"]

View file

@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.15)
project(PackageTest CXX)
find_package(skia CONFIG REQUIRED)
add_executable(example src/example.cpp)
target_link_libraries(example skia::skia)

View file

@ -0,0 +1,26 @@
import os
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run
class skiaTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"
def requirements(self):
self.requires(self.tested_reference_str)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def layout(self):
cmake_layout(self)
def test(self):
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "example")
self.run(cmd, env="conanrun")

View file

@ -0,0 +1,17 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkSurface.h"
int main()
{
sk_sp<SkSurface> surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul({1280, 720}));
SkCanvas* canvas = surface->getCanvas();
SkPaint p;
p.setColor(SK_ColorRED);
p.setAntiAlias(true);
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(10);
canvas->drawLine(20, 20, 100, 100, p);
}

View file

@ -0,0 +1,19 @@
versions:
"126.20240526.0":
folder: all
"127.20240803.0":
folder: all
"128.20241118.0":
folder: all
"129.20241118.0":
folder: all
"130.20241118.0":
folder: all
"131.20250131.0":
folder: all
"132.20250131.0":
folder: all
"133.20250327.0":
folder: all
"134.20250327.0":
folder: all

5
conan/conan_skia_command.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
cd conan-skia/recipes/skia/all
conan create . -o use_system_expat=False -o use_system_freetype=False -o use_system_harfbuzz=False -o use_system_icu=False -o use_system_libjpeg_turbo=False -o use_system_libpng=False -o use_system_libwebp=False -o use_system_zlib=False --build=missing --version=134.20250327.0
cd ../../../..

3
conan/export_libs.bat Executable file
View file

@ -0,0 +1,3 @@
conan export %0/../libjuice/all/conanfile.py --version=1.6.1
conan export %0/../libdatachannel/all/conanfile.py --version=0.23.1
conan export %0/../conan-skia/recipes/skia/all/conanfile.py --version=134.20250327.0

10
conan/export_libs.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
conan export "$(dirname "$0")/libjuice/all/conanfile.py" --version=1.6.1
conan export "$(dirname "$0")/libdatachannel/all/conanfile.py" --version=0.23.1
conan export "$(dirname "$0")/mpg123/all/conanfile.py" --version=1.32.10
conan export "$(dirname "$0")/conan-skia/recipes/skia/all/conanfile.py" --version=134.20250327.0
#conan create . -o use_system_expat=False -o use_system_freetype=False -o use_system_harfbuzz=False -o use_system_icu=False -o use_system_libjpeg_turbo=False -o use_system_libpng=False -o use_system_libwebp=False -o use_system_zlib=False --build=missing --version=134.20250327.0
#cd ../../../..

View file

@ -0,0 +1,7 @@
sources:
"0.23.1":
url: "https://github.com/paullouisageneau/libdatachannel/archive/refs/tags/v0.23.1.tar.gz"
sha256: "63e14d619ac4d9cc310a0c7620b80e6da88abf878f27ccc78cd099f95d47b121"
"0.22.2":
url: "https://github.com/paullouisageneau/libdatachannel/archive/refs/tags/v0.22.2.tar.gz"
sha256: "8431ba62a3c83fbee05257226fb8bcb256b1a5ce48b449a718e3be5dbe9b2226"

View file

@ -0,0 +1,142 @@
import os
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps
from conan.tools.files import copy, get, rm, rmdir, replace_in_file
from conan.tools.microsoft import is_msvc
from conan.tools.apple import fix_apple_shared_install_name
required_conan_version = ">=2.1"
class libdatachannelConan(ConanFile):
name = "libdatachannel"
description = "C/C++ WebRTC network library featuring Data Channels, Media Transport, and WebSockets."
license = "MPL-2.0"
topics = ("webrtc", "rtc", "datachannel", "websocket")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/paullouisageneau/libdatachannel"
settings = "os", "compiler", "build_type", "arch"
package_type = "library"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_websocket": [True, False],
"with_nice": [True, False],
"with_ssl": ["openssl", "mbedtls", "gnutls"]
}
default_options = {
"shared": False,
"fPIC": True,
"with_websocket": True,
"with_nice": False,
"with_ssl": "openssl"
}
implements = ["auto_shared_fpic"]
def requirements(self):
if self.options.with_ssl == "openssl":
self.requires("openssl/[>=1.1 <4]")
elif self.options.with_ssl == "mbedtls":
self.requires("mbedtls/3.6.2")
elif self.options.with_ssl == "gnutls":
self.requires("gnutls/3.8.7")
if self.options.with_websocket:
self.requires("nettle/3.9.1")
self.requires("plog/1.1.10")
self.requires("usrsctp/0.9.5.0")
self.requires("libsrtp/2.6.0")
if self.options.with_nice:
self.requires("libnice/0.1.21")
else:
self.requires("libjuice/1.6.1", transitive_headers=True, transitive_libs=True)
def validate(self):
check_min_cppstd(self, 17)
if self.options.with_ssl == "mbedtls":
# dtlstransport.cpp:414:3: error: use of undeclared identifier 'mbedtls_ssl_conf_dtls_srtp_protection_profiles'
raise ConanInvalidConfiguration("Compilation error with mbedtls. Contributions are welcome.")
def layout(self):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
# Let Conan handle fpic
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
"set(CMAKE_POSITION_INDEPENDENT_CODE ON)", "")
def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["PREFER_SYSTEM_LIB"] = True
tc.cache_variables["USE_SYSTEM_SRTP"] = True
tc.cache_variables["USE_SYSTEM_USRSCTP"] = True
tc.cache_variables["USE_SYSTEM_PLOG"] = True
tc.cache_variables["USE_SYSTEM_JSON"] = True
tc.cache_variables["NO_EXAMPLES"] = True
tc.cache_variables["NO_TESTS"] = True
tc.cache_variables["NO_WEBSOCKET"] = not self.options.with_websocket
tc.cache_variables["USE_NICE"] = self.options.with_nice
tc.cache_variables["USE_SYSTEM_JUICE"] = not self.options.with_nice
if self.options.with_ssl == "gnutls":
tc.cache_variables["USE_GNUTLS"] = True
elif self.options.with_ssl == "mbedtls":
tc.cache_variables["USE_MBEDTLS"] = True
tc.generate()
deps = CMakeDeps(self)
deps.set_property("usrsctp", "cmake_target_name", "Usrsctp::Usrsctp")
deps.set_property("libsrtp", "cmake_file_name", "libSRTP")
deps.set_property("libsrtp", "cmake_target_name", "libSRTP::srtp2")
if self.options.with_ssl == "mbedtls":
deps.set_property("mbedtls", "cmake_target_name", "MbedTLS::MbedTLS")
elif self.options.with_ssl == "gnutls" and self.options.with_websocket:
deps.set_property("nettle", "cmake_file_name", "Nettle")
deps.set_property("nettle", "cmake_target_name", "Nettle::Nettle")
if self.options.with_nice:
deps.set_property("libnice", "cmake_file_name", "LibNice")
deps.set_property("libnice", "cmake_target_name", "LibNice::LibNice")
elif not self.options.shared:
# Targetname is LibJuice::LibJuiceStatic for static, but upstream makes no distinction
deps.set_property("libjuice", "cmake_target_name", "LibJuice::LibJuice")
deps.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
fix_apple_shared_install_name(self)
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
def package_info(self):
suffix = ""
if is_msvc(self) and self.settings.build_type == "Debug":
suffix = "d"
self.cpp_info.libs = ["datachannel" + suffix]
self.cpp_info.set_property("cmake_file_name", "LibDataChannel")
self.cpp_info.set_property("cmake_target_name", "LibDataChannel::LibDataChannel")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["m", "pthread", "dl"])
elif self.settings.os == "Windows":
self.cpp_info.system_libs.append("ws2_32")
if not self.options.shared:
self.cpp_info.defines.append("RTC_STATIC")
self.cpp_info.defines.append("RTC_ENABLE_WEBSOCKET=" + ("1" if self.options.with_websocket else "0"))
# This is True by default, and the recipe currently does not model it
self.cpp_info.defines.append("RTC_ENABLE_MEDIA=1")

View file

@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX) # if the project uses c++
find_package(LibDataChannel REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE LibDataChannel::LibDataChannel)
#target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)

View file

@ -0,0 +1,27 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os
# It will become the standard on Conan 2.x
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
def requirements(self):
self.requires(self.tested_reference_str)
def layout(self):
cmake_layout(self)
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.bindir, "test_package")
self.run(bin_path, env="conanrun")

View file

@ -0,0 +1,9 @@
#include <cstdlib>
#include <rtc/rtc.hpp>
#include <iostream>
int main(void) {
rtc::InitLogger(rtc::LogLevel::Debug);
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,5 @@
versions:
"0.23.1":
folder: all
"0.22.2":
folder: all

View file

@ -0,0 +1,7 @@
sources:
"1.6.1":
url: "https://github.com/paullouisageneau/libjuice/archive/refs/tags/v1.6.1.tar.gz"
sha256: "14d7cfc1a541843c1678828ad52d860d043bd82ed39ff076b260565796e4e4ee"
"1.5.7":
url: "https://github.com/paullouisageneau/libjuice/archive/refs/tags/v1.5.7.tar.gz"
sha256: "6385c574f3c33f766ed25cddf919625b0ae8ca0d76871f70301e5a0cf2c93dc8"

View file

@ -0,0 +1,80 @@
import os
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rm, rmdir
from conan.tools.microsoft import is_msvc
from conan.tools.apple import fix_apple_shared_install_name
required_conan_version = ">=2.4"
class libjuiceConan(ConanFile):
name = "libjuice"
description = "JUICE is a UDP Interactive Connectivity Establishment library."
license = "MPL-2.0"
topics = ("webrtc", "ice")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/paullouisageneau/libjuice"
settings = "os", "compiler", "build_type", "arch"
package_type = "library"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
languages = "C"
implements = ["auto_shared_fpic"]
def layout(self):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["NO_TESTS"] = True
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
fix_apple_shared_install_name(self)
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
def package_info(self):
self.cpp_info.libs = ["juice"]
self.cpp_info.set_property("cmake_file_name", "LibJuice")
if self.options.shared:
self.cpp_info.set_property("cmake_target_name", "LibJuice::LibJuice")
else:
self.cpp_info.set_property("cmake_target_name", "LibJuice::LibJuiceStatic")
self.cpp_info.defines.append("JUICE_STATIC")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
self.cpp_info.system_libs.append("pthread")
self.cpp_info.system_libs.append("dl")
if self.settings.os == "Windows":
self.cpp_info.system_libs.extend(["ws2_32", "bcrypt"])
if is_msvc(self):
self.cpp_info.cxxflags.append("/bigobj")

View file

@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX) # if the project uses c++
find_package(LibJuice REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
if (BUILD_SHARED_LIBS)
target_link_libraries(${PROJECT_NAME} PRIVATE LibJuice::LibJuice)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE LibJuice::LibJuiceStatic)
endif()

View file

@ -0,0 +1,32 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
import os
# It will become the standard on Conan 2.x
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"
def requirements(self):
self.requires(self.tested_reference_str)
def layout(self):
cmake_layout(self)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_SHARED_LIBS"] = self.dependencies[self.tested_reference_str].options.shared
tc.generate()
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.bindir, "test_package")
self.run(bin_path, env="conanrun")

View file

@ -0,0 +1,8 @@
#include <cstdlib>
#include <juice/juice.h>
int main(void) {
juice_config config;
juice_set_log_level(JUICE_LOG_LEVEL_WARN);
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,5 @@
versions:
"1.6.1":
folder: all
"1.5.7":
folder: all

View file

@ -0,0 +1,29 @@
import os
import shutil
import re
def _get_files_from_folder(search_dir, output_folder):
if not os.path.isdir(search_dir):
return []
files = []
for f in os.listdir(search_dir):
src = os.path.join(search_dir, f)
if os.access(src, os.X_OK) or bool(re.search(r"lib.*\.so(\.\d+)*$", f)):
if os.path.isfile(src):
dst = os.path.join(output_folder, f)
shutil.copy2(src, dst)
files.append(dst)
else:
files += _get_files_from_folder(src, output_folder)
return files
def deploy(graph, output_folder, **kwargs):
conanfile = graph.root.conanfile
files = []
for r, d in conanfile.dependencies.items():
if d.package_folder is None:
continue
search_dirs = (d.cpp_info.libdirs or [])
for dir in search_dirs:
search_dir = os.path.join(d.package_folder, dir)
files += _get_files_from_folder(search_dir, output_folder)

View file

@ -0,0 +1,30 @@
sources:
"1.32.10":
url:
- "https://sourceforge.net/projects/mpg123/files/mpg123/1.32.10/mpg123-1.32.10.tar.bz2"
- "https://www.mpg123.de/download/mpg123-1.32.10.tar.bz2"
sha256: "87b2c17fe0c979d3ef38eeceff6362b35b28ac8589fbf1854b5be75c9ab6557c"
"1.31.2":
url:
- "https://sourceforge.net/projects/mpg123/files/mpg123/1.31.2/mpg123-1.31.2.tar.bz2"
- "https://www.mpg123.de/download/mpg123-1.31.2.tar.bz2"
sha256: "b17f22905e31f43b6b401dfdf6a71ed11bb7d056f68db449d70b9f9ae839c7de"
"1.29.3":
url:
- "https://sourceforge.net/projects/mpg123/files/mpg123/1.29.3/mpg123-1.29.3.tar.bz2"
- "https://www.mpg123.de/download/mpg123-1.29.3.tar.bz2"
sha256: "963885d8cc77262f28b77187c7d189e32195e64244de2530b798ddf32183e847"
"1.26.4":
url:
- "https://sourceforge.net/projects/mpg123/files/mpg123/1.26.4/mpg123-1.26.4.tar.bz2"
- "https://www.mpg123.de/download/mpg123-1.26.4.tar.bz2"
sha256: "081991540df7a666b29049ad870f293cfa28863b36488ab4d58ceaa7b5846454"
patches:
"1.31.2":
- patch_file: "patches/0001-msvc-export-symbols.patch"
"1.26.4":
- patch_file: "patches/0001-msvc-export-symbols.patch"
"1.29.3":
- patch_file: "patches/0001-msvc-export-symbols.patch"
- patch_file: "patches/0002-cmake-read_api_version-fix.patch"

View file

@ -0,0 +1,222 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os, fix_apple_shared_install_name
from conan.tools.cmake import cmake_layout, CMake, CMakeDeps, CMakeToolchain
from conan.tools.layout import basic_layout
from conan.tools.gnu import Autotools, AutotoolsDeps, AutotoolsToolchain
from conan.tools.files import get, copy, export_conandata_patches, apply_conandata_patches, replace_in_file, rmdir, rm
from conan.tools.microsoft import is_msvc
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.build import cross_building
import os
required_conan_version = ">=1.53.0"
class Mpg123Conan(ConanFile):
name = "mpg123"
description = "Fast console MPEG Audio Player and decoder library"
topics = ("mpeg", "audio", "player", "decoder")
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://mpg123.org/"
license = "LGPL-2.1-or-later", "GPL-2.0-or-later"
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"flexible_resampling": [True, False],
"network": [True, False],
"icy": [True, False],
"id3v2": [True, False],
"ieeefloat": [True, False],
"layer1": [True, False],
"layer2": [True, False],
"layer3": [True, False],
"moreinfo": [True, False],
"seektable": [None, "ANY"],
"module": ["dummy", "libalsa", "tinyalsa", "win32"],
}
default_options = {
"shared": False,
"fPIC": True,
"flexible_resampling": True,
"network": True,
"icy": True,
"id3v2": True,
"ieeefloat": True,
"layer1": True,
"layer2": True,
"layer3": True,
"moreinfo": True,
"seektable": "1000",
"module": "dummy",
}
@property
def _audio_module(self):
return {
"libalsa": "alsa",
}.get(str(self.options.module), str(self.options.module))
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
def configure(self):
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self):
if is_msvc(self):
cmake_layout(self, src_folder="src")
else:
basic_layout(self, src_folder="src")
def requirements(self):
if self.options.module == "libalsa":
self.requires("libalsa/1.2.10")
if self.options.module == "tinyalsa":
self.requires("tinyalsa/2.0.0")
def validate(self):
if not str(self.options.seektable).isdigit():
raise ConanInvalidConfiguration(f"The option -o {self.ref.name}:seektable must be an integer number.")
if self.settings.os != "Windows" and self.options.module == "win32":
raise ConanInvalidConfiguration(f"The option -o {self.ref.name}:module should not use 'win32' for non-Windows OS")
def build_requirements(self):
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/2.0.3")
if self.settings.arch in ["x86", "x86_64"]:
self.tool_requires("yasm/1.3.0")
if self.settings_build.os == "Windows" and not is_msvc(self):
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str):
self.tool_requires("msys2/cci.latest")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
env = VirtualBuildEnv(self)
env.generate()
if not cross_building(self):
env = VirtualRunEnv(self)
env.generate(scope="build")
if is_msvc(self):
tc = CMakeToolchain(self)
tc.variables["NO_MOREINFO"] = not self.options.moreinfo
tc.variables["NETWORK"] = self.options.network
tc.variables["NO_NTOM"] = not self.options.flexible_resampling
tc.variables["NO_ICY"] = not self.options.icy
tc.variables["NO_ID3V2"] = not self.options.id3v2
tc.variables["IEEE_FLOAT"] = self.options.ieeefloat
tc.variables["NO_LAYER1"] = not self.options.layer1
tc.variables["NO_LAYER2"] = not self.options.layer2
tc.variables["NO_LAYER3"] = not self.options.layer3
tc.variables["USE_MODULES"] = False
tc.variables["CHECK_MODULES"] = self._audio_module
tc.variables["WITH_SEEKTABLE"] = self.options.seektable
tc.generate()
tc = CMakeDeps(self)
tc.generate()
else:
yes_no = lambda v: "yes" if v else "no"
tc = AutotoolsToolchain(self)
tc.configure_args.extend([
f"--enable-moreinfo={yes_no(self.options.moreinfo)}",
f"--enable-network={yes_no(self.options.network)}",
f"--enable-ntom={yes_no(self.options.flexible_resampling)}",
f"--enable-icy={yes_no(self.options.icy)}",
f"--enable-id3v2={yes_no(self.options.id3v2)}",
f"--enable-ieeefloat={yes_no(self.options.ieeefloat)}",
f"--enable-layer1={yes_no(self.options.layer1)}",
f"--enable-layer2={yes_no(self.options.layer2)}",
f"--enable-layer3={yes_no(self.options.layer3)}",
f"--with-audio={self._audio_module}",
f"--with-default-audio={self._audio_module}",
f"--with-seektable={self.options.seektable}",
f"--enable-modules=no",
f"--enable-shared={yes_no(self.options.shared)}",
f"--enable-static={yes_no(not self.options.shared)}",
])
if is_apple_os(self):
# Needed for fix_apple_shared_install_name invocation in package method
tc.extra_cflags += ["-headerpad_max_install_names"]
# The finite-math-only optimization has no effect and will cause linking errors
# when linked against glibc >= 2.31
tc.extra_cflags += ["-fno-finite-math-only"]
tc.generate()
tc = AutotoolsDeps(self)
tc.generate()
def build(self):
apply_conandata_patches(self)
if is_msvc(self):
cmake = CMake(self)
cmake.configure(build_script_folder=os.path.join(self.source_folder, "ports", "cmake"))
cmake.build()
else:
if self.settings.compiler == "apple-clang" and cross_building(self):
# when testing if the assembler supports avx - propagate cflags (CFLAGS) to the assembler
# (which should contain "-arch x86_64" when crossbuilding with appleclang)
replace_in_file(self, os.path.join(self.source_folder, "configure"),
"$CCAS -c -o conftest.o",
"$CCAS $CFLAGS -c -o conftest.o")
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 is_msvc(self):
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
else:
autotools = Autotools(self)
autotools.install()
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))
fix_apple_shared_install_name(self)
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "mpg123")
self.cpp_info.components["libmpg123"].libs = ["mpg123"]
self.cpp_info.components["libmpg123"].set_property("pkg_config_name", "libmpg123")
self.cpp_info.components["libmpg123"].set_property("cmake_target_name", "MPG123::libmpg123")
if self.settings.os == "Windows" and self.options.shared:
self.cpp_info.components["libmpg123"].defines.append("LINK_MPG123_DLL")
self.cpp_info.components["libout123"].libs = ["out123"]
self.cpp_info.components["libout123"].set_property("pkg_config_name", "libout123")
self.cpp_info.components["libout123"].set_property("cmake_target_name", "MPG123::libout123")
self.cpp_info.components["libout123"].requires = ["libmpg123"]
self.cpp_info.components["libsyn123"].libs = ["syn123"]
self.cpp_info.components["libsyn123"].set_property("pkg_config_name", "libsyn123")
self.cpp_info.components["libsyn123"].set_property("cmake_target_name", "MPG123::libsyn123")
self.cpp_info.components["libsyn123"].requires = ["libmpg123"]
if self.settings.os == "Linux":
self.cpp_info.components["libmpg123"].system_libs = ["m"]
if self.settings.arch in ["x86", "x86_64"]:
self.cpp_info.components["libsyn123"].system_libs = ["mvec"]
elif self.settings.os == "Windows":
self.cpp_info.components["libmpg123"].system_libs = ["shlwapi"]
if self.options.module == "libalsa":
self.cpp_info.components["libout123"].requires.append("libalsa::libalsa")
if self.options.module == "tinyalsa":
self.cpp_info.components["libout123"].requires.append("tinyalsa::tinyalsa")
if self.options.module == "win32":
self.cpp_info.components["libout123"].system_libs.append("winmm")

View file

@ -0,0 +1,22 @@
--- a/ports/cmake/src/libout123/CMakeLists.txt
+++ b/ports/cmake/src/libout123/CMakeLists.txt
@@ -18,7 +18,7 @@ add_library(${TARGET}
$<TARGET_OBJECTS:compat>
$<$<BOOL:${USE_MODULES}>:$<TARGET_OBJECTS:compat_dl>>)
-set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME out123)
+set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME out123 WINDOWS_EXPORT_ALL_SYMBOLS ON)
target_link_libraries(${TARGET} PRIVATE
$<TARGET_NAME_IF_EXISTS:defaultmodule>
--- a/ports/cmake/src/libsyn123/CMakeLists.txt
+++ b/ports/cmake/src/libsyn123/CMakeLists.txt
@@ -15,7 +15,7 @@ add_library(${TARGET}
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/libsyn123/sampleconv.c"
$<TARGET_OBJECTS:compat_str>)
-set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME syn123)
+set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME syn123 WINDOWS_EXPORT_ALL_SYMBOLS ON)
target_include_directories(${TARGET} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"

View file

@ -0,0 +1,10 @@
--- a/ports/cmake/cmake/read_api_version.cmake
+++ b/ports/cmake/cmake/read_api_version.cmake
@@ -1,6 +1,6 @@
function(read_api_version project_version api_version outapi_version synapi_version )
- file( READ "${CMAKE_SOURCE_DIR}/../../configure.ac" configure_ac )
+ file( READ "${CMAKE_CURRENT_SOURCE_DIR}/../../configure.ac" configure_ac )
string( REGEX MATCH "AC_INIT\\(\\[mpg123\\], \\[([0-9\\.]+)" result ${configure_ac} )
set( ${project_version} ${CMAKE_MATCH_1} PARENT_SCOPE )

View file

@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES C)
find_package(mpg123 REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE MPG123::libmpg123)

View file

@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
def requirements(self):
self.requires(self.tested_reference_str)
def layout(self):
cmake_layout(self)
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")

View file

@ -0,0 +1,12 @@
#include "mpg123.h"
#include <stdio.h>
int main() {
int error;
mpg123_pars *pars;
pars = mpg123_new_pars(&error);
mpg123_fmt_all(pars);
mpg123_delete_pars(pars);
return 0;
}

9
conan/mpg123/config.yml Normal file
View file

@ -0,0 +1,9 @@
versions:
"1.32.10":
folder: "all"
"1.31.2":
folder: "all"
"1.29.3":
folder: "all"
"1.26.4":
folder: "all"

12
conan/profiles/emscripten Normal file
View file

@ -0,0 +1,12 @@
[settings]
os=Emscripten
arch=wasm
compiler=clang
compiler.version=15
compiler.cppstd=23
compiler.libcxx=libc++
build_type=Release
[tool_requires]
cmake/3.27.0
emsdk/3.1.73

View file

@ -0,0 +1,15 @@
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu23
compiler.libcxx=libstdc++11
compiler.version=15
os=Linux
[tool_requires]
cmake/3.27.0
[replace_requires]
libiconv/*: libiconv/1.18
mpg123/*: mpg123/1.32.10

11
conan/profiles/macOS-arm64 Executable file
View file

@ -0,0 +1,11 @@
[settings]
arch=armv8
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu23
compiler.libcxx=libc++
compiler.version=17
os=Macos
[tool_requires]
cmake/3.27.0

8
conan/profiles/win-x86_64 Executable file
View file

@ -0,0 +1,8 @@
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=23
compiler.runtime=dynamic
compiler.version=194
os=Windows