From: Brendan Le Foll Date: Wed, 11 Nov 2015 13:47:43 +0000 (+0000) Subject: javascript: Fix build for nodejs v5 which has smaller version string X-Git-Tag: v0.9.0~94 X-Git-Url: http://review.tizen.org/git/?p=contrib%2Fmraa.git;a=commitdiff_plain;h=80024ff1844d539131b453dec3a94cb4cfe579c0 javascript: Fix build for nodejs v5 which has smaller version string SWIG uses SWIG_V8_VERSION made of 0x0${V8_VERSION_MAJOR}${V8_VERSION_MINOR}${V8_VERSION_PATCH}. Because newer v8 versions don't seem to have a patch version that is padded the version string ends up too small ending with using the node.js 0.10.x paths. This fix pads the version string to 8chars which (we assume) is always correct. Fixes #358 Signed-off-by: Brendan Le Foll --- diff --git a/src/javascript/CMakeLists.txt b/src/javascript/CMakeLists.txt index 47a9096..adfc82c 100644 --- a/src/javascript/CMakeLists.txt +++ b/src/javascript/CMakeLists.txt @@ -7,11 +7,18 @@ include_directories ( # SWIG treats SWIG_FLAGS as a list and not a string so semicolon seperation is # required. This hardcodes V8_VERSION to be <10 but I assume that's not going -# to be a problem for a little while! -#set_source_files_properties (mraajs.i PROPERTIES SWIG_FLAGS "-node;-DV8_VERSION=0x0${V8_VERSION_HEX};-I${CMAKE_BINARY_DIR}/src") -#set_source_files_properties (mraajs.i PROPERTIES SWIG_FLAGS "-node;-I${CMAKE_BINARY_DIR}/src") +# to be a problem for a little while! SWIG uses a padded SWIG_V8 version which +# we hack together from our findnode module. +set (V8_VERSION_HEX 0x0${V8_VERSION_MAJOR}${V8_VERSION_MINOR}${V8_VERSION_PATCH}) +string (LENGTH "${V8_VERSION_HEX}" V8_VERSION_HEX_length) +while (V8_VERSION_HEX_length LESS 8) + set (V8_VERSION_HEX "${V8_VERSION_HEX}0") + message (DEBUG " - Padded V8 version to match SWIG format") + string (LENGTH "${V8_VERSION_HEX}" V8_VERSION_HEX_length) +endwhile () + set_property (SOURCE mraajs.i PROPERTY SWIG_FLAGS "-node" - "-I${CMAKE_BINARY_DIR}/src" "-DV8_VERSION=0x0${V8_VERSION_MAJOR}${V8_VERSION_MINOR}${V8_VERSION_PATCH}") + "-I${CMAKE_BINARY_DIR}/src" "-DV8_VERSION=${V8_VERSION_HEX}") set_source_files_properties (mraajs.i PROPERTIES CPLUSPLUS ON) swig_add_module (mraajs javascript mraajs.i ${mraa_LIB_SRCS})