diff --git a/.github/workflows/libxtracfg.yml b/.github/workflows/libxtracfg.yml index 8a6146a..0c43ba7 100644 --- a/.github/workflows/libxtracfg.yml +++ b/.github/workflows/libxtracfg.yml @@ -17,11 +17,12 @@ jobs: type: macos platform: darwin-arm64 runs-on: ${{ matrix.os.runner }} - defaults: - run: - working-directory: ./libxtracfg/c steps: - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.23.2" + cache-dependency-path: xtracfg/go.sum - uses: graalvm/setup-graalvm@v1 with: java-version: "21" @@ -31,21 +32,36 @@ jobs: cache-dependency-path: | xtracfg/*.gradle* xtracfg/**/gradle-wrapper.properties - - name: native-image - working-directory: ./xtracfg + - name: java + working-directory: ./libxtracfg/java run: | ./gradlew nativeCompile -PLIB=true - name: log run: | - ls -l ./build - - name: wrapper + ls -l ./libxtracfg/c/build + - name: c + working-directory: ./libxtracfg/c run: | ./build.sh - name: log2 run: | - ls -l ./build + ls -l ./libxtracfg/c/build + - name: go + working-directory: ./xtracfg + env: + CGO_FLAGS: ${{ matrix.os.type == 'macos' && '-framework CoreServices -framework Foundation' || '' }} + run: | + go build -o build/xtracfg -v + - name: log3 + run: | + ls -l ./xtracfg/build - uses: actions/upload-artifact@v4 with: name: libxtracfg-${{ matrix.os.platform }} path: ./libxtracfg/c/build/libxtracfg.a retention-days: 1 + - uses: actions/upload-artifact@v4 + with: + name: xtracfg-${{ matrix.os.platform }} + path: ./xtracfg/build/xtracfg + retention-days: 1 diff --git a/.github/workflows/xtracfg.yml b/.github/workflows/xtracfg.yml index 44930f6..e68d174 100644 --- a/.github/workflows/xtracfg.yml +++ b/.github/workflows/xtracfg.yml @@ -1,6 +1,6 @@ name: xtracfg -on: [push] +on: [] jobs: build: diff --git a/.github/workflows/xtractl.yml b/.github/workflows/xtractl.yml index 83bd324..1565bc0 100644 --- a/.github/workflows/xtractl.yml +++ b/.github/workflows/xtractl.yml @@ -1,6 +1,6 @@ name: xtractl -on: [push] +on: [] jobs: build: diff --git a/.gitignore b/.gitignore index ec21a4f..958fd03 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build .gradle .idea .DS_Store +libxtracfg/go/xtracfg/libxtracfg.sha1sum diff --git a/libxtracfg/c/build.sh b/libxtracfg/c/build.sh index 8477773..b2d9f57 100755 --- a/libxtracfg/c/build.sh +++ b/libxtracfg/c/build.sh @@ -17,6 +17,12 @@ echo "lib" clang -c -Wall -I./ -I$JAVA_HOME/include -I$JAVA_HOME/include/${PLATFORM} -o libxtracfg.o ../wrapper/libxtracfg.c cp libxtracfgjni.a libxtracfg.a ar -rv libxtracfg.a libxtracfg.o +if [ "$PLATFORM" = "darwin" ]; then +shasum libxtracfg.a > libxtracfg.sha1sum +else +sha1sum libxtracfg.a > libxtracfg.sha1sum +fi +cp libxtracfg.sha1sum ../../go/xtracfg/ echo "test" diff --git a/libxtracfg/c/test/main.c b/libxtracfg/c/test/main.c index bb16dca..3d2c041 100644 --- a/libxtracfg/c/test/main.c +++ b/libxtracfg/c/test/main.c @@ -3,6 +3,10 @@ #include "../include/libxtracfg.h" + void progress (const char* msg) { + printf("%s\n", msg); + } + int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); @@ -10,9 +14,14 @@ exit(1); } + xtracfg_init(); + xtracfg_progress_subscribe(progress); + int err = 0; char *result = xtracfg_execute( argv[1], &err); + xtracfg_cleanup(); + if (err > 0) { fprintf(stderr, "Unexpected error: %s\n", result); free(result); diff --git a/libxtracfg/go/xtracfg/client.go b/libxtracfg/go/xtracfg/client.go index 2912885..f270fdf 100644 --- a/libxtracfg/go/xtracfg/client.go +++ b/libxtracfg/go/xtracfg/client.go @@ -2,7 +2,7 @@ package xtracfg /* #cgo CFLAGS: -I ../../c/include -#cgo LDFLAGS: -L../../c/build -lxtracfg -framework CoreServices -framework Foundation +#cgo LDFLAGS: -L../../c/build -lxtracfg #include #include "libxtracfg.h" @@ -12,6 +12,7 @@ void progress(char *msg); import "C" import ( + _ "embed" "encoding/json" "fmt" "path/filepath" @@ -20,6 +21,11 @@ import ( "unsafe" ) +// needed to trigger a rebuild when libxtracfg.a changes +// +//go:embed libxtracfg.sha1sum +var res string + // Store is type Store struct { source *string