mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
npm: add target to generate tarballs with sources needed by NPM for publishing modules
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
64b4f040dc
commit
ebda525f85
@ -12,6 +12,7 @@ option (BUILDEXAMPLES "Build C/C++ example binaries" OFF)
|
|||||||
option (BUILDJAVAEXAMPLES "Build java example jars" OFF)
|
option (BUILDJAVAEXAMPLES "Build java example jars" OFF)
|
||||||
option (IPK "Generate IPK using CPack" OFF)
|
option (IPK "Generate IPK using CPack" OFF)
|
||||||
option (RPM "Generate RPM using CPack" OFF)
|
option (RPM "Generate RPM using CPack" OFF)
|
||||||
|
option (NPM "Generate NPM/GYP tarballs" OFF)
|
||||||
option (BUILDTESTS "Generate check-ups for upm" OFF)
|
option (BUILDTESTS "Generate check-ups for upm" OFF)
|
||||||
option (WERROR "Make all warnings into errors." OFF)
|
option (WERROR "Make all warnings into errors." OFF)
|
||||||
|
|
||||||
|
@ -204,6 +204,12 @@ macro(upm_swig_node)
|
|||||||
|
|
||||||
createpackagejson(${libname})
|
createpackagejson(${libname})
|
||||||
|
|
||||||
|
if (NPM)
|
||||||
|
add_custom_command (TARGET jsupm_${libname} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname}JAVASCRIPT_wrap.cxx
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname})
|
||||||
|
endif ()
|
||||||
|
|
||||||
install (TARGETS jsupm_${libname} DESTINATION ${NODE_MODULE_INSTALL_PATH})
|
install (TARGETS jsupm_${libname} DESTINATION ${NODE_MODULE_INSTALL_PATH})
|
||||||
endif (NOT ";${NODESWIG_BLACKLIST};" MATCHES ";${libname};")
|
endif (NOT ";${NODESWIG_BLACKLIST};" MATCHES ";${libname};")
|
||||||
endmacro(upm_swig_node)
|
endmacro(upm_swig_node)
|
||||||
@ -279,6 +285,14 @@ macro(upm_doxygen)
|
|||||||
endif ()
|
endif ()
|
||||||
endmacro(upm_doxygen)
|
endmacro(upm_doxygen)
|
||||||
|
|
||||||
|
if (NPM)
|
||||||
|
add_custom_target (npmpkg)
|
||||||
|
add_custom_command (TARGET npmpkg POST_BUILD COMMAND echo "Creating NPM tarballs..."
|
||||||
|
COMMAND find . -maxdepth 2 -type d -name "jsupm_*" -print0 |
|
||||||
|
xargs -0 -I {} tar czf `basename {}`.tar.gz -C {} .
|
||||||
|
)
|
||||||
|
endif (NPM)
|
||||||
|
|
||||||
if (BUILDSWIGNODE)
|
if (BUILDSWIGNODE)
|
||||||
if(SWIG_VERSION VERSION_LESS 3.0.5 AND NODE_VERSION_STRING VERSION_GREATER 0.12)
|
if(SWIG_VERSION VERSION_LESS 3.0.5 AND NODE_VERSION_STRING VERSION_GREATER 0.12)
|
||||||
message(WARNING "WARNING - SWIG 3.0.5+ required for building with nodejs 0.12. Current version is ${SWIG_VERSION}")
|
message(WARNING "WARNING - SWIG 3.0.5+ required for building with nodejs 0.12. Current version is ${SWIG_VERSION}")
|
||||||
@ -291,24 +305,43 @@ if (BUILDSWIGNODE)
|
|||||||
${NODE_ROOT_DIR}/include/deps/uv/include
|
${NODE_ROOT_DIR}/include/deps/uv/include
|
||||||
)
|
)
|
||||||
macro(createpackagejson)
|
macro(createpackagejson)
|
||||||
#Create list of source files
|
if (NPM)
|
||||||
foreach (srcfile ${module_src})
|
# Grab all module sources and headers, also add sources to gyp list
|
||||||
file (RELATIVE_PATH rel ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
file (GLOB srcfiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
set (upm_LIB_SRCS_GYP "'${rel}/${srcfile}',\n${upm_LIB_SRCS_GYP}")
|
"${CMAKE_CURRENT_SOURCE_DIR}/*.c"
|
||||||
endforeach (srcfile)
|
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
||||||
file (RELATIVE_PATH rel ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
"${CMAKE_CURRENT_SOURCE_DIR}/*.cxx"
|
||||||
set (upm_LIB_SRCS_GYP "'${rel}/jsupm_${libname}JAVASCRIPT_wrap.cxx',\n${upm_LIB_SRCS_GYP}")
|
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
|
||||||
#Create list of include directories
|
"${CMAKE_CURRENT_SOURCE_DIR}/*.hpp"
|
||||||
foreach (includedir ${UPM_COMMON_HEADER_DIRS})
|
"${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
|
||||||
file (RELATIVE_PATH rel ${CMAKE_SOURCE_DIR} ${includedir})
|
foreach (srcfile ${srcfiles})
|
||||||
set (upm_LIB_INCLUDE_DIRS_GYP "'${rel}',\n${upm_LIB_INCLUDE_DIRS_GYP}")
|
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/${srcfile} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname})
|
||||||
endforeach (includedir)
|
if (${srcfile} MATCHES ".c" OR ${srcfile} MATCHES ".cxx" OR ${srcfile} MATCHES ".cpp")
|
||||||
file (RELATIVE_PATH rel ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
set (upm_LIB_SRCS_GYP "'${srcfile}',\n${upm_LIB_SRCS_GYP}")
|
||||||
set (upm_LIB_SRCS_GYP "'${rel}',\n${upm_LIB_SRCS_GYP}")
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
set (upm_LIB_SRCS_GYP "'jsupm_${libname}JAVASCRIPT_wrap.cxx',\n${upm_LIB_SRCS_GYP}")
|
||||||
|
|
||||||
|
# Create list of include directories and copy them
|
||||||
|
foreach (includedir ${UPM_COMMON_HEADER_DIRS})
|
||||||
|
file (RELATIVE_PATH rel ${CMAKE_SOURCE_DIR} ${includedir})
|
||||||
|
set (upm_LIB_INCLUDE_DIRS_GYP "'${rel}',\n${upm_LIB_INCLUDE_DIRS_GYP}")
|
||||||
|
endforeach (includedir)
|
||||||
|
file (COPY ${CMAKE_SOURCE_DIR}/include DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname})
|
||||||
|
set (upm_LIB_INCLUDE_DIRS_GYP "'.',\n${upm_LIB_INCLUDE_DIRS_GYP}")
|
||||||
|
|
||||||
|
# Dependency to generate wrappers before packing
|
||||||
|
add_dependencies (npmpkg jsupm_${libname})
|
||||||
|
|
||||||
|
# Add readme for NPM and node-gyp config file
|
||||||
|
configure_file (${PROJECT_SOURCE_DIR}/src/binding.gyp.in ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname}/binding.gyp @ONLY)
|
||||||
|
configure_file (${PROJECT_SOURCE_DIR}/src/package.json.in ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname}/package.json @ONLY)
|
||||||
|
configure_file (${PROJECT_SOURCE_DIR}/doxy/README.npm.md ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname}/README.md)
|
||||||
|
endif (NPM)
|
||||||
|
|
||||||
|
# package.json is required for any kind of install
|
||||||
configure_file (${PROJECT_SOURCE_DIR}/src/package.json.in ${CMAKE_CURRENT_BINARY_DIR}/package.json @ONLY)
|
configure_file (${PROJECT_SOURCE_DIR}/src/package.json.in ${CMAKE_CURRENT_BINARY_DIR}/package.json @ONLY)
|
||||||
configure_file (${PROJECT_SOURCE_DIR}/src/binding.gyp.in ${CMAKE_CURRENT_BINARY_DIR}/binding.gyp @ONLY)
|
|
||||||
configure_file (${PROJECT_SOURCE_DIR}/doxy/README.npm.md ${CMAKE_CURRENT_BINARY_DIR}/README.md)
|
|
||||||
# If a CMAKE_INSTALL_PREFIX has NOT been provided, set NODE_MODULE_INSTALL_PATH
|
# If a CMAKE_INSTALL_PREFIX has NOT been provided, set NODE_MODULE_INSTALL_PATH
|
||||||
# base on the NODE_ROOT_DIR.
|
# base on the NODE_ROOT_DIR.
|
||||||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||||
|
@ -6,12 +6,24 @@
|
|||||||
@upm_LIB_SRCS_GYP@
|
@upm_LIB_SRCS_GYP@
|
||||||
],
|
],
|
||||||
'include_dirs': [
|
'include_dirs': [
|
||||||
|
'<@(mraa_include_dir)',
|
||||||
@upm_LIB_INCLUDE_DIRS_GYP@
|
@upm_LIB_INCLUDE_DIRS_GYP@
|
||||||
],
|
],
|
||||||
'variables': {
|
'variables': {
|
||||||
|
'node_mraa': '<!(node -p -e "require(\'path\').dirname(require.resolve(\'mraa\'))")',
|
||||||
|
'mraa_include_dir': [
|
||||||
|
'<(node_mraa)/api'
|
||||||
|
],
|
||||||
|
'mraa_libraries': [
|
||||||
|
'<(node_mraa)/mraa.node',
|
||||||
|
'-Wl,-rpath,<(node_mraa)',
|
||||||
|
],
|
||||||
"v8_version%": "<!(node -e 'console.log(process.versions.v8)' | sed 's/\.//g' | cut -c 1-5)",
|
"v8_version%": "<!(node -e 'console.log(process.versions.v8)' | sed 's/\.//g' | cut -c 1-5)",
|
||||||
"arch%": "<!(node -e 'console.log(process.arch)')"
|
"arch%": "<!(node -e 'console.log(process.arch)')"
|
||||||
},
|
},
|
||||||
|
'link_settings': {
|
||||||
|
'libraries' : [ '<@(mraa_libraries)' ]
|
||||||
|
},
|
||||||
'cflags_cc!': [ '-fno-rtti', '-fno-exceptions' ],
|
'cflags_cc!': [ '-fno-rtti', '-fno-exceptions' ],
|
||||||
'cflags!': [ '-fno-exceptions' ],
|
'cflags!': [ '-fno-exceptions' ],
|
||||||
'defines' : [
|
'defines' : [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user