diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-10-05 20:45:21 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-10-13 17:04:20 +0200 |
commit | b27af7e4654c3b2fe8c68a560c99fbffbd22789b (patch) | |
tree | 68e823c96c64cc3489db7c999a27db129e7a90df | |
parent | 7e58f33376119b53e01616139ad9354ce9cfe003 (diff) | |
download | meson-b27af7e4654c3b2fe8c68a560c99fbffbd22789b.zip meson-b27af7e4654c3b2fe8c68a560c99fbffbd22789b.tar.gz meson-b27af7e4654c3b2fe8c68a560c99fbffbd22789b.tar.bz2 |
cmake: Add cross tests
24 files changed, 95 insertions, 14 deletions
diff --git a/.github/workflows/nonative.yml b/.github/workflows/nonative.yml index 59386c5..44eeb9e 100644 --- a/.github/workflows/nonative.yml +++ b/.github/workflows/nonative.yml @@ -16,4 +16,4 @@ jobs: apt-get -y autoremove - uses: actions/checkout@v2 - name: Run tests - run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./run_tests.py $CI_ARGS --cross ubuntu-armhf.txt --cross-only' + run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./run_tests.py $CI_ARGS --cross ubuntu-armhf.json --cross-only' diff --git a/.travis.yml b/.travis.yml index 22d76e7..ab317be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,10 +34,10 @@ matrix: # Also hijack one cross build to test long commandline handling codepath (and avoid overloading Travis) - os: linux compiler: gcc - env: RUN_TESTS_ARGS="--cross ubuntu-armhf.txt --cross linux-mingw-w64-64bit.txt" MESON_RSP_THRESHOLD=0 + env: RUN_TESTS_ARGS="--cross ubuntu-armhf.json --cross linux-mingw-w64-64bit.json" MESON_RSP_THRESHOLD=0 - os: linux compiler: gcc - env: RUN_TESTS_ARGS="--cross ubuntu-armhf.txt --cross linux-mingw-w64-64bit.txt" MESON_ARGS="--unity=on" + env: RUN_TESTS_ARGS="--cross ubuntu-armhf.json --cross linux-mingw-w64-64bit.json" MESON_ARGS="--unity=on" before_install: - python ./skip_ci.py --base-branch-env=TRAVIS_BRANCH --is-pull-env=TRAVIS_PULL_REQUEST diff --git a/ci/travis_script.sh b/ci/travis_script.sh index bdfd4c2..7e26b52 100755 --- a/ci/travis_script.sh +++ b/ci/travis_script.sh @@ -31,6 +31,11 @@ fi source /ci/env_vars.sh cd /root +update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix +update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix +update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix +update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix + ./run_tests.py $RUN_TESTS_ARGS -- $MESON_ARGS #./upload.sh diff --git a/cross/linux-mingw-w64-32bit.json b/cross/linux-mingw-w64-32bit.json new file mode 100644 index 0000000..4761111 --- /dev/null +++ b/cross/linux-mingw-w64-32bit.json @@ -0,0 +1,7 @@ +{ + "file": "linux-mingw-w64-32bit.txt", + "tests": ["common", "cmake"], + "env": { + "WINEPATH": "/usr/lib/gcc/i686-w64-mingw32/9.2-posix;/usr/i686-w64-mingw32/bin;/usr/i686-w64-mingw32/lib" + } +} diff --git a/cross/linux-mingw-w64-32bit.txt b/cross/linux-mingw-w64-32bit.txt index c2ea605..a62f57f 100644 --- a/cross/linux-mingw-w64-32bit.txt +++ b/cross/linux-mingw-w64-32bit.txt @@ -19,3 +19,11 @@ system = 'windows' cpu_family = 'x86' cpu = 'i686' endian = 'little' + +[cmake] + +CMAKE_BUILD_WITH_INSTALL_RPATH = 'ON' +CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = 'NEVER' +CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = 'ONLY' diff --git a/cross/linux-mingw-w64-64bit.json b/cross/linux-mingw-w64-64bit.json new file mode 100644 index 0000000..df344da --- /dev/null +++ b/cross/linux-mingw-w64-64bit.json @@ -0,0 +1,7 @@ +{ + "file": "linux-mingw-w64-64bit.txt", + "tests": ["common", "cmake"], + "env": { + "WINEPATH": "/usr/lib/gcc/x86_64-w64-mingw32/9.2-posix;/usr/x86_64-w64-mingw32/bin;/usr/x86_64-w64-mingw32/lib" + } +} diff --git a/cross/linux-mingw-w64-64bit.txt b/cross/linux-mingw-w64-64bit.txt index 1c5c002..36d7350 100644 --- a/cross/linux-mingw-w64-64bit.txt +++ b/cross/linux-mingw-w64-64bit.txt @@ -18,3 +18,11 @@ system = 'windows' cpu_family = 'x86_64' cpu = 'x86_64' endian = 'little' + +[cmake] + +CMAKE_BUILD_WITH_INSTALL_RPATH = 'ON' +CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = 'NEVER' +CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = 'ONLY' +CMAKE_FIND_ROOT_PATH_MODE_PACKAGE = 'ONLY' diff --git a/cross/ubuntu-armhf.json b/cross/ubuntu-armhf.json new file mode 100644 index 0000000..40f5619 --- /dev/null +++ b/cross/ubuntu-armhf.json @@ -0,0 +1,5 @@ +{ + "file": "ubuntu-armhf.txt", + "tests": ["common"], + "env": {} +} diff --git a/run_cross_test.py b/run_cross_test.py index 836cf31..5ce3e55 100755 --- a/run_cross_test.py +++ b/run_cross_test.py @@ -23,10 +23,13 @@ import argparse import subprocess from mesonbuild import mesonlib from mesonbuild.coredata import version as meson_version +from pathlib import Path +import json +import os -def runtests(cross_file, failfast, cross_only): - tests = ['--only', 'common'] +def runtests(cross_file, failfast, cross_only, test_list, env=None): + tests = ['--only'] + test_list if not cross_only: tests.append('native') cmd = mesonlib.python_command + ['run_project_tests.py', '--backend', 'ninja'] @@ -36,7 +39,7 @@ def runtests(cross_file, failfast, cross_only): cmd += ['--cross-file', cross_file] if cross_only: cmd += ['--native-file', 'cross/none.txt'] - return subprocess.call(cmd) + return subprocess.call(cmd, env=env) def main(): parser = argparse.ArgumentParser() @@ -44,7 +47,16 @@ def main(): parser.add_argument('--cross-only', action='store_true') parser.add_argument('cross_file') options = parser.parse_args() - return runtests(options.cross_file, options.failfast, options.cross_only) + cf_path = Path(options.cross_file) + try: + data = json.loads(cf_path.read_text()) + real_cf = cf_path.resolve().parent / data['file'] + assert real_cf.exists() + env = os.environ.copy() + env.update(data['env']) + return runtests(real_cf.as_posix(), options.failfast, options.cross_only, data['tests'], env=env) + except Exception: + return runtests(options.cross_file, options.failfast, options.cross_only, ['common']) if __name__ == '__main__': print('Meson build system', meson_version, 'Cross Tests') diff --git a/run_project_tests.py b/run_project_tests.py index 8749957..037ba42 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -1163,6 +1163,7 @@ def check_format(): '.dub', # external deps are here '.pytest_cache', 'meson-logs', 'meson-private', + 'work area', '.eggs', '_cache', # e.g. .mypy_cache 'venv', # virtualenvs have DOS line endings } diff --git a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt index c9b2a20..7fce89e 100644 --- a/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/2 advanced/subprojects/cmMod/CMakeLists.txt @@ -25,4 +25,4 @@ target_link_libraries(testEXE cmModLib) target_compile_definitions(cmModLibStatic PUBLIC CMMODLIB_STATIC_DEFINE) -install(TARGETS cmModLib testEXE LIBRARY DESTINATION lib RUNTIME DESTINATION bin) +install(TARGETS testEXE LIBRARY DESTINATION lib RUNTIME DESTINATION bin) diff --git a/test cases/cmake/2 advanced/test.json b/test cases/cmake/2 advanced/test.json index ff3d5a7..e2d9c05 100644 --- a/test cases/cmake/2 advanced/test.json +++ b/test cases/cmake/2 advanced/test.json @@ -1,7 +1,5 @@ { "installed": [ - {"type": "expr", "file": "usr/?lib/libcm_cmModLib?so"}, - {"type": "implib", "file": "usr/lib/libcm_cmModLib"}, {"type": "exe", "file": "usr/bin/cm_testEXE"} ], "tools": { diff --git a/test cases/cmake/211 cmake module/cmake_project/CMakeLists.txt b/test cases/cmake/22 cmake module/cmake_project/CMakeLists.txt index cd91584..cd91584 100644 --- a/test cases/cmake/211 cmake module/cmake_project/CMakeLists.txt +++ b/test cases/cmake/22 cmake module/cmake_project/CMakeLists.txt diff --git a/test cases/cmake/211 cmake module/meson.build b/test cases/cmake/22 cmake module/meson.build index 68f9993..68f9993 100644 --- a/test cases/cmake/211 cmake module/meson.build +++ b/test cases/cmake/22 cmake module/meson.build diff --git a/test cases/cmake/211 cmake module/projectConfig.cmake.in b/test cases/cmake/22 cmake module/projectConfig.cmake.in index fa3dfca..fa3dfca 100644 --- a/test cases/cmake/211 cmake module/projectConfig.cmake.in +++ b/test cases/cmake/22 cmake module/projectConfig.cmake.in diff --git a/test cases/cmake/211 cmake module/test.json b/test cases/cmake/22 cmake module/test.json index 2a5625a..2a5625a 100644 --- a/test cases/cmake/211 cmake module/test.json +++ b/test cases/cmake/22 cmake module/test.json diff --git a/test cases/cmake/23 cmake toolchain/CMakeToolchain.cmake b/test cases/cmake/23 cmake toolchain/CMakeToolchain.cmake new file mode 100644 index 0000000..ab5fbac --- /dev/null +++ b/test cases/cmake/23 cmake toolchain/CMakeToolchain.cmake @@ -0,0 +1 @@ +set(MESON_TEST_VAR2 VAR2) diff --git a/test cases/cmake/23 cmake toolchain/meson.build b/test cases/cmake/23 cmake toolchain/meson.build new file mode 100644 index 0000000..98f8d21 --- /dev/null +++ b/test cases/cmake/23 cmake toolchain/meson.build @@ -0,0 +1,9 @@ +project('cmake toolchain test', ['c', 'cpp']) + +if meson.is_cross_build() + error('MESON_SKIP_TEST: skip this on cross builds') +endif + +cm = import('cmake') + +sub_pro = cm.subproject('cmMod') diff --git a/test cases/cmake/23 cmake toolchain/nativefile.ini.in b/test cases/cmake/23 cmake toolchain/nativefile.ini.in new file mode 100644 index 0000000..2cd6e94 --- /dev/null +++ b/test cases/cmake/23 cmake toolchain/nativefile.ini.in @@ -0,0 +1,8 @@ +[properties] + +cmake_toolchain_file = '@MESON_TEST_ROOT@/CMakeToolchain.cmake' + +[cmake] + +MESON_TEST_VAR1 = 'VAR1 space' +MESON_TEST_VAR2 = 'VAR2 error' diff --git a/test cases/cmake/23 cmake toolchain/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/23 cmake toolchain/subprojects/cmMod/CMakeLists.txt new file mode 100644 index 0000000..8aeabc2 --- /dev/null +++ b/test cases/cmake/23 cmake toolchain/subprojects/cmMod/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.5) + +project(cmMod) + +if(NOT "${MESON_TEST_VAR1}" STREQUAL "VAR1 space") + message(FATAL_ERROR "MESON_TEST_VAR1 -- '${MESON_TEST_VAR1}' != 'VAR1 space'") +endif() + +if(NOT "${MESON_TEST_VAR2}" STREQUAL "VAR2") + message(FATAL_ERROR "MESON_TEST_VAR2 -- '${MESON_TEST_VAR2}' != 'VAR2'") +endif() diff --git a/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt b/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt index 4c782cb..026d4c1 100644 --- a/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt +++ b/test cases/cmake/3 advanced no dep/subprojects/cmMod/CMakeLists.txt @@ -23,4 +23,4 @@ target_link_libraries(testEXE2 cmModLib) target_compile_definitions(cmModLibStatic PUBLIC CMMODLIB_STATIC_DEFINE) -install(TARGETS cmModLib testEXE testEXE2 LIBRARY DESTINATION lib RUNTIME DESTINATION bin) +install(TARGETS testEXE testEXE2 LIBRARY DESTINATION lib RUNTIME DESTINATION bin) diff --git a/test cases/cmake/3 advanced no dep/test.json b/test cases/cmake/3 advanced no dep/test.json index af25a8e..4b266c3 100644 --- a/test cases/cmake/3 advanced no dep/test.json +++ b/test cases/cmake/3 advanced no dep/test.json @@ -1,8 +1,5 @@ { "installed": [ - {"type": "expr", "file": "usr/?lib/libcm_cmModLib?so"}, - {"type": "implib", "file": "usr/lib/libcm_cmModLib"}, - {"type": "pdb", "file": "usr/bin/cm_cmModLib"}, {"type": "pdb", "file": "usr/bin/cm_testEXE"}, {"type": "exe", "file": "usr/bin/cm_testEXE"}, {"type": "pdb", "file": "usr/bin/cm_testEXE2"}, diff --git a/test cases/cmake/4 code gen/subprojects/cmCodeGen/CMakeLists.txt b/test cases/cmake/4 code gen/subprojects/cmCodeGen/CMakeLists.txt index 268743c..ff50e54 100644 --- a/test cases/cmake/4 code gen/subprojects/cmCodeGen/CMakeLists.txt +++ b/test cases/cmake/4 code gen/subprojects/cmCodeGen/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 3.7) +project(CMCodeGen) set(CMAKE_CXX_STANDARD 14) add_executable(genA main.cpp) diff --git a/test cases/cmake/7 cmake options/test.json b/test cases/cmake/7 cmake options/test.json index 046e2ee..f9f0b05 100644 --- a/test cases/cmake/7 cmake options/test.json +++ b/test cases/cmake/7 cmake options/test.json @@ -3,6 +3,9 @@ "options": { "cmake_prefix_path": [ { "val": ["val1", "val2"] } + ], + "build.cmake_prefix_path": [ + { "val": ["val1", "val2"] } ] } } |