Skip to content

Commit a61ad62

Browse files
committed
make the build happen in out
it was happening in third_party/dawn/out
1 parent 483ff80 commit a61ad62

File tree

5 files changed

+54
-29
lines changed

5 files changed

+54
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.vscode
44
node_modules
55
third_party/package.json
6+
out
67

78
# --cut-here--
89
dist

build/build.js

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,27 @@ import path from 'node:path';
22
import fs from 'node:fs';
33

44
import {execute} from './execute.js';
5-
import {addElemIf, appendPathIfItExists, exists, prependPathIfItExists} from './utils.js';
6-
7-
//const __dirname = dirname(fileURLToPath(import.meta.url));
8-
const kCwd = process.cwd();
9-
const kDepotToolsPath = path.join(kCwd, 'third_party', 'depot_tools');
10-
const kDawnPath = `${kCwd}/third_party/dawn`;
11-
const kOutDir = 'out/cmake-release';
12-
const kBuildPath = `${kDawnPath}/${kOutDir}`
13-
const kConfig = process.env.CMAKE_BUILD_TYPE ?? 'Release';
14-
15-
const isMac = process.platform === 'darwin';
16-
const isWin = process.platform === 'win32';
5+
import {
6+
addElemIf,
7+
appendPath,
8+
appendPathIfItExists,
9+
exists,
10+
prependPathIfItExists,
11+
processThenRestoreCWD,
12+
} from './utils.js';
13+
import {
14+
kDepotToolsPath,
15+
kDawnPath,
16+
kBuildPath,
17+
kConfig,
18+
isMac,
19+
isWin,
20+
} from './constants.js';
1721

1822
prependPathIfItExists(kDepotToolsPath);
1923
appendPathIfItExists('/Applications/CMake.app/Contents/bin');
2024
appendPathIfItExists('C:\\Program Files\\CMake\\bin');
21-
22-
async function processThenRestoreCWD(fn) {
23-
const cwd = process.cwd();
24-
try {
25-
await fn();
26-
} finally {
27-
process.chdir(cwd);
28-
}
29-
}
25+
appendPath(`${kDawnPath}/third_party/ninja`);
3026

3127
async function compile() {
3228
await processThenRestoreCWD(async () => {
@@ -46,11 +42,11 @@ async function createProject() {
4642
fs.copyFileSync('scripts/standalone-with-node.gclient', '.gclient');
4743
await execute('gclient', ['metrics', '--opt-out']);
4844
await execute('gclient', ['sync']);
49-
if (exists(kOutDir)) {
50-
fs.rmSync(kOutDir, {recursive: true});
45+
if (exists(kBuildPath)) {
46+
fs.rmSync(kBuildPath, {recursive: true});
5147
}
52-
fs.mkdirSync(kOutDir, {recursive: true});
53-
process.chdir(kOutDir);
48+
fs.mkdirSync(kBuildPath, {recursive: true});
49+
process.chdir(kBuildPath);
5450

5551
await execute('cmake', [
5652
kDawnPath,

build/constants.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import path from 'node:path';
2+
3+
export const kCwd = process.cwd();
4+
export const kDepotToolsPath = path.join(kCwd, 'third_party', 'depot_tools');
5+
export const kDawnPath = `${kCwd}/third_party/dawn`;
6+
export const kOutDir = `${kCwd}/out`;
7+
export const kBuildPath = `${kOutDir}/cmake-release`;
8+
export const kConfig = process.env.CMAKE_BUILD_TYPE ?? 'Release';
9+
10+
export const isMac = process.platform === 'darwin';
11+
export const isWin = process.platform === 'win32';

build/utils.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@ export function exists(filename) {
1111
}
1212
}
1313

14+
export function prependPath(filepath) {
15+
process.env.PATH = `${filepath}${path.delimiter}${process.env.PATH}`;
16+
}
17+
18+
export function appendPath(filepath) {
19+
process.env.PATH = `${process.env.PATH}${path.delimiter}${filepath}`;
20+
}
21+
1422
export function prependPathIfItExists(filepath) {
1523
if (exists(filepath)) {
16-
process.env.PATH = `${filepath}${path.delimiter}${process.env.PATH}`;
24+
prependPath(filepath);
1725
}
1826
}
1927

2028
export function appendPathIfItExists(filepath) {
2129
if (exists(filepath)) {
22-
process.env.PATH = `${process.env.PATH}${path.delimiter}${filepath}`;
30+
appendPath(filepath);
2331
}
2432
}
2533

@@ -57,4 +65,13 @@ export function parseArgs({options, args}) {
5765
process.exit(1);
5866
}
5967
return { values, positionals };
60-
}
68+
}
69+
70+
export async function processThenRestoreCWD(fn) {
71+
const cwd = process.cwd();
72+
try {
73+
await fn();
74+
} finally {
75+
process.chdir(cwd);
76+
}
77+
}

third_party/depot_tools

Submodule depot_tools updated from 6da6aec to 8ab2a53

0 commit comments

Comments
 (0)