diff options
Diffstat (limited to 'share')
| -rw-r--r-- | share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs | 52 | ||||
| -rw-r--r-- | share/qbs/modules/cpp/DarwinGCC.qbs | 6 | ||||
| -rw-r--r-- | share/qbs/modules/cpp/bundle-tools.js | 31 |
3 files changed, 54 insertions, 35 deletions
diff --git a/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs b/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs index 33b539d1f..07509034d 100644 --- a/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs +++ b/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs @@ -19,32 +19,36 @@ Probe { if (!name) throw '"name" must be specified'; var p = new Process(); - var args = [ name ]; - if (minVersion !== undefined) - args.push(name + ' >= ' + minVersion); - if (exactVersion !== undefined) - args.push(name + ' = ' + exactVersion); - if (maxVersion !== undefined) - args.push(name + ' <= ' + maxVersion); - if (p.exec(executable, args.concat([ '--cflags' ])) === 0) { - cflags = p.readStdOut().trim(); - if (cflags === "") - cflags = undefined; - else - cflags = cflags.split(/\s/); - if (p.exec(executable, args.concat([ '--libs' ])) === 0) { - libs = p.readStdOut().trim(); - if (libs === "") - libs = undefined; + try { + var args = [ name ]; + if (minVersion !== undefined) + args.push(name + ' >= ' + minVersion); + if (exactVersion !== undefined) + args.push(name + ' = ' + exactVersion); + if (maxVersion !== undefined) + args.push(name + ' <= ' + maxVersion); + if (p.exec(executable, args.concat([ '--cflags' ])) === 0) { + cflags = p.readStdOut().trim(); + if (cflags === "") + cflags = undefined; else - libs = libs.split(/\s/); - found = true; - print("PkgConfigProbe: found library " + name); - return; + cflags = cflags.split(/\s/); + if (p.exec(executable, args.concat([ '--libs' ])) === 0) { + libs = p.readStdOut().trim(); + if (libs === "") + libs = undefined; + else + libs = libs.split(/\s/); + found = true; + print("PkgConfigProbe: found library " + name); + return; + } } + found = false; + cflags = undefined; + libs = undefined; + } finally { + p.close(); } - found = false; - cflags = undefined; - libs = undefined; } } diff --git a/share/qbs/modules/cpp/DarwinGCC.qbs b/share/qbs/modules/cpp/DarwinGCC.qbs index 381174d78..458959fce 100644 --- a/share/qbs/modules/cpp/DarwinGCC.qbs +++ b/share/qbs/modules/cpp/DarwinGCC.qbs @@ -180,6 +180,7 @@ UnixGCC { process.exec("plutil", ["-convert", "json", "-o", "-", platformInfoPlist], true); platformInfo = JSON.parse(process.readStdOut()); + process.close(); var additionalProps = platformInfo["AdditionalInfo"]; for (key in additionalProps) { @@ -210,6 +211,7 @@ UnixGCC { process.exec("plutil", ["-convert", "json", "-o", "-", sdkSettingsPlist], true); sdkSettings = JSON.parse(process.readStdOut()); + process.close(); } else { print("warning: sysroot (SDK path) given but no SDKSettings.plist found"); } @@ -223,6 +225,7 @@ UnixGCC { process.exec("plutil", ["-convert", "json", "-o", "-", toolchainInfoPlist], true); toolchainInfo = JSON.parse(process.readStdOut()); + process.close(); } else { print("could not find a ToolchainInfo.plist near the toolchain install path"); } @@ -230,6 +233,7 @@ UnixGCC { process = new Process(); process.exec("sw_vers", ["-buildVersion"], true); aggregatePlist["BuildMachineOSBuild"] = process.readStdOut().trim(); + process.close(); // setup env env = { @@ -243,6 +247,7 @@ UnixGCC { process = new Process(); process.exec("sw_vers", ["-buildVersion"], true); env["MAC_OS_X_PRODUCT_BUILD_VERSION"] = process.readStdOut().trim(); + process.close(); for (key in buildEnv) env[key] = buildEnv[key]; @@ -266,6 +271,7 @@ UnixGCC { // Convert the written file to the format appropriate for the current platform process = new Process(); process.exec("plutil", ["-convert", infoPlistFormat, outputs.infoplist[0].fileName], true); + process.close(); } return cmd; } diff --git a/share/qbs/modules/cpp/bundle-tools.js b/share/qbs/modules/cpp/bundle-tools.js index 6ce48c38c..4e2bf361b 100644 --- a/share/qbs/modules/cpp/bundle-tools.js +++ b/share/qbs/modules/cpp/bundle-tools.js @@ -28,12 +28,16 @@ function infoPlistContents(infoPlistFilePath) return undefined; var process = new Process(); - process.start("plutil", ["-convert", "json", "-o", "-", infoPlistFilePath]); - process.waitForFinished(); - if (process.exitCode() != 0) - throw("plutil: " + (process.readStdErr().trim() || process.readStdOut().trim())); - - return JSON.parse(process.readStdOut()); + try { + process.start("plutil", ["-convert", "json", "-o", "-", infoPlistFilePath]); + process.waitForFinished(); + if (process.exitCode() !== 0) + throw("plutil: " + (process.readStdErr().trim() || process.readStdOut().trim())); + + return JSON.parse(process.readStdOut()); + } finally { + process.close(); + } } function infoPlistFormat(infoPlistFilePath) @@ -43,21 +47,26 @@ function infoPlistFormat(infoPlistFilePath) // Verify that the Info.plist format is actually valid in the first place var process = new Process(); - process.start("plutil", ["-lint", infoPlistFilePath]); - process.waitForFinished(); - if (process.exitCode() != 0) - throw("plutil: " + (process.readStdErr().trim() || process.readStdOut().trim())); + try { + process.start("plutil", ["-lint", infoPlistFilePath]); + process.waitForFinished(); + if (process.exitCode() !== 0) + throw("plutil: " + (process.readStdErr().trim() || process.readStdOut().trim())); + } finally { + process.close(); + } process = new Process(); process.start("file", ["-bI", infoPlistFilePath]); process.waitForFinished(); var magic = process.readStdOut().trim(); + process.close(); if (magic.indexOf("application/octet-stream;") === 0) return "binary1"; else if (magic.indexOf("application/xml;") === 0) return "xml1"; - else if (magic.indexOf("text/plain;") == 0) + else if (magic.indexOf("text/plain;") === 0) return "json"; return undefined; |
