-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (138 loc) · 5.27 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Build proj.js
on:
workflow_call:
inputs:
platform:
type: string
required: true
native:
type: boolean
required: true
description: build the native module
wasm:
type: boolean
required: true
description: build the WASM module
asan:
type: boolean
default: false
description: build the ASAN version
codecov:
type: boolean
default: false
description: build the codecov version
id:
type: string
required: true
description: artifact id
inline_projdb:
type: boolean
default: true
description: inline proj.db for WASM
enable_tiff:
type: boolean
default: true
description: include TIFF support
conan_cache:
type: boolean
default: true
description: cache conan artifacts
jobs:
build:
runs-on: ${{ inputs.platform }}
name: Build ${{ inputs.native && 'native ' || '' }}${{ inputs.wasm && 'wasm ' || '' }}${{ inputs.asan && 'ASAN ' || '' }}${{ inputs.codecov && 'codecov ' || '' }}on ${{ inputs.platform }}${{ inputs.enable_tiff && ' ' || ' w/o libtiff' }}${{ inputs.inline_projdb && ' ' || ' w/o proj.db' }}
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Visual Studio (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Setup emscripten (WASM)
uses: mymindstorm/setup-emsdk@v14
if: inputs.wasm
with:
version: 3.1.68
- name: Download the SWIG-generated wrappers
uses: actions/download-artifact@v4
with:
name: swig-generated
path: swig
- name: Install dependencies
run: |
npm install --skip-proj-wasm --skip-proj-native
npx xpm install
- name: Get conan home
shell: bash
id: conan_home
run: |
npx xpm run -q conan -- version
echo path=`npx xpm run -q conan -- config home` >> $GITHUB_OUTPUT
- name: Cache conan artifacts
uses: actions/cache@v4
if: inputs.conan_cache
with:
path: ${{ steps.conan_home.outputs.path }}
key: conan-${{ inputs.id }}
- name: Set the npm build options
shell: bash
run: |
echo "${{ inputs.inline_projdb && 'npm_config_enable_inline_projdb' || 'npm_config_disable_inline_projdb' }}=true" >> $GITHUB_ENV
echo "${{ inputs.enable_tiff && 'npm_config_enable_tiff' || 'npm_config_disable_tiff' }}=true" >> $GITHUB_ENV
- name: Build the native version
shell: bash
run: |
npm install --skip-proj-wasm --build-from-source --verbose --foreground-scripts \
${{ inputs.enable_tiff && '--enable-tiff' || '--disable-tiff' }} \
${{ inputs.inline_projdb && '--enable-inline-projdb' || '--disable-inline-projdb' }}
if: inputs.native
- name: Build the WASM version
shell: bash
run: |
npm install --skip-proj-native --build-wasm-from-source --verbose --foreground-scripts \
${{ inputs.enable_tiff && '--enable-tiff' || '--disable-tiff' }} \
${{ inputs.inline_projdb && '--enable-inline-projdb' || '--disable-inline-projdb' }}
if: inputs.wasm
- name: Build the native ASAN version
if: inputs.asan
run: |
npx xpm run prepare --config native-debug
npx xpm run configure --config native-debug -- -Db_sanitize=address
npx xpm run build --config native-debug
- name: Build the native codecov version
if: inputs.codecov
run: |
npm run configure:native
npx xpm run configure --config native -- -Db_coverage=true
npm run build:native
- name: Check WASM module size
run: |
echo "::notice::WASM version is $(( `cat lib/binding/emscripten-wasm32/proj.wasm | wc -c` / 1024 )) KBytes raw, $(( `gzip -9c lib/binding/emscripten-wasm32/proj.wasm | wc -c` / 1024 )) KBytes gzipped, $(( `brotli -9c lib/binding/emscripten-wasm32/proj.wasm | wc -c` / 1024 )) KBytes brotlied"
if: inputs.wasm
- name: Locate addon file
shell: bash
id: addon
run: node -p '"addon=" + path.resolve(__dirname, "lib", "binding", `${os.platform()}-${os.arch()}`, "proj.node")' >> $GITHUB_OUTPUT
if: inputs.native
- name: Check native module size
run: |
node -p '"::notice::native version is " + (fs.statSync(path.resolve(__dirname, "lib", "binding", `${os.platform()}-${os.arch()}`, "proj.node")).size / 1024).toFixed(0) + " KBytes${{ inputs.enable_tiff && ' ' || ' w/o libtiff' }}${{ inputs.inline_projdb && ' ' || ' w/o proj.db' }}"'
if: inputs.native
- name: List linked libraries (Linux)
run: ldd ${{ steps.addon.outputs.addon }}
if: runner.os == 'Linux' && inputs.native
- name: List linked libraries (macOS)
run: otool -L ${{ steps.addon.outputs.addon }}
if: runner.os == 'macOS' && inputs.native
- name: Upload artifact ${{ inputs.id }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.id }}
path: lib/binding/*