Skip to content

Commit

Permalink
feat: use pkg-config
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Aug 14, 2024
1 parent d7ccf98 commit 5bb23c7
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 8 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: Tests
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions:
contents: read
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ['stable', 'oldstable']
env:
GOEXPERIMENT: cgocheck2
name: Go (${{ matrix.go-version }})
steps:
-
uses: actions/checkout@v4
-
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
-
name: Fetch fswatch version
id: fswatch-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "version=$(gh release view --repo emcrisostomo/fswatch --json tagName --jq .tagName)" >> "$GITHUB_OUTPUT"
-
name: Cache libfswatch
id: libfswatch
uses: actions/cache@v4
with:
path: fswatch/target
key: ${{ runner.os }}-${{ steps.fswatch-version.outputs.version }}-fswatch
-
name: Compile libfswatch
if: steps.libfswatch.outputs.cache-hit != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir fswatch/
gh release download "${{ steps.fswatch-version.outputs.version }}" --repo emcrisostomo/fswatch --pattern 'fswatch-*.tar.gz' --output - | tar -xz -C fswatch --strip-components=1
cd fswatch/
./configure --prefix=$(pwd)/target
make -j"$(getconf _NPROCESSORS_ONLN)"
make install
-
name: Run tests
env:
PKG_CONFIG_PATH: ${{ github.workspace }}/fswatch/target/lib/pkgconfig
run: go test
2 changes: 1 addition & 1 deletion events.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fswatch

// #include <libfswatch.h>
// #include <libfswatch/c/libfswatch.h>
import "C"
import "time"

Expand Down
2 changes: 1 addition & 1 deletion filters.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fswatch

// #include <libfswatch.h>
// #include <libfswatch/c/libfswatch.h>
import "C"

type FilterType C.enum_fsw_filter_type
Expand Down
5 changes: 2 additions & 3 deletions fswatch.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Package fswatch provides bindings for libfswatch.
package fswatch

// #cgo LDFLAGS: -L/usr/local/lib -lfswatch
// #cgo CFLAGS: -I/usr/local/include/libfswatch/c
// #cgo pkg-config: libfswatch
// #include <stdint.h>
// #include <stdlib.h>
// #include <libfswatch.h>
// #include <libfswatch/c/libfswatch.h>
// #include "fswatch.h"
import "C"
import (
Expand Down
2 changes: 1 addition & 1 deletion fswatch.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <libfswatch.h>
#include <libfswatch/c/libfswatch.h>

void process_events(fsw_cevent const *const events,
const unsigned int event_num, void *data);
2 changes: 1 addition & 1 deletion monitors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fswatch

// #include <libfswatch.h>
// #include <libfswatch/c/libfswatch.h>
import "C"

type MonitorType C.enum_fsw_monitor_type
Expand Down
2 changes: 1 addition & 1 deletion options.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fswatch

// #include <stdlib.h>
// #include <libfswatch.h>
// #include <libfswatch/c/libfswatch.h>
import "C"

// Option instances allow to configure monitors.
Expand Down

0 comments on commit 5bb23c7

Please sign in to comment.