Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nodejs-module-webos-*: fix build for nodejs-0.12.2
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
- Loading branch information
1 parent
54ff0f6
commit 934e37a
Showing
8 changed files
with
3,292 additions
and
14 deletions.
There are no files selected for viewing
31 changes: 22 additions & 9 deletions
31
meta-luneos/recipes-upstreamable/nodejs/node-sqlite3/no-node-pre-gyp.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
From ad4e26a2e45b322434bd1fd1ecc77ec9f2ac7a97 Mon Sep 17 00:00:00 2001 | ||
From: Martin Jansa <Martin.Jansa@gmail.com> | ||
Date: Tue, 23 Jun 2015 15:37:27 +0200 | ||
Subject: [PATCH] sqlite3.js: hardcode node_sqlite3.node path | ||
|
||
* trying to find it, doesn't work correctly when cross compiling | ||
|
||
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> | ||
--- | ||
lib/sqlite3.js | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/lib/sqlite3.js b/lib/sqlite3.js | ||
index be9205c..4808ddf 100644 | ||
index 466b902..6464d87 100644 | ||
--- a/lib/sqlite3.js | ||
+++ b/lib/sqlite3.js | ||
@@ -1,8 +1,5 @@ | ||
@@ -1,6 +1,6 @@ | ||
var binary = require('node-pre-gyp'); | ||
var path = require('path'); | ||
-var pkg = require('../package.json'); | ||
-var module_path = path.join( | ||
- path.join(__dirname,'../' + pkg.binary.module_path), | ||
- pkg.binary.module_name + '.node'); | ||
+var module_path = '/usr/lib/nodejs/node_sqlite3.node'; | ||
var binding = require(module_path); | ||
-var binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json'))); | ||
+var binding_path = '/usr/lib/nodejs/node_sqlite3.node'; | ||
var binding = require(binding_path); | ||
var sqlite3 = module.exports = exports = binding; | ||
var util = require('util'); | ||
var EventEmitter = require('events').EventEmitter; | ||
-- | ||
2.4.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
317 changes: 317 additions & 0 deletions
317
...os/nodejs-module-webos/nodejs-module-webos-dynaload/0001-Fix-build-for-node-v0.12.2.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,317 @@ | ||
From 5b80411722670d2184b6ac41843b25694f9414de Mon Sep 17 00:00:00 2001 | ||
From: Oleksandr Ivanov <oleksandr.ivanov@lge.com> | ||
Date: Fri, 24 Apr 2015 17:00:02 +0300 | ||
Subject: [PATCH] Fix build for node v0.12.2 | ||
|
||
:Release Notes: | ||
Updated module for using with Node.js v0.12.2 | ||
|
||
:Detailed Notes: | ||
Node.js v0.12.2 uses new V8. In this version V8 was changed some | ||
internal structures and interfaces. To make "buildable" this module, | ||
was made changes which use updated V8 interface. | ||
|
||
:Testing Performed: | ||
Manual build package performed. | ||
|
||
:QA Notes: | ||
|
||
:Issues Addressed: | ||
[DRD-2007] Switch to nodejs v0.12.2 | ||
[DRD-2008] Use g2g for Node JS | ||
|
||
Open-webOS-DCO-1.0-Signed-off-by: Oleksandr Ivanov<oleksandr.ivanov@lge.com> | ||
|
||
Change-Id: I229f4557c870df0270c752c48c5e571a76979861 | ||
Reviewed-on: https://g2g.lgsvl.com/7730 | ||
Reviewed-by: DCO Verification | ||
Reviewed-by: Andrii Koval <andrii.koval@lge.com> | ||
Reviewed-by: Oleksandr Ivanov <oleksandr.ivanov@lge.com> | ||
Reviewed-by: Denys Romanchuk <denys.romanchuk@lge.com> | ||
Reviewed-by: Sergiy Kryvonos <sergiy.kryvonos@lge.com> | ||
Tested-by: Sergiy Kryvonos <sergiy.kryvonos@lge.com> | ||
--- | ||
src/external_string.cpp | 7 ++- | ||
src/node_webos.cpp | 147 ++++++++++++++++++++++++++++++++---------------- | ||
2 files changed, 101 insertions(+), 53 deletions(-) | ||
|
||
diff --git a/src/external_string.cpp b/src/external_string.cpp | ||
index aa72b0d..010d9bb 100644 | ||
--- a/src/external_string.cpp | ||
+++ b/src/external_string.cpp | ||
@@ -58,7 +58,7 @@ v8::Local<v8::String> createV8StringFromFile(const char* inPathToFile) | ||
// exception and throw a runtime exception with a less boost-flavored message. | ||
boost::uintmax_t fileSize = bf::file_size(pathToFile); | ||
if (fileSize == 0) { | ||
- return String::New(""); | ||
+ return String::NewFromUtf8(v8::Isolate::GetCurrent(), ""); | ||
} | ||
bi::file_mapping mappedFile(inPathToFile, bi::read_only); | ||
bi::mapped_region region(mappedFile, bi::read_only); | ||
@@ -73,14 +73,15 @@ v8::Local<v8::String> createV8StringFromFile(const char* inPathToFile) | ||
} | ||
// Let v8 do its normal string conversion. This should be a rare case, as there's | ||
// no good reason for a JavaScript source file to have anything but ASCII. | ||
- return String::New(startPtr, fileSize); | ||
+ return String::NewFromUtf8(v8::Isolate::GetCurrent(), startPtr); | ||
} | ||
|
||
// Wrapper function to create a v8 external string. | ||
v8::Local<v8::String> MappedRegionExternalString::create(const char* pathToFile) | ||
{ | ||
+ Isolate* isolate = Isolate::GetCurrent(); | ||
MappedRegionExternalString* extString = new MappedRegionExternalString(pathToFile); | ||
- return String::NewExternal(extString); | ||
+ return String::NewExternal(isolate, extString); | ||
} | ||
|
||
// The boost constructors do all the hard work of mapping the region and unmapping it when this object is destroyed. | ||
diff --git a/src/node_webos.cpp b/src/node_webos.cpp | ||
index 2c25083..fbc947a 100644 | ||
--- a/src/node_webos.cpp | ||
+++ b/src/node_webos.cpp | ||
@@ -32,18 +32,28 @@ const char* kDirNameGlobal="__dirname"; | ||
|
||
static void SetFileAndDirectoryGlobals(Local<Object> global, const char* path) | ||
{ | ||
+ v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
bf::path pathToFile(bf::system_complete(bf::path(path))); | ||
bf::path pathToParentDir(pathToFile.parent_path()); | ||
- Handle<String> fileName = v8::String::New(pathToFile.string().c_str()); | ||
- global->Set(String::NewSymbol(kFileNameGlobal), fileName); | ||
- Handle<String> dirName = v8::String::New(pathToParentDir.string().c_str()); | ||
- global->Set(String::NewSymbol(kDirNameGlobal), dirName); | ||
+ Handle<String> fileName = v8::String::NewFromUtf8(isolate, pathToFile.string().c_str()); | ||
+ global->Set( | ||
+ v8::String::NewFromUtf8(isolate, kFileNameGlobal, v8::String::kInternalizedString), | ||
+ fileName); | ||
+ Handle<String> dirName = v8::String::NewFromUtf8(isolate, pathToParentDir.string().c_str()); | ||
+ global->Set( | ||
+ v8::String::NewFromUtf8(isolate, kDirNameGlobal, v8::String::kInternalizedString), | ||
+ dirName); | ||
} | ||
|
||
static void ClearFileAndDirectoryGlobals(Local<Object> global) | ||
{ | ||
- global->Set(String::NewSymbol(kFileNameGlobal), v8::Undefined()); | ||
- global->Set(String::NewSymbol(kDirNameGlobal), v8::Undefined()); | ||
+ v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
+ global->Set( | ||
+ v8::String::NewFromUtf8(isolate, kFileNameGlobal, v8::String::kInternalizedString), | ||
+ v8::Undefined(isolate)); | ||
+ global->Set( | ||
+ v8::String::NewFromUtf8(isolate, kDirNameGlobal, v8::String::kInternalizedString), | ||
+ v8::Undefined(isolate)); | ||
} | ||
|
||
// Load, compile and execute a JavaScript file in the current context. Used by | ||
@@ -52,18 +62,20 @@ static void ClearFileAndDirectoryGlobals(Local<Object> global) | ||
Handle<Value> IncludeScript(char const * pathToScriptSource, bool& exceptionOccurred) | ||
{ | ||
exceptionOccurred = true; | ||
+ v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
if(!pathToScriptSource || !*pathToScriptSource ) { | ||
- return ThrowException(Exception::Error( | ||
- String::New("webOS 'include' requires a non-empty filename argument."))); | ||
+ return isolate->ThrowException(v8::Exception::Error( | ||
+ v8::String::NewFromUtf8(isolate, "webOS 'include' requires a non-empty filename argument."))); | ||
} | ||
- HandleScope scope; | ||
- Handle<Value> returnValue = Undefined(); | ||
+ EscapableHandleScope scope(isolate); | ||
+ Handle<Value> returnValue = Undefined(isolate); | ||
Local<String> scriptSource = createV8StringFromFile(pathToScriptSource); | ||
- Handle<Script> compiledScript(Script::Compile(scriptSource, String::New(pathToScriptSource))); | ||
+ Handle<Script> compiledScript(Script::Compile(scriptSource, | ||
+ String::NewFromUtf8(isolate, pathToScriptSource))); | ||
if(compiledScript.IsEmpty()) { | ||
return returnValue; | ||
} | ||
- Local<Context> currentContext = Context::GetCurrent(); | ||
+ Local<Context> currentContext = isolate->GetCurrentContext(); | ||
Local<Object> global = currentContext->Global(); | ||
SetFileAndDirectoryGlobals(global, pathToScriptSource); | ||
returnValue = compiledScript->Run(); | ||
@@ -71,32 +83,37 @@ Handle<Value> IncludeScript(char const * pathToScriptSource, bool& exceptionOccu | ||
if(returnValue.IsEmpty()) { | ||
return returnValue; | ||
} | ||
- exceptionOccurred = false; | ||
- return scope.Close(returnValue); | ||
+ exceptionOccurred = false; | ||
+ return scope.Escape(Local<Value>::New(isolate, returnValue)); | ||
} | ||
|
||
// Wrapper function that checks and converts parameters on the way in and converts | ||
// exceptions. | ||
-Handle<Value> IncludeScriptWrapper( Arguments const & arguments ) | ||
+void IncludeScriptWrapper( const v8::FunctionCallbackInfo<v8::Value> & arguments ) | ||
{ | ||
+ v8::Isolate* isolate = arguments.GetIsolate(); | ||
if (arguments.Length() != 1) { | ||
- return ThrowException(Exception::Error( | ||
- String::New("Invalid number of parameters, 1 expected."))); | ||
+ arguments.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error( | ||
+ v8::String::NewFromUtf8(isolate, "Invalid number of parameters, 1 expected.")))); | ||
+ return; | ||
} | ||
try { | ||
v8::String::Utf8Value fileName(arguments[0]); | ||
bool exceptionOccurred; | ||
- return IncludeScript(*fileName, exceptionOccurred); | ||
+ arguments.GetReturnValue().Set(IncludeScript(*fileName, exceptionOccurred)); | ||
} catch( std::exception const & ex ) { | ||
- return v8::ThrowException( v8::Exception::Error(v8::String::New(ex.what()))); | ||
+ arguments.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error( | ||
+ v8::String::NewFromUtf8(isolate, ex.what())))); | ||
} catch( ... ) { | ||
- return v8::ThrowException( v8::Exception::Error(v8::String::New("Native function threw an unknown exception."))); | ||
+ arguments.GetReturnValue().Set(isolate->ThrowException(v8::Exception::Error( | ||
+ v8::String::NewFromUtf8(isolate, "Native function threw an unknown exception.")))); | ||
} | ||
} | ||
|
||
static void CopyProperty(const Handle<Object>& src, const Handle<Object>& dst, const char* propertyName) | ||
{ | ||
- Local<String> pName(String::NewSymbol(propertyName)); | ||
+ v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
+ Local<String> pName(v8::String::NewFromUtf8(isolate, propertyName, v8::String::kInternalizedString)); | ||
Local<Value> v = src->Get(pName); | ||
dst->Set(pName, v); | ||
} | ||
@@ -108,31 +125,52 @@ static void CopyProperty(const Handle<Object>& src, const Handle<Object>& dst, c | ||
// possible to access from this function. At this point this function is only an interesting experiment. | ||
static Handle<Value> Require(const Handle<Value>& nativeRequire, const Handle<Value>& loader, const Handle<Array> & filePaths) | ||
{ | ||
+ v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
+ | ||
// fetch the current content and global object | ||
- Local<Context> currentContext = Context::GetCurrent(); | ||
+ Local<Context> currentContext = isolate->GetCurrentContext(); | ||
Local<Object> currentGlobal = currentContext->Global(); | ||
|
||
// create a new context with an empty global template. This would be the place we'd | ||
// extend the global template with the function from node if that were possible. | ||
- Handle<ObjectTemplate> globalTemplate = ObjectTemplate::New(); | ||
- Persistent<Context> utilityContext = Context::New(NULL, globalTemplate); | ||
- | ||
+ Handle<ObjectTemplate> globalTemplate = ObjectTemplate::New(isolate); | ||
+ Persistent<Context> utilityContext(isolate, Context::New(isolate, NULL, globalTemplate)); | ||
+ | ||
// If security tokens don't match between contexts then neither context can access each | ||
// other's properties. This is the mechanism that keeps JS in pages in a browser from sniffing | ||
// other pages data. It's not being used for any purpose in webOS's use of node. | ||
- utilityContext->SetSecurityToken(currentContext->GetSecurityToken()); | ||
- Context::Scope utilityScope(utilityContext); | ||
- | ||
+ Local<Context> localUtilityContext = Local<Context>::New(isolate, utilityContext); | ||
+ localUtilityContext->SetSecurityToken(currentContext->GetSecurityToken()); | ||
+ Context::Scope utilityScope(localUtilityContext); | ||
+ | ||
// Set up an exports object for use by modules. | ||
Handle<ObjectTemplate> exportsTemplate = ObjectTemplate::New(); | ||
Local<Object> exportsInstance = exportsTemplate->NewInstance(); | ||
- Local<Object> global = utilityContext->Global(); | ||
- global->Set(String::NewSymbol("exports"), exportsInstance); | ||
- global->Set(String::NewSymbol("global"), global); | ||
- global->Set(String::NewSymbol("globals"), currentGlobal); | ||
- global->Set(String::NewSymbol("root"), currentGlobal); | ||
- global->Set(String::NewSymbol("MojoLoader"), loader); | ||
- global->Set(String::NewSymbol("require"), nativeRequire); | ||
+ Local<Object> global = localUtilityContext->Global(); | ||
+ global->Set( | ||
+ v8::String::NewFromUtf8( | ||
+ isolate, "exports", v8::String::kInternalizedString), | ||
+ exportsInstance); | ||
+ global->Set( | ||
+ v8::String::NewFromUtf8( | ||
+ isolate, "global", v8::String::kInternalizedString), | ||
+ global); | ||
+ global->Set( | ||
+ v8::String::NewFromUtf8( | ||
+ isolate, "globals", v8::String::kInternalizedString), | ||
+ currentGlobal); | ||
+ global->Set( | ||
+ v8::String::NewFromUtf8( | ||
+ isolate, "root", v8::String::kInternalizedString), | ||
+ currentGlobal); | ||
+ global->Set( | ||
+ v8::String::NewFromUtf8( | ||
+ isolate, "MojoLoader", v8::String::kInternalizedString), | ||
+ loader); | ||
+ global->Set( | ||
+ v8::String::NewFromUtf8( | ||
+ isolate, "require", v8::String::kInternalizedString), | ||
+ nativeRequire); | ||
|
||
// copy a number of useful properties from the loading node context. | ||
CopyProperty(currentGlobal, global, "console"); | ||
@@ -146,8 +184,8 @@ static Handle<Value> Require(const Handle<Value>& nativeRequire, const Handle<Va | ||
for(uint32_t i = 0; i < length; ++i) { | ||
Local<Value> fileNameObject(filePaths->Get(i)); | ||
if (!fileNameObject->IsString()) { | ||
- return ThrowException(Exception::Error( | ||
- String::New("All elements of file paths array must be strings."))); | ||
+ return isolate->ThrowException(v8::Exception::Error( | ||
+ v8::String::NewFromUtf8(isolate, "All elements of file paths array must be strings."))); | ||
} | ||
v8::String::Utf8Value fileName(fileNameObject); | ||
bool exceptionOccurred; | ||
@@ -161,32 +199,41 @@ static Handle<Value> Require(const Handle<Value>& nativeRequire, const Handle<Va | ||
return global; | ||
} | ||
|
||
-static Handle<Value> RequireWrapper(const Arguments& arguments) | ||
+static void RequireWrapper(const v8::FunctionCallbackInfo<v8::Value>& arguments) | ||
{ | ||
+ Isolate* isolate = Isolate::GetCurrent(); | ||
if (arguments.Length() != 3) { | ||
- return ThrowException(Exception::Error( | ||
- String::New("Invalid number of parameters, 3 expected."))); | ||
+ arguments.GetReturnValue().Set(isolate->ThrowException(Exception::Error( | ||
+ String::NewFromUtf8(isolate, "Invalid number of parameters, 3 expected.")))); | ||
+ return; | ||
} | ||
if (!arguments[0]->IsFunction()) { | ||
- return ThrowException(Exception::Error( | ||
- String::New("Argument 2 must be an function."))); | ||
+ arguments.GetReturnValue().Set(isolate->ThrowException(Exception::Error( | ||
+ String::NewFromUtf8(isolate, "Argument 2 must be an function.")))); | ||
+ return; | ||
} | ||
if (!arguments[2]->IsArray()) { | ||
- return ThrowException(Exception::Error( | ||
- String::New("Argument 3 must be an array."))); | ||
+ arguments.GetReturnValue().Set(isolate->ThrowException(Exception::Error( | ||
+ String::NewFromUtf8(isolate, "Argument 3 must be an array.")))); | ||
+ return; | ||
} | ||
Local<Array> fileList = Local<Array>::Cast(arguments[2]); | ||
- return Require(arguments[0], arguments[1], fileList); | ||
+ arguments.GetReturnValue().Set(Require(arguments[0], arguments[1], fileList)); | ||
} | ||
|
||
|
||
void init(Handle<Object> target) | ||
{ | ||
- HandleScope scope; | ||
- Local<FunctionTemplate> includeTemplate = FunctionTemplate::New(IncludeScriptWrapper); | ||
- target->Set(String::NewSymbol("include"), includeTemplate->GetFunction()); | ||
- Local<FunctionTemplate> requireTemplate = FunctionTemplate::New(RequireWrapper); | ||
- target->Set(String::NewSymbol("require"), requireTemplate->GetFunction()); | ||
+ Isolate* isolate = Isolate::GetCurrent(); | ||
+ HandleScope scope(isolate); | ||
+ Local<FunctionTemplate> includeTemplate = FunctionTemplate::New(isolate, IncludeScriptWrapper); | ||
+ target->Set( | ||
+ v8::String::NewFromUtf8(isolate, "include", v8::String::kInternalizedString), | ||
+ includeTemplate->GetFunction()); | ||
+ Local<FunctionTemplate> requireTemplate = FunctionTemplate::New(isolate, RequireWrapper); | ||
+ target->Set( | ||
+ v8::String::NewFromUtf8(isolate, "require", v8::String::kInternalizedString), | ||
+ requireTemplate->GetFunction()); | ||
} | ||
|
||
NODE_MODULE(webos, init) | ||
-- | ||
2.1.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.