-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
191 lines (172 loc) · 4.71 KB
/
Taskfile.yml
File metadata and controls
191 lines (172 loc) · 4.71 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
---
version: '3'
vars:
CC: gcc
CC_FLAGS: "-Werror -Wextra -Wall -Wfree-nonheap-object -std=c17"
LAB_EXECUTABLE_NAME: lab
SOURCE_FILES:
- json.c
- lexer.c
- parser.c
- hashmap.c
- dynamicarray.c
DYN_LIBS_USED_PATH: -L/usr/local/lib/standardloop
DYN_LIBS_USED: "-lstandardloop-util"
DYLIB_NAME: libstandardloop-json.dylib
DYLIB_PATH: /usr/local/lib/standardloop/
DYLIB_INCLUDE_PATH: /usr/local/include/standardloop/
RELEASE_VERSION: 0.0.5
# Inputs
# - REPO_NAME
# - DYLIB_VERSION
# - DYLIB_NAME
download-dependency: &download-dependency |
mkdir -p dependencies/tmp-{{.DYLIB_NAME}}
cd dependencies/tmp-{{.DYLIB_NAME}}
curl -O -J -L https://github.com/standardloop/{{.REPO_NAME}}/releases/download/v{{.DYLIB_VERSION}}/libstandardloop-{{.DYLIB_NAME}}.zip
unzip libstandardloop-{{.DYLIB_NAME}}.zip
sudo mkdir -p /usr/local/lib/standardloop/
sudo mkdir -p /usr/local/include/standardloop/
sudo mv libstandardloop-{{.DYLIB_NAME}}.dylib /usr/local/lib/standardloop/
sudo mv {{.DYLIB_NAME}}.h /usr/local/include/standardloop/ && rm libstandardloop-{{.DYLIB_NAME}}.zip
tasks:
default:
deps:
- lab
check-version:
silent: true
cmds:
- cat json.h | grep -q {{.RELEASE_VERSION}}
- cat json.h | grep -q "MAJOR_VERSION 0"
- cat json.h | grep -q "MINOR_VERSION 0"
- cat json.h | grep -q "PATCH_VERSION 5"
dependencies:
deps:
- dependencies:util
dependencies:util:
vars:
REPO_NAME: c-util
DYLIB_VERSION: 0.0.6
DYLIB_NAME: util
cmds:
- sudo -v
- *download-dependency
status:
- otool -L /usr/local/lib/standardloop/libstandardloop-{{.DYLIB_NAME}}.dylib | head -n 2 | tail -n 1 | grep "current version {{.DYLIB_VERSION}}"
- cat /usr/local/include/standardloop/{{.DYLIB_NAME}}.h | grep "STANDARDLOOP_{{.DYLIB_NAME | upper}}_H_VERSION \"{{.DYLIB_VERSION}}\""
release:
deps:
- check-version
- release:build
- release:move-files
release:build:
run: once
deps:
- check-version
- dependencies
cmds:
- |
{{.CC}} {{.CC_FLAGS}} \
{{range .SOURCE_FILES}} {{.}} {{end}} \
{{.DYN_LIBS_USED_PATH}} \
{{.DYN_LIBS_USED}} \
-O3 \
-dynamiclib \
-current_version {{.RELEASE_VERSION}} \
-compatibility_version {{.RELEASE_VERSION}} \
-o {{.DYLIB_NAME}}
sources:
- "*.c"
generates:
- "{{.DYLIB_NAME}}"
release:move-files:
deps:
- release:build
cmds:
- sudo -v
- sudo mv {{.DYLIB_NAME}} {{.DYLIB_PATH}}
- sudo cp json.h {{.DYLIB_INCLUDE_PATH}}
release:clean:
allow_failure: true
cmds:
- sudo -v
- sudo rm -f {{.DYLIB_PATH}}/{{.DYLIB_NAME}}
- sudo rm -f {{.DYLIB_INCLUDE_PATH}}/json.h
# local test
remote:download:
run: once
cmds:
- |
mkdir -p tmp
cd tmp
curl -O -J -L https://github.com/standardloop/c-json/releases/download/v{{.RELEASE_VERSION}}/libstandardloop-json.zip
unzip libstandardloop-json.zip
rm libstandardloop-json.zip
remote:move:
deps:
- remote:download
cmds:
- |
cd tmp/
sudo -v
sudo mv {{.DYLIB_NAME}} {{.DYLIB_PATH}}
sudo mv json.h {{.DYLIB_INCLUDE_PATH}}
lab:
deps:
- lab:run
lab:build:
run: once
cmds:
- |
{{.CC}} {{.CC_FLAGS}} \
lab.c \
{{range .SOURCE_FILES}} {{.}} {{end}} \
{{.DYN_LIBS_USED_PATH}} \
{{.DYN_LIBS_USED}} \
-O0 \
-lstandardloop-json \
-o {{.LAB_EXECUTABLE_NAME}}
sources:
- "*.c"
generates:
- "{{.LAB_EXECUTABLE_NAME}}"
lab:sanitize:
deps:
- lab:run-sanitize
lab:build-sanitize:
run: once
cmds:
- |
{{.CC}} {{.CC_FLAGS}} \
lab.c \
{{range .SOURCE_FILES}} {{.}} {{end}} \
{{.DYN_LIBS_USED_PATH}} \
{{.DYN_LIBS_USED}} \
-O0 \
-lstandardloop-json \
-fno-omit-frame-pointer \
-fsanitize=address \
-o {{.LAB_EXECUTABLE_NAME}}-sanitize
sources:
- "*.c"
generates:
- "{{.LAB_EXECUTABLE_NAME}}-sanitize"
lab:run:
deps:
- lab:build
cmds:
- ./{{.LAB_EXECUTABLE_NAME}}
lab:run-sanitize:
deps:
- lab:build-sanitize
cmds:
- ./{{.LAB_EXECUTABLE_NAME}}-sanitize
lab:leaks:
deps:
- lab:build
cmds:
- cp /usr/local/lib/standardloop/libstandardloop-util.dylib ./ # to get around sips we need to move dylibs to local dir :(
- cp /usr/local/lib/standardloop/libstandardloop-json.dylib ./
- leaks --atExit -- ./{{.LAB_EXECUTABLE_NAME}}
- rm libstandardloop-util.dylib
- rm libstandardloop-json.dylib