Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 23, 2024
1 parent 38ba6c3 commit 1f8ada3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 51 deletions.
14 changes: 13 additions & 1 deletion Lib.cmake
Expand Up @@ -69,8 +69,20 @@ FUNCTION (cmake_js_add_node_addon PROJECT_NAME)
# message("Found nan: ${NODE_NAN_DIR}")
# target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_NAN_DIR})
# endif()

# TODO nan and headers

# include headers
set (NODE_HEADERS_DIR "") # TODO
target_include_directories(${PROJECT_NAME} PRIVATE
# some runtimes provide tidy headers
"${NODE_HEADERS_DIR}/include/node"
# some runtimes provide a lot more stuff
"${NODE_HEADERS_DIR}/src"
"${NODE_HEADERS_DIR}/deps/v8/include"
"${NODE_HEADERS_DIR}/deps/uv/include"
)

else()
# Find node-addon-api
execute_process(COMMAND ${NODE_PATH} -p "require('node-api-headers').include_dir"
Expand Down
12 changes: 0 additions & 12 deletions rewrite/old/buildSystem.js
Expand Up @@ -7,24 +7,12 @@ const npmConfig = require('./npmConfig')
const path = require('path')
const Toolset = require('./toolset')

function isNodeApi(log, projectRoot) {
try {
const projectPkgJson = require(path.join(projectRoot, 'package.json'))
// Make sure the property exists
return !!projectPkgJson?.binary?.napi_versions
} catch (e) {
log.silly('CFG', "'package.json' not found.")
return false
}
}

class BuildSystem {
constructor(options) {
this.options = options || {}
this.options.directory = path.resolve(this.options.directory || process.cwd())
this.options.out = path.resolve(this.options.out || path.join(this.options.directory, 'build'))
this.log = new CMLog(this.options)
this.options.isNodeApi = isNodeApi(this.log, this.options.directory)
const npmOptions = npmConfig(this.log)

if (npmOptions && typeof npmOptions === 'object' && Object.keys(npmOptions).length) {
Expand Down
32 changes: 0 additions & 32 deletions rewrite/old/cMake.js
Expand Up @@ -120,14 +120,6 @@ class CMake {
D.push({ CMAKE_LIBRARY_OUTPUT_DIRECTORY: this.buildDir })
}

// In some configurations MD builds will crash upon attempting to free memory.
// This tries to encourage MT builds which are larger but less likely to have this crash.
D.push({ CMAKE_MSVC_RUNTIME_LIBRARY: 'MultiThreaded$<$<CONFIG:Debug>:Debug>' })

// Includes:
const includesString = await this.getCmakeJsIncludeString()
D.push({ CMAKE_JS_INC: includesString })

// Runtime:
D.push({ NODE_RUNTIME: this.targetOptions.runtime })
D.push({ NODE_RUNTIMEVERSION: this.targetOptions.runtimeVersion })
Expand Down Expand Up @@ -206,30 +198,6 @@ class CMake {
}
return libs.join(';')
}
async getCmakeJsIncludeString() {
let incPaths = []
if (!this.options.isNodeApi) {
// Include and lib:
if (this.dist.headerOnly) {
incPaths = [path.join(this.dist.internalPath, '/include/node')]
} else {
const nodeH = path.join(this.dist.internalPath, '/src')
const v8H = path.join(this.dist.internalPath, '/deps/v8/include')
const uvH = path.join(this.dist.internalPath, '/deps/uv/include')
incPaths = [nodeH, v8H, uvH]
}

// NAN
const nanH = await locateNAN(this.projectRoot)
if (nanH) {
incPaths.push(nanH)
}
} else {

}

return incPaths.join(';')
}

async configure() {
this.verifyIfAvailable()
Expand Down
12 changes: 6 additions & 6 deletions rewrite/old/runtimePaths.js
Expand Up @@ -13,10 +13,10 @@ const runtimePaths = {
winLibs: [
{
dir: targetOptions.isX64 ? 'x64' : '',
name: targetOptions.runtime + '.lib',
name: 'node.lib',
},
],
tarPath: targetOptions.runtime + '-v' + targetOptions.runtimeVersion + '.tar.gz',
tarPath: 'node-v' + targetOptions.runtimeVersion + '.tar.gz',
headerOnly: false,
}
} else {
Expand All @@ -25,10 +25,10 @@ const runtimePaths = {
winLibs: [
{
dir: targetOptions.isX64 ? 'win-x64' : 'win-x86',
name: targetOptions.runtime + '.lib',
name: 'node.lib',
},
],
tarPath: targetOptions.runtime + '-v' + targetOptions.runtimeVersion + '-headers.tar.gz',
tarPath: 'node-v' + targetOptions.runtimeVersion + '-headers.tar.gz',
headerOnly: true,
}
}
Expand All @@ -40,7 +40,7 @@ const runtimePaths = {
winLibs: [
{
dir: targetOptions.isX64 ? 'x64' : '',
name: targetOptions.runtime + '.lib',
name: 'nw.lib',
},
{
dir: targetOptions.isX64 ? 'x64' : '',
Expand All @@ -56,7 +56,7 @@ const runtimePaths = {
winLibs: [
{
dir: targetOptions.isX64 ? 'x64' : '',
name: targetOptions.runtime + '.lib',
name: 'nw.lib',
},
],
tarPath: 'nw-headers-v' + targetOptions.runtimeVersion + '.tar.gz',
Expand Down

0 comments on commit 1f8ada3

Please sign in to comment.