Skip to content

Commit

Permalink
plugin: fix Android scripts finding node-gyp-build-mobile (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
okhiroyuki authored Oct 28, 2023
1 parent 11f1d21 commit 1710139
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,22 @@ cdvPluginPostBuildExtras += { ->
outputs.dir "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/nodejs-project/"
description = "Building native modules for ${abi_name}."
workingDir "${rootProject.buildDir}/nodejs-native-assets-temp-build/nodejs-native-assets-${abi_name}/nodejs-project/"
commandLine npmCommandName, '--verbose', 'rebuild', '--build-from-source'
//environment ('PATH', "${npm_toolchain_add_to_path}" + System.getProperty("path.separator") + "${System.env.PATH}")
environment ('npm_config_node_engine', 'v8' )
environment ('npm_config_nodedir', "${project.projectDir}/libs/cdvnodejsmobile/libnode/" )

String npm_gyp_path_to_use;
if( file("${rootProject.projectDir}/../../plugins/@red-mobile/nodejs-mobile-cordova/node_modules/nodejs-mobile-gyp/bin/node-gyp.js").exists() ) {
npm_gyp_path_to_use = "${rootProject.projectDir}/../../plugins/@red-mobile/nodejs-mobile-cordova/node_modules/nodejs-mobile-gyp/bin/node-gyp.js";
} else {
npm_gyp_path_to_use = "${rootProject.projectDir}/../../node_modules/nodejs-mobile-gyp/bin/node-gyp.js";
}

environment ('npm_config_node_engine', 'v8' )
environment ('npm_config_nodedir', "${project.projectDir}/libnode/" )
environment ('npm_config_node_gyp', npm_gyp_path_to_use)
environment ('npm_config_arch', temp_arch)
environment ('npm_config_platform', 'android')
environment ('npm_config_format', 'make-android')
environment ('PROJECT_DIR', "${rootProject.projectDir}")
environment ('NODEJS_MOBILE_GYP', npm_gyp_path_to_use)

// Adds the original project .bin to the path. It's a workaround
// to correctly build some modules that depend on symlinked modules,
Expand All @@ -253,12 +255,14 @@ cdvPluginPostBuildExtras += { ->
environment ("CARGO_TARGET_${cargo_target_triple}_AR", "${npm_toolchain_ar}")
environment ("CARGO_TARGET_${cargo_target_triple}_LINKER", "${npm_toolchain_link}")

environment ('TOOLCHAIN',"${toolchain_path}")
environment ('AR',"${npm_toolchain_ar}")
environment ('CC',"${npm_toolchain_cc}")
environment ('CXX',"${npm_toolchain_cxx}")
environment ('LINK',"${npm_toolchain_link}")
environment ('GYP_DEFINES',"${npm_gyp_defines}")
environment ('TOOLCHAIN', "${toolchain_path}")
environment ('AR', "${npm_toolchain_ar}")
environment ('CC', "${npm_toolchain_cc}")
environment ('CXX', "${npm_toolchain_cxx}")
environment ('LINK', "${npm_toolchain_link}")
environment ('GYP_DEFINES', "${npm_gyp_defines}")

commandLine npmCommandName, '--verbose', '--foreground-scripts', 'rebuild', '--build-from-source'
}

task "CopyBuiltNpmAssets${abi_name}" (type:Sync) {
Expand Down

0 comments on commit 1710139

Please sign in to comment.