Skip to content

Commit 5c29e6f

Browse files
committed
feat: use pkg-config
1 parent d7ccf98 commit 5c29e6f

File tree

7 files changed

+65
-8
lines changed

7 files changed

+65
-8
lines changed

.github/workflows/tests.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
name: Tests
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
permissions:
11+
contents: read
12+
jobs:
13+
tests:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
go-version: ['stable', 'oldstable']
19+
env:
20+
GOEXPERIMENT: cgocheck2
21+
name: Go (${{ matrix.go-version }})
22+
steps:
23+
-
24+
uses: actions/checkout@v4
25+
-
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version: ${{ matrix.go-version }}
29+
-
30+
name: Fetch fswatch version
31+
id: fswatch-version
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: echo "version=$(gh release view --repo emcrisostomo/fswatch --json tagName --jq .tagName)" >> "$GITHUB_OUTPUT"
35+
-
36+
name: Cache libfswatch
37+
id: libfswatch
38+
uses: actions/cache@v4
39+
with:
40+
path: fswatch/target
41+
key: ${{ runner.os }}-${{ steps.fswatch-version.outputs.version }}-fswatch
42+
-
43+
name: Compile libfswatch
44+
if: steps.libfswatch.outputs.cache-hit != 'true'
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
mkdir fswatch/
49+
gh release download "${{ steps.fswatch-version.outputs.version }}" --repo emcrisostomo/fswatch --pattern 'fswatch-*.tar.gz' --output - | tar -x -C fswatch --strip-components=1
50+
cd fswatch/
51+
./configure --prefix=$(pwd)/target
52+
make -j"$(getconf _NPROCESSORS_ONLN)"
53+
make install
54+
-
55+
name: Run tests
56+
env:
57+
PKG_CONFIG_PATH: ${{ github.workspace }}/fswatch/target/lib/pkgconfig
58+
run: go test

events.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package fswatch
22

3-
// #include <libfswatch.h>
3+
// #include <libfswatch/c/libfswatch.h>
44
import "C"
55
import "time"
66

filters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package fswatch
22

3-
// #include <libfswatch.h>
3+
// #include <libfswatch/c/libfswatch.h>
44
import "C"
55

66
type FilterType C.enum_fsw_filter_type

fswatch.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// Package fswatch provides bindings for libfswatch.
22
package fswatch
33

4-
// #cgo LDFLAGS: -L/usr/local/lib -lfswatch
5-
// #cgo CFLAGS: -I/usr/local/include/libfswatch/c
4+
// #cgo pkg-config: libfswatch
65
// #include <stdint.h>
76
// #include <stdlib.h>
8-
// #include <libfswatch.h>
7+
// #include <libfswatch/c/libfswatch.h>
98
// #include "fswatch.h"
109
import "C"
1110
import (

fswatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <libfswatch.h>
1+
#include <libfswatch/c/libfswatch.h>
22

33
void process_events(fsw_cevent const *const events,
44
const unsigned int event_num, void *data);

monitors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package fswatch
22

3-
// #include <libfswatch.h>
3+
// #include <libfswatch/c/libfswatch.h>
44
import "C"
55

66
type MonitorType C.enum_fsw_monitor_type

options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package fswatch
22

33
// #include <stdlib.h>
4-
// #include <libfswatch.h>
4+
// #include <libfswatch/c/libfswatch.h>
55
import "C"
66

77
// Option instances allow to configure monitors.

0 commit comments

Comments
 (0)