Skip to content

Commit

Permalink
docs: disable options.nativeAddon (#996)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra authored Dec 18, 2023
1 parent 593483d commit 95c56ea
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 54 deletions.
9 changes: 9 additions & 0 deletions src/bld.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ import util from "./util.js"
* });
*
* @example
* // Rebuild Node native modules
* // This behaviour is currently disabled.
* // Tracking issue: https://github.com/nwutils/nw-builder/pull/993
* nwbuild({
* mode: "build",
* nodeAddon: "gyp"
* });
*
* @example
* // For MacOS ARM unofficial builds (<= v0.75), remove quarantine flag post build.
* sudo xattr -r -d com.apple.quarantine /path/to/nwjs.app
*
Expand Down
76 changes: 37 additions & 39 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,18 @@ const nwbuild = async (options) => {
let releaseInfo = {};
let manifest = {};

const { version, flavor, platform, arch, downloadUrl, manifestUrl, srcDir, cacheDir, outDir, app, glob, managedManifest, nativeAddon, zip, argv, cache, ffmpeg } = options;

try {
// Parse options
options = await parse(options, manifest);

manifest = await util.getNodeManifest({ srcDir, glob });
manifest = await util.getNodeManifest({ srcDir: srcDir, glob: glob });
if (typeof manifest?.nwbuild === "object") {
options = manifest.nwbuild;
}

options = await parse(options, manifest);

//TODO: impl loggging
//TODO: impl logging

built = fs.existsSync(options.cacheDir);
if (built === false) {
Expand All @@ -108,11 +106,11 @@ const nwbuild = async (options) => {

// Validate options.version to get the version specific release info
releaseInfo = await util.getReleaseInfo(
version,
platform,
arch,
cacheDir,
manifestUrl,
options.version,
options.platform,
options.arch,
options.cacheDir,
options.manifestUrl,
);

await validate(options, releaseInfo);
Expand All @@ -122,15 +120,15 @@ const nwbuild = async (options) => {

// Download binaries
await get({
version,
flavor,
platform,
arch,
downloadUrl,
cacheDir,
cache,
ffmpeg,
nativeAddon,
version: options.version,
flavor: options.flavor,
platform: options.platform,
arch: options.arch,
downloadUrl: options.downloadUrl,
cacheDir: options.cacheDir,
cache: options.cache,
ffmpeg: options.ffmpeg,
nativeAddon: options.nativeAddon,
});

if (options.mode === "get") {
Expand All @@ -140,30 +138,30 @@ const nwbuild = async (options) => {

if (options.mode === "run") {
await run({
version,
flavor,
platform,
arch,
srcDir,
cacheDir,
glob,
argv,
version: options.version,
flavor: options.flavor,
platform: options.platform,
arch: options.arch,
srcDir: options.srcDir,
cacheDir: options.cacheDir,
glob: options.glob,
argv: options.argv,
});
} else if (options.mode === "build") {
await bld({
version,
flavor,
platform,
arch,
manifestUrl,
srcDir,
cacheDir,
outDir,
app,
glob,
managedManifest,
nativeAddon,
zip,
version: options.version,
flavor: options.flavor,
platform: options.platform,
arch: options.arch,
manifestUrl: options.manifestUrl,
srcDir: options.srcDir,
cacheDir: options.cacheDir,
outDir: options.outDir,
app: options.app,
glob: options.glob,
managedManifest: options.managedManifest,
nativeAddon: options.nativeAddon,
zip: options.zip,
});
}
} catch (error) {
Expand Down
16 changes: 8 additions & 8 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ import * as GlobModule from "glob";
function getManifest(manifestUrl) {
let chunks = undefined;

return new Promise((res) => {
const req = https.get(manifestUrl, (res) => {
res.on("data", (chunk) => {
return new Promise((resolve) => {
const req = https.get(manifestUrl, (response) => {
response.on("data", (chunk) => {
chunks += chunk;
});

res.on("error", (e) => {
response.on("error", (e) => {
console.error(e);
res(undefined);
resolve(undefined);
});

res.on("end", () => {
res(chunks);
response.on("end", () => {
resolve(chunks);
});
});
req.on("error", (e) => {
console.error(e);
res(undefined);
resolve(undefined);
});
});
}
Expand Down
9 changes: 5 additions & 4 deletions src/util/parse.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from "node:path";
import { arch, platform } from "node:process";

import { ARCH_KV, PLATFORM_KV } from "../util.js";
import util from "../util.js";

/**
* Parse options
Expand All @@ -16,8 +16,8 @@ export const parse = async (options, pkg) => {

options.version = options.version ?? "latest";
options.flavor = options.flavor ?? "normal";
options.platform = options.platform ?? PLATFORM_KV(platform);
options.arch = options.arch ?? ARCH_KV(arch);
options.platform = options.platform ?? util.PLATFORM_KV[platform];
options.arch = options.arch ?? util.ARCH_KV[arch];
options.downloadUrl = options.downloadUrl ?? "https://dl.nwjs.io";
options.manifestUrl = options.manifestUrl ?? "https://nwjs.io/versions";
options.cacheDir = options.cacheDir ?? "./cache";
Expand All @@ -41,7 +41,8 @@ export const parse = async (options, pkg) => {
options.zip = options.zip ?? false;

options.managedManifest = options.managedManifest ?? false;
options.nativeAddon = options.nativeAddon ?? false;
// Node Native addons are disabled for now. See https://github.com/nwutils/nw-builder/pull/993
options.nativeAddon = false;

options.app = options.app ?? {};
options.app.name = options.app.name ?? pkg.name;
Expand Down
7 changes: 4 additions & 3 deletions test/fixture/demo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import nwbuild from "nw-builder";

await nwbuild({
srcDir: "app",
mode: "build",
glob: false,
mode: "get",
flavor: "sdk",
platform: "osx",
srcDir: "app"
});

0 comments on commit 95c56ea

Please sign in to comment.