|
1 | 1 | const os = require("os"); |
2 | | -const { spawn } = require('child_process'); |
3 | 2 |
|
4 | 3 | function iosCMake() { |
5 | | - const { spawn, spawnSync } = require('child_process'); |
6 | | - const fs = require('fs'); |
7 | | - const path = require('path'); |
| 4 | + const { spawn } = require('child_process'); |
8 | 5 |
|
9 | | - // Determine cmake path in order of preference |
10 | | - let cmakePath = process.env.BABYLON_CMAKE_PATH; |
11 | | - |
12 | | - if (!cmakePath) { |
13 | | - // Check if cmake-runtime package is installed |
14 | | - try { |
15 | | - // Try multiple ways to find cmake-runtime |
16 | | - const possiblePaths = [ |
17 | | - path.join(__dirname, 'node_modules', 'cmake-runtime', 'bin', 'cmake'), |
18 | | - path.join(process.cwd(), 'node_modules', 'cmake-runtime', 'bin', 'cmake'), |
19 | | - path.join(__dirname, '..', 'node_modules', 'cmake-runtime', 'bin', 'cmake'), |
20 | | - path.join(__dirname, '..', '..', 'node_modules', 'cmake-runtime', 'bin', 'cmake') |
21 | | - ]; |
22 | | - |
23 | | - for (const possiblePath of possiblePaths) { |
24 | | - if (fs.existsSync(possiblePath)) { |
25 | | - cmakePath = possiblePath; |
26 | | - break; |
27 | | - } |
28 | | - } |
29 | | - |
30 | | - // If not found by path, try require.resolve as fallback |
31 | | - if (!cmakePath) { |
32 | | - try { |
33 | | - const cmakeRuntimePath = require.resolve('cmake-runtime/cmake'); |
34 | | - if (fs.existsSync(cmakeRuntimePath)) { |
35 | | - cmakePath = cmakeRuntimePath; |
36 | | - } |
37 | | - } catch (e) { |
38 | | - // cmake-runtime not resolvable |
39 | | - console.warn(`cmake-runtime not resolvable.`); |
40 | | - } |
41 | | - } |
42 | | - } catch (e) { |
43 | | - // cmake-runtime not installed, continue to default |
44 | | - console.warn(`CMake not found in installed packages.`); |
45 | | - } |
46 | | - } |
47 | | - |
48 | | - if (!cmakePath) { |
49 | | - cmakePath = 'cmake'; |
50 | | - } |
51 | | - |
52 | | - // Check if cmake exists and get version |
53 | | - const versionResult = spawnSync(cmakePath, ['--version'], { encoding: 'utf8' }); |
54 | | - |
55 | | - if (versionResult.error) { |
56 | | - console.error('CMake is not installed or not found in PATH'); |
57 | | - process.exit(1); |
58 | | - } |
59 | | - |
60 | | - // Parse version from output (format: "cmake version 3.26.0") |
61 | | - const versionMatch = versionResult.stdout.match(/cmake version (\d+)\.(\d+)\.(\d+)/); |
62 | | - if (!versionMatch) { |
63 | | - console.error('Unable to parse CMake version'); |
64 | | - process.exit(1); |
65 | | - } |
66 | | - |
67 | | - const majorVersion = parseInt(versionMatch[1]); |
68 | | - const minorVersion = parseInt(versionMatch[2]); |
69 | | - |
70 | | - // Check if version is >= 3.26 |
71 | | - if (majorVersion < 3 || (majorVersion === 3 && minorVersion < 26)) { |
72 | | - console.error(`CMake version ${majorVersion}.${minorVersion} is not supported. Please upgrade to version 3.26 or higher.`); |
73 | | - process.exit(1); |
74 | | - } |
75 | | - |
76 | | - console.log(`Using CMake version ${majorVersion}.${minorVersion}.${versionMatch[3]} from ${cmakePath}`); |
77 | | - |
78 | | - const cmake = spawn(cmakePath, [ |
| 6 | + const cmake = spawn('npx cmake', [ |
79 | 7 | '-S', 'ios', |
80 | 8 | '-B', 'Build/iOS', |
81 | 9 | '-G', 'Xcode', |
|
0 commit comments