Browse Source

[conan] move options to profiles

Andrey Filipenkov 7 months ago
parent
commit
3ee4f6650b
6 changed files with 255 additions and 207 deletions
  1. 12 0
      CI/conan/base/android
  2. 4 0
      CI/conan/base/apple
  3. 209 0
      CI/conan/base/common
  4. 10 0
      CI/conan/base/ios
  5. 3 0
      CI/conan/base/msvc
  6. 17 207
      conanfile.py

+ 12 - 0
CI/conan/base/android

@@ -14,3 +14,15 @@ zlib/*: zlib/[*]@system
 # https://github.com/conan-io/conan-center-index/issues/25342
 # https://github.com/conan-io/conan/issues/16468#issuecomment-2175877245
 tools.meson.mesontoolchain:extra_machine_files={{ [os.path.join(profile_dir, "meson_workaround.txt")] }}
+
+[options]
+# TODO https://github.com/conan-io/conan-center-index/issues/26020
+# freetype/*:shared=True
+sdl/*:shared=False
+sdl_image/*:shared=False
+sdl_mixer/*:shared=False
+sdl_ttf/*:shared=False
+
+qt/*:opengl=es2
+qt/*:qtandroidextras=True
+qt/*:with_freetype=True

+ 4 - 0
CI/conan/base/apple

@@ -14,3 +14,7 @@ zlib/*: zlib/[*]@system
 
 [conf]
 tools.apple:enable_bitcode=False
+
+[options]
+qt/*:openssl=False
+sdl_image/*:imageio=True

+ 209 - 0
CI/conan/base/common

@@ -12,3 +12,212 @@ md4c/0.4.8: md4c/0.5.2
 
 [conf]
 tools.cmake.cmaketoolchain:generator=Ninja
+
+[options]
+# shared (dynamic) libs
+boost/*:shared=True
+bzip2/*:shared=True
+libiconv/*:shared=True
+libpng/*:shared=True
+minizip/*:shared=True
+ogg/*:shared=True
+opus/*:shared=True
+qt/*:shared=True
+sdl/*:shared=True
+sdl_image/*:shared=True
+sdl_mixer/*:shared=True
+sdl_ttf/*:shared=True
+xz_utils/*:shared=True
+zlib/*:shared=True
+
+# Boost
+# we need only the following parts:
+# date_time filesystem iostreams locale program_options system
+# some other parts are also enabled because they're dependents
+# see e.g. conan-center-index/recipes/boost/all/dependencies
+boost/*:without_context=True
+boost/*:without_contract=True
+boost/*:without_coroutine=True
+boost/*:without_fiber=True
+boost/*:without_graph=True
+boost/*:without_graph_parallel=True
+boost/*:without_json=True
+boost/*:without_log=True
+boost/*:without_math=True
+boost/*:without_mpi=True
+boost/*:without_nowide=True
+boost/*:without_process=True
+boost/*:without_python=True
+boost/*:without_serialization=True
+boost/*:without_stacktrace=True
+boost/*:without_test=True
+boost/*:without_timer=True
+boost/*:without_type_erasure=True
+boost/*:without_wave=True
+boost/*:without_url=True
+
+# FFmpeg
+ffmpeg/*:avcodec=True
+ffmpeg/*:avdevice=False
+ffmpeg/*:avfilter=False
+ffmpeg/*:avformat=True
+ffmpeg/*:postproc=False
+# for resampling of audio in 'planar' formats
+ffmpeg/*:swresample=True
+# for video scaling
+ffmpeg/*:swscale=True
+
+ffmpeg/*:disable_all_bitstream_filters=True
+ffmpeg/*:disable_all_decoders=True
+ffmpeg/*:disable_all_demuxers=True
+ffmpeg/*:disable_all_encoders=True
+ffmpeg/*:disable_all_filters=True
+ffmpeg/*:disable_all_hardware_accelerators=True
+ffmpeg/*:disable_all_muxers=True
+ffmpeg/*:disable_all_parsers=True
+ffmpeg/*:disable_all_protocols=True
+
+ffmpeg/*:with_asm=False
+ffmpeg/*:with_freetype=False
+ffmpeg/*:with_libaom=False
+ffmpeg/*:with_libdav1d=False
+ffmpeg/*:with_libfdk_aac=False
+ffmpeg/*:with_libiconv=False
+ffmpeg/*:with_libmp3lame=False
+ffmpeg/*:with_libsvtav1=False
+ffmpeg/*:with_libvpx=False
+ffmpeg/*:with_libwebp=False
+ffmpeg/*:with_libx264=False
+ffmpeg/*:with_libx265=False
+ffmpeg/*:with_lzma=True
+ffmpeg/*:with_openh264=False
+ffmpeg/*:with_openjpeg=False
+ffmpeg/*:with_programs=False
+ffmpeg/*:with_sdl=False
+ffmpeg/*:with_ssl=False
+ffmpeg/*:with_vorbis=False
+
+# We want following options supported:
+# H3:SoD - .bik and .smk
+# H3:HD  -  ogg container / theora video / vorbis sound (not supported by VCMI at the moment, but might be supported in future)
+# and for mods - webm container / vp8 or vp9 video / opus sound
+# TODO: add av1 support for mods (requires enabling libdav1d)
+{% set ffDecoders = [
+    'bink',
+    'binkaudio_dct',
+    'binkaudio_rdft',
+    'opus',
+    'smackaud',
+    'smacker',
+    'theora',
+    'vorbis',
+    'vp8',
+    'vp9',
+] %}
+{% set ffDemuxers = [
+    'bink',
+    'binka',
+    'ogg',
+    'smacker',
+    'webm_dash_manifest',
+] %}
+{% set ffParsers = [
+    'opus',
+    'vorbis',
+    'vp8',
+    'vp9',
+    'webp',
+] %}
+{% set ffProtocols = [
+    'file',
+] %}
+ffmpeg/*:enable_decoders={{ ffDecoders|join(',') }}
+ffmpeg/*:enable_demuxers={{ ffDemuxers|join(',') }}
+ffmpeg/*:enable_parsers={{ ffParsers|join(',') }}
+ffmpeg/*:enable_protocols={{ ffProtocols|join(',') }}
+
+# optionally, for testing - enable ffplay/ffprobe binaries:
+# ffmpeg/*:avfilter=True
+# ffmpeg/*:enable_filters=aresample,scale
+# ffmpeg/*:with_programs=True
+# ffmpeg/*:with_sdl=True
+
+# oneTBB
+onetbb/*:tbbbind=False
+onetbb/*:tbbmalloc=False
+onetbb/*:tbbproxy=False
+
+# Qt
+# xpm format is required for Drag'n'Drop support
+# we need only win/macdeployqt
+# TODO: disabling these doesn't disable generation of CMake targets
+# TODO: in Qt 6.3 it's a part of qtbase
+# '-no-feature-assistant',
+# '-no-feature-designer',
+# '-no-feature-distancefieldgenerator',
+# '-no-feature-kmap2qmap',
+# '-no-feature-linguist',
+# '-no-feature-makeqpf',
+# '-no-feature-pixeltool',
+# '-no-feature-qdbus',
+# '-no-feature-qev',
+# '-no-feature-qtattributionsscanner',
+# '-no-feature-qtdiag',
+# '-no-feature-qtpaths',
+# '-no-feature-qtplugininfo',
+{% set qtConfig = [
+    '-no-gif',
+    '-no-ico',
+
+    '-no-feature-imageformat_bmp',
+    '-no-feature-imageformat_jpeg',
+    '-no-feature-imageformat_ppm',
+    '-no-feature-imageformat_xbm',
+] %}
+qt/*:config={{ qtConfig|join(' ') }}
+qt/*:essential_modules=False
+qt/*:openssl=True
+qt/*:qttools=True
+qt/*:with_freetype=False
+qt/*:with_libjpeg=False
+qt/*:with_mysql=False
+qt/*:with_odbc=False
+qt/*:with_openal=False
+qt/*:with_pq=False
+
+# SDL
+sdl/*:iconv=True
+sdl/*:sdl2main=True
+sdl/*:vulkan=False
+
+# SDL_image
+# bmp, png are the only ones that needs to be supported
+# dds support may be useful for HD edition, but not supported by sdl_image at the moment
+sdl_image/*:gif=False
+sdl_image/*:lbm=False
+sdl_image/*:pcx=False
+sdl_image/*:pnm=False
+sdl_image/*:qoi=False
+sdl_image/*:svg=False
+sdl_image/*:tga=False
+sdl_image/*:with_libjpeg=False
+sdl_image/*:with_libtiff=False
+sdl_image/*:with_libwebp=False
+sdl_image/*:xcf=False
+sdl_image/*:xpm=False
+sdl_image/*:xv=False
+
+# SDL_mixer
+# mp3, ogg and wav are the only ones that needs to be supported, flac is a bonus
+sdl_mixer/*:mad=False
+sdl_mixer/*:mikmod=False
+sdl_mixer/*:modplug=False
+sdl_mixer/*:nativemidi=False
+sdl_mixer/*:tinymidi=False
+
+# transitive deps, stuff that's not needed
+# doesn't link to bzip2 & zlib from "system" recipes
+pcre2/*:build_pcre2grep=False
+sqlite3/*:build_executable=False
+opusfile/*:http=False
+zstd/*:build_programs=False

+ 10 - 0
CI/conan/base/ios

@@ -3,3 +3,13 @@ include(apple)
 [settings]
 os=iOS
 os.sdk=iphoneos
+
+[options]
+qt/*:shared=False
+sdl/*:shared=False
+sdl_image/*:shared=False
+sdl_mixer/*:shared=False
+sdl_ttf/*:shared=False
+
+qt/*:opengl=es2
+sdl/*:sdl2main=False

+ 3 - 0
CI/conan/base/msvc

@@ -19,3 +19,6 @@ os=Windows
     'NTDDI_VERSION={}'.format(NTDDI_WIN7),
 ] %}
 tools.build:defines={{ win7_defines }}
+
+[options]
+ffmpeg/*:shared=True

+ 17 - 207
conanfile.py

@@ -35,229 +35,39 @@ class VCMI(ConanFile):
     }
     default_options = {
         "with_ffmpeg": True,
-
-        "boost/*:shared": True,
-        "bzip2/*:shared": True,
-        "libiconv/*:shared": True,
-        "libpng/*:shared": True,
-        "minizip/*:shared": True,
-        "ogg/*:shared": True,
-        "opus/*:shared": True,
-        "xz_utils/*:shared": True,
-        "zlib/*:shared": True,
     }
 
-    def configure(self):
-        self.options["ffmpeg"].shared = is_msvc(self) # MSVC static build requires static runtime, but VCMI uses dynamic runtime
-        # self.options["freetype"].shared = self.settings.os == "Android" # TODO https://github.com/conan-io/conan-center-index/issues/26020
-
-        # static Qt for iOS is the only viable option at the moment
-        self.options["qt"].shared = self.settings.os != "iOS"
-
-        if self.settings.os == "Android":
-            self.options["qt"].android_sdk = os.getenv("ANDROID_HOME") # , default=""
-
-        # we need only the following Boost parts:
-        # date_time filesystem iostreams locale program_options system
-        # some other parts are also enabled because they're dependents
-        # see e.g. conan-center-index/recipes/boost/all/dependencies
-        self.options["boost"].without_context = True
-        self.options["boost"].without_contract = True
-        self.options["boost"].without_coroutine = True
-        self.options["boost"].without_fiber = True
-        self.options["boost"].without_graph = True
-        self.options["boost"].without_graph_parallel = True
-        self.options["boost"].without_json = True
-        self.options["boost"].without_log = True
-        self.options["boost"].without_math = True
-        self.options["boost"].without_mpi = True
-        self.options["boost"].without_nowide = True
-        self.options["boost"].without_process = True
-        self.options["boost"].without_python = True
-        self.options["boost"].without_serialization = True
-        self.options["boost"].without_stacktrace = True
-        self.options["boost"].without_test = True
-        self.options["boost"].without_timer = True
-        self.options["boost"].without_type_erasure = True
-        self.options["boost"].without_wave = True
-        self.options["boost"].without_url = True
-
-        self.options["ffmpeg"].disable_all_bitstream_filters = True
-        self.options["ffmpeg"].disable_all_decoders = True
-        self.options["ffmpeg"].disable_all_demuxers = True
-        self.options["ffmpeg"].disable_all_encoders = True
-        self.options["ffmpeg"].disable_all_filters = True
-        self.options["ffmpeg"].disable_all_hardware_accelerators = True
-        self.options["ffmpeg"].disable_all_muxers = True
-        self.options["ffmpeg"].disable_all_parsers = True
-        self.options["ffmpeg"].disable_all_protocols = True
-
-        self.options["ffmpeg"].with_asm = False
-        self.options["ffmpeg"].with_freetype = False
-        self.options["ffmpeg"].with_libaom = False
-        self.options["ffmpeg"].with_libdav1d = False
-        self.options["ffmpeg"].with_libiconv = False
-        self.options["ffmpeg"].with_libmp3lame = False
-        self.options["ffmpeg"].with_libsvtav1 = False
-        self.options["ffmpeg"].with_libvpx = False
-        self.options["ffmpeg"].with_libwebp = False
-        self.options["ffmpeg"].with_libx264 = False
-        self.options["ffmpeg"].with_libx265 = False
-        self.options["ffmpeg"].with_lzma = True
-        self.options["ffmpeg"].with_openh264 = False
-        self.options["ffmpeg"].with_openjpeg = False
-        self.options["ffmpeg"].with_programs = False
-        self.options["ffmpeg"].with_sdl = False
-        self.options["ffmpeg"].with_ssl = False
-        self.options["ffmpeg"].with_vorbis = False
-        # option not available on Android
-        if self.settings.os != "Android":
-            self.options["ffmpeg"].with_libfdk_aac = False
-
-        self.options["ffmpeg"].avcodec = True
-        self.options["ffmpeg"].avdevice = False
-        self.options["ffmpeg"].avfilter = False
-        self.options["ffmpeg"].avformat = True
-        self.options["ffmpeg"].postproc = False
-        self.options["ffmpeg"].swresample = True # For resampling of audio in 'planar' formats
-        self.options["ffmpeg"].swscale = True    # For video scaling
-
-        # We want following options supported:
-        # H3:SoD - .bik and .smk
-        # H3:HD  -  ogg container / theora video / vorbis sound (not supported by vcmi at the moment, but might be supported in future)
-        # and for mods - webm container / vp8 or vp9 video / opus sound
-        # TODO: add av1 support for mods (requires enabling libdav1d which currently fails to build via Conan)
-        self.options["ffmpeg"].enable_protocols = "file"
-        self.options["ffmpeg"].enable_demuxers = ",".join([
-            "bink",
-            "binka",
-            "ogg",
-            "smacker",
-            "webm_dash_manifest",
-        ])
-        self.options["ffmpeg"].enable_parsers = ",".join([
-            "opus",
-            "vorbis",
-            "vp8",
-            "vp9",
-            "webp",
-        ])
-        self.options["ffmpeg"].enable_decoders = ",".join([
-            "bink",
-            "binkaudio_dct",
-            "binkaudio_rdft",
-            "opus",
-            "smackaud",
-            "smacker",
-            "theora",
-            "vorbis",
-            "vp8",
-            "vp9",
-        ])
-
-        #optionally, for testing - enable ffplay/ffprobe binaries in conan package:
-        #if self.settings.os == "Windows":
-        #    self.options["ffmpeg"].with_programs = True
-        #    self.options["ffmpeg"].avfilter = True
-        #    self.options["ffmpeg"].with_sdl = True
-        #    self.options["ffmpeg"].enable_filters = "aresample,scale"
-
-        self.options["onetbb"].tbbbind = False
-        self.options["onetbb"].tbbmalloc = False
-        self.options["onetbb"].tbbproxy = False
-
-        self.options["sdl"].iconv = True
-        self.options["sdl"].sdl2main = self.settings.os != "iOS"
-        self.options["sdl"].vulkan = False
-
-        # bmp, png are the only ones that needs to be supported
-        # dds support may be useful for HD edition, but not supported by sdl_image at the moment
-        self.options["sdl_image"].gif = False
-        self.options["sdl_image"].lbm = False
-        self.options["sdl_image"].pnm = False
-        self.options["sdl_image"].pcx = False
-        self.options["sdl_image"].qoi = False
-        self.options["sdl_image"].svg = False
-        self.options["sdl_image"].tga = False
-        self.options["sdl_image"].with_libjpeg = False
-        self.options["sdl_image"].with_libtiff = False
-        self.options["sdl_image"].with_libwebp = False
-        self.options["sdl_image"].xcf = False
-        self.options["sdl_image"].xpm = False
-        self.options["sdl_image"].xv = False
-        if is_apple_os(self):
-            self.options["sdl_image"].imageio = True
-
-        # mp3, ogg and wav are the only ones that needs to be supported, flac is a bonus
-        self.options["sdl_mixer"].mad = False
-        self.options["sdl_mixer"].mikmod = False
-        self.options["sdl_mixer"].modplug = False
-        self.options["sdl_mixer"].nativemidi = False
-        self.options["sdl_mixer"].tinymidi = False
+    @property
+    def _isMobilePlatform(self):
+        return self.settings.os == "iOS" or self.settings.os == "Android"
 
+    def config_options(self):
         # static on "single app" platforms
-        isSdlShared = self.settings.os != "iOS" and self.settings.os != "Android"
+        isSdlShared = not self._isMobilePlatform
         self.options["sdl"].shared = isSdlShared
         self.options["sdl_image"].shared = isSdlShared
         self.options["sdl_mixer"].shared = isSdlShared
         self.options["sdl_ttf"].shared = isSdlShared
 
-        def _disableQtOptions(disableFlag, options):
-            return " ".join([f"-{disableFlag}-{tool}" for tool in options])
+        if self.settings.os == "Android":
+            self.options["qt"].android_sdk = os.getenv("ANDROID_HOME")
 
-        _qtOptions = [
-            _disableQtOptions("no", [
-                "gif",
-                "ico",
-            ]),
-            _disableQtOptions("no-feature", [
-                # xpm format is required for Drag'n'Drop support
-                "imageformat_bmp",
-                "imageformat_jpeg",
-                "imageformat_ppm",
-                "imageformat_xbm",
+    def configure(self):
+        self.options["sdl"].sdl2main = self.settings.os != "iOS"
 
-                # we need only win/macdeployqt
-                # TODO: disabling these doesn't disable generation of CMake targets
-                # TODO: in Qt 6.3 it's a part of qtbase
-                # "assistant",
-                # "designer",
-                # "distancefieldgenerator",
-                # "kmap2qmap",
-                # "linguist",
-                # "makeqpf",
-                # "pixeltool",
-                # "qdbus",
-                # "qev",
-                # "qtattributionsscanner",
-                # "qtdiag",
-                # "qtpaths",
-                # "qtplugininfo",
-            ]),
-        ]
-        self.options["qt"].config = " ".join(_qtOptions)
-        self.options["qt"].essential_modules = False
         self.options["qt"].qttools = True
         self.options["qt"].qtandroidextras = self.settings.os == "Android" # TODO: in Qt 6 it's part of Core
-        self.options["qt"].with_freetype = self.settings.os == "Android"
-        self.options["qt"].with_libjpeg = False
-        self.options["qt"].with_mysql = False
-        self.options["qt"].with_odbc = False
-        self.options["qt"].with_openal = False
-        self.options["qt"].with_pq = False
         self.options["qt"].openssl = not is_apple_os(self)
-        if self.settings.os == "iOS" or self.settings.os == "Android":
+        if self._isMobilePlatform:
             self.options["qt"].opengl = "es2"
 
-        # transitive deps
-        # doesn't link to overridden bzip2 & zlib, the tool isn't needed anyway
-        self.options["pcre2"].build_pcre2grep = False
-        # executable not needed
-        self.options["sqlite3"].build_executable = False
-        # prevents pulling openssl in and isn't needed anyway
-        self.options["opusfile"].http = False
-        # programs not needed
-        self.options["zstd"].build_programs = False
+        # static Qt for iOS is the only viable option at the moment
+        if self.settings.os == "iOS":
+            self.options["qt"].shared = False
+
+        # MSVC static build requires static runtime, but VCMI uses dynamic runtime
+        if is_msvc(self):
+            self.options["ffmpeg"].shared = True
 
     def requirements(self):
         # client