|
25 | 25 | * boundary. |
26 | 26 | */ |
27 | 27 |
|
28 | | -const {execSync} = require('child_process'); |
| 28 | +const {execFileSync} = require('child_process'); |
29 | 29 | const fs = require('fs'); |
30 | 30 | const path = require('path'); |
31 | 31 |
|
@@ -94,9 +94,13 @@ function stubSlicesFromXcframework( |
94 | 94 | xcfwPath /*: string */, |
95 | 95 | ) /*: Array<StubSlice> */ { |
96 | 96 | const plist = JSON.parse( |
97 | | - execSync( |
98 | | - `plutil -convert json -o - "${path.join(xcfwPath, 'Info.plist')}"`, |
99 | | - ).toString(), |
| 97 | + execFileSync('plutil', [ |
| 98 | + '-convert', |
| 99 | + 'json', |
| 100 | + '-o', |
| 101 | + '-', |
| 102 | + path.join(xcfwPath, 'Info.plist'), |
| 103 | + ]).toString(), |
100 | 104 | ); |
101 | 105 | return plist.AvailableLibraries.map(lib => { |
102 | 106 | const key = |
@@ -142,37 +146,49 @@ function composeHeadersOnlyXcframework( |
142 | 146 | `static int ${name}Stub __attribute__((unused)) = 0;\n`, |
143 | 147 | ); |
144 | 148 | const libs = slices.map(slice => { |
145 | | - const sdkPath = execSync(`xcrun --sdk ${slice.sdk} --show-sdk-path`) |
| 149 | + const sdkPath = execFileSync('xcrun', [ |
| 150 | + '--sdk', |
| 151 | + slice.sdk, |
| 152 | + '--show-sdk-path', |
| 153 | + ]) |
146 | 154 | .toString() |
147 | 155 | .trim(); |
148 | 156 | const thins = slice.targets.map((t, i) => { |
149 | 157 | const obj = path.join(work, `stub-${slice.name}-${i}.o`); |
150 | | - execSync( |
151 | | - `xcrun clang -c -target ${t} -isysroot "${sdkPath}" "${path.join(work, 'stub.c')}" -o "${obj}"`, |
152 | | - ); |
| 158 | + execFileSync('xcrun', [ |
| 159 | + 'clang', |
| 160 | + '-c', |
| 161 | + '-target', |
| 162 | + t, |
| 163 | + '-isysroot', |
| 164 | + sdkPath, |
| 165 | + path.join(work, 'stub.c'), |
| 166 | + '-o', |
| 167 | + obj, |
| 168 | + ]); |
153 | 169 | const lib = path.join(work, `stub-${slice.name}-${i}.a`); |
154 | | - execSync(`xcrun libtool -static -o "${lib}" "${obj}" 2>/dev/null`); |
| 170 | + execFileSync('xcrun', ['libtool', '-static', '-o', lib, obj], { |
| 171 | + stdio: ['ignore', 'pipe', 'ignore'], |
| 172 | + }); |
155 | 173 | return lib; |
156 | 174 | }); |
157 | 175 | const outLib = path.join(work, `lib${name}-${slice.name}.a`); |
158 | 176 | if (thins.length === 1) { |
159 | 177 | fs.copyFileSync(thins[0], outLib); |
160 | 178 | } else { |
161 | | - execSync( |
162 | | - `xcrun lipo -create ${thins.map(l => `"${l}"`).join(' ')} -output "${outLib}"`, |
163 | | - ); |
| 179 | + execFileSync('xcrun', ['lipo', '-create', ...thins, '-output', outLib]); |
164 | 180 | } |
165 | 181 | return outLib; |
166 | 182 | }); |
167 | 183 |
|
168 | 184 | const outXcfw = path.join(outDir, `${name}.xcframework`); |
169 | 185 | fs.rmSync(outXcfw, {recursive: true, force: true}); |
170 | | - execSync( |
171 | | - `xcodebuild -create-xcframework ` + |
172 | | - libs.map(l => `-library "${l}" -headers "${stage}"`).join(' ') + |
173 | | - ` -output "${outXcfw}"`, |
174 | | - {stdio: 'pipe'}, |
175 | | - ); |
| 186 | + const xcframeworkArgs = ['-create-xcframework']; |
| 187 | + for (const l of libs) { |
| 188 | + xcframeworkArgs.push('-library', l, '-headers', stage); |
| 189 | + } |
| 190 | + xcframeworkArgs.push('-output', outXcfw); |
| 191 | + execFileSync('xcodebuild', xcframeworkArgs, {stdio: 'pipe'}); |
176 | 192 | return outXcfw; |
177 | 193 | } finally { |
178 | 194 | fs.rmSync(work, {recursive: true, force: true}); |
@@ -225,9 +241,11 @@ function buildDepsHeadersXcframework( |
225 | 241 | let outXcfw; |
226 | 242 | try { |
227 | 243 | for (const ns of namespaces) { |
228 | | - execSync( |
229 | | - `/bin/cp ${CP_FLAGS} "${path.join(depsHeaders, ns)}" "${path.join(stage, ns)}"`, |
230 | | - ); |
| 244 | + execFileSync('/bin/cp', [ |
| 245 | + CP_FLAGS, |
| 246 | + path.join(depsHeaders, ns), |
| 247 | + path.join(stage, ns), |
| 248 | + ]); |
231 | 249 | } |
232 | 250 | outXcfw = composeHeadersOnlyXcframework( |
233 | 251 | outDir, |
|
0 commit comments