Skip to content

Commit 56470ad

Browse files
committed
Refactor taskfiles.
1 parent 22a27c8 commit 56470ad

File tree

6 files changed

+83
-52
lines changed

6 files changed

+83
-52
lines changed

taskfile.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ shopt: ["globstar"]
66
includes:
77
build: "./taskfiles/build.yaml"
88
deps: "./taskfiles/deps.yaml"
9+
examples: "./taskfiles/examples.yaml"
910
lint: "./taskfiles/lint.yaml"
1011
test: "./taskfiles/test.yaml"
1112
utils: "./tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml"
1213

1314
vars:
1415
G_BUILD_DIR: "{{.ROOT_DIR}}/build"
15-
G_CPP_SRC_DIR: "{{.ROOT_DIR}}/src"
16+
G_EXAMPLES_BUILD_DIR: "{{.G_BUILD_DIR}}/examples"
17+
G_EXAMPLES_SRC_DIR: "{{.ROOT_DIR}}/examples/src"
1618
G_YSTDLIB_BUILD_DIR: "{{.G_BUILD_DIR}}/ystdlib"
19+
G_YSTDLIB_SRC_DIR: "{{.ROOT_DIR}}/src"
1720

1821
G_VALID_BUILD_TYPES:
1922
- "debug"

taskfiles/build.yaml

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ includes:
88
internal: true
99
taskfile: "../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml"
1010

11-
vars:
12-
G_EXAMPLES_BUILD_DIR: "{{.G_BUILD_DIR}}/examples"
13-
1411
tasks:
1512
build-*-*:
1613
desc: "build-<target>-<build type>: Builds the specified build target with build type."
@@ -41,19 +38,6 @@ tasks:
4138
vars:
4239
BUILD_DIR: "{{.G_YSTDLIB_BUILD_DIR}}/{{.BUILD_TYPE}}"
4340

44-
examples-*:
45-
desc: "examples-<build type>: Builds the examples with build type."
46-
vars:
47-
BUILD_TYPE: "{{index .MATCH 0}}"
48-
deps:
49-
- task: ":validate-build-type"
50-
vars:
51-
BUILD_TYPE: "{{.BUILD_TYPE}}"
52-
cmds:
53-
- task: "examples"
54-
vars:
55-
BUILD_TYPE: "{{.BUILD_TYPE}}"
56-
5741
install-*-*:
5842
desc: >-
5943
install-<target>-<build type> INSTALL_PREFIX="<prefix path>": Install the specified build
@@ -94,30 +78,6 @@ tasks:
9478
TARGETS:
9579
- "{{.TARGET}}"
9680

97-
examples:
98-
internal: true
99-
requires:
100-
vars: ["BUILD_TYPE"]
101-
vars:
102-
INSTALL_PREFIX: "{{.G_EXAMPLES_BUILD_DIR}}/deps/ystdlib/{{.BUILD_TYPE}}"
103-
deps:
104-
- task: "install"
105-
vars:
106-
BUILD_TYPE: "{{.BUILD_TYPE}}"
107-
INSTALL_PREFIX: "{{.INSTALL_PREFIX}}"
108-
TARGET: "all"
109-
cmds:
110-
- task: "utils:cmake:generate"
111-
vars:
112-
BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}"
113-
EXTRA_ARGS:
114-
- "-DCMAKE_BUILD_TYPE={{.BUILD_TYPE}}"
115-
- "-Dystdlib_ROOT={{.INSTALL_PREFIX}}"
116-
SOURCE_DIR: "{{.ROOT_DIR}}/examples"
117-
- task: "utils:cmake:build"
118-
vars:
119-
BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}"
120-
12181
install:
12282
internal: true
12383
requires:

taskfiles/examples.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
version: "3"
2+
3+
includes:
4+
build:
5+
internal: true
6+
taskfile: "build.yaml"
7+
deps:
8+
internal: true
9+
taskfile: "deps.yaml"
10+
utils:
11+
internal: true
12+
taskfile: "../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml"
13+
14+
tasks:
15+
build-*:
16+
desc: "build-<build type>: Builds the examples with build type."
17+
vars:
18+
BUILD_TYPE: "{{index .MATCH 0}}"
19+
deps:
20+
- task: ":validate-build-type"
21+
vars:
22+
BUILD_TYPE: "{{.BUILD_TYPE}}"
23+
cmds:
24+
- task: "build"
25+
vars:
26+
BUILD_TYPE: "{{.BUILD_TYPE}}"
27+
28+
clean-*:
29+
desc: "clean-<build type>: Clean the examples of build type."
30+
vars:
31+
BUILD_TYPE: "{{index .MATCH 0}}"
32+
deps:
33+
- task: ":validate-build-type"
34+
vars:
35+
BUILD_TYPE: "{{.BUILD_TYPE}}"
36+
cmds:
37+
- task: "utils:cmake:clean"
38+
vars:
39+
BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}"
40+
41+
build:
42+
internal: true
43+
requires:
44+
vars: ["BUILD_TYPE"]
45+
vars:
46+
INSTALL_PREFIX: "{{.G_EXAMPLES_BUILD_DIR}}/deps/ystdlib/{{.BUILD_TYPE}}"
47+
deps:
48+
- task: "build:install"
49+
vars:
50+
BUILD_TYPE: "{{.BUILD_TYPE}}"
51+
INSTALL_PREFIX: "{{.INSTALL_PREFIX}}"
52+
TARGET: "all"
53+
cmds:
54+
- task: "utils:cmake:generate"
55+
vars:
56+
BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}"
57+
EXTRA_ARGS:
58+
- "-DCMAKE_BUILD_TYPE={{.BUILD_TYPE}}"
59+
- "-Dystdlib_ROOT={{.INSTALL_PREFIX}}"
60+
SOURCE_DIR: "{{.ROOT_DIR}}/examples"
61+
- task: "utils:cmake:build"
62+
vars:
63+
BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}"

taskfiles/lint-cpp.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ tasks:
2020
cpp-format-check:
2121
desc: "Runs the C++ linters that identify formatting issues."
2222
sources: &cpp_format_src_files
23+
- "{{.G_EXAMPLES_SRC_DIR}}/**/*.cpp"
24+
- "{{.G_EXAMPLES_SRC_DIR}}/**/*.h"
25+
- "{{.G_EXAMPLES_SRC_DIR}}/**/*.hpp"
2326
- "{{.G_LINT_VENV_CHECKSUM_FILE}}"
24-
- "{{.G_CPP_SRC_DIR}}/**/*.cpp"
25-
- "{{.G_CPP_SRC_DIR}}/**/*.h"
26-
- "{{.G_CPP_SRC_DIR}}/**/*.hpp"
27+
- "{{.G_YSTDLIB_SRC_DIR}}/**/*.cpp"
28+
- "{{.G_YSTDLIB_SRC_DIR}}/**/*.h"
29+
- "{{.G_YSTDLIB_SRC_DIR}}/**/*.hpp"
2730
- "{{.ROOT_DIR}}/.clang-format"
2831
- "{{.TASKFILE}}"
2932
deps:
@@ -33,8 +36,8 @@ tasks:
3336
- task: ":utils:cpp-lint:clang-format"
3437
vars:
3538
FLAGS: ["--dry-run"]
36-
INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp"]
37-
ROOT_PATHS: ["{{.G_CPP_SRC_DIR}}"]
39+
ROOT_PATHS:
40+
ref: ".G_LINT_CPP_ROOT_DIRS"
3841
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
3942

4043
cpp-format-fix:
@@ -47,8 +50,8 @@ tasks:
4750
- task: ":utils:cpp-lint:clang-format"
4851
vars:
4952
FLAGS: ["-i"]
50-
INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp"]
51-
ROOT_PATHS: ["{{.G_CPP_SRC_DIR}}"]
53+
ROOT_PATHS:
54+
ref: ".G_LINT_CPP_ROOT_DIRS"
5255
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
5356

5457
cpp-static-check:
@@ -70,7 +73,8 @@ tasks:
7073
- "--config-file '{{.ROOT_DIR}}/.clang-tidy'"
7174
- "-p '{{.G_COMPILE_COMMANDS_DB}}'"
7275
OUTPUT_DIR: "{{.G_LINT_CLANG_TIDY_DIR}}"
73-
ROOT_PATHS: ["{{.G_CPP_SRC_DIR}}"]
76+
ROOT_PATHS:
77+
ref: ".G_LINT_CPP_ROOT_DIRS"
7478
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
7579

7680
cpp-configs:

taskfiles/lint.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ includes:
1515
taskfile: "./lint-yaml.yaml"
1616

1717
vars:
18-
G_LINT_CPP_DIRS:
19-
- "{{.G_CPP_SRC_DIR}}"
18+
G_LINT_CPP_ROOT_DIRS:
19+
- "{{.G_EXAMPLES_SRC_DIR}}"
20+
- "{{.G_YSTDLIB_SRC_DIR}}"
2021
G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv"
2122
G_LINT_VENV_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/lint#venv.md5"
2223

taskfiles/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ tasks:
2323
vars:
2424
BUILD_TYPE: "{{.BUILD_TYPE}}"
2525
TARGET: "{{.TEST_TARGET}}"
26-
- "{{.G_YSTDLIB_BUILD_DIR}}/testbin/{{.TEST_TARGET}}"
26+
- "{{.G_YSTDLIB_BUILD_DIR}}/{{.BUILD_TYPE}}/testbin/{{.TEST_TARGET}}"

0 commit comments

Comments
 (0)