javascript: Add nodejs 4.1.1 support
API changes in V8 API mean that node.js 4 needs some changes both in mraajs.i but also require a C++11 compiler Signed-off-by: Eugene Bolshakov <pub@relvarsoft.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -3,8 +3,8 @@ project (mraa)
|
|||||||
|
|
||||||
FIND_PACKAGE (Threads REQUIRED)
|
FIND_PACKAGE (Threads REQUIRED)
|
||||||
|
|
||||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fno-omit-frame-pointer")
|
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fno-omit-frame-pointer ")
|
||||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
|
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall ")
|
||||||
set (LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries")
|
set (LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Installation path for libraries")
|
||||||
|
|
||||||
# Set CMAKE_LIB_INSTALL_DIR if not defined
|
# Set CMAKE_LIB_INSTALL_DIR if not defined
|
||||||
@@ -16,7 +16,7 @@ set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_
|
|||||||
# Make a version file containing the current version from git.
|
# Make a version file containing the current version from git.
|
||||||
include (GetGitRevisionDescription)
|
include (GetGitRevisionDescription)
|
||||||
git_describe (VERSION "--tags")
|
git_describe (VERSION "--tags")
|
||||||
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_HEAD-HASH-NOTFOUND")
|
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_HEAD-HASH-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND")
|
||||||
message (WARNING " - Install git to compile a production libmraa!")
|
message (WARNING " - Install git to compile a production libmraa!")
|
||||||
set (VERSION "v0.8.0-dirty")
|
set (VERSION "v0.8.0-dirty")
|
||||||
endif ()
|
endif ()
|
||||||
|
|||||||
@@ -23,6 +23,15 @@ set_target_properties (mraajs PROPERTIES
|
|||||||
OUTPUT_NAME mraa
|
OUTPUT_NAME mraa
|
||||||
SUFFIX ".node"
|
SUFFIX ".node"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (${V8_VERSION_MAJOR} GREATER 3)
|
||||||
|
message (INFO " - Using V8 version > 3 so requiring C++11 compiler")
|
||||||
|
# Node 0.12.x V8 engine major version is '3'.
|
||||||
|
# Node 2.1.0 V8 engine major version is '4'.
|
||||||
|
set_property (TARGET mraajs PROPERTY CXX_STANDARD 11)
|
||||||
|
set_property (TARGET mraajs PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||||
|
endif ()
|
||||||
|
|
||||||
macro (mraa_CREATE_INSTALL_PACKAGE_JSON generated_file install_location)
|
macro (mraa_CREATE_INSTALL_PACKAGE_JSON generated_file install_location)
|
||||||
configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
|
configure_file (${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
|
||||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
|
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
|
||||||
|
|||||||
@@ -42,12 +42,20 @@ namespace mraa {
|
|||||||
class Spi;
|
class Spi;
|
||||||
%typemap(out) uint8_t*
|
%typemap(out) uint8_t*
|
||||||
{
|
{
|
||||||
%#if SWIG_V8_VERSION > 0x032870
|
%#if SWIG_V8_VERSION > 0x040000
|
||||||
|
v8::MaybeLocal<v8::Object> objret = node::Buffer::New(v8::Isolate::GetCurrent(), (char*) $1, arg3);
|
||||||
|
free($1);
|
||||||
|
if(!objret.ToLocal(&$result)) {
|
||||||
|
SWIG_exception_fail(SWIG_ERROR, "Spi buffer failed");
|
||||||
|
SWIGV8_RETURN(SWIGV8_UNDEFINED());
|
||||||
|
}
|
||||||
|
%#elif SWIG_V8_VERSION > 0x032870
|
||||||
$result = node::Buffer::New((char*) $1, arg3);
|
$result = node::Buffer::New((char*) $1, arg3);
|
||||||
|
free($1);
|
||||||
%#else
|
%#else
|
||||||
$result = node::Buffer::New((char*) $1, arg3)->handle_;
|
$result = node::Buffer::New((char*) $1, arg3)->handle_;
|
||||||
%#endif
|
|
||||||
free($1);
|
free($1);
|
||||||
|
%#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,15 +81,24 @@ class Spi;
|
|||||||
%typemap(argout) (char* data, int length) {
|
%typemap(argout) (char* data, int length) {
|
||||||
if (result < 0) { /* Check for I/O error */
|
if (result < 0) { /* Check for I/O error */
|
||||||
free($1);
|
free($1);
|
||||||
SWIG_exception_fail(SWIG_ERROR, "I2c write failed");
|
SWIG_exception_fail(SWIG_ERROR, "Uart write failed");
|
||||||
SWIGV8_RETURN(SWIGV8_UNDEFINED());
|
SWIGV8_RETURN(SWIGV8_UNDEFINED());
|
||||||
}
|
}
|
||||||
%#if SWIG_V8_VERSION > 0x032870
|
%#if SWIG_V8_VERSION > 0x040000
|
||||||
|
v8::MaybeLocal<v8::Object> objret = node::Buffer::New(v8::Isolate::GetCurrent(), (char*) $1, result);
|
||||||
|
free($1);
|
||||||
|
if(!objret.ToLocal(&$result)) {
|
||||||
|
SWIG_exception_fail(SWIG_ERROR, "Uart buffer failed");
|
||||||
|
SWIGV8_RETURN(SWIGV8_UNDEFINED());
|
||||||
|
}
|
||||||
|
%#elif SWIG_V8_VERSION > 0x032870
|
||||||
$result = node::Buffer::New((char*) $1, result);
|
$result = node::Buffer::New((char*) $1, result);
|
||||||
|
free($1);
|
||||||
%#else
|
%#else
|
||||||
$result = node::Buffer::New((char*) $1, result)->handle_;
|
$result = node::Buffer::New((char*) $1, result)->handle_;
|
||||||
%#endif
|
|
||||||
free($1);
|
free($1);
|
||||||
|
%#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//I2c::read()
|
//I2c::read()
|
||||||
@@ -105,12 +122,20 @@ class Spi;
|
|||||||
SWIG_exception_fail(SWIG_ERROR, "I2c write failed");
|
SWIG_exception_fail(SWIG_ERROR, "I2c write failed");
|
||||||
SWIGV8_RETURN(SWIGV8_UNDEFINED());
|
SWIGV8_RETURN(SWIGV8_UNDEFINED());
|
||||||
}
|
}
|
||||||
%#if SWIG_V8_VERSION > 0x032870
|
%#if SWIG_V8_VERSION > 0x040000
|
||||||
|
v8::MaybeLocal<v8::Object> objret = node::Buffer::New(v8::Isolate::GetCurrent(), (char*) $1, result);
|
||||||
|
free($1);
|
||||||
|
if(!objret.ToLocal(&$result)) {
|
||||||
|
SWIG_exception_fail(SWIG_ERROR, "I2c buffer failed");
|
||||||
|
SWIGV8_RETURN(SWIGV8_UNDEFINED());
|
||||||
|
}
|
||||||
|
%#elif SWIG_V8_VERSION > 0x032870
|
||||||
$result = node::Buffer::New((char*) $1, result);
|
$result = node::Buffer::New((char*) $1, result);
|
||||||
|
free($1);
|
||||||
%#else
|
%#else
|
||||||
$result = node::Buffer::New((char*) $1, result)->handle_;
|
$result = node::Buffer::New((char*) $1, result)->handle_;
|
||||||
%#endif
|
|
||||||
free($1);
|
free($1);
|
||||||
|
%#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
%include ../mraa.i
|
%include ../mraa.i
|
||||||
|
|||||||
Reference in New Issue
Block a user