Skip to content

Commit b3769e2

Browse files
committed
support bstracing -C
1 parent 514edef commit b3769e2

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,4 @@ native/
142142
vendor/ocaml
143143
jscomp/.lsp
144144
.vscode/launch.json
145+
tracing*.json

lib/bstracing

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ function category(target, obj) {
160160
return obj;
161161
}
162162
/**
163-
*
163+
* @param {string} file
164164
* @param {boolean} showAll
165165
*/
166-
function readTargets(showAll) {
166+
function readTargets(file, showAll) {
167167
let lastEndSeen = 0;
168168
let targets = new Map();
169169
processEntry(
170-
path.join("lib", "bs", ".ninja_log"),
170+
file,
171171
line => {
172172
let lineTrim = line.trim();
173173
if (lineTrim.startsWith("#")) {
@@ -207,5 +207,37 @@ function readTargets(showAll) {
207207
}
208208
);
209209
}
210+
let logName = ".ninja_log";
210211

211-
readTargets(false);
212+
/**
213+
* @type {string}
214+
*/
215+
var file;
216+
/**
217+
*
218+
* @param ps {string[]}
219+
*/
220+
function tryLocation(ps) {
221+
for (let p of ps) {
222+
let log = path.join(p, logName);
223+
if (fs.existsSync(log)) {
224+
file = log;
225+
return;
226+
}
227+
}
228+
console.error(
229+
`no .ninja_log found in specified paths, make sure you set bstracing to the proper directory`
230+
);
231+
process.exit(2);
232+
}
233+
{
234+
let index = process.argv.indexOf(`-C`);
235+
if (index >= 0) {
236+
let p = process.argv[index + 1];
237+
tryLocation([p]);
238+
} else {
239+
tryLocation([path.join("lib", "bs"), "."]);
240+
}
241+
}
242+
console.log("loading build log", file, "is used");
243+
readTargets(file, false);

0 commit comments

Comments
 (0)