Merge pull request #13796 from keymanapp/maint/meson-versioning-improvements

maint(common): cleanup meson versioning
This commit is contained in:
Marc Durdin 2025-05-02 13:39:47 +07:00 committed by GitHub
commit 43cf66a9d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 75 additions and 46 deletions

View file

@ -115,12 +115,10 @@ builder_describe_outputs \
build:arch /core/build/arch/$BUILDER_CONFIGURATION/src/libkeymancore.a \
build:wasm /core/build/wasm/$BUILDER_CONFIGURATION/src/libkeymancore.a
# Import our standard compiler defines; this is copied from
# /resources/build/meson/standard.meson.build by build.sh, because meson doesn't
# allow us to reference a file outside its root
if builder_has_action configure; then
mkdir -p "$THIS_SCRIPT_PATH/resources"
cp "$KEYMAN_ROOT/resources/build/meson/standard.meson.build" "$THIS_SCRIPT_PATH/resources/meson.build"
# Import our standard compiler defines
source "$KEYMAN_ROOT/resources/build/meson/standard_meson_build.inc.sh"
standard_meson_build
fi
# Iterate through all possible targets; note that targets that cannot be built

View file

@ -1,3 +0,0 @@
@echo off
REM Get the version number from VERSION.md
more ..\VERSION.md

View file

@ -1,3 +0,0 @@
#!/usr/bin/env bash
# Get the version number from VERSION.md
cat ../VERSION.md

View file

@ -6,7 +6,7 @@
#
project('keyman_core', 'cpp', 'c',
version: run_command(find_program('getversion.bat', 'getversion.sh'), check:true).stdout().strip(),
version: files('../VERSION.md'),
license: 'MIT',
default_options : ['buildtype=release',
'cpp_std=c++17',

View file

@ -92,12 +92,10 @@ fi
do_action clean
# Note, we have a 'global' configure and also a per-arch configure
if builder_start_action configure; then
# Import our standard compiler defines; this is copied from
# /resources/build/meson/standard.meson.build by build.sh, because meson doesn't
# allow us to reference a file outside its root
mkdir -p "$THIS_SCRIPT_PATH/resources"
cp "$KEYMAN_ROOT/resources/build/meson/standard.meson.build" "$THIS_SCRIPT_PATH/resources/meson.build"
if builder_has_action configure; then
# Import our standard compiler defines
source "$KEYMAN_ROOT/resources/build/meson/standard_meson_build.inc.sh"
standard_meson_build
# We have to checkout the keyboards repo in a 'configure' action because
# otherwise meson will not get the right list of keyboard source files,
@ -105,8 +103,6 @@ if builder_start_action configure; then
if should_do_full_test; then
checkout_keyboards
fi
builder_finish_action success configure
fi
do_action configure

View file

@ -1,3 +0,0 @@
@echo off
REM Get the version number from VERSION.md
more ..\..\..\VERSION.md

View file

@ -1,4 +0,0 @@
#!/bin/bash
# Get the version number from VERSION.md
VERSIONFILE=../../../VERSION.md
cat $VERSIONFILE

View file

@ -5,7 +5,7 @@
#
project('kmcmplib', 'cpp', 'c',
version: run_command(find_program('getversion.bat', 'getversion.sh'), check: true).stdout().strip(),
version: files('../../../VERSION.md'),
license: 'MIT',
default_options : ['buildtype=release',
'cpp_std=c++14',

View file

@ -45,13 +45,10 @@ else
MESON_COVERAGE=
fi
# Import our standard compiler defines; this is copied from
# /resources/build/meson/standard.meson.build by build.sh, because meson doesn't
# allow us to reference a file outside its root. ${THIS_SCRIPT_PATH}/meson.build
# then includes `resources` as a subdir.
if builder_has_action configure; then
mkdir -p "${THIS_SCRIPT_PATH}/resources"
cp "${KEYMAN_ROOT}/resources/build/meson/standard.meson.build" "${THIS_SCRIPT_PATH}/resources/meson.build"
# Import our standard compiler defines
source "$KEYMAN_ROOT/resources/build/meson/standard_meson_build.inc.sh"
standard_meson_build
fi
configure_action() {

View file

@ -1,5 +1,5 @@
project('ibus-keyman', 'c', 'cpp',
version: run_command('cat', '../../VERSION.md', check: true).stdout().strip(),
version: files('../../VERSION.md'),
license: 'GPL-2+',
meson_version: '>=1.0')

View file

@ -23,12 +23,12 @@ builder_describe \
builder_parse "$@"
# Import our standard compiler defines; this is copied from
# /resources/build/meson/standard.meson.build by build.sh, because meson doesn't
# allow us to reference a file outside its root. ${THIS_SCRIPT_PATH}/meson.build
# then includes `resources` as a subdir.
if builder_has_action configure; then
cp "${KEYMAN_ROOT}/resources/build/meson/standard.meson.build" "${THIS_SCRIPT_PATH}/resources/meson.build"
# Import our standard compiler defines
source "$KEYMAN_ROOT/resources/build/meson/standard_meson_build.inc.sh"
standard_meson_build
# TODO: it would be cleaner to split this from the standard.meson.build file/folder
cat "${THIS_SCRIPT_PATH}/resources/meson.build.in" >> "${THIS_SCRIPT_PATH}/resources/meson.build"
fi

View file

@ -1,5 +1,5 @@
project('keyman-system-service', 'c', 'cpp',
version: run_command('cat', '../../VERSION.md', check: true).stdout().strip(),
version: files('../../VERSION.md'),
license: 'GPL-2+',
meson_version: '>=1.0')

View file

@ -1,5 +1,6 @@
project(
'mcompile', 'c', 'cpp',
version: files('../../../VERSION.md'),
license: 'MIT',
meson_version: '>=1.0',
)

View file

@ -1,4 +1,5 @@
project('mcompile', 'c', 'cpp',
version: files('../../VERSION.md'),
license: 'MIT',
meson_version: '>=1.0')

View file

@ -2,6 +2,7 @@
# This script contains common meson functions
source "$KEYMAN_ROOT/resources/build/meson/standard_meson_build.inc.sh"
# ----------------------------------------------------------------------------
# clean
@ -17,11 +18,8 @@ do_meson_clean() {
# ----------------------------------------------------------------------------
do_meson_configure() {
# Import our standard compiler defines; this is copied from
# /resources/build/meson/standard.meson.build by build.sh, because meson doesn't
# allow us to reference a file outside its root
mkdir -p "$THIS_SCRIPT_PATH/resources"
cp "$KEYMAN_ROOT/resources/build/meson/standard.meson.build" "$THIS_SCRIPT_PATH/resources/meson.build"
# Import our standard compiler defines
standard_meson_build
pushd "$THIS_SCRIPT_PATH" > /dev/null
# Additional arguments are used by Linux build, e.g. -Dprefix=${INSTALLDIR}

View file

@ -4,6 +4,11 @@
# This file has the master location /resources/build/meson/standard.meson.build,
# and is copied into each project's <project>/resources/meson.build in the
# configure step, so that it can be referenced by meson directly.
#
# Use standard_meson_build.inc.sh to make the file copy
#
#
# Where possible, we want to use these flags everywhere
#
@ -26,6 +31,17 @@ message('meson.project_version(): ' + meson.project_version())
message('host_machine.system(): ' + host_machine.system())
message('compiler.get_id(): ' + cpp_compiler.get_id())
#
# Import `VERSION_WITH_TAG` which we can use where appropriate instead of
# meson.project_version() which is only major.minor.patch.
#
fs = import('fs')
if fs.exists('VERSION_WITH_TAG.md')
VERSION_WITH_TAG = fs.read('VERSION_WITH_TAG.md').strip()
message('VERSION_WITH_TAG: ' + VERSION_WITH_TAG)
endif
#
# Standard compiler flags for all platforms
#

View file

@ -0,0 +1,35 @@
#
# Keyman is copyright (C) SIL Global. MIT License.
#
# Created by mcdurdin on 2025-04-30
#
# This import script helps us setup a consistent meson environment across all
# our build scripts. It will generate two files in the calling scripts
# resources/ folder (which should be git-ignored):
#
# * resources/meson.build - a copy of standard.meson.build from this folder
# * resources/VERSION_WITH_TAG.md - the value of the env var $VERSION_WITH_TAG
#
# We do this because meson doesn't allow us to:
#
# * reference a file outside the project root, or
# * read environment variables
#
# Sample of normal usage:
#
# if builder_has_action configure; then
# # Import our standard compiler defines
# source "$KEYMAN_ROOT/resources/build/meson/standard_meson_build.inc.sh"
# standard_meson_build
# fi
#
# ${THIS_SCRIPT_PATH}/meson.build then includes `resources` as a subdir:
#
# subdir('resources')
#
standard_meson_build() {
mkdir -p "$THIS_SCRIPT_PATH/resources"
cp "$KEYMAN_ROOT/resources/build/meson/standard.meson.build" "$THIS_SCRIPT_PATH/resources/meson.build"
echo "$VERSION_WITH_TAG" > "$THIS_SCRIPT_PATH/resources/VERSION_WITH_TAG.md"
}