Private
Public Access
2
0

npm: add node-gyp build support

This commit adds all the infrastructure necessary for doing node-gyp builds of
mraa. Note this will only build the mraa js bindings and will dirty your git
tree whilst doing it. It also assumes the user does not have SWIG installed on
their machines and so the swig wrapper is static. The target to use this
feature is 'npmpkg'.

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2014-11-24 15:18:53 +00:00
parent d4552fdc5e
commit a38c07f7b1
6 changed files with 104 additions and 3 deletions

View File

@@ -37,5 +37,32 @@ macro (mraa_CREATE_INSTALL_PACKAGE_JSON generated_file install_location)
endmacro (mraa_CREATE_INSTALL_PACKAGE_JSON)
mraa_create_install_package_json (package.json lib/node_modules/mraa)
macro (mraa_CREATE_BINDING_GYP generated_file)
set (mraa_LIB_SRCS_GYP "")
foreach (srcfile ${mraa_LIB_SRCS_NOAUTO})
file (RELATIVE_PATH rel ${CMAKE_SOURCE_DIR} ${srcfile})
set (mraa_LIB_SRCS_GYP "'${rel}',\n${mraa_LIB_SRCS_GYP}")
endforeach (srcfile)
foreach (includedir ${mraa_LIB_INCLUDE_DIRS})
file (RELATIVE_PATH rel ${CMAKE_SOURCE_DIR} ${includedir})
set (mraa_LIB_INCLUDE_DIRS_GYP "'${rel}',\n${mraa_LIB_INCLUDE_DIRS_GYP}")
endforeach (includedir)
configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
endmacro (mraa_CREATE_BINDING_GYP)
mraa_create_binding_gyp (binding.gyp)
add_custom_target (npmpkg)
add_custom_command (TARGET npmpkg POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/mraajsJAVASCRIPT_wrap.cxx ${CMAKE_SOURCE_DIR}/src
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/src/version.c ${CMAKE_SOURCE_DIR}/src
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/package.json ${CMAKE_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/binding.gyp ${CMAKE_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/docs/npm.md ${CMAKE_SOURCE_DIR}/READMEFIRST)
add_dependencies (npmpkg mraajs)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/mraa.node
DESTINATION lib/node_modules/mraa)

View File

@@ -0,0 +1,18 @@
{
'targets': [
{
'target_name': 'mraa',
'sources': [
@mraa_LIB_SRCS_GYP@
'src/version.c',
'src/mraajsJAVASCRIPT_wrap.cxx' ],
'include_dirs': [
@mraa_LIB_INCLUDE_DIRS_GYP@
],
'cflags_cc!': [ '-fno-rtti', '-fno-exceptions' ],
'cflags!': [ '-fno-exceptions' ],
'defines' : [ 'SWIG',
'SWIGNODE' ],
}
]
}

View File

@@ -1,9 +1,22 @@
{
"name" : "mraa",
"description": "IO library that helps you use I2c, SPI, gpio, uart, pwm, analog inputs (aio) and more on a number of platforms such as the Intel galileo, the Intel edison and others",
"keywords":["gpio", "edison","galileo","io", "mraajs", "spi", "i2c", "minnow", "intel"],
"homepage": "http://github.com/intel-iot-devkit/mraa",
"repository" : {
"type" : "git",
"url" : "http://github.com/intel-iot-devkit/mraa.git"
},
"main" : "./mraa.node",
"engines": {
"node": ">= 1.0.x"
},
"bugs": {
"url" : "http://github.com/intel-iot-devkit/mraa/issues"
},
"license": "MIT",
"version": "@VERSION@"
"version": "@VERSION@",
"authors": "See github.com/intel-iot-devkit/mraa/graphs/contributors"
}