Skip to content

Commit

Permalink
Fix building on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Apr 1, 2024
1 parent 7295d8f commit e4e8b60
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
18 changes: 10 additions & 8 deletions scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

const path = require('path')

const {targetCpu, cmake, mkdir, spawnSync} = require('./common')
const {targetCpu, mkdir, spawnSync} = require('./common')

const cmake = path.resolve('node_modules', '@yogalayout', 'cmake-bin', 'bin', 'cmake')

mkdir('out')

if (process.platform == 'win32') {
process.exit(spawnSync(cmake,
['-S', '.', '-B', 'out',
'-G', 'Visual Studio 19 2022',
process.exit(spawnSync(process.execPath,
[cmake, '-S', '.', '-B', 'out',
'-G', 'Visual Studio 17 2022',
'-A', targetCpu == 'x64' ? 'x64' : 'Win32']).status)
} else {
mkdir('out/Release')
let code = spawnSync(cmake,
['-D', `CMAKE_BUILD_TYPE=Release`, '../..'],
let code = spawnSync(process.execPath,
[cmake, '-D', `CMAKE_BUILD_TYPE=Release`, '../..'],
{cwd: 'out/Release'}).status
if (code != 0)
process.exit(code)
mkdir('out/Debug')
process.exit(spawnSync(cmake,
['-D', `CMAKE_BUILD_TYPE=Debug`, '../..'],
process.exit(spawnSync(process.execPath,
[cmake, '-D', `CMAKE_BUILD_TYPE=Debug`, '../..'],
{cwd: 'out/Debug'}).status)
}
4 changes: 2 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const config = process.argv[2] ? process.argv[2] : 'Debug'

if (process.platform == 'win32') {
const vsPaths = [
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin',
'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\Bin',
'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin',
'C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\Bin',
process.env.PATH
]
const env = Object.assign(process.env, {PATH: vsPaths.join(path.delimiter)})
Expand Down
6 changes: 0 additions & 6 deletions scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ const targetCpu = {
arm64: 'arm64',
}[narch]

// Find the path of cmake.
let cmake = path.resolve('node_modules', '@yogalayout', 'cmake-bin', 'bin', 'cmake')
if (process.platform == 'win')
cmake += '.exe'

// Make dir and ignore error.
function mkdir(dir) {
if (fs.existsSync(dir)) return
Expand Down Expand Up @@ -52,7 +47,6 @@ const spawnSyncWrapper = (exec, args, options = {}) => {
// Export public APIs.
module.exports = {
targetCpu,
cmake,
mkdir,
execSync: execSyncWrapper,
spawnSync: spawnSyncWrapper,
Expand Down

0 comments on commit e4e8b60

Please sign in to comment.