diff --git a/.github/workflows/emscripten-experimental.yml b/.github/workflows/emscripten-experimental.yml index 7720000b9f..ffa12bd837 100644 --- a/.github/workflows/emscripten-experimental.yml +++ b/.github/workflows/emscripten-experimental.yml @@ -11,7 +11,7 @@ on: - cron: '0 10 * * 4' env: - MESON_VERSION: '0.56.2' + MESON_VERSION: '0.63.3' EM_VERSION: 'tot' EM_CACHE_FOLDER: 'emsdk' @@ -66,6 +66,7 @@ jobs: source ${{ env.EM_CACHE_FOLDER }}/emsdk_env.sh meson setup build/ + --cross-file misc/ci/common-options.ini --cross-file misc/ci/emscripten-ephemeral-ci.ini --cross-file misc/ci/emscripten-build.ini --prefix=$(pwd)/build-test diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 235ca883b4..47ea08730b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ on: - "**.wrap" env: - MESON_VERSION: '0.56.2' + MESON_VERSION: '0.63.3' EM_VERSION: '3.1.5' EM_CACHE_FOLDER: 'emsdk' TAISEI_NOPRELOAD: 0 @@ -72,6 +72,7 @@ jobs: - name: Configure run: > meson setup build/ + --native-file misc/ci/common-options.ini --native-file misc/ci/linux-x86_64-build-test-ci.ini --prefix=$(pwd)/build-test @@ -132,6 +133,7 @@ jobs: - name: Configure run: > meson setup build/ + --native-file misc/ci/common-options.ini --native-file misc/ci/macos-x86_64-build-test-ci.ini --prefix=$(pwd)/build-test @@ -158,7 +160,7 @@ jobs: name: Windows (x64) if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-20.04 - container: taiseiproject/windows-toolkit:20220221 # cross-compiler with mingw + container: taiseiproject/windows-toolkit:20221226 # cross-compiler with mingw steps: - name: Checkout Code uses: actions/checkout@v3 @@ -168,6 +170,7 @@ jobs: - name: Configure Taisei (Meson) run: > meson setup build/ + --cross-file misc/ci/common-options.ini --cross-file misc/ci/windows-llvm_mingw-x86_64-build-test-ci.ini --prefix=$(pwd)/build-test @@ -243,6 +246,7 @@ jobs: source ${{ env.EM_CACHE_FOLDER }}/emsdk_env.sh meson setup build/ + --cross-file misc/ci/common-options.ini --cross-file misc/ci/emscripten-ephemeral-ci.ini --cross-file misc/ci/emscripten-build.ini --prefix=$(pwd)/build-test @@ -268,7 +272,7 @@ jobs: name: Switch (ARM64) if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-20.04 - container: taiseiproject/switch-toolkit:20210530 + container: taiseiproject/switch-toolkit:20221226 steps: - name: Checkout Code uses: actions/checkout@v3 @@ -280,7 +284,9 @@ jobs: switch/crossfile.sh > misc/ci/switch-crossfile-ci.ini meson setup build/ - --cross-file=misc/ci/switch-crossfile-ci.ini + --cross-file misc/ci/common-options.ini + --cross-file misc/ci/switch-options.ini + --cross-file misc/ci/switch-crossfile-ci.ini --prefix=$(pwd)/build-test - name: Build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3ae7c09f2..e32e4bc279 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ on: description: "Input git-ref to build as a test release" env: - MESON_VERSION: '0.56.2' + MESON_VERSION: '0.63.3' EM_VERSION: '2.0.29' EM_CACHE_FOLDER: 'emsdk' TAISEI_NOPRELOAD: 0 @@ -74,6 +74,7 @@ jobs: git fetch --force --tags # see: https://github.com/actions/checkout/issues/290 meson setup build/linux + --native-file misc/ci/common-options.ini --native-file misc/ci/linux-x86_64-build-release.ini --prefix=$(pwd)/build-release @@ -112,8 +113,6 @@ jobs: - name: Package (Source) run: | - meson rewrite kwargs set project / version ${{ env.BUILD_VERSION }} # meson dist uses 'project.version' instead of 'git describe' for the tag to use, so this overwrites it as a workaround - meson --reconfigure build/linux meson dist -C build/linux --no-tests # disable test build, since we already know it compiles scripts/sign-release.py build/linux/meson-dist/taisei-${{ env.BUILD_VERSION }}.tar.xz @@ -212,7 +211,7 @@ jobs: windows-release-build-x64: name: Windows (x64) runs-on: ubuntu-20.04 - container: taiseiproject/windows-toolkit:20220221 + container: taiseiproject/windows-toolkit:20221226 steps: - name: Import GPG Key uses: taisei-project/ghaction-import-gpg@v5 @@ -240,6 +239,7 @@ jobs: meson setup build/windows -Dangle_libegl=$(pwd)/angle-compiled/lib/Windows-x64-dll/libEGL.dll -Dangle_libgles=$(pwd)/angle-compiled/lib/Windows-x64-dll/libGLESv2.dll + --cross-file misc/ci/common-options.ini --cross-file misc/ci/windows-llvm_mingw-x86_64-build-release.ini --prefix=$(pwd)/build-release @@ -290,7 +290,7 @@ jobs: windows-release-build-x86: name: Windows (x86) runs-on: ubuntu-20.04 - container: taiseiproject/windows-toolkit:20220221 + container: taiseiproject/windows-toolkit:20221226 steps: - name: Import GPG Key uses: taisei-project/ghaction-import-gpg@v5 @@ -318,6 +318,7 @@ jobs: meson setup build/windows -Dangle_libegl=$(pwd)/angle-compiled/lib/Windows-x86-dll/libEGL.dll -Dangle_libgles=$(pwd)/angle-compiled/lib/Windows-x86-dll/libGLESv2.dll + --cross-file misc/ci/common-options.ini --cross-file misc/ci/windows-llvm_mingw-x86-build-release.ini --prefix=$(pwd)/build-release @@ -434,6 +435,7 @@ jobs: source ${{ env.EM_CACHE_FOLDER }}/emsdk_env.sh meson setup build/emscripten + --cross-file misc/ci/common-options.ini --cross-file misc/ci/emscripten-build.ini --cross-file misc/ci/emscripten-ephemeral-ci.ini --prefix=$(pwd)/build-release @@ -474,7 +476,7 @@ jobs: switch-release-build: name: Switch (ARM64) runs-on: ubuntu-20.04 - container: taiseiproject/switch-toolkit:20210829 + container: taiseiproject/switch-toolkit:20221226 steps: - name: Import GPG Key uses: taisei-project/ghaction-import-gpg@v5 @@ -496,7 +498,9 @@ jobs: switch/crossfile.sh > misc/ci/switch-crossfile-ci.ini meson setup build/nx - --cross-file=misc/ci/switch-crossfile-ci.ini + --cross-file misc/ci/common-options.ini + --cross-file misc/ci/switch-options.ini + --cross-file misc/ci/switch-crossfile-ci.ini --prefix=$(pwd)/build-release - name: Set Package Version diff --git a/.gitignore b/.gitignore index 6b0d8d66f9..79c672cecd 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ __pycache__ *~ *-autosave.kra *.swp +.VERSION diff --git a/doc/BUILD.rst b/doc/BUILD.rst index a58e4a7a99..c0eb5a38e0 100644 --- a/doc/BUILD.rst +++ b/doc/BUILD.rst @@ -33,8 +33,8 @@ Build-Time Dependenices """"""""""""""""""""""" - ``gcc`` or ``clang`` -- meson >= 0.53.0 (0.56.2 recommended) -- Python >= 3.6 +- meson >= 0.63.0 +- Python >= 3.7 - `python-zstandard `__ >= 0.11.1 - `python-docutils `__ (optional, for generating documentation) @@ -45,7 +45,7 @@ Required '''''''' - OpenGL >= 3.3, or OpenGL ES >= 3.0 -- SDL2 >= 2.0.10 +- SDL2 >= 2.0.16 - cglm >= 0.7.8 - libpng >= 1.5.0 - libwebpdecoder >= 0.5 or libwebp >= 0.5 @@ -237,32 +237,39 @@ instead relying on system libraries. Useful for CI. # disables in-repo repositories meson configure build/ --wrap-mode=nofallback -Relative Directory Install (``-Dinstall_relative``) +Relative Directory Install (``-Dinstall_relocatable``) """"""""""""""""""""""""""""""""""""""""""""""""""" -* Default: ``true`` or ``false`` (platform-dependent) +* Default: ``auto`` +* Options: ``auto``, ``enabled``, ``disabled`` + +This option enables a "relocatable" installation layout, where everything is confined +to one directory and no full paths are hardcoded into the executable. -``-Dinstall_relative`` is a special option that changes depending on the -platform build target. +The ``auto`` defaults to ``enabled`` when building for Windows, Emscripten, Switch, +or macOS with ``install_macos_bundle`` enabled. Otherwise, it defaults to ``disabled``. -It is set to ``true`` when building for macOS, Windows, Emscripten, and Switch. +Note that you probably want to change the ``--prefix`` with this option enabled. + +.. code:: sh -It is set to ``false`` when building for Linux. + meson configure build/ -Dinstall_relocatable=enabled Install Prefix (``--prefix``) """"""""""""""""""""""""""""" -* Default: ``/usr/local`` +* Default: ``/usr/local`` (usually; platform-dependent) -``--prefix`` installs the Taisei binary and content files to a path of your -choice on your filesystem. +Specifies a path under which all game files are installed. -On Linux without ``-Dinstall_relative`` enabled (i.e: ``false``), it should be -kept to its default ``/usr/local``. In general, don't touch it unless you need -to. +If ``install_relocatable`` is enabled, Taisei will be installed into the root of this +directory, and thus you will probably want to change it from the default value. -On other platforms, it will install all Taisei game files to the directory of -your choice. +Otherwise, it's not recommended to touch this option unless you know what you are +doing. + +This is a Meson built-in option; see `Meson Manual `__ +for more information. .. code:: sh @@ -272,29 +279,31 @@ Package Data (``-Dpackage_data``) """"""""""""""""""""""""""""""""" * Default: ``auto`` -* Options: ``auto``, ``true``, ``false`` +* Options: ``auto``, ``enabled``, ``disabled`` + +If enabled, game assets will be packaged into a ``.zip`` archive. Otherwise, they will +be installed into the filesystem directly. + +This option is not available for Emscripten. -Packages game data into either a directory or a ``.zip`` depending on if -``-Denable_zip`` is ``true`` (see below). +Requires ``vfs_zip`` to be enabled as well. .. code:: sh - meson configure build/ -Dpackage_data=false + meson configure build/ -Dpackage_data=disabled -Enable ZIP Loading (``-Denable_zip``) +ZIP Package Loading (``-Dvfs_zip``) """"""""""""""""""""""""""""""""""""" -* Default: ``true``` -* Options: ``true``, ``false`` +* Default: ``auto``` +* Options: ``auto``, ``enabled``, ``disabled`` Controls whether or not Taisei can load game data (textures, shaders, etc) from -``.zip`` files. Useful for distribution and packaging. - -**NOTE:** Setting this to ``false`` automatically disables ``-Dpackage_data``. +``.zip`` files. Requires ``libzip``. .. code:: sh - meson configure build/ -Denable_zip=false + meson configure build/ -Dvfs_zip=disabled In-Game Developer Options (``-Ddeveloper``) """"""""""""""""""""""""""""""""""""""""""" @@ -302,9 +311,8 @@ In-Game Developer Options (``-Ddeveloper``) * Default: ``false`` * Options: ``true``, ``false`` -For testing actual gameplay, you can set this option and it will enable cheats -and other 'fast-forward' options by the pressing keys defined in -``src/config.h``. +Enables various tools useful for developers and testers, such as cheats, stage menu, +quick save/load, extra debugging information, etc. .. code:: sh @@ -314,10 +322,12 @@ Build Type (``-Dbuildtype``) """""""""""""""""""""""""""" * Default: ``release`` -* Options: ``release``, ``debug`` +* Options: ``plain``, ``debug``, ``debugoptimized``, ``release``, ``minsize``, ``custom`` -Sets the type of build. ``debug`` enables several additional debugging features, -as well as reduced optimizations and more debugging symbols. +Sets the type of build. ``debug`` reduces optimizations and enables debugging symbols. + +This is a Meson built-in option; see `Meson Manual `__ +for more information. .. code:: sh @@ -326,8 +336,8 @@ as well as reduced optimizations and more debugging symbols. Assertions (``-Db_ndebug``) """"""""""""""""""""""""""" -* Default: ``true`` -* Options: ``true``, ``false`` +* Default: ``if-release`` +* Options: ``if-release``, ``true``, ``false`` The name of this flag is opposite of what you'd expect. Think of it as "Not Debugging". It controls the ``NDEBUG`` declaration which is responsible for @@ -337,6 +347,9 @@ Setting to ``false`` will *enable* assertions (i.e: good for debugging). Keep ``true`` during release. +This is a Meson built-in option; see `Meson Manual `__ +for more information. + .. code:: sh meson configure build/ -Db_ndebug=false @@ -355,6 +368,9 @@ for the engine. Sometimes, it's overly-pedantic, but much of the time, it provides useful advice. (For example, it can detect potential null-pointer exceptions that may not be obvious to the human eye.) +This is a Meson built-in option; see `Meson Manual `__ +for more information. + .. code:: sh meson configure build/ -Dwerror=true @@ -400,6 +416,9 @@ is correct by browsing to the parent directory of ``../clang``. Then, you can launch Taisei's binary from the command line (using macOS as an example): +This is a Meson built-in option; see `Meson Manual `__ +for more information. + .. code:: sh /path/to/Taisei.app/Contents/MacOS/Taisei @@ -418,6 +437,9 @@ For release builds, this should be kept ``true``. See: `Interprocedural Optimization `__ +This is a Meson built-in option; see `Meson Manual `__ +for more information. + .. code:: sh meson configure build/ -Db_lto=false @@ -441,11 +463,11 @@ strip out useful debugging symbols. Rendering """"""""" -Backends (``-Dr_gl*``) +Backends (``-Dr_*``) '''''''''''''''''''''' -* Default: ``false`` -* Options: ``true``, ``false`` +* Default: ``auto`` +* Options: ``auto``, ``enabled``, ``disabled`` Enable or disable the various renderer backends for Taisei. @@ -454,11 +476,14 @@ Enable or disable the various renderer backends for Taisei. .. code:: sh # for GL 3.3 (default) - meson configure build/ -Dr_gl33=true + meson configure build/ -Dr_gl33=enabled # for GL ES 3.0 - meson configure build/ -Dr_gles30=true + meson configure build/ -Dr_gles30=enabled # for GL ES 2.0 (not recommended) - meson configure build/ -Dr_gles20=true + meson configure build/ -Dr_gles20=enabled + # No-op backend (nothing displayed). + # Disabling this will break the replay-verification mode. + meson configure build/ -Dr_null=enabled **NOTE:** GL ES 2.0 is *not recommended* as it is unsupported and may not work correctly. However, if for some reason you still want to use it, @@ -475,11 +500,16 @@ correctly, most notably: Default Renderer (``-Dr_default``) '''''''''''''''''''''''''''''''''' -* Default: ``gl33`` -* Options: ``gl33``, ``gles30``, ``gles20``, ``null`` +* Default: ``auto`` +* Options: ``auto``, ``gl33``, ``gles30``, ``gles20``, ``null`` Sets the default renderer to use when Taisei launches. +When set to ``auto``, defaults to the first enabled backend in this order: +``gl33``, ``gles30``, ``gles20``. + +The chosen backend must not be disabled. + .. code:: sh # for GL 3.3 (default) @@ -490,20 +520,25 @@ Sets the default renderer to use when Taisei launches. meson configure build/ -Dr_default=gles20 You can switch the renderer using the ``--renderer`` flag on the ``taisei`` -binary. (i.e: ``taisei --renderer gl33``). +binary. (i.e: ``taisei --renderer gles30``). Shader Transpiler (``-Dshader_transpiler``) ''''''''''''''''''''''''''''''''''''''''''' -* Default: ``false`` -* Options: ``true``, ``false`` +* Default: ``auto`` +* Options: ``auto``, ``enabled``, ``disabled`` For using OpenGL ES, the shader transpiler is necessary for converting Taisei's shaders to a format usable by that driver. +Requires ``shaderc`` and ``SPIRV-cross``. + +Note that for Emscripten and Switch platforms, the translation is performed offline, +and this option is not available. + .. code:: sh - meson configure build/ -Dshader_transpiler=true + meson configure build/ -Dshader_transpiler=enabled ANGLE """"" diff --git a/doc/ENVIRON.rst b/doc/ENVIRON.rst index 901c3f17bf..a69be9bb8b 100644 --- a/doc/ENVIRON.rst +++ b/doc/ENVIRON.rst @@ -134,7 +134,7 @@ Video and OpenGL portable). **TAISEI_GL_DEBUG** - | Default: ``0`` for release builds, ``1`` for debug builds + | Default: ``0`` Enables OpenGL debugging. A debug context will be requested, all OpenGL messages will be logged, and errors are fatal. Requires the ``KHR_debug`` diff --git a/doc/meson.build b/doc/meson.build index 43b5b715fd..8012ce7a90 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -1,27 +1,33 @@ -if install_docs - rst2html_variants = [] +if angle_enabled + bindist_deps += custom_target('LICENSE.ANGLE', + command : [eolconv_command, host_eol_style, '@INPUT@', '@OUTPUT@'], + input : 'LICENSE.ANGLE', + output : 'LICENSE.txt', + install : true, + install_dir : angle_install_path + ) +endif - # This is *completely* ridiculous, but apparently this thing has THAT many faces. - basenames = ['rst2html5', 'rst2html', 'rst2html4'] - suffixes = ['', '-3', '3', '-docutils'] +rst2html_variants = [] - foreach basename : basenames - foreach suffix : suffixes - variant = '@0@@1@'.format(basename, suffix) - rst2html_variants += [variant, '@0@.py'.format(variant)] - endforeach - endforeach +# This is *completely* ridiculous, but apparently this thing has THAT many faces. +basenames = ['rst2html5', 'rst2html', 'rst2html4'] +suffixes = ['', '-3', '3', '-docutils'] - rst2html5 = find_program( - rst2html_variants, - required : false - ) +foreach basename : basenames + foreach suffix : suffixes + variant = '@0@@1@'.format(basename, suffix) + rst2html_variants += [variant, '@0@.py'.format(variant)] + endforeach +endforeach - if not rst2html5.found() - error('rst2html5 from docutils is required to build documentation. Please install it, or disable the `docs` option if you don\'t want it.') - endif +rst2html5 = find_program( + rst2html_variants, + required : get_option('docs') +) +if rst2html5.found() rst_to_html = generator(rst2html5, arguments : [ '--no-datestamp', @@ -67,14 +73,4 @@ if install_docs depend_files : files('taisei.css') ) endforeach - - if angle_enabled - bindist_deps += custom_target('LICENSE.ANGLE', - command : [eolconv_command, host_eol_style, '@INPUT@', '@OUTPUT@'], - input : 'LICENSE.ANGLE', - output : 'LICENSE.txt', - install : true, - install_dir : angle_install_path - ) - endif endif diff --git a/meson.build b/meson.build index 02c29e48a5..f256591bc2 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,11 @@ project('taisei', 'c', license : 'MIT', - version : 'v1.4-dev', - meson_version : '>=0.53.0', + # NOTE: See https://github.com/mesonbuild/meson/issues/11163 + version : run_command([ + files('scripts/version.py'), + '--rootdir', meson.project_source_root(), + ], check : true).stdout().strip(), + meson_version : '>=0.63.0', default_options : [ 'c_std=gnu11', @@ -63,12 +67,13 @@ project('taisei', 'c', ] ) +taisei_version_string = meson.project_version() + is_debug_build = get_option('debug') is_developer_build = (get_option('developer') == 'auto' ? is_debug_build : get_option('developer') == 'true') cc = meson.get_compiler('c') python = import('python').find_installation() -macos_app_bundle = get_option('macos_bundle') and host_machine.system() == 'darwin' subdir('scripts') @@ -136,11 +141,6 @@ elif deprecation_warnings == 'ignore' taisei_c_args += '-Wno-deprecated-declarations' endif -if meson.version().version_compare('<0.50.0') and get_option('b_pch') - # Workaround for Meson bug: https://github.com/mesonbuild/meson/issues/4905 - taisei_c_args += ['-fpch-deps'] -endif - taisei_c_args = cc.get_supported_arguments(taisei_c_args) foreach arglist : [ @@ -151,7 +151,7 @@ foreach arglist : [ endif endforeach -sm_check = run_command(check_submodules_command) +sm_check = run_command(check_submodules_command, check : false) if sm_check.stdout() != '' foreach line : sm_check.stdout().strip().split('\n') @@ -163,19 +163,20 @@ if sm_check.stderr() != '' warning('Submodule check completed with errors:\n@0@'.format(sm_check.stderr())) endif -static = get_option('static') or ['emscripten', 'nx'].contains(host_machine.system()) - -dep_freetype = dependency('freetype2', required : true, static : static, fallback : ['freetype', 'freetype_dep']) -dep_png = dependency('libpng', version : '>=1.5', required : true, static : static, fallback : ['libpng', 'png_dep']) -dep_sdl2 = dependency('sdl2', version : '>=2.0.10',required : true, static : static, fallback : ['sdl2', 'sdl2_dep']) -dep_webp = dependency('libwebp', version : '>=0.5', required : true, static : static, fallback : ['libwebp', 'webpdecoder_dep']) -dep_webpdecoder = dependency('libwebpdecoder', version : '>=0.5', required : false, static : static) -dep_zlib = dependency('zlib', required : true, static : static, fallback : ['zlib', 'zlib_dep']) -dep_zstd = dependency('libzstd', version : '>=1.4.0', required : true, static : static, fallback : ['libzstd', 'libzstd_dep']) -dep_zip = dependency('libzip', version : '>=1.5.0', required : false, static : static, fallback : ['libzip', 'libzip_dep']) -dep_cglm = dependency('cglm', version : '>=0.7.8', required : true, static : static, fallback : ['cglm', 'cglm_dep']) -dep_crypto = dependency('libcrypto', required : false, static : static) -dep_gamemode = dependency('gamemode', required : false, static : static) +opt_vfs_zip = get_option('vfs_zip').require(host_machine.system() != 'emscripten', + error_message : 'ZIP packages are not supported on Emscripten') + +dep_freetype = dependency('freetype2', required : true) +dep_png = dependency('libpng', version : '>=1.5', required : true) +dep_sdl2 = dependency('sdl2', version : '>=2.0.10',required : true) +dep_webp = dependency('libwebp', version : '>=0.5', required : true) +dep_webpdecoder = dependency('libwebpdecoder', version : '>=0.5', required : false) +dep_zlib = dependency('zlib', required : true) +dep_zstd = dependency('libzstd', version : '>=1.4.0', fallback : ['libzstd', 'libzstd_dep']) +dep_zip = dependency('libzip', version : '>=1.5.0', required : opt_vfs_zip, allow_fallback : true) +dep_cglm = dependency('cglm', version : '>=0.7.8', required : true) +dep_crypto = dependency('libcrypto', required : get_option('use_libcrypto')) +dep_gamemode = dependency('gamemode', required : false) dep_m = cc.find_library('m', required : false) @@ -186,22 +187,20 @@ dep_koishi = subproject('koishi').get_variable('koishi_dep') taisei_deps = [ dep_basisu_transcoder, dep_cglm, + dep_crypto, dep_freetype, dep_gamemode, dep_koishi, dep_m, dep_png, dep_sdl2, + dep_zip, dep_zlib, dep_zstd, # don't add glad here ] -if meson.version().version_compare('<0.49.0') - wrap_mode_forcefallback = false -else - wrap_mode_forcefallback = (get_option('wrap_mode') == 'forcefallback') -endif +wrap_mode_forcefallback = (get_option('wrap_mode') == 'forcefallback') if dep_webpdecoder.found() and not wrap_mode_forcefallback # distro libwebpdecoder @@ -215,25 +214,14 @@ if host_machine.system() == 'windows' taisei_deps += cc.find_library('shlwapi') endif -if host_machine.system() == 'emscripten' - package_data = false - enable_zip = false -else - package_data = get_option('package_data') - enable_zip = get_option('enable_zip') - package_data = (package_data == 'auto' ? enable_zip : package_data == 'true') -endif - -if enable_zip - assert(dep_zip.found(), 'ZIP support enabled but libzip not found') - taisei_deps += dep_zip -endif - -if package_data and not enable_zip - error('ZIP support must be enabled for data packaging to work') -endif +package_data = ( + get_option('package_data') + .require(dep_zip.found(), + error_message : 'libzip not found or VFS ZIP support is disabled') + .allowed() +) -config.set('TAISEI_BUILDCONF_USE_ZIP', taisei_deps.contains(dep_zip)) +config.set('TAISEI_BUILDCONF_USE_ZIP', dep_zip.found()) have_posix = cc.has_header_symbol('unistd.h', '_POSIX_VERSION') @@ -296,7 +284,7 @@ config.set('TAISEI_BUILDCONF_HAVE_BUILTIN_POPCOUNTLL', cc.has_function('__builti config.set('TAISEI_BUILDCONF_HAVE_BUILTIN_POPCOUNT', cc.has_function('__builtin_popcount')) config.set('TAISEI_BUILDCONF_HAVE_BUILTIN_AVAILABLE', cc.has_function('__builtin_available')) -if enable_zip and dep_zip.found() +if dep_zip.found() if dep_zip.type_name() == 'internal' have_zip_compression_method_supported = dep_zip.version().version_compare('>=1.7.0') else @@ -317,52 +305,40 @@ force_relpath_systems = [ 'nx' ] -if macos_app_bundle - bundle_dir = 'Taisei.app' +opt_install_macos_bundle = get_option('install_macos_bundle') +opt_install_macos_bundle = opt_install_macos_bundle.require( + host_machine.system() == 'darwin', + error_message : 'only supported on macOS') - bundle_datadir = join_paths('Contents', 'Resources') - bundle_bindir = join_paths('Contents', 'MacOS') - bundle_libdir = bundle_bindir +prefer_relocatable = ( + host_machine.system() in (prefer_relpath_systems + force_relpath_systems) or + opt_install_macos_bundle.allowed()) - datadir = join_paths(bundle_dir, bundle_datadir) - bindir = join_paths(bundle_dir, bundle_bindir) - libdir = join_paths(bundle_dir, bundle_libdir) +opt_install_relocatable = get_option('install_relocatable') +opt_install_relocatable = opt_install_relocatable.disable_auto_if( + not prefer_relocatable) - is_relocatable_install = true +opt_install_macos_bundle = opt_install_macos_bundle.require( + opt_install_relocatable.allowed(), + error_message : 'install_relocatable is required') - # arguments must be strings... - meson.add_install_script( - python.path(), - join_paths(meson.source_root(), 'scripts', 'macos-install-dylibs.py'), - ':'.join(meson.get_cross_property('macos_lib_path', [])), - ':'.join(meson.get_cross_property('macos_tool_path', [])), - meson.get_cross_property('macos_tool_prefix', ''), - ) -else - datadir = get_option('datadir') +if host_machine.system() in force_relpath_systems and opt_install_relocatable.disabled() + error('install_relocatable must be enabled on this platform') +endif - if force_relpath_systems.contains(host_machine.system()) - is_relocatable_install = true - elif get_option('install_relative') == 'auto' - is_relocatable_install = prefer_relpath_systems.contains(host_machine.system()) - else - is_relocatable_install = (get_option('install_relative') == 'true') - endif +is_relocatable_install = opt_install_relocatable.allowed() +macos_app_bundle = opt_install_macos_bundle.allowed() - if is_relocatable_install - bindir = '.' - libdir = '.' - else - bindir = get_option('bindir') - libdir = get_option('libdir') - endif -endif +opt_install_freedesktop = ( + get_option('install_freedesktop') + .disable_auto_if(is_relocatable_install or host_machine.system() == 'darwin') + .require(not macos_app_bundle, + error_message : 'installing freedesktop.org stuff into a macOS bundle makes no sense') +) -if get_option('install_freedesktop') == 'auto' - install_xdg = not is_relocatable_install -else - install_xdg = get_option('install_freedesktop') == 'true' -endif +install_xdg = opt_install_freedesktop.allowed() + +datadir = get_option('datadir') if is_relocatable_install data_path = 'data' @@ -371,22 +347,44 @@ if is_relocatable_install lib_path = '.' if macos_app_bundle + bundle_dir = 'Taisei.app' + + bundle_datadir = join_paths('Contents', 'Resources') + bundle_bindir = join_paths('Contents', 'MacOS') + bundle_libdir = bundle_bindir + + datadir = join_paths(bundle_dir, bundle_datadir) + bindir = join_paths(bundle_dir, bundle_bindir) + libdir = join_paths(bundle_dir, bundle_libdir) + + # arguments must be strings... + meson.add_install_script( + python.path(), + join_paths(meson.source_root(), 'scripts', 'macos-install-dylibs.py'), + ':'.join(meson.get_cross_property('macos_lib_path', [])), + ':'.join(meson.get_cross_property('macos_tool_path', [])), + meson.get_cross_property('macos_tool_prefix', ''), + ) + # Relative to SDL_GetBasePath() (bundle root) config.set_quoted('TAISEI_BUILDCONF_DATA_PATH', join_paths(bundle_datadir, data_path)) config.set_quoted('TAISEI_BUILDCONF_LIB_PATH', join_paths(bundle_libdir)) # Make paths prefix-relative for installation - data_path = join_paths(datadir, data_path) lib_path = libdir - # I don't know why would you do that, but more power to you - xdg_path = join_paths(datadir, xdg_path) - else + else # Relocatable; not macOS bundle + bindir = '.' + libdir = '.' + # Relative to SDL_GetBasePath() (typically contains the executable) config.set_quoted('TAISEI_BUILDCONF_DATA_PATH', data_path) - config.set_quoted('TAISEI_BUILDCONF_LIB_PATH', '.') + config.set_quoted('TAISEI_BUILDCONF_LIB_PATH', lib_path) endif -else +else # Non-relocatable + bindir = get_option('bindir') + libdir = get_option('libdir') + data_path = join_paths(datadir, 'taisei') lib_path = join_paths(libdir, 'taisei') doc_path = join_paths(datadir, 'doc', 'taisei') @@ -405,26 +403,17 @@ config.set('TAISEI_BUILDCONF_LOG_FATAL_MSGBOX', ( host_machine.system() == 'darwin' or not is_developer_build )) -config.set('TAISEI_BUILDCONF_DEBUG_OPENGL', get_option('debug_opengl')) - -install_docs = get_option('docs') and host_machine.system() != 'emscripten' if host_machine.system() == 'windows' - if install_docs - custom_target('COPYING.txt', - command : [eolconv_command, host_eol_style, '@INPUT@', '@OUTPUT@'], - input : 'COPYING', - output : 'COPYING.txt', - install : true, - install_dir : doc_path - ) - endif - + custom_target('COPYING.txt', + command : [eolconv_command, host_eol_style, '@INPUT@', '@OUTPUT@'], + input : 'COPYING', + output : 'COPYING.txt', + install : true, + install_dir : doc_path + ) else - if install_docs - install_data('COPYING', install_dir : doc_path) - endif - + install_data('COPYING', install_dir : doc_path) endif if angle_enabled @@ -443,7 +432,7 @@ if angle_enabled endif # Where to install the libs (prefix-relative) - # Also used in docs/meson.build to install the license + # Also used in doc/meson.build to install the license angle_install_path = join_paths(lib_path, angle_dir) # Where the game should look (either absolute or SDL_GetBasePath()-relative, depending on configuration) @@ -518,7 +507,7 @@ config.set('TAISEI_BUILDCONF_TESTING_STAGES', use_testing_stages) # Stolen from Sway # Compute the relative path used by compiler invocations. source_root = meson.current_source_dir().split('/') -build_root = meson.build_root().split('/') +build_root = meson.project_build_root().split('/') if build_machine.system() == 'windows' source_root = source_root.replace('\\', '/') build_root = build_root.replace('\\', '/') @@ -587,49 +576,35 @@ foreach bindist_target : bindist_targets ) endforeach -summary = ''' - -Summary: - Taisei version: @0@ - System type: @1@ - Build type: @2@ - Developer mode: @15@ - Stages live reload: @16@ - - Audio backends: @3@ (default: @4@) - Renderers: @5@ (default: @6@) - Shader translation: @7@ - ZIP support: @8@ - Package data: @9@ - - Relative install paths: @10@ - Prefix: @11@ - Executables: @12@ - Data: @13@ - Documentation: @14@ -'''.format( - taisei_version_string, - systype, - get_option('buildtype'), - - ', '.join(enabled_audio_backends), - get_option('a_default'), - ', '.join(enabled_renderers), - default_renderer, - get_option('shader_transpiler'), - enable_zip, - package_data, - - is_relocatable_install, - get_option('prefix'), - # the $ is intentional - join_paths('$prefix', bindir), - join_paths('$prefix', data_path), - join_paths('$prefix', doc_path), - is_developer_build, - stages_live_reload - ) - -message(summary) - -run_command(postconf_command) +meson.add_devenv({ + 'TAISEI_RES_PATH': meson.current_source_dir() / 'resources', + 'TAISEI_GL_DEBUG': '1', + # TODO: Add support for this in libkoishi + 'ASAN_OPTIONS': 'detect_stack_use_after_return=false', +}) + +summary({ + 'System type' : systype, + 'Build type' : get_option('buildtype'), + 'Developer mode' : is_developer_build, +}, section : 'Main', bool_yn : true) + +summary({ + 'Audio backends' : '@0@ (default: @1@)'.format(', '.join(enabled_audio_backends), default_audio_backend), + 'Rendering backends' : '@0@ (default: @1@)'.format(', '.join(enabled_renderers), default_renderer), + 'Shader translation' : shader_transpiler_enabled, + 'ZIP packages' : dep_zip.found(), + 'Stages live reload' : stages_live_reload, +}, section : 'Features', bool_yn : true) + +summary({ + 'Relocatable layout' : is_relocatable_install, + 'Data in ZIP packages' : package_data, + 'Bundle ANGLE libraries' : angle_enabled, + 'Prefix' : get_option('prefix'), + 'Executables' : join_paths('$prefix', bindir), + 'Data' : join_paths('$prefix', data_path), + 'Documentation' : join_paths('$prefix', doc_path), +}, section : 'Installation', bool_yn : true) + +run_command(postconf_command, check : false) diff --git a/meson_options.txt b/meson_options.txt index 5e8ce6403a..23f24f0343 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,44 +1,74 @@ -option( - 'version_fallback', - type : 'string', - description : 'Overrides the version string when not building in a git repository' -) option( 'developer', type : 'combo', - choices : ['auto', 'true', 'false'], + choices : ['true', 'false', 'auto'], + value : 'false', + deprecated : ['auto'], description : 'Make a "developer" build with cheats and extra debugging features' ) +option('vfs_zip', + type : 'feature', + value : 'auto', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, + description : 'Support loading of game data from ZIP packages (requires libzip)' +) + option( 'enable_zip', type : 'boolean', - value : 'true', - description : 'Enable loading of game data from ZIP packages (requires libzip)' + deprecated : 'vfs_zip', + description : 'DEPRECATED: use vfs_zip instead', ) option( 'package_data', - type : 'combo', - choices : ['auto', 'true', 'false'], - description : 'Package the game’s assets into a compressed archive (requires enable_zip)' + type : 'feature', + value : 'auto', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, + description : 'Package the game’s assets into a compressed archive (requires vfs_zip)' +) + +option( + 'install_relocatable', + type : 'feature', + value : 'auto', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, + description : 'Install everything into the same directory, don\'t hardcode absolute paths into the executable. Prefix is assumed to be an empty directory reserved for Taisei in this mode.' ) option( 'install_relative', type : 'combo', choices : ['auto', 'true', 'false'], - description : 'Use only relative paths to the executable and install everything in the same directory. Always enabled for macOS bundles' + deprecated : 'install_relocatable', + description : 'DEPRECATED: use install_relocatable instead', ) option( 'install_freedesktop', - type : 'combo', - choices : ['auto', 'true', 'false'], + type : 'feature', + value : 'auto', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, description : 'Install freedesktop.org integration files (launchers, icons, replay file associations, etc.). Mostly relevant for Linux/BSD/etc. desktop systems' ) +option( + 'install_macos_bundle', + type : 'feature', + value : 'auto', + deprecated : {'true' : 'auto', 'false' : 'disabled'}, + description : 'Install into a macOS application bundle' +) + +option( + 'macos_bundle', + type : 'boolean', + deprecated : 'install_macos_bundle', + description : 'DEPRECATED: use install_macos_bundle instead', +) + option( 'install_angle', type : 'boolean', @@ -69,97 +99,90 @@ option( 'static', type : 'boolean', value : false, - description : 'Build statically linked executable' -) - -option( - 'debug_opengl', - type : 'boolean', - value : true, - description : 'Enable OpenGL debugging. Create a debug context, enable logging, and crash the game on errors. Only available in debug builds' -) - -option( - 'macos_bundle', - type : 'boolean', - value : true, - description : 'Make a macOS application bundle on install (ignored on other platforms)' + deprecated : 'prefer_static', + description : 'DEPRECATED: use prefer_static instead', ) option( 'docs', - type : 'boolean', - value : true, - description : 'Build and install documentation' + type : 'feature', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, + description : 'Build and install documentation (requires docutils)' ) option( 'shader_transpiler', - type : 'boolean', - value : false, + type : 'feature', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, description : 'Enable shader trans-compilation (requires shaderc)' ) option( 'validate_glsl', - type : 'combo', - choices : ['auto', 'true', 'false'], + type : 'feature', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, description : 'Enable validation of GLSL shaders (requires glslc)' ) option( 'r_default', type : 'combo', - choices : ['gl33', 'gles20', 'gles30', 'null'], + choices : ['auto', 'gl33', 'gles20', 'gles30', 'null'], description : 'Which rendering backend to use by default' ) option( 'r_gl33', - type : 'boolean', - value : true, + type : 'feature', + value : 'auto', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, description : 'Build the OpenGL 3.3 Core renderer' ) option( 'r_gles20', - type : 'boolean', - value : false, + type : 'feature', + value : 'disabled', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, description : 'Build the OpenGL ES 2.0 renderer (incomplete)' ) option( 'r_gles30', - type : 'boolean', - value : false, + type : 'feature', + value : 'auto', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, description : 'Build the OpenGL ES 3.0 renderer' ) option( 'r_null', - type : 'boolean', - value : true, - description : 'Build the no-op renderer (nothing is displayed)' + type : 'feature', + value : 'auto', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, + description : 'Build the no-op renderer (nothing is displayed). Required for --verify-replay to work properly' ) option( 'a_default', type : 'combo', - choices : ['sdl', 'null'], + choices : ['auto', 'sdl', 'null'], description : 'Which audio backend to use by default' ) option( 'a_sdl', - type : 'boolean', - value : true, + type : 'feature', + value : 'auto', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, description : 'Build the SDL audio backend' ) option( 'a_null', - type : 'boolean', - value : true, + type : 'feature', + value : 'auto', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, description : 'Build the no-op audio backend (silence); you want this on!' ) @@ -172,8 +195,8 @@ option( option( 'use_libcrypto', - type : 'combo', - choices : ['auto', 'true', 'false'], + type : 'feature', + deprecated : {'true' : 'enabled', 'false' : 'disabled'}, description : 'Use libcrypto from OpenSSL for better SHA implementations' ) diff --git a/misc/ci/Dockerfile.linux b/misc/ci/Dockerfile.linux index 06a0d4194c..995c8b58dd 100644 --- a/misc/ci/Dockerfile.linux +++ b/misc/ci/Dockerfile.linux @@ -23,6 +23,6 @@ RUN apt update && \ git RUN pip3 install \ - meson==0.56.2 \ + meson==0.63.3 \ ninja \ zstandard diff --git a/misc/ci/Dockerfile.switch b/misc/ci/Dockerfile.switch index f46f0e8ef7..c0697598a3 100644 --- a/misc/ci/Dockerfile.switch +++ b/misc/ci/Dockerfile.switch @@ -4,8 +4,9 @@ LABEL maintainer="Alice D. " ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ +RUN apt update && \ + apt dist-upgrade -yqq && \ + apt install -y --no-install-recommends \ apt-utils \ sudo \ ca-certificates \ @@ -23,25 +24,25 @@ RUN apt-get update && \ python3-docutils \ python3-pip \ gdebi-core \ - cmake && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* + apt-transport-https \ + cmake RUN pip3 install \ - meson==0.56.2 \ + meson==0.63.3 \ ninja \ zstandard \ python-gnupg -RUN wget https://github.com/devkitPro/pacman/releases/latest/download/devkitpro-pacman.amd64.deb && \ - gdebi -n devkitpro-pacman.amd64.deb && \ - rm devkitpro-pacman.amd64.deb && \ - dkp-pacman -Scc --noconfirm - ENV DEVKITPRO=/opt/devkitpro ENV PATH=${DEVKITPRO}/tools/bin:$PATH -RUN ln -s /proc/self/mounts /etc/mtab +RUN mkdir -p /usr/local/share/keyring/ && \ + curl https://apt.devkitpro.org/devkitpro-pub.gpg -o /usr/local/share/keyring/devkitpro-pub.gpg && \ + echo "deb [signed-by=/usr/local/share/keyring/devkitpro-pub.gpg] https://apt.devkitpro.org stable main" > /etc/apt/sources.list.d/devkitpro.list && \ + apt update && \ + apt install devkitpro-pacman -yqq && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* RUN dkp-pacman -Syyu --noconfirm \ switch-dev \ diff --git a/misc/ci/Dockerfile.windows b/misc/ci/Dockerfile.windows index 886ba070c1..fbce62a194 100644 --- a/misc/ci/Dockerfile.windows +++ b/misc/ci/Dockerfile.windows @@ -20,7 +20,7 @@ RUN apt-get update -qq && \ rm -rf /var/lib/apt/lists/* RUN pip3 install \ - meson==0.56.2 \ + meson==0.63.3 \ ninja \ zstandard \ python-gnupg diff --git a/misc/ci/common-options.ini b/misc/ci/common-options.ini new file mode 100644 index 0000000000..70dace4a0b --- /dev/null +++ b/misc/ci/common-options.ini @@ -0,0 +1,12 @@ + +[project options] +deprecation_warnings = 'no-error' +vfs_zip = 'enabled' +docs = 'enabled' +use_libcrypto = 'disabled' +force_vendored_shader_tools = true +validate_glsl = 'disabled' + +[sdl2:project options] +use_joystick_wgi = 'disabled' + diff --git a/misc/ci/emscripten-build.ini b/misc/ci/emscripten-build.ini index bcba12b28d..f58d4bdbad 100644 --- a/misc/ci/emscripten-build.ini +++ b/misc/ci/emscripten-build.ini @@ -17,6 +17,10 @@ file_packager = toolchain / 'tools/file_packager' needs_exe_wrapper = true source_map_base = 'http://localhost:6931/' +[project options] +validate_glsl = 'enabled' +vfs_zip = 'disabled' + [built-in options] b_ndebug = 'true' b_pie = false @@ -34,11 +38,6 @@ default_library = 'static' optimization = 's' wrap_mode = 'forcefallback' -[project options] -enable_zip = false -force_vendored_shader_tools = true -package_data = 'false' - [sdl2:project options] use_audio_alsa = 'disabled' use_audio_pulseaudio = 'disabled' diff --git a/misc/ci/linux-x86_64-build-release.ini b/misc/ci/linux-x86_64-build-release.ini index dc40c549c1..b8858abd9c 100644 --- a/misc/ci/linux-x86_64-build-release.ini +++ b/misc/ci/linux-x86_64-build-release.ini @@ -5,9 +5,7 @@ cflags = ['-march='+march, '-mtune='+mtune] ldflags = [] [project options] -deprecation_warnings = 'no-error' -use_libcrypto = 'false' -install_relative = 'true' +install_relocatable = 'enabled' [built-in options] c_args = cflags diff --git a/misc/ci/linux-x86_64-build-test-ci.ini b/misc/ci/linux-x86_64-build-test-ci.ini index c9d2a4cd10..5361f922c7 100644 --- a/misc/ci/linux-x86_64-build-test-ci.ini +++ b/misc/ci/linux-x86_64-build-test-ci.ini @@ -5,9 +5,6 @@ mtune = 'skylake' cflags = ['-march='+march, '-mtune='+mtune] ldflags = [] -[project options] -deprecation_warnings = 'no-error' - [built-in options] c_args = cflags c_link_args = ldflags diff --git a/misc/ci/macos-aarch64-build-release.ini b/misc/ci/macos-aarch64-build-release.ini index dec5cea776..f853860d94 100644 --- a/misc/ci/macos-aarch64-build-release.ini +++ b/misc/ci/macos-aarch64-build-release.ini @@ -21,7 +21,7 @@ pkgconfig = 'pkg-config' needs_exe_wrapper = true [project options] -deprecation_warnings = 'no-error' +install_macos_bundle = 'enabled' [built-in options] c_args = cflags diff --git a/misc/ci/macos-x86_64-build-release.ini b/misc/ci/macos-x86_64-build-release.ini index 1c0acfbe1b..3b3f99e22d 100644 --- a/misc/ci/macos-x86_64-build-release.ini +++ b/misc/ci/macos-x86_64-build-release.ini @@ -5,9 +5,6 @@ macos_min = '10.9' cflags = ['-mmacosx-version-min='+macos_min, '-march='+march, '-mtune='+mtune] ldflags = ['-mmacosx-version-min='+macos_min] -[project options] -deprecation_warnings = 'no-error' - [built-in options] c_args = cflags c_link_args = ldflags diff --git a/misc/ci/macos-x86_64-build-test-ci.ini b/misc/ci/macos-x86_64-build-test-ci.ini index 38cecbeed6..a9caa88be4 100644 --- a/misc/ci/macos-x86_64-build-test-ci.ini +++ b/misc/ci/macos-x86_64-build-test-ci.ini @@ -7,9 +7,6 @@ cflags = ['-mmacosx-version-min='+macos_min, '-march='+march, '-mtune='+mtune] # NOTE: might need to pass -sdk_version to the linker as well, not sure how that works... ldflags = ['-mmacosx-version-min='+macos_min] -[project options] -deprecation_warnings = 'no-error' - [built-in options] c_args = cflags c_link_args = ldflags diff --git a/misc/ci/switch-options.ini b/misc/ci/switch-options.ini new file mode 100644 index 0000000000..69942c40ef --- /dev/null +++ b/misc/ci/switch-options.ini @@ -0,0 +1,4 @@ + +[project options] +validate_glsl = 'enabled' + diff --git a/misc/ci/windows-llvm_mingw-x86-build-release.ini b/misc/ci/windows-llvm_mingw-x86-build-release.ini index 104856fe09..5348afa473 100644 --- a/misc/ci/windows-llvm_mingw-x86-build-release.ini +++ b/misc/ci/windows-llvm_mingw-x86-build-release.ini @@ -34,10 +34,9 @@ windres = exeprefix+'windres' ld = exeprefix+'ld' [project options] -deprecation_warnings = 'no-error' install_angle = true -r_gles30 = true -shader_transpiler = true +r_gles30 = 'enabled' +shader_transpiler = 'enabled' [built-in options] c_args = cflags diff --git a/misc/ci/windows-llvm_mingw-x86_64-build-release.ini b/misc/ci/windows-llvm_mingw-x86_64-build-release.ini index f90f8fb204..be3f97b548 100644 --- a/misc/ci/windows-llvm_mingw-x86_64-build-release.ini +++ b/misc/ci/windows-llvm_mingw-x86_64-build-release.ini @@ -34,10 +34,9 @@ windres = exeprefix+'windres' ld = exeprefix+'ld' [project options] -deprecation_warnings = 'no-error' install_angle = true -r_gles30 = true -shader_transpiler = true +r_gles30 = 'enabled' +shader_transpiler = 'enabled' [built-in options] c_args = cflags diff --git a/misc/ci/windows-llvm_mingw-x86_64-build-test-ci.ini b/misc/ci/windows-llvm_mingw-x86_64-build-test-ci.ini index 9d65d7f328..6b673faa8f 100644 --- a/misc/ci/windows-llvm_mingw-x86_64-build-test-ci.ini +++ b/misc/ci/windows-llvm_mingw-x86_64-build-test-ci.ini @@ -34,9 +34,6 @@ widl = exeprefix+'widl' windres = exeprefix+'windres' ld = exeprefix+'ld' -[project options] -deprecation_warnings = 'no-error' - [built-in options] c_args = cflags c_link_args = ldflags diff --git a/resources/00-taisei.pkgdir/shader/meson.build b/resources/00-taisei.pkgdir/shader/meson.build index 5c696f1e57..bd34b530be 100644 --- a/resources/00-taisei.pkgdir/shader/meson.build +++ b/resources/00-taisei.pkgdir/shader/meson.build @@ -153,28 +153,30 @@ spvc_vert_args = [ '--stage', 'vert', ] -if ['emscripten', 'nx'].contains(host_machine.system()) - validate_glsl = 'true' - transpile_glsl = true -else - validate_glsl = get_option('validate_glsl') - transpile_glsl = false +transpile_glsl = (host_machine.system() in ['emscripten', 'nx']) +opt_validate_glsl = get_option('validate_glsl') + +if opt_validate_glsl.disabled() and transpile_glsl + error('GLSL validation can\'t be disabled on this platform') endif force_vendored_shader_tools = get_option('force_vendored_shader_tools') +force_validate_glsl = ( + opt_validate_glsl.enabled() or + transpile_glsl or + (force_vendored_shader_tools and opt_validate_glsl.allowed()) +) -if force_vendored_shader_tools and validate_glsl != 'false' - validate_glsl = 'true' -endif +validate_glsl = false -if validate_glsl != 'false' +if opt_validate_glsl.allowed() if force_vendored_shader_tools glslc_command = disabler() else glslc_command = find_program('glslc', required : false) endif - if not glslc_command.found() and validate_glsl == 'true' + if not glslc_command.found() and force_validate_glsl glslc_command = subproject('shaderc').get_variable('glslc_native') glslc_args += '-Werror' validate_glsl = true @@ -184,7 +186,8 @@ if validate_glsl != 'false' glslc_frag_args, glslc_test_uniform_location_file, '-o', '-', - capture : false + capture : false, + check : false ) if test_result.returncode() == 0 @@ -199,7 +202,8 @@ if validate_glsl != 'false' glslc_frag_args, glslc_test_basic_file, '-o', '-', - capture : false + capture : false, + check : false ) if test_result.returncode() == 0 @@ -207,12 +211,12 @@ if validate_glsl != 'false' else warning(test_result.stderr()) - if validate_glsl == 'auto' - warning('Basic glslc test failed, you probably have a broken/incompatible version. GLSL validation will be disabled.') - validate_glsl = false - else + if force_validate_glsl error('Basic glslc test failed, you probably have a broken/incompatible version.') endif + + warning('Basic glslc test failed, you probably have a broken/incompatible version. GLSL validation will be disabled.') + validate_glsl = false endif else warning('GLSL validation or translation requested, but glslc was not found') @@ -232,10 +236,10 @@ if validate_glsl != 'false' glslc_args += ['-Os', '-g'] endif -else - validate_glsl = false endif +transpile_glsl = transpile_glsl and validate_glsl + # @begin validate if validate_glsl foreach src : glsl_files diff --git a/resources/meson.build b/resources/meson.build index 338ed168c8..f11dc695b6 100644 --- a/resources/meson.build +++ b/resources/meson.build @@ -65,8 +65,7 @@ foreach pkg : packages var_files = 'em_bundle_@0@_files'.format(bundle) var_packer_args = 'em_bundle_@0@_packer_args'.format(bundle) - glob_result = run_command(glob_command, pkg_path, get_variable(var_patterns)) - assert(glob_result.returncode() == 0, 'Glob script failed') + glob_result = run_command(glob_command, pkg_path, get_variable(var_patterns), check : true) foreach file : glob_result.stdout().strip().split('\n') if file != '' @@ -95,8 +94,7 @@ foreach pkg : packages console : true, ) else - glob_result = run_command(glob_command, pkg_path, '**/meson.build') - assert(glob_result.returncode() == 0, 'Glob script failed') + glob_result = run_command(glob_command, pkg_path, '**/meson.build', check : true) install_subdir(pkg_pkgdir, install_dir : data_path, exclude_files : glob_result.stdout().split('\n')) endif endforeach @@ -122,8 +120,7 @@ if host_machine.system() == 'nx' console : true, ) else - glob_result = run_command(glob_command, shaders_build_dir, '**/*.spv', '**/meson.build') - assert(glob_result.returncode() == 0, 'Glob script failed') + glob_result = run_command(glob_command, shaders_build_dir, '**/*.spv', '**/meson.build', check : true) install_subdir(shaders_build_dir, install_dir : data_path, exclude_files : glob_result.stdout().split('\n')) endif endif diff --git a/scripts/macos_setup_universal.sh b/scripts/macos_setup_universal.sh index 84c48b375b..d18afc989e 100755 --- a/scripts/macos_setup_universal.sh +++ b/scripts/macos_setup_universal.sh @@ -5,5 +5,15 @@ set -e source $(pwd)/.mac_env mkdir -p $MAC_BUILD_DIR/compiled $MESON_BUILD_ROOT_MACOS_COMBINED -meson setup --native-file $TAISEI_ROOT/misc/ci/macos-x86_64-build-release.ini --prefix $MESON_BUILD_ROOT_MACOS_X64_COMPILED $MESON_BUILD_ROOT_MACOS_X64 $TAISEI_ROOT -meson setup --cross-file $TAISEI_ROOT/misc/ci/macos-aarch64-build-release.ini --prefix $MESON_BUILD_ROOT_MACOS_AARCH64_COMPILED $MESON_BUILD_ROOT_MACOS_AARCH64 $TAISEI_ROOT +meson setup \ + --native-file $TAISEI_ROOT/misc/ci/common-options.ini \ + --native-file $TAISEI_ROOT/misc/ci/macos-x86_64-build-release.ini \ + --prefix $MESON_BUILD_ROOT_MACOS_X64_COMPILED \ + $MESON_BUILD_ROOT_MACOS_X64 \ + $TAISEI_ROOT +meson setup \ + --cross-file $TAISEI_ROOT/misc/ci/common-options.ini \ + --cross-file $TAISEI_ROOT/misc/ci/macos-aarch64-build-release.ini \ + --prefix $MESON_BUILD_ROOT_MACOS_AARCH64_COMPILED \ + $MESON_BUILD_ROOT_MACOS_AARCH64 \ + $TAISEI_ROOT diff --git a/scripts/meson.build b/scripts/meson.build index 04948b2901..a97909bd86 100644 --- a/scripts/meson.build +++ b/scripts/meson.build @@ -1,46 +1,25 @@ -ver_fb = get_option('version_fallback').strip() -version_fallback = ver_fb != '' ? ver_fb : meson.project_version() - common_taiseilib_args = [ - '--rootdir', meson.source_root(), - '--fallback-version', version_fallback + '--rootdir', meson.project_source_root(), ] common_taiseilib_defs = [ - '-DMESON_BUILD_ROOT=@0@'.format(meson.build_root()), - '-DMESON_SOURCE_ROOT=@0@'.format(meson.source_root()), + '-DMESON_BUILD_ROOT=@0@'.format(meson.project_build_root()), + '-DMESON_SOURCE_ROOT=@0@'.format(meson.project_source_root()), ] -# Workaround for Meson bug: https://github.com/mesonbuild/meson/issues/4947 -python_thunk = find_program(files('thunk.py')) - -version_script = files('version.py') -version_command = [python_thunk, version_script, common_taiseilib_args] - -taisei_version_result = run_command(version_command, '{string}') -assert(taisei_version_result.returncode() == 0, 'Version script failed') - -if taisei_version_result.stderr() != '' - warning(taisei_version_result.stderr().strip()) -endif - -taisei_version_string = taisei_version_result.stdout().strip() +preprocess_script = find_program(files('configure-file.py')) +preprocess_args = common_taiseilib_args + common_taiseilib_defs +preprocess_command = [preprocess_script, preprocess_args] -preprocess_script = files('configure-file.py') -# generators are string supremacists apparently... -preprocess_script_path = join_paths(meson.source_root(), '@0@'.format(preprocess_script[0])) -preprocess_args = [preprocess_script_path] + common_taiseilib_args + common_taiseilib_defs -preprocess_command = [python_thunk, preprocess_args] - -preprocessor = generator(preprocess_command[0], +preprocessor = generator(preprocess_script, arguments: preprocess_args + ['@EXTRA_ARGS@', '--depfile', '@DEPFILE@', '@INPUT@', '@OUTPUT@'], output: '@BASENAME@', depfile: '@BASENAME@.d', ) -eolconv_script = files('eolconv.py') -eolconv_command = [python_thunk, eolconv_script] +eolconv_script = find_program(files('eolconv.py')) +eolconv_command = [eolconv_script] package_system_name = host_machine.system() @@ -62,39 +41,39 @@ if is_debug_build dist_version_string = '@0@-debug'.format(dist_version_string) endif -dist_script = files('gen-dist.py') +dist_script = find_program(files('gen-dist.py')) dist_name = 'Taisei-@0@-@1@-@2@'.format(dist_version_string, package_system_name, host_machine.cpu_family()) -dist_command = [python_thunk, dist_script, common_taiseilib_args] +dist_command = [dist_script, common_taiseilib_args] dist_prefix_args = ['--prefix=@0@'.format(dist_name)] zip_filename = '@0@.zip'.format(dist_name) -zip_outpath = join_paths(meson.build_root(), zip_filename) -zip_command = [dist_command, '--format=zip', meson.build_root(), zip_outpath] +zip_outpath = join_paths(meson.project_build_root(), zip_filename) +zip_command = [dist_command, '--format=zip', meson.project_build_root(), zip_outpath] txz_filename = '@0@.tar.xz'.format(dist_name) -txz_outpath = join_paths(meson.build_root(), txz_filename) -txz_command = [dist_command, '--format=xztar', dist_prefix_args, meson.build_root(), txz_outpath] +txz_outpath = join_paths(meson.project_build_root(), txz_filename) +txz_command = [dist_command, '--format=xztar', dist_prefix_args, meson.project_build_root(), txz_outpath] tgz_filename = '@0@.tar.gz'.format(dist_name) -tgz_outpath = join_paths(meson.build_root(), tgz_filename) -tgz_command = [dist_command, '--format=gztar', dist_prefix_args, meson.build_root(), tgz_outpath] +tgz_outpath = join_paths(meson.project_build_root(), tgz_filename) +tgz_command = [dist_command, '--format=gztar', dist_prefix_args, meson.project_build_root(), tgz_outpath] tbz_filename = '@0@.tar.bz2'.format(dist_name) -tbz_outpath = join_paths(meson.build_root(), tbz_filename) -tbz_command = [dist_command, '--format=bztar', dist_prefix_args, meson.build_root(), tbz_outpath] +tbz_outpath = join_paths(meson.project_build_root(), tbz_filename) +tbz_command = [dist_command, '--format=bztar', dist_prefix_args, meson.project_build_root(), tbz_outpath] tar_filename = '@0@.tar'.format(dist_name) -tar_outpath = join_paths(meson.build_root(), tar_filename) -tar_command = [dist_command, '--format=tar', dist_prefix_args, meson.build_root(), tar_outpath] +tar_outpath = join_paths(meson.project_build_root(), tar_filename) +tar_command = [dist_command, '--format=tar', dist_prefix_args, meson.project_build_root(), tar_outpath] -dmg_script = files('macos-gen-dmg.py') +dmg_script = find_program(files('macos-gen-dmg.py')) dmg_filename = '@0@.dmg'.format(dist_name) -dmg_command = [python_thunk, dmg_script, join_paths(meson.build_root(), dmg_filename), meson.build_root()] +dmg_command = [dmg_script, join_paths(meson.project_build_root(), dmg_filename), meson.project_build_root()] angle_enabled = get_option('install_angle') if package_system_name == 'windows' - nsis_script = files('win-gen-nsis.py') + nsis_script = find_program(files('win-gen-nsis.py')) nsis_filename = 'Taisei-@0@-setup-@1@.exe'.format(dist_version_string, host_machine.cpu_family()) nsis_outpath = join_paths(meson.build_root(), nsis_filename) @@ -115,7 +94,6 @@ if package_system_name == 'windows' endif nsis_command = [ - python_thunk, nsis_script, common_taiseilib_args, common_taiseilib_defs, @@ -125,33 +103,36 @@ if package_system_name == 'windows' ] endif -gen_atlas_script = files('gen-atlas.py') -gen_atlas_command = [python_thunk, gen_atlas_script] +gen_atlas_script = find_program(files('gen-atlas.py')) +gen_atlas_command = [gen_atlas_script] -gen_atlases_script = files('gen-atlases.py') -gen_atlases_command = [python_thunk, gen_atlases_script] +gen_atlases_script = find_program(files('gen-atlases.py')) +gen_atlases_command = [gen_atlases_script] -upkeep_script = files('upkeep.py') -upkeep_command = [python_thunk, upkeep_script, common_taiseilib_args] +upkeep_script = find_program(files('upkeep.py')) +upkeep_command = [upkeep_script, common_taiseilib_args] upkeep_target = run_target('upkeep', command: upkeep_command) -postconf_script = files('dump-build-options.py') -postconf_command = [python_thunk, postconf_script] +postconf_script = find_program(files('dump-build-options.py')) +postconf_command = [postconf_script] + +pack_script = find_program(files('pack.py')) +pack_command = [pack_script, common_taiseilib_args] -pack_script = files('pack.py') -pack_command = [python_thunk, pack_script, common_taiseilib_args] +glob_script = find_program(files('glob-search.py')) +glob_command = [glob_script] -glob_script = files('glob-search.py') -glob_command = [python_thunk, glob_script] +check_submodules_script = find_program(files('check-submodules.py')) +check_submodules_command = [check_submodules_script] -check_submodules_script = files('check-submodules.py') -check_submodules_command = [python_thunk, check_submodules_script] +em_set_bundle_uuid_script = find_program(files('em-set-bundle-uuid.py')) +em_set_bundle_uuid_command = [em_set_bundle_uuid_script] -em_set_bundle_uuid_script = files('em-set-bundle-uuid.py') -em_set_bundle_uuid_command = [python_thunk, em_set_bundle_uuid_script] +fix_path_script = find_program(files('unfuck-path.py')) +fix_path_command = [fix_path_script] -fix_path_script = files('unfuck-path.py') -fix_path_command = [python_thunk, fix_path_script] +format_array_script = find_program(files('format-array.py')) +format_array_command = [format_array_script] -format_array_script = files('format-array.py') -format_array_command = [python_thunk, format_array_script] +on_dist_script = find_program(files('on-meson-dist.py')) +meson.add_dist_script(on_dist_script) diff --git a/scripts/on-meson-dist.py b/scripts/on-meson-dist.py new file mode 100755 index 0000000000..c861c16737 --- /dev/null +++ b/scripts/on-meson-dist.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 + +import os +import sys +import pathlib +import taiseilib.version +import shutil + + +def main(args): + def env_dir_path(v): + try: + s = os.environ[v] + except KeyError: + print("{} is not set".format(v)) + + p = pathlib.Path(s) + assert p.is_dir() + return p + + src_root = env_dir_path('MESON_PROJECT_SOURCE_ROOT') + dist_root = env_dir_path('MESON_PROJECT_DIST_ROOT') + src_version = taiseilib.version.get(rootdir=src_root) + + (dist_root / taiseilib.version.OVERRIDE_FILE_NAME).write_text(src_version.string) + + remove_files = [ + '.dockerignore', + '.gitattributes', + '.gitignore', + '.gitmodules', + '.mailmap', + 'checkout', + 'pull', + ] + + for fname in remove_files: + (dist_root / fname).unlink(fname) + + shutil.rmtree(str(dist_root / '.github')) + + +if __name__ == '__main__': + from taiseilib.common import run_main + run_main(main) + diff --git a/scripts/taiseilib/version.py b/scripts/taiseilib/version.py index 26049621a2..33f3f21e27 100644 --- a/scripts/taiseilib/version.py +++ b/scripts/taiseilib/version.py @@ -5,12 +5,17 @@ import subprocess import shlex import re +import os class VersionFormatError(common.TaiseiError): pass +VERSION_FALLBACK = 'v1.4-dev' +OVERRIDE_FILE_NAME = '.VERSION' + + class Version(object): regex = re.compile(r'^v?(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[-+](\d+))?(?:[-+](.*))?$') @@ -53,13 +58,23 @@ def format(self, template='{string}'): return template.format(**self.__dict__) -def get(*, rootdir=None, fallback=None, args=common.default_args): +def get(*, rootdir=None, fallback=VERSION_FALLBACK, args=common.default_args): rootdir = rootdir if rootdir is not None else args.rootdir - fallback = fallback if fallback is not None else args.fallback_version if rootdir is None: import pathlib rootdir = pathlib.Path(__file__).parent + elif not isinstance(rootdir, os.PathLike): + rootdir = pathlib.Path(rootdir) + + version_override_path = rootdir / OVERRIDE_FILE_NAME + + try: + version_str = version_override_path.read_text().strip() + except FileNotFoundError: + pass + else: + return Version(version_str) try: version_str = subprocess.check_output( @@ -80,6 +95,7 @@ def get(*, rootdir=None, fallback=None, args=common.default_args): print(e, file=sys.stderr) print("Warning: git not found or not a git repository; using fallback version {0}".format(fallback), file=sys.stderr) + print("Hint: if you are packaging Taisei, write the appropriate version into", str(version_override_path), file=sys.stderr) version_str = fallback return Version(version_str) diff --git a/scripts/thunk.py b/scripts/thunk.py deleted file mode 100755 index cb76b292b9..0000000000 --- a/scripts/thunk.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -import runpy - -assert len(sys.argv) > 1 -sys.argv = sys.argv[1:] -sys.path.insert(0, os.path.dirname(sys.argv[0])) -runpy.run_path(sys.argv[0], run_name='__main__') diff --git a/src/arch_switch.c b/src/arch_switch.c index ab61c4d0d8..11e981bb6c 100644 --- a/src/arch_switch.c +++ b/src/arch_switch.c @@ -8,11 +8,13 @@ #include "taisei.h" #include "arch_switch.h" +#include "renderer/glcommon/debug.h" #include #include #include #include +#include #include #include @@ -58,24 +60,24 @@ void userAppInit(void) { getcwd(g_programDir, FS_MAX_PATH); -#if defined(DEBUG) && defined(TAISEI_BUILDCONF_DEBUG_OPENGL) - // enable Mesa logging: - NX_SETENV("EGL_LOG_LEVEL", "debug"); - NX_SETENV("MESA_VERBOSE", "all"); - NX_SETENV("MESA_DEBUG", "1"); - NX_SETENV("MESA_INFO", "1"); - NX_SETENV("MESA_GLSL", "errors"); - NX_SETENV("NOUVEAU_MESA_DEBUG", "1"); - NX_SETENV("LIBGL_DEBUG", "verbose"); - - // enable shader debugging in Nouveau: - NX_SETENV("NV50_PROG_OPTIMIZE", "0"); - NX_SETENV("NV50_PROG_DEBUG", "1"); - NX_SETENV("NV50_PROG_CHIPSET", "0x120"); -#else - // disable error checking and save CPU time - NX_SETENV("MESA_NO_ERROR", "1"); -#endif + if(glcommon_debug_requested()) { + // enable Mesa logging: + NX_SETENV("EGL_LOG_LEVEL", "debug"); + NX_SETENV("MESA_VERBOSE", "all"); + NX_SETENV("MESA_DEBUG", "1"); + NX_SETENV("MESA_INFO", "1"); + NX_SETENV("MESA_GLSL", "errors"); + NX_SETENV("NOUVEAU_MESA_DEBUG", "1"); + NX_SETENV("LIBGL_DEBUG", "verbose"); + + // enable shader debugging in Nouveau: + NX_SETENV("NV50_PROG_OPTIMIZE", "0"); + NX_SETENV("NV50_PROG_DEBUG", "1"); + NX_SETENV("NV50_PROG_CHIPSET", "0x120"); + } else { + // disable error checking and save CPU time + NX_SETENV("MESA_NO_ERROR", "1"); + } } attr_used diff --git a/src/audio/meson.build b/src/audio/meson.build index f58f753f68..8ccf66d9ce 100644 --- a/src/audio/meson.build +++ b/src/audio/meson.build @@ -1,39 +1,55 @@ -default_backend = get_option('a_default') +audio_backend_opts = { + 'sdl' : get_option('a_sdl'), + 'null' : get_option('a_null'), +} -if default_backend == 'sdl2mixer' - error('Your build directory is outdated. Try running the following command:\n\n$ meson --wipe @0@ @1@ -Da_default=sdl\n'.format(meson.source_root(), meson.build_root())) -endif +default_audio_backend = get_option('a_default') +audio_backends_prio = ['sdl', 'null'] + +if default_audio_backend == 'auto' + foreach audio_backend : audio_backends_prio + if audio_backend_opts[audio_backend].allowed() + default_audio_backend = audio_backend + break + endif + endforeach + + if default_audio_backend == 'auto' + audio_backends_prio_opts = [] + foreach audio_backend : audio_backends_prio + audio_backends_prio_opts + f'a_@audio_backend@' + endforeach + audio_backends_prio_opts = ', '.join(audio_backends_prio_opts) -if not get_option('a_@0@'.format(default_backend)) - error('Default audio backend \'@0@\' is not enabled. Enable it with -Da_@0@=true, or set a_default to something else.'.format(default_backend)) + error('Could not pick a default audio backend. ' + + f'Make sure you have at least one of audio_backends_prio_opts enabled.') + endif endif +assert(audio_backend_opts[default_audio_backend].allowed(), + f'Default audio backend @default_audio_backend@ is not enabled') + audio_src = files( 'audio.c', 'backend.c', ) -modules = [ - 'sdl', - 'null', -] - audio_deps = [] enabled_audio_backends = [] included_deps = [] needed_deps = [] a_macro = [] -foreach m : modules - if get_option('a_@0@'.format(m)) - subdir(m) - included_deps += [m] - enabled_audio_backends += [m] - a_macro += ['A(@0@)'.format(m)] - audio_src += get_variable('a_@0@_src'.format(m)) - needed_deps += get_variable('a_@0@_deps'.format(m)) - audio_deps += get_variable('a_@0@_libdeps'.format(m)) +foreach audio_backend, aopt : audio_backend_opts + if aopt.allowed() + subdir(audio_backend) + included_deps += [audio_backend] + enabled_audio_backends += [audio_backend] + a_macro += ['A(@0@)'.format(audio_backend)] + audio_src += get_variable(f'a_@audio_backend@_src') + needed_deps += get_variable(f'a_@audio_backend@_deps') + audio_deps += get_variable(f'a_@audio_backend@_libdeps') endif endforeach @@ -48,4 +64,4 @@ endforeach a_macro = ' '.join(a_macro) config.set('TAISEI_BUILDCONF_AUDIO_BACKENDS', a_macro) -config.set_quoted('TAISEI_BUILDCONF_AUDIO_DEFAULT', default_backend) +config.set_quoted('TAISEI_BUILDCONF_AUDIO_DEFAULT', default_audio_backend) diff --git a/src/audio/stream/meson.build b/src/audio/stream/meson.build index d7318b42e2..92d78c98e8 100644 --- a/src/audio/stream/meson.build +++ b/src/audio/stream/meson.build @@ -7,7 +7,7 @@ a_stream_src = files( 'stream_pcm.c', ) -dep_opusfile = dependency('opusfile', required : true, static : static, fallback : ['opusfile', 'opusfile_dep']) +dep_opusfile = dependency('opusfile') a_stream_deps = [] a_stream_libdeps = [dep_opusfile] diff --git a/src/meson.build b/src/meson.build index ad65233453..120194a4a7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -445,19 +445,15 @@ elif host_machine.system() == 'nx' taisei_nro_name = '@0@.nro'.format(taisei_basename) taisei_nro = custom_target(taisei_nro_name, - # NOTE: Unfortunately we can't just put 'taisei_elf' directly into the command array. - # Meson then makes an invalid assumption that we are going to execute it ("use as a generator"), - # and aborts because there's no exe wrapper in the cross file (which wouldn't make sense to have). - command : [ find_program('elf2nro'), - taisei_elf.full_path(), # workaround for the above issue + taisei_elf, '@OUTPUT@', '--nacp=@0@'.format(taisei_nacp.full_path()), # if we could pass the path in a standalone argument, we could have meson generate an implicit dependency here... '--icon=@0@'.format(nx_icon_path), ], build_by_default : true, - depends : [taisei_elf, taisei_nacp], + depends : [taisei_nacp], install : true, install_dir : bindir, output : taisei_nro_name, @@ -468,7 +464,7 @@ else dependencies : taisei_deps, c_args : taisei_c_args, c_pch : 'pch/taisei_pch.h', - gui_app : not get_option('win_console'), + win_subsystem : get_option('win_console') ? 'console' : 'windows', install : true, install_dir : bindir, export_dynamic : stages_live_reload, diff --git a/src/renderer/common/shaderlib/meson.build b/src/renderer/common/shaderlib/meson.build index 720b9e1518..bf9d6393ef 100644 --- a/src/renderer/common/shaderlib/meson.build +++ b/src/renderer/common/shaderlib/meson.build @@ -8,41 +8,14 @@ r_shaderlib_src = files( r_shaderlib_libdeps = [] -if get_option('shader_transpiler') - dep_spvc = dependency('spirv-cross-c-shared', required : true, static : static, fallback : ['SPIRV-Cross', 'spirv_cross_dep']) - - if get_option('wrap_mode') != 'forcefallback' - dep_shaderc = dependency('shaderc', static : static, required : false) - - if not dep_shaderc.found() - # Thanks, google. - # https://github.com/google/shaderc/issues/392 - if static - dep_shaderc = cc.find_library('shaderc_combined', required : false) - else - dep_shaderc = cc.find_library('shaderc_shared', required : false) - endif - endif - if not dep_shaderc.found() - dep_shaderc = dependency('shaderc', static : static, fallback : ['shaderc', 'shaderc_dep'], required : true) - endif - else - dep_shaderc = dependency('shaderc', static : static, fallback : ['shaderc', 'shaderc_dep'], required : true) - endif - - assert(dep_shaderc.found(), 'shaderc is required for the shader transpiler') - - r_shaderlib_src += files( - 'lang_spirv.c' - ) +opt_shader_transpiler = get_option('shader_transpiler') +dep_spvc = dependency('spirv-cross-c-shared', required : opt_shader_transpiler) +dep_shaderc = dependency('shaderc', required : opt_shader_transpiler) +shader_transpiler_enabled = dep_spvc.found() and dep_shaderc.found() +if shader_transpiler_enabled + r_shaderlib_src += files('lang_spirv.c') r_shaderlib_libdeps += [dep_shaderc, dep_spvc] - - if false and host_machine.system() == 'windows' and get_option('b_lto') and get_option('static') and cc.get_id() == 'gcc' - warning('LTO is known to break glslang on GCC-mingw64 based toolchains') - endif else - r_shaderlib_src += files( - 'lang_spirv_stub.c' - ) + r_shaderlib_src += files('lang_spirv_stub.c') endif diff --git a/src/renderer/glcommon/debug.c b/src/renderer/glcommon/debug.c index 7bfa2be7fd..e828ea48ca 100644 --- a/src/renderer/glcommon/debug.c +++ b/src/renderer/glcommon/debug.c @@ -113,7 +113,7 @@ void glcommon_debug_enable(void) { #endif bool glcommon_debug_requested(void) { - return env_get("TAISEI_GL_DEBUG", DEBUG_GL_DEFAULT); + return env_get("TAISEI_GL_DEBUG", false); } void glcommon_set_debug_label_local(char *label_storage, const char *kind_name, GLuint gl_handle, const char *label) { diff --git a/src/renderer/glcommon/opengl.h b/src/renderer/glcommon/opengl.h index a43b0f2cd6..0bbb819c7b 100644 --- a/src/renderer/glcommon/opengl.h +++ b/src/renderer/glcommon/opengl.h @@ -148,12 +148,6 @@ ext_flag_t glcommon_check_extension(const char *ext) attr_nonnull_all; ext_flag_t glcommon_require_extension(const char *ext) attr_nonnull_all; void glcommon_setup_attributes(SDL_GLprofile profile, uint major, uint minor, SDL_GLcontextFlag ctxflags); -#if defined(DEBUG) && defined(TAISEI_BUILDCONF_DEBUG_OPENGL) - #define DEBUG_GL_DEFAULT 1 -#else - #define DEBUG_GL_DEFAULT 0 -#endif - struct glext_s { struct { char major; diff --git a/src/renderer/meson.build b/src/renderer/meson.build index 2d2e016f19..badf0823d9 100644 --- a/src/renderer/meson.build +++ b/src/renderer/meson.build @@ -1,23 +1,48 @@ -modules = [ - 'gl33', - 'gles20', - 'gles30', - 'null', -] - -if ['nx', 'emscripten'].contains(host_machine.system()) - forced_renderer = 'gles30' -else - forced_renderer = '' -endif -default_renderer = (forced_renderer == '') ? get_option('r_default') : forced_renderer -static_gles30 = (host_machine.system() == 'emscripten') +subdir('common') + +renderer_opts = { + 'gl33' : get_option('r_gl33').require( + host_machine.system() not in ['nx', 'emscripten'], + error_message : 'OpenGL 3.3 is not supported on this platform'), + 'gles20' : get_option('r_gles20').disable_auto_if(not shader_transpiler_enabled), + 'gles30' : get_option('r_gles30').disable_auto_if( + not (shader_transpiler_enabled or transpile_glsl)), + 'null' : get_option('r_null'), +} + +default_renderer = get_option('r_default') +renderers_prio = ['gl33', 'gles30', 'gles20'] + +if default_renderer == 'auto' + foreach renderer : renderers_prio + if renderer_opts[renderer].allowed() + default_renderer = renderer + break + endif + endforeach + + if default_renderer == 'auto' + renderers_prio_opts = [] + foreach renderer : renderers_prio + renderers_prio_opts + f'r_@renderer@' + endforeach + renderers_prio_opts = ', '.join(renderers_prio_opts) -if forced_renderer == '' and not get_option('r_@0@'.format(default_renderer)) - error('Default renderer \'@0@\' is not enabled. Enable it with -Dr_@0@=true, or set r_default to something else.'.format(default_renderer)) + error('Could not pick a default renderer. ' + + f'Make sure you have at least one of @renderers_prio_opts@ enabled, ' + + 'or force r_default=null if you really mean it.') + endif endif +assert(renderer_opts[default_renderer].allowed(), + f'Default renderer @default_renderer@ is not enabled') + +static_gles30 = ( + renderer_opts['gles30'].allowed() and + host_machine.system() == 'emscripten' +) + renderer_src = files( 'api.c', ) @@ -27,7 +52,6 @@ enabled_renderers = [] # NOTE: Order matters here. subdir('null') -subdir('common') subdir('glcommon') subdir('gl33') subdir('glescommon') @@ -38,15 +62,14 @@ included_deps = [] needed_deps = ['common'] r_macro = [] -foreach m : modules - should_include = (forced_renderer == '') ? get_option('r_@0@'.format(m)) : (m == forced_renderer) - if should_include - renderer_src += get_variable('r_@0@_src'.format(m)) - r_macro += ['R(@0@)'.format(m)] - enabled_renderers += [m] - needed_deps += get_variable('r_@0@_deps'.format(m)) - included_deps += [m] - renderer_deps += get_variable('r_@0@_libdeps'.format(m)) +foreach renderer, ropt : renderer_opts + if ropt.allowed() + renderer_src += get_variable(f'r_@renderer@_src') + r_macro += f'R(@renderer@)' + enabled_renderers += renderer + needed_deps += get_variable(f'r_@renderer@_deps') + included_deps += renderer + renderer_deps += get_variable(f'r_@renderer@_libdeps') endif endforeach @@ -62,9 +85,11 @@ r_macro = ' '.join(r_macro) config.set('TAISEI_BUILDCONF_RENDERER_BACKENDS', r_macro) config.set_quoted('TAISEI_BUILDCONF_RENDERER_DEFAULT', default_renderer) -if angle_enabled - assert( - enabled_renderers.contains('gles30') or enabled_renderers.contains('gles20'), - 'An OpenGL ES renderer is required to use ANGLE. Enable r_gles30 or r_gles20, or disable install_angle.' - ) +have_gles_renderer = ( + renderer_opts['gles30'].allowed() or + renderer_opts['gles20'].allowed()) + +if angle_enabled and not have_gles_renderer + error('An OpenGL ES renderer is required to use ANGLE. ' + + 'Enable r_gles30 or r_gles20, or disable install_angle.') endif diff --git a/src/rwops/meson.build b/src/rwops/meson.build index 9aaceaf23b..698c35e986 100644 --- a/src/rwops/meson.build +++ b/src/rwops/meson.build @@ -11,7 +11,7 @@ rwops_src = files( 'rwops_zstd.c', ) -if taisei_deps.contains(dep_zip) +if dep_zip.found() rwops_src += files( 'rwops_zipfile.c', ) diff --git a/src/util/meson.build b/src/util/meson.build index f1083bf344..a3688bb7bd 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -29,18 +29,8 @@ config.set('TAISEI_BUILDCONF_USE_DESIGNATED_INIT', cc.compiles( args : ['-Wattributes', '-Werror'] )) -use_libcrypto = get_option('use_libcrypto') - -if use_libcrypto == 'auto' - use_libcrypto = dep_crypto.found() -else - use_libcrypto = (use_libcrypto == 'true') -endif - -if use_libcrypto - assert(dep_crypto.found(), 'use_libcrypto forced but libcrypto not found. Install OpenSSL or disable use_libcrypto.') +if dep_crypto.found() util_src += files('sha256_openssl.c') - util_deps += [dep_crypto] else util_src += files('sha256.c') endif diff --git a/src/vfs/meson.build b/src/vfs/meson.build index 5c3b518204..3170fa5f44 100644 --- a/src/vfs/meson.build +++ b/src/vfs/meson.build @@ -14,7 +14,7 @@ vfs_src = files( 'zipfile_public.c', ) -if taisei_deps.contains(dep_zip) +if dep_zip.found() vfs_src += files( 'zipfile.c', 'zippath.c', diff --git a/subprojects/SPIRV-Cross.wrap b/subprojects/SPIRV-Cross.wrap index 8f18da78f4..1e16fa4621 100644 --- a/subprojects/SPIRV-Cross.wrap +++ b/subprojects/SPIRV-Cross.wrap @@ -3,3 +3,6 @@ directory=SPIRV-Cross url=https://github.com/taisei-project/SPIRV-Cross.git push-url=git@github.com:taisei-project/SPIRV-Cross.git revision=meson-2021.01.15 + +[provide] +spirv-cross-c-shared=spirv_cross_dep diff --git a/subprojects/cglm.wrap b/subprojects/cglm.wrap index 1d38836313..700b6fa269 100644 --- a/subprojects/cglm.wrap +++ b/subprojects/cglm.wrap @@ -3,3 +3,6 @@ directory=cglm url=https://github.com/taisei-project/cglm.git push-url=git@github.com:taisei-project/cglm.git revision=taisei-0.8.0 + +[provide] +cglm=cglm_dep diff --git a/subprojects/freetype.wrap b/subprojects/freetype.wrap index 9b07ed939b..482def76b5 100644 --- a/subprojects/freetype.wrap +++ b/subprojects/freetype.wrap @@ -3,3 +3,6 @@ directory=freetype url=https://github.com/taisei-project/freetype2.git push-url=git@github.com:taisei-project/freetype2.git revision=meson-2.10.1 + +[provide] +freetype2=freetype_dep diff --git a/subprojects/libpng.wrap b/subprojects/libpng.wrap index 315d49da0b..c219a1cf02 100644 --- a/subprojects/libpng.wrap +++ b/subprojects/libpng.wrap @@ -3,3 +3,6 @@ directory=libpng url=https://github.com/taisei-project/libpng.git push-url=git@github.com:taisei-project/libpng.git revision=meson-1.6.37 + +[provide] +libpng=png_dep diff --git a/subprojects/libwebp.wrap b/subprojects/libwebp.wrap index 49525d10d8..f6c5d987d2 100644 --- a/subprojects/libwebp.wrap +++ b/subprojects/libwebp.wrap @@ -3,3 +3,7 @@ directory=libwebp url=https://github.com/taisei-project/libwebp.git push-url=git@github.com:taisei-project/libwebp.git revision=meson-1.2.0 + +[provide] +libwebp=webpdecoder_dep +libwebpdecoder=webpdecoder_dep diff --git a/subprojects/libzip.wrap b/subprojects/libzip.wrap index 42a397d4ad..325abbf096 100644 --- a/subprojects/libzip.wrap +++ b/subprojects/libzip.wrap @@ -3,3 +3,6 @@ directory=libzip url=https://github.com/taisei-project/libzip.git push-url=git@github.com:taisei-project/libzip.git revision=meson-1.7.3.142 + +[provide] +libzip=libzip_dep diff --git a/subprojects/opusfile.wrap b/subprojects/opusfile.wrap index 4b9e918a85..c2b56382bc 100644 --- a/subprojects/opusfile.wrap +++ b/subprojects/opusfile.wrap @@ -3,3 +3,6 @@ directory=opusfile url=https://github.com/taisei-project/opusfile.git push-url=git@github.com:taisei-project/opusfile.git revision=meson-0.12 + +[provide] +opusfile=opusfile_dep diff --git a/subprojects/sdl2.wrap b/subprojects/sdl2.wrap index 1a341d6d0d..5a362709d3 100644 --- a/subprojects/sdl2.wrap +++ b/subprojects/sdl2.wrap @@ -3,3 +3,6 @@ directory=sdl2 url=https://github.com/taisei-project/SDL.git push-url=git@github.com:taisei-project/SDL.git revision=meson-2.0.20 + +[provide] +sdl2=sdl2_dep diff --git a/subprojects/shaderc.wrap b/subprojects/shaderc.wrap index 021e9842a5..3c24aa0b7a 100644 --- a/subprojects/shaderc.wrap +++ b/subprojects/shaderc.wrap @@ -3,3 +3,6 @@ directory=shaderc url=https://github.com/taisei-project/shaderc.git push-url=git@github.com:taisei-project/shaderc.git revision=meson-2020.5 + +[provide] +shaderc=shaderc_dep diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap index 4a4f5683ab..dcb6e07e97 100644 --- a/subprojects/zlib.wrap +++ b/subprojects/zlib.wrap @@ -3,3 +3,6 @@ directory=zlib url=https://github.com/taisei-project/zlib.git push-url=git@github.com:taisei-project/zlib.git revision=meson-1.2.11 + +[provide] +zlib=zlib_dep diff --git a/switch/crossfile.sh b/switch/crossfile.sh index 4def80bb33..db1203caeb 100755 --- a/switch/crossfile.sh +++ b/switch/crossfile.sh @@ -33,15 +33,13 @@ pkgconfig = '$(bin_path pkg-config)' elf2nro = '$(which elf2nro)' nacptool = '$(which nacptool)' -[project options] -deprecation_warnings = 'no-error' - [built-in options] c_args = [$(meson_arg_list $CPPFLAGS $CFLAGS)] c_link_args = [$(meson_arg_list $LDFLAGS $LIBS $ADDITIONAL_LINK_FLAGS)] cpp_args = [$(meson_arg_list $CPPFLAGS $CXXFLAGS)] cpp_link_args = [$(meson_arg_list $LDFLAGS $LIBS $ADDITIONAL_LINK_FLAGS)] werror = false +prefer_static = true [host_machine] system = 'nx'