diff options
32 files changed, 572 insertions, 151 deletions
diff --git a/.github/workflows/ci_frameworks.yml b/.github/workflows/ci_frameworks.yml deleted file mode 100644 index 1ace2a6..0000000 --- a/.github/workflows/ci_frameworks.yml +++ /dev/null @@ -1,86 +0,0 @@ -name: ci_frameworks - -on: - push: - paths: - - "mesonbuild/dependencies/**" - - "test cases/frameworks/**" - - ".github/workflows/ci_frameworks.yml" - pull_request: - paths: - - "mesonbuild/dependencies/**" - - "test cases/frameworks/**" - - ".github/workflows/ci_frameworks.yml" - -jobs: - - scalapackMacOS: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - run: python -m pip install -e . - - run: brew install pkg-config ninja gcc openmpi lapack scalapack - - run: meson setup "test cases/frameworks/30 scalapack" build - - run: meson compile -C build - - uses: actions/upload-artifact@v1 - if: failure() - with: - name: Scalapack_Mac_build - path: build/meson-logs/meson-log.txt - - run: meson test -C build -v - - uses: actions/upload-artifact@v1 - if: failure() - with: - name: Scalapack_Mac_test - path: build/meson-logs/testlog.txt - - HDF5macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - run: python -m pip install -e . - - run: brew install pkg-config ninja gcc hdf5 - - run: meson setup "test cases/frameworks/25 hdf5" build -Dmethod=config-tool - - run: meson compile -C build - - uses: actions/upload-artifact@v1 - if: failure() - with: - name: HDF5_Mac_build - path: build/meson-logs/meson-log.txt - - run: meson test -C build -v - - uses: actions/upload-artifact@v1 - if: failure() - with: - name: HDF5_Mac_test - path: build/meson-logs/testlog.txt - - Qt4macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - run: python -m pip install -e . - - run: brew install pkg-config ninja gcc - - run: brew tap cartr/qt4 - - run: brew install qt@4 - - run: meson setup "test cases/frameworks/4 qt" build -Drequired=qt4 - - run: meson compile -C build - - uses: actions/upload-artifact@v1 - if: failure() - with: - name: Qt4_Mac_build - path: build/meson-logs/meson-log.txt - - run: meson test -C build -v - - uses: actions/upload-artifact@v1 - if: failure() - with: - name: Qt4_Mac_test - path: build/meson-logs/testlog.txt diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..bf559e8 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,85 @@ +name: macos + +on: + push: + paths: + - "mesonbuild/**" + - "test cases/**" + - ".github/workflows/macos.yml" + pull_request: + paths: + - "mesonbuild/**" + - "test cases/**" + - ".github/workflows/macos.yml" + +jobs: + unittests-appleclang: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.x' + - run: | + python -m pip install --upgrade pip + python -m pip install pytest pytest-xdist jsonschema + - run: brew install pkg-config ninja llvm qt + - env: + CPPFLAGS: "-I/usr/local/include" + LDFLAGS: "-L/usr/local/lib" + MESON_UNIT_TEST_BACKEND: ninja + # These cannot evaluate anything, so we cannot set PATH or SDKROOT here + run: | + export SDKROOT="$(xcodebuild -version -sdk macosx Path)" + export PATH="$HOME/tools:/usr/local/opt/qt/bin:$PATH:$(brew --prefix llvm)/bin" + ./run_unittests.py + + project-tests-appleclang: + runs-on: macos-latest + strategy: + matrix: + unity: ["on", "off"] + steps: + - uses: actions/checkout@v2 + # use python3 from homebrew because it is a valid framework, unlike the actions one: + # https://github.com/actions/setup-python/issues/58 + - run: brew install pkg-config ninja llvm qt boost ldc hdf5 openmpi lapack scalapack sdl2 python3 + - run: | + python3 -m pip install --upgrade setuptools + python3 -m pip install --upgrade pip + python3 -m pip install cython + - env: + CPPFLAGS: "-I/usr/local/include" + LDFLAGS: "-L/usr/local/lib" + MESON_ARGS: --unity=${{ matrix.unity }} + CI: 1 + # These cannot evaluate anything, so we cannot set PATH or SDKROOT here + run: | + export SDKROOT="$(xcodebuild -version -sdk macosx Path)" + export PATH="$HOME/tools:/usr/local/opt/qt/bin:$PATH:$(brew --prefix llvm)/bin" + ./run_project_tests.py --backend=ninja + + Qt4macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.x' + - run: python -m pip install -e . + - run: brew install pkg-config ninja gcc + - run: brew tap cartr/qt4 + - run: brew install qt@4 + - run: meson setup "test cases/frameworks/4 qt" build -Drequired=qt4 + - run: meson compile -C build + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: Qt4_Mac_build + path: build/meson-logs/meson-log.txt + - run: meson test -C build -v + - uses: actions/upload-artifact@v1 + if: failure() + with: + name: Qt4_Mac_test + path: build/meson-logs/testlog.txt diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml index 57a3f52..642e1de 100644 --- a/.github/workflows/msys2.yml +++ b/.github/workflows/msys2.yml @@ -2,7 +2,15 @@ name: msys2 on: push: + paths: + - "mesonbuild/**" + - "test cases/**" + - ".github/workflows/msys.yml" pull_request: + paths: + - "mesonbuild/**" + - "test cases/**" + - ".github/workflows/msys.yml" jobs: test: @@ -83,4 +91,4 @@ jobs: - uses: actions/upload-artifact@v2 with: name: ${{ matrix.NAME }} - path: meson-test-run.*
\ No newline at end of file + path: meson-test-run.* diff --git a/.travis.yml b/.travis.yml index ab317be..9f61c96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ branches: os: - linux - - osx compiler: - gcc @@ -25,10 +24,6 @@ services: - docker matrix: - exclude: - # On OS X gcc is just a wrapper around clang, so don't waste time testing that - - os: osx - compiler: gcc include: # Test cross builds separately, they do not use the global compiler # Also hijack one cross build to test long commandline handling codepath (and avoid overloading Travis) diff --git a/ci/travis_install.sh b/ci/travis_install.sh index d9d308a..bbeb100 100755 --- a/ci/travis_install.sh +++ b/ci/travis_install.sh @@ -4,19 +4,6 @@ set -e msg() { echo -e "\x1b[1;32mINFO: \x1b[37m$*\x1b[0m"; } -if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - msg "Running OSX setup" - brew update - # Run one macOS build with pkg-config available (pulled in by qt), and the - # other (unity=on) without pkg-config - brew install qt ldc llvm ninja - if [[ "$MESON_ARGS" =~ .*unity=on.* ]]; then - which pkg-config && rm -f $(which pkg-config) - fi - python3 -m pip install jsonschema -elif [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - msg "Running Linux setup" - docker pull mesonbuild/eoan -fi - +msg "Running Linux setup" +docker pull mesonbuild/eoan msg "Setup finished" diff --git a/ci/travis_script.sh b/ci/travis_script.sh index 7e26b52..e60e3a3 100755 --- a/ci/travis_script.sh +++ b/ci/travis_script.sh @@ -4,16 +4,15 @@ set -e msg() { echo -e "\x1b[1;32mINFO: \x1b[37m$*\x1b[0m"; } -if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - # TODO enable coverage - #curl -s https://codecov.io/bash > upload.sh - #chmod +x upload.sh +# TODO enable coverage +#curl -s https://codecov.io/bash > upload.sh +#chmod +x upload.sh - # We need to copy the current checkout inside the Docker container, - # because it has the MR id to be tested checked out. +# We need to copy the current checkout inside the Docker container, +# because it has the MR id to be tested checked out. - msg "Generating runner:" - cat <<EOF | tee run.sh +msg "Generating runner:" +cat <<EOF | tee run.sh #!/bin/bash set -e @@ -50,23 +49,9 @@ ADD . /root EOF - msg "Building the docker image..." - docker build -t test_img . - - msg "Start running tests" - #ci_env=`bash <(curl -s https://codecov.io/env)` - docker run --security-opt seccomp:unconfined test_img /root/run.sh - -elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - # Ensure that llvm is added after $PATH, otherwise the clang from that llvm install will be used instead of the native apple clang. - export SDKROOT=$(xcodebuild -version -sdk macosx Path) - export CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib - export OBJC=$CC - export OBJCXX=$CXX - export PATH=$HOME/tools:/usr/local/opt/qt/bin:$PATH:$(brew --prefix llvm)/bin - if test "$MESON_RSP_THRESHOLD" != "" - then - export MESON_RSP_THRESHOLD=$MESON_RSP_THRESHOLD - fi - ./run_tests.py $RUN_TESTS_ARGS --backend=ninja -- $MESON_ARGS -fi +msg "Building the docker image..." +docker build -t test_img . + +msg "Start running tests" +#ci_env=`bash <(curl -s https://codecov.io/env)` +docker run --security-opt seccomp:unconfined test_img /root/run.sh diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 3af78ef..aeaeccb 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -2409,6 +2409,12 @@ page](Configuration.md) It has three methods: - `has(varname)`: returns `true` if the specified variable is set +- `keys()`*(since 0.57.0)*: returns an array of keys of + the configuration data object. + + You can iterate over this array with the [`foreach` + statement](Syntax.md#foreach-statements). + - `merge_from(other)` *(since 0.42.0)*: takes as argument a different configuration data object and copies all entries from that object to the current. diff --git a/docs/markdown/snippets/keys_of_configuration_data.md b/docs/markdown/snippets/keys_of_configuration_data.md new file mode 100644 index 0000000..c0cbfc2 --- /dev/null +++ b/docs/markdown/snippets/keys_of_configuration_data.md @@ -0,0 +1,4 @@ +## Get keys of configuration data object + +All keys of the `configuration_data` object can be obtained with the `keys()` +method as an alphabetically sorted array. diff --git a/docs/markdown/snippets/thinlto.md b/docs/markdown/snippets/thinlto.md index ac242a8..44bc972 100644 --- a/docs/markdown/snippets/thinlto.md +++ b/docs/markdown/snippets/thinlto.md @@ -23,5 +23,5 @@ if get_option('b_lto') == 'true' endif ``` -This should not affect any comman line invocations as configuring LTO +This should not affect any command line invocations as configuring LTO with `-Db_lto=true` still works and behaves the same way as before. diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 09f06da..1ed742b 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -266,7 +266,7 @@ class NinjaRule: # expand variables in command command = ' '.join([self._quoter(x) for x in self.command + self.args]) estimate = len(command) - for m in re.finditer(r'(\${\w*}|\$\w*)?[^$]*', command): + for m in re.finditer(r'(\${\w+}|\$\w+)?[^$]*', command): if m.start(1) != -1: estimate -= m.end(1) - m.start(1) + 1 chunk = m.group(1) @@ -1494,6 +1494,10 @@ int dummy; # Rust compiler takes only the main file as input and # figures out what other files are needed via import # statements and magic. + base_proxy = self.get_base_options_for_target(target) + args = rustc.compiler_args() + # Compiler args for compiling this target + args += compilers.get_base_compile_args(base_proxy, rustc) main_rust_file = None for i in target.get_sources(): if not rustc.can_compile(i): @@ -1503,7 +1507,6 @@ int dummy; if main_rust_file is None: raise RuntimeError('A Rust target has no Rust sources. This is weird. Also a bug. Please report') target_name = os.path.join(target.subdir, target.get_filename()) - args = ['--crate-type'] if isinstance(target, build.Executable): cratetype = 'bin' elif hasattr(target, 'rust_crate_type'): @@ -1514,7 +1517,7 @@ int dummy; cratetype = 'rlib' else: raise InvalidArguments('Unknown target type for rustc.') - args.append(cratetype) + args.extend(['--crate-type', cratetype]) # If we're dynamically linking, add those arguments # diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index 469859b..1be0cd8 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -17,7 +17,7 @@ import textwrap import typing as T from .. import coredata -from ..mesonlib import EnvironmentException, MachineChoice, Popen_safe +from ..mesonlib import EnvironmentException, MachineChoice, MesonException, Popen_safe from .compilers import Compiler, rust_buildtype_args, clike_debug_args if T.TYPE_CHECKING: @@ -52,6 +52,9 @@ class RustCompiler(Compiler): linker=linker) self.exe_wrapper = exe_wrapper self.id = 'rustc' + self.base_options.append('b_colorout') + if 'link' in self.linker.id: + self.base_options.append('b_vscrt') def needs_static_linker(self) -> bool: return False @@ -141,3 +144,12 @@ class RustCompiler(Compiler): if std.value != 'none': args.append('--edition=' + std.value) return args + + def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]: + # Rust handles this for us, we don't need to do anything + return [] + + def get_colorout_args(self, colortype: str) -> T.List[str]: + if colortype in {'always', 'never', 'auto'}: + return [f'--color={colortype}'] + raise MesonException(f'Invalid color type for rust {colortype}') diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 3a5f5f8..87518e1 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -869,9 +869,13 @@ class PkgConfigDependency(ExternalDependency): def _set_libs(self): env = None - libcmd = [self.name, '--libs'] + libcmd = ['--libs'] + if self.static: libcmd.append('--static') + + libcmd.append(self.name) + # Force pkg-config to output -L fields even if they are system # paths so we can do manual searching with cc.find_library() later. env = os.environ.copy() diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 28ac74f..138f6f8 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -308,6 +308,7 @@ class ConfigurationDataHolder(MutableInterpreterObject, ObjectHolder): 'set_quoted': self.set_quoted_method, 'has': self.has_method, 'get': self.get_method, + 'keys': self.keys_method, 'get_unquoted': self.get_unquoted_method, 'merge_from': self.merge_from_method, }) @@ -401,6 +402,10 @@ class ConfigurationDataHolder(MutableInterpreterObject, ObjectHolder): def get(self, name): return self.held_object.values[name] # (val, desc) + @FeatureNew('configuration_data.keys()', '0.57.0') + def keys_method(self, args, kwargs): + return sorted(self.keys()) + def keys(self): return self.held_object.values.keys() @@ -3170,6 +3175,8 @@ external dependencies (including libraries) must go to "dependencies".''') self.build.project_name = proj_name self.active_projectname = proj_name self.project_version = kwargs.get('version', 'undefined') + if not isinstance(self.project_version, str): + raise InvalidCode('The version keyword argument must be a string.') if self.build.project_version is None: self.build.project_version = self.project_version proj_license = mesonlib.stringlistify(kwargs.get('license', 'unknown')) @@ -4636,7 +4643,11 @@ different subdirectory. self.add_project_arguments(node, self.build.projects_link_args[for_machine], args, kwargs) def warn_about_builtin_args(self, args): - warnargs = ('/W1', '/W2', '/W3', '/W4', '/Wall', '-Wall', '-Wextra', '-Wpedantic') + # -Wpedantic is deliberately not included, since some people want to use it but not use -Wextra + # see e.g. + # https://github.com/mesonbuild/meson/issues/3275#issuecomment-641354956 + # https://github.com/mesonbuild/meson/issues/3742 + warnargs = ('/W1', '/W2', '/W3', '/W4', '/Wall', '-Wall', '-Wextra') optargs = ('-O0', '-O2', '-O3', '-Os', '/O1', '/O2', '/Os') for arg in args: if arg in warnargs: diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 2d32328..9fd31c7 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -554,15 +554,16 @@ class GnomeModule(ExtensionModule): else: # Because of https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/72 # we can't use the full path until this is merged. + libpath = os.path.join(girtarget.get_subdir(), girtarget.get_filename()) if isinstance(girtarget, build.SharedLibrary): + # need to put our output directory first as we need to use the + # generated libraries instead of any possibly installed system/prefix + # ones. + ret += ["-L@BUILD_ROOT@/{}".format(os.path.dirname(libpath))] libname = girtarget.get_basename() else: - libname = os.path.join("@PRIVATE_OUTDIR_ABS_%s@" % girtarget.get_id(), girtarget.get_filename()) + libname = os.path.join("@BUILD_ROOT@/{}".format(libpath)) ret += ['--library', libname] - # need to put our output directory first as we need to use the - # generated libraries instead of any possibly installed system/prefix - # ones. - ret += ["-L@PRIVATE_OUTDIR_ABS_%s@" % girtarget.get_id()] # Needed for the following binutils bug: # https://github.com/mesonbuild/meson/issues/1911 # However, g-ir-scanner does not understand -Wl,-rpath diff --git a/run_project_tests.py b/run_project_tests.py index e4a458e..8bf6437 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -870,6 +870,10 @@ def skippable(suite, test): if test.endswith('15 llvm'): return True + # This test breaks with gobject-introspection <= 1.58.1 + if test.endswith('34 gir static lib'): + return True + # No frameworks test should be skipped on linux CI, as we expect all # prerequisites to be installed if mesonlib.is_linux(): diff --git a/run_unittests.py b/run_unittests.py index f0c2f65..97110bc 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from mesonbuild.compilers.objc import AppleClangObjCCompiler import time import stat import subprocess @@ -885,11 +886,11 @@ class InternalTests(unittest.TestCase): def fake_call_pkgbin(self, args, env=None): if '--libs' not in args: return 0, '', '' - if args[0] == 'foo': + if args[-1] == 'foo': return 0, '-L{} -lfoo -L{} -lbar'.format(p2.as_posix(), p1.as_posix()), '' - if args[0] == 'bar': + if args[-1] == 'bar': return 0, '-L{} -lbar'.format(p2.as_posix()), '' - if args[0] == 'internal': + if args[-1] == 'internal': return 0, '-L{} -lpthread -lm -lc -lrt -ldl'.format(p1.as_posix()), '' old_call = PkgConfigDependency._call_pkgbin @@ -7334,6 +7335,11 @@ c = ['{0}'] with mock.patch.dict(os.environ, {envvar: name}): env = get_fake_env() comp = getattr(env, 'detect_{}_compiler'.format(lang))(MachineChoice.HOST) + if isinstance(comp, (mesonbuild.compilers.AppleClangCCompiler, + mesonbuild.compilers.AppleClangCPPCompiler, + mesonbuild.compilers.AppleClangObjCCompiler, + mesonbuild.compilers.AppleClangObjCPPCompiler)): + raise unittest.SkipTest('AppleClang is currently only supported with ld64') if lang != 'rust' and comp.use_linker_args('bfd') == []: raise unittest.SkipTest( 'Compiler {} does not support using alternative linkers'.format(comp.id)) diff --git a/test cases/common/14 configure file/meson.build b/test cases/common/14 configure file/meson.build index f40dc52..f7e0eeb 100644 --- a/test cases/common/14 configure file/meson.build +++ b/test cases/common/14 configure file/meson.build @@ -10,6 +10,7 @@ conf.set('BE_TRUE', true) assert(conf.get('var') == 'mystring', 'Get function is not working.') assert(conf.get('var', 'default') == 'mystring', 'Get function is not working.') assert(conf.get('notthere', 'default') == 'default', 'Default value getting is not working.') +assert(conf.keys() == ['BE_TRUE', 'other', 'second', 'var'], 'Keys function is not working') cfile = configure_file(input : 'config.h.in', output : 'config.h', diff --git a/test cases/common/231 external project/libfoo/configure b/test cases/common/231 external project/libfoo/configure index a867b48..0e4aa72 100755 --- a/test cases/common/231 external project/libfoo/configure +++ b/test cases/common/231 external project/libfoo/configure @@ -27,7 +27,7 @@ case $i in esac done -DEP_ARGS=$(pkg-config somelib --cflags --libs) +DEP_ARGS=$(pkg-config --cflags --libs somelib) cat > Makefile << EOL all: libfoo.$LIBEXT diff --git a/test cases/common/28 multiline string/meson.build b/test cases/common/28 multiline string/meson.build index 9cec114..a87d29a 100644 --- a/test cases/common/28 multiline string/meson.build +++ b/test cases/common/28 multiline string/meson.build @@ -26,6 +26,8 @@ endif cc = meson.get_compiler('c') prog = ''' +#include <stdio.h> + int main(void) { int num = 1; printf("%d\n", num); diff --git a/test cases/frameworks/34 gir static lib/meson.build b/test cases/frameworks/34 gir static lib/meson.build new file mode 100644 index 0000000..d7ab9bf --- /dev/null +++ b/test cases/frameworks/34 gir static lib/meson.build @@ -0,0 +1,18 @@ +project('gobject-introspection-static-helper', 'c') + +gir = find_program('g-ir-scanner', required: false) +if not gir.found() + error('MESON_SKIP_TEST g-ir-scanner not found.') +endif + +gobject_introspection = dependency('gobject-introspection-1.0') +# This won't work without https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/72 +if gobject_introspection.version().version_compare('< 1.58.1') + error('MESON_SKIP_TEST gobject-introspection is too old to support static libraries') +endif + +gnome = import('gnome') +gobj = dependency('gobject-2.0') + +subdir('statichelper') +subdir('subdir/gir') diff --git a/test cases/frameworks/34 gir static lib/statichelper/meson-sample.c b/test cases/frameworks/34 gir static lib/statichelper/meson-sample.c new file mode 100644 index 0000000..2ed9cdf --- /dev/null +++ b/test cases/frameworks/34 gir static lib/statichelper/meson-sample.c @@ -0,0 +1,126 @@ +#include "meson-sample.h" + +typedef struct _MesonSamplePrivate +{ + gchar *msg; +} MesonSamplePrivate; + + +G_DEFINE_TYPE_WITH_PRIVATE (MesonSample, meson_sample, G_TYPE_OBJECT) + +enum { + PROP_0, + PROP_MSG, + LAST_PROP +}; + +static GParamSpec *gParamSpecs [LAST_PROP]; + +/** + * meson_sample_new: + * @msg: The message to set. + * + * Allocates a new #MesonSample. + * + * Returns: (transfer full): a #MesonSample. + */ +MesonSample * +meson_sample_new (const gchar *msg) +{ + g_return_val_if_fail (msg != NULL, NULL); + + return g_object_new (MESON_TYPE_SAMPLE, + "message", msg, + NULL); +} + +static void +meson_sample_finalize (GObject *object) +{ + MesonSamplePrivate *priv = meson_sample_get_instance_private ((MesonSample *) object); + + g_clear_pointer (&priv->msg, g_free); + + G_OBJECT_CLASS (meson_sample_parent_class)->finalize (object); +} + +static void +meson_sample_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + MesonSamplePrivate *priv = meson_sample_get_instance_private ((MesonSample *) object); + + switch (prop_id) + { + case PROP_MSG: + g_value_set_string (value, priv->msg); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +meson_sample_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + MesonSamplePrivate *priv = meson_sample_get_instance_private ((MesonSample *) object); + + switch (prop_id) + { + case PROP_MSG: + priv->msg = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +meson_sample_class_init (MesonSampleClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = meson_sample_finalize; + object_class->get_property = meson_sample_get_property; + object_class->set_property = meson_sample_set_property; + + gParamSpecs [PROP_MSG] = + g_param_spec_string ("message", + "Message", + "The message to print.", + NULL, + (G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_properties (object_class, LAST_PROP, gParamSpecs); +} + +static void +meson_sample_init (MesonSample *self) +{ +} + +/** + * meson_sample_print_message: + * @self: a #MesonSample. + * + * Prints the message. + * + */ +void +meson_sample_print_message (MesonSample *self) +{ + MesonSamplePrivate *priv; + + g_return_if_fail (MESON_IS_SAMPLE (self)); + + priv = meson_sample_get_instance_private (self); + + g_print ("Message: %s\n", priv->msg); +} diff --git a/test cases/frameworks/34 gir static lib/statichelper/meson-sample.h.in b/test cases/frameworks/34 gir static lib/statichelper/meson-sample.h.in new file mode 100644 index 0000000..d0ab29e --- /dev/null +++ b/test cases/frameworks/34 gir static lib/statichelper/meson-sample.h.in @@ -0,0 +1,22 @@ +#ifndef MESON_SAMPLE_H +#define MESON_SAMPLE_H + +#include <@HEADER@> + +G_BEGIN_DECLS + +#define MESON_TYPE_SAMPLE (meson_sample_get_type()) + +G_DECLARE_DERIVABLE_TYPE (MesonSample, meson_sample, MESON, SAMPLE, GObject) + +struct _MesonSampleClass { + GObjectClass parent_class; +}; + + +MesonSample *meson_sample_new (const gchar *msg); +void meson_sample_print_message (MesonSample *self); + +G_END_DECLS + +#endif /* MESON_SAMPLE_H */ diff --git a/test cases/frameworks/34 gir static lib/statichelper/meson.build b/test cases/frameworks/34 gir static lib/statichelper/meson.build new file mode 100644 index 0000000..a815372 --- /dev/null +++ b/test cases/frameworks/34 gir static lib/statichelper/meson.build @@ -0,0 +1,22 @@ +conf = configuration_data() +conf.set('HEADER', 'glib-object.h') + +meson_sample_header = configure_file( + input : 'meson-sample.h.in', + output : 'meson-sample.h', + configuration : conf) + +statichelper_sources = files('meson-sample.c') + [meson_sample_header] + +statichelper_lib = static_library( + 'statichelper', + sources : statichelper_sources, + dependencies : gobj, +) + +statichelper_inc = include_directories('.') +statichelper_dep = declare_dependency( + link_with: statichelper_lib, + dependencies : gobj, + include_directories : [statichelper_inc], +) diff --git a/test cases/frameworks/34 gir static lib/subdir/gir/meson-subsample.c b/test cases/frameworks/34 gir static lib/subdir/gir/meson-subsample.c new file mode 100644 index 0000000..2d58a10 --- /dev/null +++ b/test cases/frameworks/34 gir static lib/subdir/gir/meson-subsample.c @@ -0,0 +1,124 @@ +#include "meson-subsample.h" + +struct _MesonSubSample +{ + MesonSample parent_instance; + + gchar *msg; +}; + +G_DEFINE_TYPE (MesonSubSample, meson_sub_sample, MESON_TYPE_SAMPLE) + +enum { + PROP_0, + PROP_MSG, + LAST_PROP +}; + +static GParamSpec *gParamSpecs [LAST_PROP]; + +/** + * meson_sub_sample_new: + * @msg: The message to set. + * + * Allocates a new #MesonSubSample. + * + * Returns: (transfer full): a #MesonSubSample. + */ +MesonSubSample * +meson_sub_sample_new (const gchar *msg) +{ + g_return_val_if_fail (msg != NULL, NULL); + + return g_object_new (MESON_TYPE_SUB_SAMPLE, + "message", msg, + NULL); +} + +static void +meson_sub_sample_finalize (GObject *object) +{ + MesonSubSample *self = (MesonSubSample *)object; + + g_clear_pointer (&self->msg, g_free); + + G_OBJECT_CLASS (meson_sub_sample_parent_class)->finalize (object); +} + +static void +meson_sub_sample_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + MesonSubSample *self = MESON_SUB_SAMPLE (object); + + switch (prop_id) + { + case PROP_MSG: + g_value_set_string (value, self->msg); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +meson_sub_sample_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + MesonSubSample *self = MESON_SUB_SAMPLE (object); + + switch (prop_id) + { + case PROP_MSG: + self->msg = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +meson_sub_sample_class_init (MesonSubSampleClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = meson_sub_sample_finalize; + object_class->get_property = meson_sub_sample_get_property; + object_class->set_property = meson_sub_sample_set_property; + + gParamSpecs [PROP_MSG] = + g_param_spec_string ("message", + "Message", + "The message to print.", + NULL, + (G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_properties (object_class, LAST_PROP, gParamSpecs); +} + +static void +meson_sub_sample_init (MesonSubSample *self) +{ +} + +/** + * meson_sub_sample_print_message: + * @self: a #MesonSubSample. + * + * Prints the message. + * + * Returns: Nothing. + */ +void +meson_sub_sample_print_message (MesonSubSample *self) +{ + g_return_if_fail (MESON_IS_SUB_SAMPLE (self)); + + g_print ("Message: %s\n", self->msg); +} diff --git a/test cases/frameworks/34 gir static lib/subdir/gir/meson-subsample.h b/test cases/frameworks/34 gir static lib/subdir/gir/meson-subsample.h new file mode 100644 index 0000000..9d34a08 --- /dev/null +++ b/test cases/frameworks/34 gir static lib/subdir/gir/meson-subsample.h @@ -0,0 +1,17 @@ +#ifndef MESON_SUB_SAMPLE_H +#define MESON_SUB_SAMPLE_H + +#include <glib-object.h> +#include <meson-sample.h> + +G_BEGIN_DECLS + +#define MESON_TYPE_SUB_SAMPLE (meson_sub_sample_get_type()) + +G_DECLARE_FINAL_TYPE (MesonSubSample, meson_sub_sample, MESON, SUB_SAMPLE, MesonSample) + +MesonSubSample *meson_sub_sample_new (const gchar *msg); + +G_END_DECLS + +#endif /* MESON_SUB_SAMPLE_H */ diff --git a/test cases/frameworks/34 gir static lib/subdir/gir/meson.build b/test cases/frameworks/34 gir static lib/subdir/gir/meson.build new file mode 100644 index 0000000..b26f04e --- /dev/null +++ b/test cases/frameworks/34 gir static lib/subdir/gir/meson.build @@ -0,0 +1,28 @@ +libsources = ['meson-subsample.c', 'meson-subsample.h'] + +girlib = shared_library( + 'girlib', + sources : libsources, + dependencies : [gobj, statichelper_dep], + install : true +) + +girexe = executable( + 'girprog', + sources : 'prog.c', + dependencies : [gobj, statichelper_dep], + link_with : girlib +) + +gnome.generate_gir( + girlib, statichelper_lib, + sources : [ libsources, statichelper_sources ], + nsversion : '1.0', + namespace : 'Meson', + symbol_prefix : 'meson_', + identifier_prefix : 'Meson', + includes : ['GObject-2.0'], + install : true +) + +test('gobject introspection/subproject/c', girexe) diff --git a/test cases/frameworks/34 gir static lib/subdir/gir/prog.c b/test cases/frameworks/34 gir static lib/subdir/gir/prog.c new file mode 100644 index 0000000..f25c9d8 --- /dev/null +++ b/test cases/frameworks/34 gir static lib/subdir/gir/prog.c @@ -0,0 +1,12 @@ +#include "meson-subsample.h" + +gint +main (gint argc, + gchar *argv[]) +{ + MesonSample * i = (MesonSample*) meson_sub_sample_new ("Hello, sub/meson/c!"); + meson_sample_print_message (i); + g_object_unref (i); + + return 0; +} diff --git a/test cases/frameworks/34 gir static lib/test.json b/test cases/frameworks/34 gir static lib/test.json new file mode 100644 index 0000000..a99e5a7 --- /dev/null +++ b/test cases/frameworks/34 gir static lib/test.json @@ -0,0 +1,8 @@ +{ + "installed": [ + {"type": "file", "file": "usr/lib/girepository-1.0/Meson-1.0.typelib"}, + {"type": "expr", "file": "usr/lib/?libgirlib.so"}, + {"type": "file", "platform": "cygwin", "file": "usr/lib/libgirlib.dll.a"}, + {"type": "file", "file": "usr/share/gir-1.0/Meson-1.0.gir"} + ] +} diff --git a/test cases/frameworks/8 flex/lexer.l b/test cases/frameworks/8 flex/lexer.l index 85293b2..952eeea 100644 --- a/test cases/frameworks/8 flex/lexer.l +++ b/test cases/frameworks/8 flex/lexer.l @@ -1,6 +1,9 @@ %{ #include <stdlib.h> #include "parser.tab.h" + +extern int yylex(void); +extern int yyerror(); %} %% diff --git a/test cases/frameworks/8 flex/parser.y b/test cases/frameworks/8 flex/parser.y index ff8754f..663f2f3 100644 --- a/test cases/frameworks/8 flex/parser.y +++ b/test cases/frameworks/8 flex/parser.y @@ -1,3 +1,8 @@ +%{ +extern int yylex(void); +extern int yyerror(); +%} + %token BOOLEAN %% diff --git a/test cases/rust/2 sharedlib/meson.build b/test cases/rust/2 sharedlib/meson.build index 42f6e23..aac2968 100644 --- a/test cases/rust/2 sharedlib/meson.build +++ b/test cases/rust/2 sharedlib/meson.build @@ -1,5 +1,9 @@ project('rust shared library', 'rust') +if host_machine.system() == 'darwin' + error('MESON_SKIP_TEST: doesnt work right on macos, please fix!') +endif + l = shared_library('stuff', 'stuff.rs', install : true) e = executable('prog', 'prog.rs', link_with : l, install : true) diff --git a/test cases/rust/4 polyglot/meson.build b/test cases/rust/4 polyglot/meson.build index b7eef57..4955516 100644 --- a/test cases/rust/4 polyglot/meson.build +++ b/test cases/rust/4 polyglot/meson.build @@ -1,5 +1,9 @@ project('rust and c polyglot executable', 'c', 'rust') +if host_machine.system() == 'darwin' + error('MESON_SKIP_TEST: doesnt work right on macos, please fix!') +endif + l = library('stuff', 'stuff.rs', rust_crate_type: 'cdylib', install : true) e = executable('prog', 'prog.c', link_with : l, install : true) test('polyglottest', e) |