This repository has been archived on 2025-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
The-Powder-Toy/src/meson.build
Tamás Bálint Misius 7fc3fb4c15
Sort out version info
The idea is to have the following version information included:

 - 1-component save version
   - 2-component under the hood but the minor component shouldn't ever change again
   - see currentVersionMajor in GameSave.cpp
 - 1-component website API version
   - again, currently 2-component because that's what the website code expects
   - see apiVersion in requestmanager/Common.cpp
 - 2-component display version, entirely cosmetic
   - exposed as meson options display_version_major and display_version_minor
   - see APP_VERSION in Config.template.h
 - 1-component business logic version aka build number
   - exposed as meson option build_num
   - see APP_VERSION in Config.template.h
 - variant id aka mod id, tightly coupled with the build number
   - exposed as meson option mod_id
   - see MOD_ID in Config.template.h
 - display and business logic versions repeated for the upstream
   - exposed as meson options upstream_version_major, upstream_version_minor, and upstream_build_num
   - we'll have to update these alongside display_version_major, display_version_minor, and build_num, but mod owners can just merge our changes
   - see UPSTREAM_VERSION in Config.template.h
 - update channel, makes sense in the context of the variant (and yes, this would later enable mod snapshots)
   - currently not exposed as a meson option but derived from meson options snapshot and mod_id
   - see IDENT_RELTYPE in Config.template.h
 - vcs tag aka git commit hash
   - set by build.sh in ghactions workflows
   - see VCS_TAG in VcsTag.tempalte.h

Rather importantly, the save and website API versions are now allowed to change independently of the display version.

These changes also allowed me to remove the ugly sed hacks in build.sh used to provision some manifest files; they are now provisioned by meson.

Also add version info for windows and android.
2023-10-19 12:51:03 +02:00

197 lines
6.0 KiB
Meson

conf_data = configuration_data()
app_id = get_option('app_id')
mod_id = get_option('mod_id')
is_snapshot = get_option('snapshot')
is_beta = get_option('beta')
is_mod = mod_id > 0
conf_data.set('X86', is_x86.to_string())
conf_data.set('BETA', is_beta.to_string())
conf_data.set('MOD_ID', mod_id)
conf_data.set('DEBUG', is_debug.to_string())
conf_data.set('MOD', is_mod.to_string())
conf_data.set('SNAPSHOT', is_snapshot.to_string())
conf_data.set('SNAPSHOT_ID', get_option('snapshot_id'))
conf_data.set('DISPLAY_VERSION_MAJOR', get_option('display_version_major'))
conf_data.set('DISPLAY_VERSION_MINOR', get_option('display_version_minor'))
conf_data.set('BUILD_NUM', get_option('build_num'))
conf_data.set('UPSTREAM_VERSION_MAJOR', get_option('upstream_version_major'))
conf_data.set('UPSTREAM_VERSION_MINOR', get_option('upstream_version_minor'))
conf_data.set('UPSTREAM_BUILD_NUM', get_option('upstream_build_num'))
conf_data.set('MANIFEST_COPYRIGHT', get_option('manifest_copyright'))
conf_data.set('MANIFEST_MACOS_MIN_VER', get_option('manifest_macos_min_ver'))
conf_data.set('MANIFEST_DATE', get_option('manifest_date'))
conf_data.set('ALLOW_FAKE_NEWER_VERSION', (is_snapshot or is_beta or is_debug or is_mod).to_string())
conf_data.set('IDENT_PLATFORM', ident_platform)
conf_data.set('IDENT', '@0@-@1@-@2@'.format(host_arch, host_platform, host_libc).to_upper())
update_server = get_option('update_server')
conf_data.set('UPDATESERVER', update_server)
conf_data.set('USE_UPDATESERVER', (update_server != '').to_string())
enforce_https = get_option('enforce_https')
allow_quit = true
force_window_frame_ops = 'forceWindowFrameOpsNone'
allow_data_folder = true
if host_platform == 'emscripten'
allow_quit = false
force_window_frame_ops = 'forceWindowFrameOpsEmbedded'
allow_data_folder = false
endif
default_touch_ui = false
if host_platform == 'android'
default_touch_ui = true # TODO: some more sophisticated heuristic at runtime instead
force_window_frame_ops = 'forceWindowFrameOpsHandheld'
endif
secure_ciphers_only = get_option('secure_ciphers_only')
if not is_debug and not enforce_https
error('refusing to build a release binary without enforcing HTTPS, configure with -Denforce_https=true to fix this error')
endif
conf_data.set('ALLOW_QUIT', allow_quit.to_string())
conf_data.set('FORCE_WINDOW_FRAME_OPS', force_window_frame_ops)
conf_data.set('DEFAULT_TOUCH_UI', default_touch_ui.to_string())
conf_data.set('ALLOW_DATA_FOLDER', allow_data_folder.to_string())
conf_data.set('ENFORCE_HTTPS', enforce_https.to_string())
conf_data.set('SECURE_CIPHERS_ONLY', secure_ciphers_only.to_string())
conf_data.set('IGNORE_UPDATES', get_option('ignore_updates').to_string())
conf_data.set('SERVER', get_option('server'))
conf_data.set('STATICSERVER', get_option('static_server'))
conf_data.set('APPNAME', get_option('app_name'))
conf_data.set('APPCOMMENT', get_option('app_comment'))
conf_data.set('APPEXE', app_exe)
conf_data.set('APPID', app_id)
conf_data.set('APPDATA', get_option('app_data'))
conf_data.set('APPVENDOR', get_option('app_vendor'))
if host_platform == 'android'
android_permissions = [
'<uses-permission android:name="android.permission.VIBRATE" />',
]
if enable_http
android_permissions += [
'<uses-permission android:name="android.permission.INTERNET" />',
]
endif
android_properties = []
if is_debug
android_properties += [ 'android:debuggable="true"' ]
endif
conf_data.set('ANDROID_PERMISSIONS', '\n'.join(android_permissions))
conf_data.set('ANDROID_PROPERTIES', '\n'.join(android_properties))
endif
powder_files = files(
'SDLCompat.cpp',
'PowderToySDL.cpp',
'PowderToy.cpp',
'lua/CommandInterface.cpp',
'lua/TPTScriptInterface.cpp',
'lua/TPTSTypes.cpp',
)
if host_platform == 'emscripten'
powder_files += files(
'PowderToySDLEmscripten.cpp',
)
else
powder_files += files(
'PowderToySDLCommon.cpp',
)
endif
if is_x86
powder_files += files('X86KillDenormals.cpp')
endif
render_files = files(
'PowderToyRenderer.cpp',
)
font_files = files(
'PowderToyFontEditor.cpp',
'PowderToySDL.cpp',
'PowderToySDLCommon.cpp',
)
common_files = files(
'Format.cpp',
'Misc.cpp',
'Probability.cpp',
)
resolve_vcs_tag = get_option('resolve_vcs_tag')
if resolve_vcs_tag == 'yes' or (resolve_vcs_tag == 'static_release_only' and not is_debug and is_static)
common_files += vcs_tag(
input: 'VcsTag.template.h',
output: 'VcsTag.h',
fallback: 'unknown',
)
else
vcs_tag_conf_data = configuration_data()
vcs_tag_conf_data.set('VCS_TAG', '')
configure_file(
input: 'VcsTag.template.h',
output: 'VcsTag.h',
configuration: vcs_tag_conf_data
)
endif
if host_platform == 'linux'
powder_files += files('WindowIcon.cpp')
font_files += files('WindowIcon.cpp')
endif
subdir('bson')
subdir('bzip2')
subdir('client')
subdir('common')
subdir('debug')
subdir('graphics')
subdir('gui')
if lua_variant != 'none'
subdir('lua')
conf_data.set('LUACONSOLE', 'true')
else
powder_files += files(
'lua/PlainCommandInterface.cpp',
)
conf_data.set('LUACONSOLE', 'false')
endif
subdir('prefs')
subdir('resampler')
subdir('simulation')
subdir('tasks')
powder_files += common_files
render_files += common_files
font_files += common_files
simulation_elem_defs = []
foreach elem_name_id : simulation_elem_ids
simulation_elem_defs += 'ELEMENT_DEFINE(' + elem_name_id[0] + ', ' + elem_name_id[1].to_string() + ');'
endforeach
elements_conf_data = configuration_data()
elements_conf_data.set('element_defs', '\n'.join(simulation_elem_defs))
configure_file(
input: 'simulation/ElementNumbers.template.h',
output: 'ElementNumbers.h',
configuration: elements_conf_data
)
simulation_tool_defs = []
foreach tool_name_id : simulation_tool_ids
simulation_tool_defs += 'TOOL_DEFINE(' + tool_name_id[0] + ', ' + tool_name_id[1].to_string() + ');'
endforeach
tools_conf_data = configuration_data()
tools_conf_data.set('tool_defs', '\n'.join(simulation_tool_defs))
configure_file(
input: 'simulation/ToolNumbers.template.h',
output: 'ToolNumbers.h',
configuration: tools_conf_data
)
configure_file(
input: 'Config.template.h',
output: 'Config.h',
configuration: conf_data
)