Skip to content

Commit 94f320b

Browse files
committed
deps,test: fixed failures
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
1 parent 7be98d0 commit 94f320b

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

deps/libffi/generate-headers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def render_fficonfig(os_name, target_arch):
158158

159159
def generate_headers(output_dir, target_arch, os_name):
160160
base_dir = Path(__file__).resolve().parent
161-
output_dir = Path(output_dir)
161+
output_dir = Path(str(output_dir).strip().strip('"'))
162162
output_dir.mkdir(parents=True, exist_ok=True)
163163

164164
target, target_dir = get_target(os_name, target_arch)

test/ffi/ffi-test-common.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const libraryPath = path.join(
2222
const fixtureSourcePath = path.join(__dirname, 'fixture_library', 'ffi_test_library.c');
2323
const fixtureExportsPath = path.join(__dirname, 'fixture_library', 'ffi_test_library.def');
2424
const buildLockPath = `${libraryPath}.lock`;
25+
const tempLibraryPath = `${libraryPath}.tmp`;
2526

2627
function sleep(ms) {
2728
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
@@ -32,13 +33,15 @@ function getCompiler(defaultCompiler) {
3233
}
3334

3435
function getBuildCommand() {
36+
const outputPath = tempLibraryPath;
37+
3538
if (process.platform === 'win32') {
3639
return {
3740
command: getCompiler('cl'),
3841
args: [
3942
'/nologo',
4043
'/LD',
41-
`/Fe:${libraryPath}`,
44+
`/Fe:${outputPath}`,
4245
fixtureSourcePath,
4346
'/link',
4447
`/DEF:${fixtureExportsPath}`,
@@ -53,7 +56,7 @@ function getBuildCommand() {
5356
'-dynamiclib',
5457
'-fPIC',
5558
'-o',
56-
libraryPath,
59+
outputPath,
5760
fixtureSourcePath,
5861
],
5962
};
@@ -65,24 +68,28 @@ function getBuildCommand() {
6568
'-shared',
6669
'-fPIC',
6770
'-o',
68-
libraryPath,
71+
outputPath,
6972
fixtureSourcePath,
7073
],
7174
};
7275
}
7376

7477
function buildFixtureLibrary() {
7578
fs.mkdirSync(fixtureBuildDir, { recursive: true });
79+
fs.rmSync(tempLibraryPath, { force: true });
7680

7781
const { command, args } = getBuildCommand();
7882
const { status, error, stderr } = childProcess.spawnSync(command, args, {
7983
stdio: ['ignore', 'ignore', 'pipe'],
8084
});
8185

82-
if (status === 0 && fs.existsSync(libraryPath)) {
86+
if (status === 0 && fs.existsSync(tempLibraryPath)) {
87+
fs.renameSync(tempLibraryPath, libraryPath);
8388
return;
8489
}
8590

91+
fs.rmSync(tempLibraryPath, { force: true });
92+
8693
const renderedCommand = [command, ...args].join(' ');
8794
const details = (error?.message || stderr?.toString() || `exit code ${status}`).trim();
8895
throw new Error(
@@ -106,16 +113,13 @@ function ensureFixtureLibrary() {
106113

107114
const deadline = Date.now() + 30000;
108115
while (Date.now() < deadline) {
109-
if (fs.existsSync(libraryPath)) {
110-
return;
111-
}
112116
if (!fs.existsSync(buildLockPath)) {
113117
break;
114118
}
115119
sleep(50);
116120
}
117121

118-
if (fs.existsSync(libraryPath)) {
122+
if (fs.existsSync(libraryPath) && !fs.existsSync(buildLockPath)) {
119123
return;
120124
}
121125
}

0 commit comments

Comments
 (0)