Skip to content

Commit

Permalink
watcher/python, watcher/cross
Browse files Browse the repository at this point in the history
Will committed Jul 14, 2024
1 parent 6041503 commit 585c0ef
Showing 11 changed files with 94 additions and 70 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/libcwatcher-cross.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: libcwatcher-cross

on:
push:
branches: [ release, next ]
pull_request:
branches: [ release, next ]

jobs:
build-all:
runs-on: macos-14
strategy:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: |
which meson || brew install meson
- run: |
libcwatcher/cross-compile.sh
- uses: actions/upload-artifact@v4
with:
path: libcwatcher/out
42 changes: 0 additions & 42 deletions .github/workflows/libcwatcher.yml

This file was deleted.

24 changes: 24 additions & 0 deletions libcwatcher/cross-compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#! /usr/bin/env bash
set -e
[ -d "$(dirname "$0")/out" ] || mkdir "$(dirname "$0")/out"
cd "$(dirname "$0")"
linux-cross-compilation-containers/build-containers.sh
[ -f out/meson.build ] || cp meson.build out
[ -d out/src ] || cp -r src out
[ -d out/include ] || cp -r include out
(
cd out
SRC=$PWD
docker run --platform linux/amd64 --rm -v "$SRC:/src" meson-builder-x86_64-unknown-linux-gnu:latest
docker run --platform linux/arm64 --rm -v "$SRC:/src" meson-builder-aarch64-unknown-linux-gnu:latest
docker run --platform linux/arm/v7 --rm -v "$SRC:/src" meson-builder-armv7-unknown-linux-gnueabihf:latest
)
[ "$(uname)" = Darwin ] && {
[ -d out/x86_64-apple-darwin ] || meson setup --cross-file cross-files/x86_64-apple-darwin.txt out/x86_64-apple-darwin
[ -d out/aarch64-apple-darwin ] || meson setup --cross-file cross-files/aarch64-apple-darwin.txt out/aarch64-apple-darwin
meson compile -C out/x86_64-apple-darwin
meson compile -C out/aarch64-apple-darwin
}
for pattern in '*.a' '*.so' '*.dylib'
do find out -type f -name "$pattern" -exec file {} \;
done
16 changes: 14 additions & 2 deletions libcwatcher/cross-files/aarch64-apple-darwin.txt
Original file line number Diff line number Diff line change
@@ -3,10 +3,22 @@ c = 'clang'
cpp = 'clang++'
ar = 'ar'
strip = 'strip'
pkg-config = 'pkg-config'

[host_machine]
[built-in options]
c_args = ['-target', 'aarch64-apple-darwin20.0.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk']
cpp_args = ['-target', 'aarch64-apple-darwin20.0.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk']
c_link_args = ['-target', 'aarch64-apple-darwin20.0.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk']
cpp_link_args = ['-target', 'aarch64-apple-darwin20.0.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk']

[target_machine]
system = 'darwin'
cpu_family = 'aarch64'
cpu = 'arm'
cpu = 'aarch64'
endian = 'little'

[host_machine]
system = 'darwin'
cpu_family = 'aarch64'
cpu = 'aarch64'
endian = 'little'
12 changes: 0 additions & 12 deletions libcwatcher/cross-files/aarch64-unknown-linux-gnu.txt

This file was deleted.

14 changes: 13 additions & 1 deletion libcwatcher/cross-files/x86_64-apple-darwin.txt
Original file line number Diff line number Diff line change
@@ -3,10 +3,22 @@ c = 'clang'
cpp = 'clang++'
ar = 'ar'
strip = 'strip'
pkg-config = 'pkg-config'

[host_machine]
[built-in options]
c_args = ['-target', 'x86_64-apple-darwin', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk']
cpp_args = ['-target', 'x86_64-apple-darwin', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk']
c_link_args = ['-target', 'x86_64-apple-darwin', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk']
cpp_link_args = ['-target', 'x86_64-apple-darwin', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk']

[target_machine]
system = 'darwin'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

[host_machine]
system = 'darwin'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
12 changes: 0 additions & 12 deletions libcwatcher/cross-files/x86_64-unknown-linux-gnu.txt

This file was deleted.

6 changes: 6 additions & 0 deletions libcwatcher/linux-cross-compilation-containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM debian:latest
ARG BUILD_DIR
RUN apt-get update -yqq && apt-get install -yqq build-essential meson ninja-build
COPY build.sh /usr/local/bin/build.sh
ENV BUILD_DIR=$BUILD_DIR
ENTRYPOINT ["build.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /usr/bin/env bash
set -e
cd "$(dirname "$0")"
docker build -t meson-builder-x86_64-unknown-linux-gnu --build-arg BUILD_DIR=x86_64-unknown-linux-gnu --platform linux/amd64 .
docker build -t meson-builder-aarch64-unknown-linux-gnu --build-arg BUILD_DIR=aarch64-unknown-linux-gnu --platform linux/arm64 .
docker build -t meson-builder-armv7-unknown-linux-gnueabihf --build-arg BUILD_DIR=armv7-unknown-linux-gnueabihf --platform linux/arm/v7 .
5 changes: 5 additions & 0 deletions libcwatcher/linux-cross-compilation-containers/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /usr/bin/env sh
set -e
cd /src
[ -d "$BUILD_DIR" ] || meson setup "$BUILD_DIR"
meson compile -C "$BUILD_DIR"
4 changes: 3 additions & 1 deletion libcwatcher/meson.build
Original file line number Diff line number Diff line change
@@ -5,10 +5,12 @@ project(
default_options : ['c_std=c99', 'cpp_std=c++20'],
)

# I know it's not the convential way to version a shared library...
# But I'm not sure how to do it the "right" way in Meson.
libname = 'cwatcher-' + meson.project_version()

if target_machine.system() == 'darwin'
deps = dependency('appleframeworks', ['CoreServices', 'CoreFoundation'])
deps = dependency(['CoreServices', 'CoreFoundation'])
else
deps = dependency('threads')
endif

0 comments on commit 585c0ef

Please sign in to comment.