diff --git a/build.js b/build.js index 71f30b6..89e5708 100644 --- a/build.js +++ b/build.js @@ -57,16 +57,41 @@ function getDefaultExtraLinkLibs(lbugBuildDir, precompiledLibPath) { const tokens = fs.readFileSync(linkTxtPath, "utf8").match(tokenPattern) || []; const libs = []; let sawPrecompiledLib = false; - - for (const rawToken of tokens) { + const linkLineHasPrecompiledLib = tokens.some((rawToken) => { + const token = rawToken.replace(/^"(.*)"$/, "$1"); + if (token.startsWith("-")) { + return false; + } + const resolvedToken = fs.existsSync(path.resolve(linkBaseDir, token)) + ? path.resolve(linkBaseDir, token) + : path.resolve(linkTxtDir, token); + return resolvedToken === precompiledLibPath; + }); + let outputPath = null; + + for (let i = 0; i < tokens.length; i++) { + const rawToken = tokens[i]; const token = rawToken.replace(/^"(.*)"$/, "$1"); + if (token === "-o") { + const outputToken = tokens[++i]?.replace(/^"(.*)"$/, "$1"); + outputPath = outputToken ? path.resolve(linkBaseDir, outputToken) : null; + continue; + } + if (token === "-install_name" || token === "-current_version" || token === "-compatibility_version") { + i++; + continue; + } + if (token.startsWith("@")) { + continue; + } + const resolvedToken = token.startsWith("-") ? token : fs.existsSync(path.resolve(linkBaseDir, token)) ? path.resolve(linkBaseDir, token) : path.resolve(linkTxtDir, token); - if (!sawPrecompiledLib) { + if (!sawPrecompiledLib && linkLineHasPrecompiledLib) { if (resolvedToken === precompiledLibPath) { sawPrecompiledLib = true; } @@ -80,7 +105,7 @@ function getDefaultExtraLinkLibs(lbugBuildDir, precompiledLibPath) { if (!/\.(a|lib|dylib|so|tbd)$/.test(token)) { continue; } - if (resolvedToken === precompiledLibPath) { + if (resolvedToken === precompiledLibPath || resolvedToken === outputPath) { continue; } libs.push(resolvedToken); diff --git a/src_cpp/node_util.cpp b/src_cpp/node_util.cpp index 94ef204..fef89d6 100644 --- a/src_cpp/node_util.cpp +++ b/src_cpp/node_util.cpp @@ -199,7 +199,7 @@ Napi::Value Util::ConvertToNapiObject(const Value& value, Napi::Env env) { return Napi::String::New(env, valString).ToNumber(); } case LogicalTypeID::JSON: { - auto valString = value.getValue(); + auto valString = value.toString(); auto global = env.Global(); auto jsonObj = global.Get("JSON").As(); auto parseFunc = jsonObj.Get("parse").As();