Skip to content

Commit 3c41d51

Browse files
authored
refactor(taskfile): Refactor taskfiles to separate log-surgeon and examples. (#142)
1 parent dfd5c79 commit 3c41d51

File tree

9 files changed

+199
-159
lines changed

9 files changed

+199
-159
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ jobs:
5050
run: "npm install -g @go-task/cli"
5151

5252
- name: "Build and run unit tests"
53-
run: "task test:${{matrix.build_type}}"
53+
run: "task test:run-${{matrix.build_type}}"
5454

5555
- name: "Print test log on failure"
5656
if: "failure()"
5757
run: "cat ./build/log-surgeon/Testing/Temporary/LastTest.log"
5858

5959
- name: "Build and run examples"
6060
run: |-
61-
task build:examples-${{matrix.build_type}}
61+
task examples:build-${{matrix.build_type}}
6262
./build/examples/${{matrix.build_type}}/buffer-parser ./examples/schema.txt README.md
6363
./build/examples/${{matrix.build_type}}/reader-parser ./examples/schema.txt README.md
6464
./build/examples/${{matrix.build_type}}/intersect-test

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,22 @@ Requirements:
9191
* [GSL] >= 4.0.0
9292
* [Task] >= 3.38
9393

94-
To build and install the project to `~/.local`:
94+
To build and install the project to `$HOME/.local`:
9595

9696
```shell
97-
task install:release INSTALL_PREFIX="~/.local"
97+
task log-surgeon:install-release INSTALL_PREFIX="$HOME/.local"
9898
```
9999

100100
Or to only build the project:
101101

102102
```shell
103-
task build:release
103+
task log-surgeon:build-release
104104
```
105105

106106
To build the debug version:
107107

108108
```shell
109-
task build:debug
109+
task log-surgeon:build-debug
110110
```
111111

112112
## Examples
@@ -141,7 +141,7 @@ To host the site locally and view it:
141141
To build and run all unit tests:
142142

143143
```shell
144-
task test:debug
144+
task test:run-debug
145145
```
146146

147147
When generating targets, the CMake variable `BUILD_TESTING` is followed (unless overruled by setting

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ First, ensure you've built and installed the library by following
1414
[these steps][2]. Then run the following command:
1515

1616
```shell
17-
task build:examples-debug
17+
task examples:build-debug
1818
```
1919

2020
## Running

taskfile.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,26 @@ set: ["u", "pipefail"]
44
shopt: ["globstar"]
55

66
includes:
7-
build: "taskfiles/build.yaml"
87
deps: "taskfiles/deps.yaml"
98
docs: "taskfiles/docs.yaml"
9+
examples: "taskfiles/examples.yaml"
1010
lint: "taskfiles/lint.yaml"
11+
log-surgeon: "taskfiles/log-surgeon.yaml"
1112
test: "taskfiles/test.yaml"
1213

1314
vars:
15+
# General variables
16+
# This must match the package name in CMakeLists.txt.
17+
G_CMAKE_PACKAGE_NAME: "log_surgeon"
18+
19+
# Build directories
1420
G_BUILD_DIR: "{{.ROOT_DIR}}/build"
1521
G_EXAMPLES_BUILD_DIR: "{{.G_BUILD_DIR}}/examples"
16-
G_LOG_SURGEON_BUILD_DIR: "{{.G_BUILD_DIR}}/log-surgeon"
22+
G_EXAMPLES_DEBUG_BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/debug"
23+
G_EXAMPLES_RELEASE_BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/release"
24+
G_LOG_SURGEON_BUILD_DIR: "{{.G_BUILD_DIR}}/{{.G_CMAKE_PACKAGE_NAME}}"
25+
G_LOG_SURGEON_DEBUG_BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/debug"
26+
G_LOG_SURGEON_RELEASE_BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/release"
1727

1828
tasks:
1929
clean: "rm -rf '{{.G_BUILD_DIR}}'"

taskfiles/build.yaml

Lines changed: 0 additions & 128 deletions
This file was deleted.

taskfiles/deps.yaml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,23 @@ vars:
1212
G_DEPS_CMAKE_SETTINGS_DIR: "{{.G_DEPS_DIR}}/cmake-settings"
1313

1414
tasks:
15-
default:
16-
deps:
17-
- "all"
18-
19-
all:
15+
install-all:
2016
run: "once"
2117
cmds:
2218
- task: "utils:cmake:install-deps-and-generate-settings"
2319
vars:
2420
CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}"
25-
DEP_TASK: "all-parallel"
21+
DEP_TASK: "install-all-parallel"
2622

27-
all-parallel:
23+
install-all-parallel:
2824
internal: true
2925
run: "once"
3026
deps:
31-
- "Catch2"
32-
- "fmt"
33-
- "Microsoft.GSL"
27+
- "install-catch2"
28+
- "install-fmt"
29+
- "install-microsoft.gsl"
3430

35-
Catch2:
31+
install-catch2:
3632
internal: true
3733
run: "once"
3834
cmds:
@@ -48,7 +44,7 @@ tasks:
4844
TAR_URL: "https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.1.tar.gz"
4945
WORK_DIR: "{{.G_DEPS_DIR}}"
5046

51-
fmt:
47+
install-fmt:
5248
internal: true
5349
run: "once"
5450
cmds:
@@ -65,7 +61,7 @@ tasks:
6561
TAR_URL: "https://github.com/fmtlib/fmt/archive/refs/tags/8.0.1.tar.gz"
6662
WORK_DIR: "{{.G_DEPS_DIR}}"
6763

68-
Microsoft.GSL:
64+
install-microsoft.gsl:
6965
internal: true
7066
run: "once"
7167
cmds:

taskfiles/examples.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
version: "3"
2+
3+
includes:
4+
log-surgeon:
5+
internal: true
6+
taskfile: "log-surgeon.yaml"
7+
utils:
8+
internal: true
9+
taskfile: "../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml"
10+
11+
tasks:
12+
build-debug:
13+
vars:
14+
BUILD_DIR: "{{.G_EXAMPLES_DEBUG_BUILD_DIR}}"
15+
deps:
16+
- task: "generate"
17+
vars:
18+
BUILD_DIR: "{{.BUILD_DIR}}"
19+
BUILD_TYPE: "debug"
20+
cmds:
21+
- task: "utils:cmake:build"
22+
vars:
23+
BUILD_DIR: "{{.BUILD_DIR}}"
24+
25+
build-release:
26+
vars:
27+
BUILD_DIR: "{{.G_EXAMPLES_RELEASE_BUILD_DIR}}"
28+
deps:
29+
- task: "generate"
30+
vars:
31+
BUILD_DIR: "{{.BUILD_DIR}}"
32+
BUILD_TYPE: "release"
33+
cmds:
34+
- task: "utils:cmake:build"
35+
vars:
36+
BUILD_DIR: "{{.BUILD_DIR}}"
37+
38+
clean-debug:
39+
cmds:
40+
- task: "utils:cmake:clean"
41+
vars:
42+
BUILD_DIR: "{{.G_EXAMPLES_DEBUG_BUILD_DIR}}"
43+
44+
clean-release:
45+
cmds:
46+
- task: "utils:cmake:clean"
47+
vars:
48+
BUILD_DIR: "{{.G_EXAMPLES_RELEASE_BUILD_DIR}}"
49+
50+
generate:
51+
internal: true
52+
requires:
53+
vars:
54+
- "BUILD_DIR"
55+
- "BUILD_TYPE"
56+
vars:
57+
LOG_SURGEON_INSTALL_PREFIX: >-
58+
{{.G_EXAMPLES_BUILD_DIR}}/deps/{{.G_CMAKE_PACKAGE_NAME}}/{{.BUILD_TYPE}}
59+
deps:
60+
- task: "log-surgeon:install-{{.BUILD_TYPE}}"
61+
vars:
62+
INSTALL_PREFIX: "{{.LOG_SURGEON_INSTALL_PREFIX}}"
63+
cmds:
64+
- task: "utils:cmake:generate"
65+
vars:
66+
BUILD_DIR: "{{.BUILD_DIR}}"
67+
EXTRA_ARGS:
68+
- "-DCMAKE_BUILD_TYPE={{.BUILD_TYPE}}"
69+
- "-D{{.G_CMAKE_PACKAGE_NAME}}_ROOT={{.LOG_SURGEON_INSTALL_PREFIX}}"
70+
SOURCE_DIR: "{{.ROOT_DIR}}/examples"

0 commit comments

Comments
 (0)