async function bld({
  version = 'latest',
  flavor = 'normal',
  platform = util.PLATFORM_KV[process.platform],
  arch = util.ARCH_KV[process.arch],
  srcDir = './src',
  cacheDir = './cache',
  outDir = './out',
  app,
  glob = true,
  managedManifest = false,
  nativeAddon = false,
  zip = false,
  releaseInfo = {},
}) {
  const nwDir = path.resolve(
    cacheDir,
    `nwjs${flavor === 'sdk' ? '-sdk' : ''}-v${version}-${platform
    }-${arch}`,
  );

  await fs.promises.rm(outDir, { force: true, recursive: true });
  await fs.promises.cp(nwDir, outDir, { recursive: true, verbatimSymlinks: true });

  const files = await util.globFiles({ srcDir, glob });
  let manifest = await util.getNodeManifest({ srcDir, glob });

  /* Set `product_string` in manifest for MacOS. This is used in renaming the Helper apps. */
  if (platform === 'osx') {
    manifest.json.product_string = app.name;
    await fs.promises.writeFile(manifest.path, JSON.stringify(manifest.json));
  }

  if (glob) {
    for (let file of files) {
      const stats = await fs.promises.stat(file);
      if (stats.isDirectory()) {
        continue;
      }
      await fs.promises.cp(
        file,
        path.resolve(
          outDir,
          platform !== 'osx'
            ? 'package.nw'
            : 'nwjs.app/Contents/Resources/app.nw',
          file,
        ),
        { recursive: true, force: true },
      );
    }
  } else {
    await fs.promises.cp(
      files,
      path.resolve(
        outDir,
        platform !== 'osx'
          ? 'package.nw'
          : 'nwjs.app/Contents/Resources/app.nw',
      ),
      { recursive: true, verbatimSymlinks: true },
    );
  }

  // const nodeVersion = releaseInfo.components.node;

  if (
    managedManifest === true ||
    typeof managedManifest === 'object' ||
    typeof managedManifest === 'string'
  ) {
    await manageManifest({ nwPkg: manifest.json, managedManifest, outDir, platform });
  }

  if (platform === 'linux') {
    await setLinuxConfig({ app, outDir });
  } else if (platform === 'win') {
    await setWinConfig({ app, outDir });
  } else if (platform === 'osx') {
    await setOsxConfig({ app, outDir, releaseInfo });
  }

  if (nativeAddon === 'gyp') {
    throw new Error('Rebuilding Node addons functionality is broken and has been disabled. This functionality may be removed in the future.');
    // buildNativeAddon({ cacheDir, version, platform, arch, outDir, nodeVersion });
  }

  if (zip !== false) {
    await compress({ zip, outDir });
  }
}
Build NW.js application.
@async
@function
@param  {BuildOptions}  options  - Build options
@returns {Promise<void>}