How to use the node-abi.getAbi function in node-abi

To help you get started, we’ve selected a few node-abi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github packem / packem / scripts / build.js View on Github external
if (!existsSync("./bin/index.node")) writeFileSync("./bin/index.node", "");

// Download binaries from Packem's GitHub release page.
const https = require("https");
const url = require("url");
const { sep: pathSeperator } = require("path");
const { getAbi } = require("node-abi");
const Octokit = require("@octokit/rest");
const { x: extractTarGz } = require("tar");

const AUTH_TOKEN = process.env.NODE_PRE_GYP_GITHUB_TOKEN;
const PREBUILT_REPO_OWNER = process.env.PREBUILT_REPO_OWNER || "packem";
const PREBUILT_REPO_NAME = process.env.PREBUILT_REPO_NAME || "packem";
const PREBUILT_REPO_URL = `https://github.com/${PREBUILT_REPO_OWNER}/${PREBUILT_REPO_NAME}`;
const CWD = process.cwd();
const NODE_ABI = getAbi(process.version.replace(/^v/, ""), "node");
const PLATFORM = process.platform;
const ARCH = process.arch;

const octokit = new Octokit({ auth: AUTH_TOKEN });

octokit.repos
  .getLatestRelease({
    owner: PREBUILT_REPO_OWNER,
    repo: PREBUILT_REPO_NAME
  })
  .then(({ data: { tag_name: VERSION }, status, headers }) => {
    // Handle data.
    const TARBALL_URL = `${PREBUILT_REPO_URL}/releases/download/${VERSION}/node-v${NODE_ABI}-${PLATFORM}-${ARCH}.tar.gz`;

    https.get(TARBALL_URL, response => {
      if (
github prebuild / prebuild / prebuild.js View on Github external
var pkg = opts.pkg
  var buildLog = opts.buildLog || function () {}
  opts.target = target
  opts.runtime = runtime

  if (opts.runtime === 'node-webkit') {
    opts.backend = 'nw-gyp'
  }

  var buildLogMessage = 'Preparing to prebuild ' + pkg.name + '@' + pkg.version + ' for ' + runtime + ' ' + target + ' on ' + opts.platform + '-' + opts.arch + ' using ' + opts.backend
  if (opts.libc && opts.libc.length > 0) buildLogMessage += 'using libc ' + opts.libc
  buildLog(buildLogMessage)

  // --target can be target or abi
  if (!napi.isNapiRuntime(runtime)) target = getTarget(target, runtime)
  var abi = getAbi(target, runtime)

  var tarPath = getTarPath(opts, abi)
  fs.stat(tarPath, function (err, st) {
    if (!err && !opts.force) {
      buildLog(tarPath + ' exists, skipping build')
      return callback(null, tarPath)
    }
    var tasks = [
      function (cb) {
        build(opts, target, function (err, filenames) {
          if (err) return cb(err)
          cb(null, filenames)
        })
      },
      function (filenames, cb) {
        buildLog('Packing ' + filenames.join(', ') + ' into ' + tarPath)
github stackimpact / stackimpact-nodejs / build-addons.js View on Github external
versions.forEach((version) => {
  let abi = nodeAbi.getAbi(version);
  let addonPath = `${addonDir}/stackimpact-addon-v${abi}.node`;

  if (!fs.existsSync(addonPath)) {
    cp.execSync(`node node_modules/node-gyp/bin/node-gyp.js rebuild --target=${version}`, {stdio: [0,1,2]});
    fs.copyFileSync('build/Release/stackimpact-addon.node', addonPath);
  }
  else {
    console.log(`Addon with ABI ${abi} exists, skipping.`);
  }

  abiMap[version] = abi;
});
github Hackzzila / krypton / build.js View on Github external
config.target_defaults.msvs_settings = {
        VCCLCompilerTool: {
          AdditionalOptions: [
            '/arch:AVX2',
          ],
        },
      };
    } else {
      config.target_defaults.defines.push('KRYPTON_DISABLE_NEON');
    }

    fs.writeFileSync('config.gypi', JSON.stringify(config, undefined, 2));

    for (const target of targets) {
      const id = abi.getAbi(target, 'node');

      execSync(`${path.resolve('node_modules', '.bin', 'node-gyp')} rebuild --target=v${target} --arch=${arch}`, {
        stdio: 'inherit',
        env: {
          ...process.env,
          ...env[arch],
        },
      });

      fs.copyFileSync(path.resolve('build', 'Release', 'krypton.node'), path.resolve('builds', `${process.platform}-${arch}-${id}.node`));
    }
  }
}
github prebuild / prebuildify / index.js View on Github external
function prebuildName (target, opts) {
  var tags = [target.runtime]

  if (opts.napi) {
    tags.push('napi')
  } else {
    tags.push('abi' + abi.getAbi(target.target, target.runtime))
  }

  if (opts.tagUv) {
    var uv = opts.tagUv === true ? opts.uv : opts.tagUv
    if (uv) tags.push('uv' + uv)
  }

  if (opts.tagArmv) {
    var armv = opts.tagArmv === true ? opts.armv : opts.tagArmv
    if (armv) tags.push('armv' + armv)
  }

  if (opts.tagLibc) {
    var libc = opts.tagLibc === true ? opts.libc : opts.tagLibc
    if (libc) tags.push(libc)
  }
github electron / electron-rebuild / src / rebuild.ts View on Github external
constructor(
      public lifecycle: EventEmitter,
      public buildPath: string,
      public electronVersion: string,
      public arch = process.arch,
      public extraModules: string[] = [],
      public forceRebuild = false,
      public headerURL = 'https://atom.io/download/electron',
      public types = ['prod', 'optional'],
      public mode = defaultMode) {
    this.ABI = nodeAbi.getAbi(electronVersion, 'electron');
    this.prodDeps = extraModules.reduce((acc, x) => acc.add(x), new Set());
    this.rebuilds = [];
    this.realModulePaths = new Set();
    this.realNodeModulesPaths = new Set();
  }
github Hackzzila / krypton / build.js View on Github external
msvs_settings: {
          VCCLCompilerTool: {
            AdditionalOptions: [
              '/arch:AVX2',
            ],
          },
        },
      },
    };

    if (arch === 'ia32') config.target_defaults.defines.push('KRYPTON_DISABLE_SODIUM');

    fs.writeFileSync('config.gypi', JSON.stringify(config, undefined, 2));

    for (const target of targets) {
      const id = abi.getAbi(target, 'node');

      execSync(`${path.resolve('node_modules', '.bin', 'node-gyp')} configure --target=v${target} --arch=${arch}`, {
        stdio: 'inherit',
        env: {
          ...process.env,
          ...env[arch],
        },
      });

      const vcxproj = xml.xml2js(fs.readFileSync(path.resolve('build', 'krypton.vcxproj'), 'utf8'));

      const globals = vcxproj.elements.find(x => x.name === 'Project').elements.find(x => x.name === 'PropertyGroup' && x.attributes.Label === 'Globals');

      globals.elements.push({
        type: 'element',
        name: 'VcpkgTriplet',
github prebuild / prebuild-install / rc.js View on Github external
download: 'd',
      'build-from-source': 'compile',
      compile: 'c',
      token: 'T'
    }
  }))

  if (rc.path === true) {
    delete rc.path
  }

  if (napi.isNapiRuntime(rc.runtime) && rc.target === process.versions.node) {
    rc.target = napi.getBestNapiBuildVersion()
  }

  rc.abi = napi.isNapiRuntime(rc.runtime) ? rc.target : getAbi(rc.target, rc.runtime)

  return rc
}

node-abi

Get the Node ABI for a given target and runtime, and vice versa.

MIT
Latest version published 2 days ago

Package Health Score

88 / 100
Full package analysis