@andersbakken/fisk 4.0.63 → 4.0.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ var require$$0$1 = require('stream');
9
9
  var require$$4 = require('util');
10
10
  var path$h = require('path');
11
11
  var require$$1$1 = require('os');
12
- var posix = require('posix');
12
+ var fiskNative = require('@andersbakken/fisk-native');
13
13
 
14
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
15
 
@@ -22,7 +22,6 @@ var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
22
22
  var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
23
23
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path$h);
24
24
  var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
25
- var posix__default = /*#__PURE__*/_interopDefaultLegacy(posix);
26
25
 
27
26
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
28
27
 
@@ -3045,7 +3044,7 @@ class Compile extends EventEmitter__default["default"] {
3045
3044
  let outputFileName;
3046
3045
  let hasDashO = false;
3047
3046
  let hasDashX = false;
3048
- let sourceFile;
3047
+ let sourcePath;
3049
3048
  for (let i = 0; i < args.length; ++i) {
3050
3049
  // console.log(i, args[i]);
3051
3050
  switch (args[i]) {
@@ -3126,21 +3125,21 @@ class Compile extends EventEmitter__default["default"] {
3126
3125
  break;
3127
3126
  }
3128
3127
  if (args[i][0] !== "-") {
3129
- if (sourceFile) {
3130
- console.log("Multiple source files", sourceFile, args[i]);
3128
+ if (sourcePath) {
3129
+ console.log("Multiple source files", sourcePath, args[i]);
3131
3130
  throw new Error("More than one source file");
3132
3131
  }
3133
- sourceFile = args[i];
3132
+ sourcePath = args[i];
3134
3133
  args[i] = path__default["default"].join(dir, "sourcefile");
3135
3134
  }
3136
3135
  break;
3137
3136
  }
3138
3137
  }
3139
- if (!sourceFile) {
3138
+ if (!sourcePath) {
3140
3139
  throw new Error("No sourcefile");
3141
3140
  }
3142
3141
  if (!hasDashX) {
3143
- switch (path__default["default"].extname(sourceFile)) {
3142
+ switch (path__default["default"].extname(sourcePath)) {
3144
3143
  case ".C":
3145
3144
  case ".cc":
3146
3145
  case ".cpp":
@@ -3184,7 +3183,7 @@ class Compile extends EventEmitter__default["default"] {
3184
3183
  args.unshift(isClang ? "objective-c++" : "objective-c++-cpp-output");
3185
3184
  break;
3186
3185
  default:
3187
- throw new Error(`Can't determine source language for file: ${sourceFile}`);
3186
+ throw new Error(`Can't determine source language for file: ${sourcePath}`);
3188
3187
  }
3189
3188
  args.unshift("-x");
3190
3189
  }
@@ -3195,8 +3194,8 @@ class Compile extends EventEmitter__default["default"] {
3195
3194
  args.push("-Wno-stdlibcxx-not-found");
3196
3195
  }
3197
3196
  if (!hasDashO) {
3198
- const suffix = path__default["default"].extname(sourceFile);
3199
- outputFileName = output = sourceFile.substring(0, sourceFile.length - suffix.length) + ".o";
3197
+ const suffix = path__default["default"].extname(sourcePath);
3198
+ outputFileName = output = sourcePath.substring(0, sourcePath.length - suffix.length) + ".o";
3200
3199
  args.push("-o", outputFileName);
3201
3200
  }
3202
3201
  // debug = true;
@@ -3206,7 +3205,7 @@ class Compile extends EventEmitter__default["default"] {
3206
3205
  if (!fs.existsSync("/usr/bin/as")) {
3207
3206
  this.emit("stderr", "as doesn't exist");
3208
3207
  }
3209
- console.log("going for it", compiler, args);
3208
+ console.log(`Compiling source file: ${sourcePath}\n${[compiler, ...args].join(" ")}`);
3210
3209
  // const env = Object.assign({ TMPDIR: dir, TEMPDIR: dir, TEMP: dir }, process.env);
3211
3210
  const proc = child_process__default["default"].spawn(compiler, args, {
3212
3211
  /*env: env, */ cwd: dir // , maxBuffer: 1024 * 1024 * 16
@@ -3226,6 +3225,7 @@ class Compile extends EventEmitter__default["default"] {
3226
3225
  proc.on("exit", (exitCode) => {
3227
3226
  // try {
3228
3227
  const files = [];
3228
+ let addDirError;
3229
3229
  const addDir = (directory, prefix) => {
3230
3230
  try {
3231
3231
  fs.readdirSync(directory).forEach((file) => {
@@ -3242,21 +3242,21 @@ class Compile extends EventEmitter__default["default"] {
3242
3242
  if (file === outputFileName) {
3243
3243
  files.push({ path: output, mapped: path__default["default"].join(prefix, file) });
3244
3244
  }
3245
- else if (path__default["default"].extname(file) === ".gcno") {
3246
- // console.log("mapping", output, prefix, file);
3247
- files.push({
3248
- path: output.substring(0, output.length - 1) + "gcno",
3249
- mapped: path__default["default"].join(prefix, file)
3250
- });
3251
- }
3252
- else if (path__default["default"].extname(file) === ".gcda") {
3253
- files.push({
3254
- path: output.substring(0, output.length - 1) + "gcda",
3255
- mapped: path__default["default"].join(prefix, file)
3256
- });
3257
- }
3258
3245
  else {
3259
- files.push({ path: path__default["default"].join(prefix, file) });
3246
+ const ext = path__default["default"].extname(file);
3247
+ switch (ext) {
3248
+ case ".gcno":
3249
+ case ".gcda":
3250
+ case ".dwo":
3251
+ files.push({
3252
+ path: output.substring(0, output.length - 2) + ext,
3253
+ mapped: path__default["default"].join(prefix, file)
3254
+ });
3255
+ break;
3256
+ default:
3257
+ files.push({ path: path__default["default"].join(prefix, file) });
3258
+ break;
3259
+ }
3260
3260
  }
3261
3261
  if (debug) {
3262
3262
  console.log("Added file", file, files[files.length - 1]);
@@ -3264,30 +3264,33 @@ class Compile extends EventEmitter__default["default"] {
3264
3264
  }
3265
3265
  }
3266
3266
  catch (err) {
3267
- /* */
3267
+ console.error("Got an error file", path__default["default"].join(directory, file), err);
3268
3268
  }
3269
3269
  });
3270
3270
  }
3271
3271
  catch (err) {
3272
- console.error("Got an error processing outputs for", sourceFile, err);
3273
- assert__default["default"](sourceFile !== undefined, "Must have sourceFile");
3274
- const errorExitEvent = {
3275
- exitCode: 110,
3276
- files: [],
3277
- error: err.toString(),
3278
- sourceFile
3279
- };
3280
- this.emit("exit", errorExitEvent);
3272
+ console.error("Got an error processing outputs for", sourcePath, err);
3273
+ addDirError = err;
3281
3274
  }
3282
3275
  };
3283
3276
  if (exitCode === 0) {
3284
3277
  addDir(dir, dir);
3285
3278
  }
3279
+ assert__default["default"](sourcePath !== undefined, "Must have sourcePath4");
3280
+ if (addDirError) {
3281
+ const errorExitEvent = {
3282
+ exitCode: 110,
3283
+ files: [],
3284
+ error: addDirError.toString(),
3285
+ sourcePath
3286
+ };
3287
+ this.emit("exit", errorExitEvent);
3288
+ return;
3289
+ }
3286
3290
  if (exitCode === null) {
3287
3291
  exitCode = 111;
3288
3292
  }
3289
- assert__default["default"](sourceFile !== undefined, "Must have sourceFile4");
3290
- const exitEvent = { exitCode, files, sourceFile };
3293
+ const exitEvent = { exitCode, files, sourcePath };
3291
3294
  this.emit("exit", exitEvent);
3292
3295
  });
3293
3296
  }
@@ -3595,7 +3598,7 @@ process.on("uncaughtException", (err) => {
3595
3598
  let pwd;
3596
3599
  if (argv.user) {
3597
3600
  try {
3598
- pwd = posix__default["default"].getpwnam(argv.user);
3601
+ pwd = fiskNative.getpwnam(argv.user);
3599
3602
  }
3600
3603
  catch (err) {
3601
3604
  console.error("Couldn't find user", argv.user);
@@ -3610,7 +3613,7 @@ if (argv.user) {
3610
3613
  }
3611
3614
  try {
3612
3615
  console.log("Chrooting to", argv.root);
3613
- posix__default["default"].chroot(argv.root);
3616
+ fiskNative.chroot(argv.root);
3614
3617
  }
3615
3618
  catch (err) {
3616
3619
  console.error("Changing root or user failed", err);
@@ -3731,7 +3734,7 @@ process.on("message", (msg) => {
3731
3734
  id: msg.id,
3732
3735
  files: event.files,
3733
3736
  exitCode: event.exitCode,
3734
- sourceFile: event.sourceFile
3737
+ sourcePath: event.sourcePath
3735
3738
  });
3736
3739
  }
3737
3740
  else {
@@ -3741,7 +3744,7 @@ process.on("message", (msg) => {
3741
3744
  id: msg.id,
3742
3745
  files: event.files,
3743
3746
  exitCode: event.exitCode,
3744
- sourceFile: event.sourceFile
3747
+ sourcePath: event.sourcePath
3745
3748
  });
3746
3749
  }
3747
3750
  if (destroying && !compiles.size) {