Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 93 additions & 1 deletion taskfiles/utils-cmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ tasks:
cmake-build:
internal: true
label: "{{.TASK}}:{{.BUILD_DIR}}-{{.TARGETS}}-{{.EXTRA_ARGS}}"
vars:
EXTRA_ARGS:
ref: default (list) .EXTRA_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
JOBS: >-
{{default "" .JOBS}}
TARGETS:
ref: default (list) .TARGETS
Comment thread
davidlion marked this conversation as resolved.
Outdated
requires:
vars: ["BUILD_DIR"]
cmds:
Expand All @@ -37,14 +44,17 @@ tasks:
# @param {string[]} [EXTRA_ARGS] Any additional arguments to pass with the clean target.
cmake-clean:
internal: true
vars:
EXTRA_ARGS:
ref: default (list) .EXTRA_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
requires:
vars: ["BUILD_DIR"]
cmds:
- task: "cmake-build"
vars:
BUILD_DIR: "{{.BUILD_DIR}}"
EXTRA_ARGS:
ref: "default (list) .EXTRA_ARGS"
ref: .EXTRA_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
TARGETS: ["clean"]

# Runs the CMake generate step for the given source and build directories. We purposely omit
Expand All @@ -57,6 +67,9 @@ tasks:
cmake-generate:
internal: true
label: "{{.TASK}}:{{.SOURCE_DIR}}-{{.BUILD_DIR}}-{{.EXTRA_ARGS}}"
vars:
EXTRA_ARGS:
ref: default (list) .EXTRA_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
requires:
vars: ["BUILD_DIR", "SOURCE_DIR"]
cmds:
Expand All @@ -78,6 +91,9 @@ tasks:
cmake-install:
internal: true
label: "{{.TASK}}:{{.BUILD_DIR}}-{{.INSTALL_PREFIX}}-{{.EXTRA_ARGS}}"
vars:
EXTRA_ARGS:
ref: default (list) .EXTRA_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
requires:
vars: ["BUILD_DIR", "INSTALL_PREFIX"]
cmds:
Expand All @@ -88,3 +104,79 @@ tasks:
{{- range .EXTRA_ARGS}}
"{{.}}"
{{- end}}

# Downloads a CMake project tar file from `URL` and then generates, builds, and installs the
# project. We purposely omit `sources` and `generates` as we defer to `cmake` to decide whether it
# should perform any actions. However, the download and extraction will be skipped if unnecessary.
#
# @param {string} FILE_SHA256 Content hash to verify the downloaded tar file against.
# @param {string} NAME Project name used for directory names.
Comment thread
davidlion marked this conversation as resolved.
Outdated
# @param {string} URL
# @param {string[]} [BUILD_ARGS] Any additional arguments to pass to the build command.
Comment thread
davidlion marked this conversation as resolved.
Outdated
# @param {string} [BUILD_DIR={{.WORK_DIR}}/{{.NAME}}-build] Directory in which to generate the
# build system and perform the build.
# @param {string[]} [GEN_ARGS] Any additional arguments to pass to the generate command.
# @param {string[]} [INSTALL_ARGS] Any additional arguments to pass to the install command.
Comment thread
davidlion marked this conversation as resolved.
Outdated
# @param {string} [INSTALL_PREFIX={{.WORK_DIR}}/{{.NAME}}-install] Path prefix of where the
# project should be installed.
# @param {int} [JOBS] The maximum number of concurrent processes to use when building. If
# omitted, the native build tool's default number is used. See `man cmake`.
# @param {string} [SOURCE_DIR={{.WORK_DIR}}/{{.NAME}}-src] Directory in which to extract the tar
# file.
# @param {string[]} [TARGETS] A list of specific targets to build instead of the default target.
# @param {string} [WORK_DIR={{.TASK_DIR}}] Base directory to store the build, install, and src
# directories inside.
cmake-install-remote-tar:
internal: true
label: "{{.TASK}}:{{.NAME}}-{{.URL}}-{{.INSTALL_PREFIX}}"
vars:
# Paths
WORK_DIR: >-
{{default .ROOT_DIR .WORK_DIR}}
Comment on lines +143 to +144

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix WORK_DIR default value

The default value uses .ROOT_DIR but the documentation states it should default to .TASK_DIR.

Apply this diff to fix the default value:

-        {{default .ROOT_DIR .WORK_DIR}}
+        {{default .TASK_DIR .WORK_DIR}}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
WORK_DIR: >-
{{default .ROOT_DIR .WORK_DIR}}
WORK_DIR: >-
{{default .TASK_DIR .WORK_DIR}}

BUILD_DIR: >-
{{default (printf "%s/%s-build" .WORK_DIR .NAME) .BUILD_DIR}}
INSTALL_PREFIX: >-
{{default (printf "%s/%s-install" .WORK_DIR .NAME) .INSTALL_PREFIX}}
SOURCE_DIR: >-
{{default (printf "%s/%s-src" .WORK_DIR .NAME) .SOURCE_DIR}}

# Optional CMake arguments
BUILD_ARGS:
ref: default (list) .BUILD_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
GEN_ARGS:
ref: default (list) .GEN_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
INSTALL_ARGS:
ref: default (list) .INSTALL_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
JOBS: >-
{{default "" .JOBS}}
TARGETS:
ref: default (list) .TARGETS
Comment thread
davidlion marked this conversation as resolved.
Outdated
requires:
vars: ["FILE_SHA256", "NAME", "URL"]
deps:
- task: ":utils:download-and-extract-tar"
vars:
FILE_SHA256: "{{.FILE_SHA256}}"
OUTPUT_DIR: "{{.SOURCE_DIR}}"
URL: "{{.URL}}"
cmds:
- task: ":utils:cmake-generate"
vars:
BUILD_DIR: "{{.BUILD_DIR}}"
EXTRA_ARGS:
ref: .GEN_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
Comment thread
davidlion marked this conversation as resolved.
Outdated
SOURCE_DIR: "{{.SOURCE_DIR}}"
- task: ":utils:cmake-build"
vars:
BUILD_DIR: "{{.BUILD_DIR}}"
EXTRA_ARGS:
ref: .BUILD_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
JOBS: "{{.JOBS}}"
TARGETS:
ref: .TARGETS
Comment thread
davidlion marked this conversation as resolved.
Outdated
- task: ":utils:cmake-install"
vars:
BUILD_DIR: "{{.BUILD_DIR}}"
EXTRA_ARGS:
ref: .INSTALL_ARGS
Comment thread
davidlion marked this conversation as resolved.
Outdated
INSTALL_PREFIX: "{{.INSTALL_PREFIX}}"