@andersbakken/fisk 4.0.61 → 4.0.62

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