From 3a4827991fcadd3afc6e62856a1b7cb0e12e5520 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Tue, 10 Sep 2024 19:51:20 -0300 Subject: [PATCH] CI: support testing on Windows --- .github/workflows/example-project.yml | 49 ++++++++++++++++++++++++ example-project/usage-from-c/meson.build | 7 ++++ 2 files changed, 56 insertions(+) create mode 100644 example-project/usage-from-c/meson.build diff --git a/.github/workflows/example-project.yml b/.github/workflows/example-project.yml index 6e6c31cb..9d066347 100644 --- a/.github/workflows/example-project.yml +++ b/.github/workflows/example-project.yml @@ -62,6 +62,12 @@ jobs: working-directory: example-project run: | sudo cp -r temp/usr/local/* /usr/local/ + + - name: Install into Cargo root + if: startsWith(matrix.os, 'windows') + working-directory: example-project + run: | + cargo cinstall --verbose --release --prefix=$CARGO_HOME - name: Test pkg-config if: startsWith(matrix.os, 'macos') @@ -76,6 +82,17 @@ jobs: with: packages: pkgconf + # https://github.com/pkgconf/pkgconf/issues/364 + - name: Install pkgconf + if: startsWith(matrix.os, 'windows') + shell: bash + run: | + git clone https://github.com/amyspark/pkgconf --branch msvc + cd pkgconf + meson setup build --prefix=$CARGO_HOME + meson compile -C build + meson install -C build + - name: Test pkgconf if: startsWith(matrix.os, 'ubuntu') run: | @@ -90,6 +107,18 @@ jobs: test "${CFLAGS%% }" = "-I/usr/local/include/example-project-0.1" test "${LIBS%% }" = "-L/usr/local/lib/${ARCHDIR} -lexample-project" + - name: Test pkgconf + if: startsWith(matrix.os, 'windows') + shell: bash + run: | + set -x + pkgconf --version + CFLAGS=$(pkgconf --cflags example_project) + LIBS=$(pkgconf --libs example_project) + + test "${CFLAGS%% }" = "-I$CARGO_HOME/bin/../include/example-project-0.1" + test "${LIBS%% }" = "-L$CARGO_HOME/bin/../lib -lexample-project" + - name: Update dynamic linker cache if: startsWith(matrix.os, 'ubuntu') run: | @@ -101,3 +130,23 @@ jobs: run: | make + - name: Setup MSVC for test + if: startsWith(matrix.os, 'windows') + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x86_64 + + - name: Setup Meson + Ninja + if: startsWith(matrix.os, 'windows') + run: | + python3 -m pip install --upgrade pip setuptools wheel + python3 -m pip install meson ninja + + - name: Test usage from C (Meson) + if: startsWith(matrix.os, 'windows') + working-directory: example-project/usage-from-c + shell: pwsh + run: + meson setup build + meson compile -C build + meson test -C build diff --git a/example-project/usage-from-c/meson.build b/example-project/usage-from-c/meson.build new file mode 100644 index 00000000..e4ca61e9 --- /dev/null +++ b/example-project/usage-from-c/meson.build @@ -0,0 +1,7 @@ +project('example', 'c') + +dep = dependency('example_project', static: true, required: true) + +exe = executable('run_tests', files('run_tests.c'), dependencies: dep) + +test('run_tests', exe)