Introduced an extra Makefile for the custom javascript interpreter.
This commit is contained in:
parent
bf1606c0f9
commit
b216a739c4
7 changed files with 233 additions and 44 deletions
56
Tools/javascript/Makefile.in
Normal file
56
Tools/javascript/Makefile.in
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# ----------------------------------------------------------------
|
||||
# Compile a custom javascript interpreter
|
||||
# ----------------------------------------------------------------
|
||||
#
|
||||
# Note:
|
||||
# There is no common CLI Javascript interpreter.
|
||||
# V8 comes with one 'd8' which however does not provide a means
|
||||
# to load extensions. Therefore, by default we use nodejs as
|
||||
# environment.
|
||||
# For testing native v8 and jsc extensions we provide our own
|
||||
# interpreter (see 'Tools/javascript').
|
||||
#
|
||||
# ----------------------------------------------------------------
|
||||
CC = @CC@
|
||||
# HACK: under OSX a g++ compiled interpreter is seg-faulting when loading module libraries
|
||||
# with 'c++' it works... probably some missing flags?
|
||||
CXX = @JSINTERPRETERCXX@
|
||||
CFLAGS = @BOOST_CPPFLAGS@ @PLATFLAGS@
|
||||
|
||||
ROOT_DIR = @ROOT_DIR@
|
||||
JSCFLAGS = @JSCFLAGS@
|
||||
JSCXXFLAGS = @JSCXXFLAGS@
|
||||
JSINCLUDES = @JSCOREINC@ @JSV8INC@
|
||||
JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
|
||||
JSLIBRARYPREFIX = @JSLIBRARYPREFIX@
|
||||
JSSO =@JSSO@
|
||||
JSLDSHARED = @JSLDSHARED@
|
||||
JSCXXSHARED = @JSCXXSHARED@
|
||||
JSV8ENABLED = @JSV8ENABLED@
|
||||
JSCENABLED = @JSCENABLED@
|
||||
|
||||
# These settings are provided by 'configure' (see '/configure.in')
|
||||
ifeq (1, $(JSV8ENABLED))
|
||||
JS_INTERPRETER_SRC_V8 = v8_shell.cxx
|
||||
JS_INTERPRETER_CXXFLAGS_V8 = -DENABLE_V8
|
||||
endif
|
||||
|
||||
ifeq (1, $(JSCENABLED))
|
||||
JS_INTERPRETER_SRC_JSC = jsc_shell.cxx
|
||||
JS_INTERPRETER_CXXFLAGS_JSC = -DENABLE_JSC
|
||||
endif
|
||||
|
||||
JS_INTERPRETER_CXXFLAGS = $(JS_INTERPRETER_CXXFLAGS_JSC) $(JS_INTERPRETER_CXXFLAGS_V8)
|
||||
JS_INTERPRETER_SRC = javascript.cxx js_shell.cxx $(JS_INTERPRETER_SRC_JSC) $(JS_INTERPRETER_SRC_V8)
|
||||
|
||||
JS_INTERPRETER_OBJS = $(JS_INTERPRETER_SRC:.cxx=.o)
|
||||
|
||||
%.o: %.cxx
|
||||
$(CXX) $(JS_INTERPRETER_CXXFLAGS) -g $(JSINCLUDES) -o $@ -c $<
|
||||
|
||||
javascript: $(JS_INTERPRETER_OBJS)
|
||||
$(CXX) -g -Wl,-search_paths_first -Wl,-headerpad_max_install_names $^ $(CFLAGS) -o javascript $(JSDYNAMICLINKING)
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f javascript
|
||||
|
|
@ -13,6 +13,11 @@ void print_usage() {
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
#if defined(JAVASCRIPT_INTERPRETER_STOP)
|
||||
std::cout << "Attach your Debugger and press any key to continue" << std::endl;
|
||||
std::cin.get();
|
||||
#endif
|
||||
|
||||
std::string scriptPath = "";
|
||||
|
||||
bool interactive = false;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#ifdef __GNUC__
|
||||
#ifdef __APPLE__
|
||||
#define LIBRARY_EXT ".dylib"
|
||||
#define LIBRARY_EXT ".bundle"
|
||||
#else
|
||||
#define LIBRARY_EXT ".so"
|
||||
#endif
|
||||
|
|
@ -52,7 +52,7 @@ std::string JSShell::LoadModule(const std::string& name, HANDLE* library) {
|
|||
|
||||
HANDLE handle = LOAD_LIBRARY(lib_name.c_str());
|
||||
if(handle == 0) {
|
||||
std::cout << "Could not load library " << lib_name << ":"
|
||||
std::cerr << "Could not load library " << lib_name << ":"
|
||||
<< std::endl << LIBRARY_ERROR() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,10 @@ bool JSCShell::InitializeEngine() {
|
|||
JSClassRef __shell_class__ = JSClassCreate(&__shell_classdef__);
|
||||
JSObjectRef __shell__ = JSObjectMake(context, __shell_class__, 0);
|
||||
bool success = JSObjectSetPrivate(__shell__, (void*) (long) this);
|
||||
if (!success) {
|
||||
std::cerr << "Could not register the shell in the Javascript context" << std::endl;
|
||||
return false;
|
||||
}
|
||||
JSStringRef shellKey = JSStringCreateWithUTF8CString("__shell__");
|
||||
JSObjectSetProperty(context, globalObject, shellKey, __shell__, kJSPropertyAttributeReadOnly, NULL);
|
||||
JSStringRelease(shellKey);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue