Skip to content
64 changes: 56 additions & 8 deletions taskfiles/deps/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -390,27 +390,75 @@ tasks:
TARBALL_SHA256: "537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b"
TARBALL_URL: "https://github.com/lz4/lz4/releases/download/v1.10.0/lz4-1.10.0.tar.gz"

mariadb-connector-cpp-download-and-validate-checksum:
internal: true
requires:
vars: ["CHECKSUM_FILE"]
cmds:
- task: "yscope-dev-utils:remote:download-and-extract-tar"
vars:
FILE_SHA256: "0e3dfe9f2bc3f7bb6f7c159009556290064a7c23402ea08019fa8aebfc3ff2c9"
OUTPUT_DIR: "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-extracted"
Comment on lines +393 to +401
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Validate before downloading; add run: once and stable TAR_FILE

Run checksum:validate first to bail out early and skip the whole download/extract when install is unchanged. Also mark the helper run: "once" and set a stable TAR_FILE (and forward CHECKSUM_FILE) to maximise caching.

   mariadb-connector-cpp-download-and-validate-checksum:
     internal: true
+    run: "once"
     requires:
       vars: ["CHECKSUM_FILE"]
     cmds:
-      - task: "yscope-dev-utils:remote:download-and-extract-tar"
-        vars:
-          FILE_SHA256: "0e3dfe9f2bc3f7bb6f7c159009556290064a7c23402ea08019fa8aebfc3ff2c9"
-          OUTPUT_DIR: "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-extracted"
-          URL: "https://github.com/mariadb-corporation/mariadb-connector-cpp/archive/refs/tags/\
-            1.1.5.tar.gz"
-      # Uses checksum to skip mariadb-connector-cpp installation because the build updates the
-      # source directory and will always rebuild.
       - task: "yscope-dev-utils:checksum:validate"
         vars:
           CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
           INCLUDE_PATTERNS: &mariadb-cmake-include-patterns
             - "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-install"
+      - task: "yscope-dev-utils:remote:download-and-extract-tar"
+        vars:
+          CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
+          FILE_SHA256: "0e3dfe9f2bc3f7bb6f7c159009556290064a7c23402ea08019fa8aebfc3ff2c9"
+          OUTPUT_DIR: "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-extracted"
+          TAR_FILE: "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-extracted.tar.gz"
+          URL: "https://github.com/mariadb-corporation/mariadb-connector-cpp/archive/refs/tags/\
+            1.1.5.tar.gz"

Also applies to: 406-411

🤖 Prompt for AI Agents
In taskfiles/deps/main.yaml around lines 393 to 401 (and similarly lines 406 to
411), the download-and-extract helper is invoked unconditionally without running
checksum:validate first, without run: once, and without a stable TAR_FILE or
forwarding CHECKSUM_FILE; update the task entries to first run checksum:validate
to short-circuit when unchanged, add run: "once" to the helper invocation to
enable caching, set a stable TAR_FILE var pointing to the exact tarball name (so
cache keys remain stable), and forward the CHECKSUM_FILE variable into the
helper so it can validate against the provided checksum before
downloading/extracting.

URL: "https://github.com/mariadb-corporation/mariadb-connector-cpp/archive/refs/tags/\
1.1.5.tar.gz"
# Uses checksum to skip mariadb-connector-cpp installation because the build updates the
# source directory and will always rebuild.
- task: "yscope-dev-utils:checksum:validate"
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
INCLUDE_PATTERNS: &mariadb-cmake-include-patterns
- "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-install"

mariadb-connector-cpp:
internal: true
vars:
# Cannot use dependency checksum directory because it is cleaned up in `utils:init`.
CHECKSUM_FILE: "{{.G_DEPS_CPP_CHECKSUMS_DIR}}/mariadb-connector-cpp.md5"
sources:
- "{{.TASKFILE}}"
- "{{.CHECKSUM_FILE}}"
platforms: ["linux"]
generates: ["{{.CHECKSUM_FILE}}"]
run: "once"
deps:
- task: "mariadb-connector-cpp-download-and-validate-checksum"
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
preconditions:
# NOTE: The MariaDB connector is only required for building Spider, which is only supported on
# Ubuntu. `INSTALL_LAYOUT` is currently hardcoded to "DEB". To support other Linux distros:
# - Update the precondition accordingly.
# - Make `INSTALL_LAYOUT` configurable.
- >-
source /etc/os-release && [[ "$ID" == "ubuntu" ]]
internal: true
run: "once"
cmds:
- task: "utils:install-remote-cmake-lib"
# Copies extracted files so that the build won't pollute the extracted files and cause
# unnecessary rebuilds.
- |-
rm -rf "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-src"
cp -r "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-extracted" \
"{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-src"
- task: "yscope-dev-utils:cmake:generate"
Comment on lines +438 to +441
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Copy step is fine; consider rsync for robustness (optional)

Current rm/cp works. If large trees or hidden files become an issue, rsync reduces risk and handles deletions:

-rm -rf "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-src"
-cp -r "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-extracted" \
-"{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-src"
+rsync -a --delete "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-extracted/" \
+  "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-src/"
🤖 Prompt for AI Agents
In taskfiles/deps/main.yaml around lines 438-441, the current remove-and-cp
sequence is fragile for large trees and hidden files; replace it with an
rsync-based copy so deletions and hidden files are handled robustly. Use rsync
in archive mode with delete semantics (preserve permissions, links, times, and
handle hidden files) from the extracted directory to the src directory, ensure
correct trailing-slash semantics on the source to copy contents not the parent
dir, and remove the preceding rm -rf so rsync alone manages updates and
deletions.

vars:
CMAKE_GEN_ARGS:
BUILD_DIR: "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-build"
EXTRA_ARGS:
- "-DUSE_SYSTEM_INSTALLED_LIB=ON"
- "-DINSTALL_LAYOUT=DEB"
LIB_NAME: "mariadb-connector-cpp"
TARBALL_URL: "https://github.com/mariadb-corporation/mariadb-connector-cpp/archive/refs/\
tags/1.1.5.tar.gz"
TARBALL_SHA256: "0e3dfe9f2bc3f7bb6f7c159009556290064a7c23402ea08019fa8aebfc3ff2c9"
SOURCE_DIR: "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-src"
- task: "yscope-dev-utils:cmake:build"
vars:
BUILD_DIR: "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-build"
JOBS: "{{.G_CPP_MAX_PARALLELISM_PER_BUILD_TASK}}"
- task: "yscope-dev-utils:cmake:install"
vars:
BUILD_DIR: "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-build"
CMAKE_PACKAGE_NAME: "mariadb-connector-cpp"
CMAKE_SETTINGS_DIR: "{{.G_DEPS_CPP_CMAKE_SETTINGS_DIR}}"
INSTALL_PREFIX: "{{.G_DEPS_CPP_DIR}}/mariadb-connector-cpp-install"
- task: "yscope-dev-utils:checksum:compute"
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
INCLUDE_PATTERNS: *mariadb-cmake-include-patterns

microsoft.gsl:
internal: true
Expand Down
Loading