Skip to content

Commit

Permalink
Restore caches
Browse files Browse the repository at this point in the history
  • Loading branch information
Electroid committed Sep 25, 2024
1 parent d38ef1a commit e70944a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
8 changes: 7 additions & 1 deletion cmake/Globals.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ else()
set(WARNING WARNING)
endif()

optionx(VENDOR_PATH FILEPATH "The path to the vendor directory" DEFAULT ${CWD}/vendor)
if(CI)
set(DEFAULT_VENDOR_PATH ${CACHE_PATH}/vendor)
else()
set(DEFAULT_VENDOR_PATH ${CWD}/vendor)
endif()

optionx(VENDOR_PATH FILEPATH "The path to the vendor directory" DEFAULT ${DEFAULT_VENDOR_PATH})
optionx(TMP_PATH FILEPATH "The path to the temporary directory" DEFAULT ${BUILD_PATH}/tmp)

optionx(FRESH BOOL "Set when --fresh is used" DEFAULT OFF)
Expand Down
4 changes: 1 addition & 3 deletions cmake/scripts/DownloadUrl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,5 @@ else()
file(RENAME ${DOWNLOAD_TMP_FILE} ${DOWNLOAD_PATH})
endif()

get_filename_component(DOWNLOAD_FILENAME ${DOWNLOAD_PATH} NAME)
message(STATUS "Saved ${DOWNLOAD_FILENAME}")

file(REMOVE_RECURSE ${DOWNLOAD_TMP_PATH})
message(STATUS "Saved ${DOWNLOAD_PATH}")
56 changes: 28 additions & 28 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node

import { spawn as nodeSpawn } from "node:child_process";
import { existsSync, readFileSync, readdirSync, mkdirSync, cpSync, chmodSync } from "node:fs";
import { basename, join, relative, resolve } from "node:path";
import { existsSync, readFileSync, mkdirSync, cpSync, chmodSync } from "node:fs";
import { basename, join, resolve } from "node:path";

// https://cmake.org/cmake/help/latest/manual/cmake.1.html#generate-a-project-buildsystem
const generateFlags = [
Expand Down Expand Up @@ -57,32 +57,32 @@ async function build(args) {
const cacheRead = isCacheReadEnabled();
const cacheWrite = isCacheWriteEnabled();
if (cacheRead || cacheWrite) {
// const cachePath = getCachePath();
// if (cacheRead && !existsSync(cachePath)) {
// const mainCachePath = getCachePath(getDefaultBranch());
// if (existsSync(mainCachePath)) {
// mkdirSync(cachePath, { recursive: true });
// try {
// cpSync(mainCachePath, cachePath, { recursive: true, force: true });
// } catch (error) {
// const { code } = error;
// switch (code) {
// case "EPERM":
// case "EACCES":
// try {
// chmodSync(mainCachePath, 0o777);
// cpSync(mainCachePath, cachePath, { recursive: true, force: true });
// } catch (error) {
// console.warn("Failed to copy cache with permissions fix", error);
// }
// break;
// default:
// console.warn("Failed to copy cache", error);
// }
// }
// }
// }
// generateOptions["-DCACHE_PATH"] = cmakePath(cachePath);
const cachePath = getCachePath();
if (cacheRead && !existsSync(cachePath)) {
const mainCachePath = getCachePath(getDefaultBranch());
if (existsSync(mainCachePath)) {
mkdirSync(cachePath, { recursive: true });
try {
cpSync(mainCachePath, cachePath, { recursive: true, force: true });
} catch (error) {
const { code } = error;
switch (code) {
case "EPERM":
case "EACCES":
try {
chmodSync(mainCachePath, 0o777);
cpSync(mainCachePath, cachePath, { recursive: true, force: true });
} catch (error) {
console.warn("Failed to copy cache with permissions fix", error);
}
break;
default:
console.warn("Failed to copy cache", error);
}
}
}
}
generateOptions["-DCACHE_PATH"] = cmakePath(cachePath);
generateOptions["--fresh"] = undefined;
if (cacheRead && cacheWrite) {
generateOptions["-DCACHE_STRATEGY"] = "read-write";
Expand Down

0 comments on commit e70944a

Please sign in to comment.