Skip to content

Commit 6ce1f14

Browse files
committed
fix package cache
1 parent 2e6893d commit 6ce1f14

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/build-cache.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ async function getBuildCachePath(): Promise<string> {
5656
const projectRootPath = getProjectRootPath();
5757
if (projectRootPath && projectRootPath !== '' && fsutils.isDir(projectRootPath)) {
5858
const options: ExecOptions = {};
59+
options.env = {
60+
...process.env,
61+
XMAKE_ROOT: 'y'
62+
};
5963
options.cwd = projectRootPath;
6064
options.listeners = {
6165
stdout: (data: Buffer) => {
@@ -153,7 +157,12 @@ export async function saveBuildCache(): Promise<void> {
153157
await io.cp(buildCachePath, fullCachePath, {
154158
recursive: true,
155159
});
156-
await exec('xmake', ['l', 'os.touch', path.join(fullCachePath, 'build_cache_saved.txt')]);
160+
const options: ExecOptions = {};
161+
options.env = {
162+
...process.env,
163+
XMAKE_ROOT: 'y'
164+
};
165+
await exec('xmake', ['l', 'os.touch', path.join(fullCachePath, 'build_cache_saved.txt')], options);
157166
await cache.saveCache([buildCacheFolder], buildCacheKey);
158167
}
159168
}

src/package-cache.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ async function getPackageCacheKey(): Promise<string> {
2727
const projectRootPath = getProjectRootPath();
2828
if (projectRootPath && projectRootPath !== '' && fsutils.isDir(projectRootPath)) {
2929
const options: ExecOptions = {};
30+
options.env = {
31+
...process.env,
32+
XMAKE_ROOT: 'y'
33+
};
3034
options.cwd = projectRootPath;
3135
options.listeners = {
3236
stdout: (data: Buffer) => {
@@ -43,6 +47,10 @@ async function getPackageCacheKey(): Promise<string> {
4347
async function getPackageCachePath(): Promise<string> {
4448
let packageCachePath = '';
4549
const options: ExecOptions = {};
50+
options.env = {
51+
...process.env,
52+
XMAKE_ROOT: 'y'
53+
};
4654
options.listeners = {
4755
stdout: (data: Buffer) => {
4856
packageCachePath += data.toString();
@@ -112,6 +120,12 @@ export async function savePackageCache(): Promise<void> {
112120
await io.cp(packageCachePath, fullCachePath, {
113121
recursive: true,
114122
});
123+
const options: ExecOptions = {};
124+
options.env = {
125+
...process.env,
126+
XMAKE_ROOT: 'y'
127+
};
128+
await exec('xmake', ['l', 'os.touch', path.join(fullCachePath, 'package_cache_saved.txt')], options);
115129
await cache.saveCache([packageCacheFolder], packageCacheKey);
116130
}
117131
}

tests/sample/xmake.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
add_rules("mode.debug", "mode.release")
22

3-
add_requires("libpng", "libogg", {system = false})
3+
add_requires("libpng", "libogg", "libjpeg", {system = false})
44

55
target("sample")
66
set_kind("binary")
77
add_files("src/*.cpp")
8-
add_packages("libpng", "libogg")
8+
add_packages("libpng", "libogg", "libjpeg")
99

0 commit comments

Comments
 (0)