Fix custom javascript interpreter configuration for OSX.
This commit is contained in:
parent
15f12d9b59
commit
424e3f4712
7 changed files with 42 additions and 15 deletions
|
|
@ -668,7 +668,7 @@ android_clean:
|
||||||
##### JAVASCRIPT ######
|
##### JAVASCRIPT ######
|
||||||
##################################################################
|
##################################################################
|
||||||
|
|
||||||
# Note: These targets are used from withing Makefiles in the Example directories.
|
# Note: These targets are also from within Makefiles in the Example directories.
|
||||||
# There is a common makefile, 'Examples/javascript/js_example.mk' to simplify
|
# There is a common makefile, 'Examples/javascript/js_example.mk' to simplify
|
||||||
# create a configuration for a new example.
|
# create a configuration for a new example.
|
||||||
|
|
||||||
|
|
@ -690,10 +690,10 @@ SWIGJS = $(SWIG) -javascript
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
javascript_wrapper:
|
javascript_wrapper:
|
||||||
$(SWIGJS) $(SWIGOPT) $(INTERFACEPATH)
|
$(SWIGJS) $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH)
|
||||||
|
|
||||||
javascript_wrapper_cpp: $(SRCS)
|
javascript_wrapper_cpp: $(SRCS)
|
||||||
$(SWIGJS) -c++ $(SWIGOPT) $(INTERFACEPATH)
|
$(SWIGJS) -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cxx $(INTERFACEPATH)
|
||||||
|
|
||||||
javascript_build: $(SRCS)
|
javascript_build: $(SRCS)
|
||||||
$(CC) -c $(CCSHARED) $(CFLAGS) $(JSCFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(JSINCLUDES)
|
$(CC) -c $(CCSHARED) $(CFLAGS) $(JSCFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(JSINCLUDES)
|
||||||
|
|
@ -727,7 +727,7 @@ javascript_custom_interpreter:
|
||||||
(cd $(ROOT_DIR)/Tools/javascript && $(MAKE) JSENGINE='$(JSENGINE)')
|
(cd $(ROOT_DIR)/Tools/javascript && $(MAKE) JSENGINE='$(JSENGINE)')
|
||||||
|
|
||||||
javascript_run: javascript_custom_interpreter
|
javascript_run: javascript_custom_interpreter
|
||||||
$(ROOT_DIR)/Tools/javascript/javascript -$(JSENGINE) runme.js
|
$(ROOT_DIR)/Tools/javascript/javascript -$(JSENGINE) -L $(TARGET) runme.js
|
||||||
|
|
||||||
# TODO: make node configurable and detected via ./configure
|
# TODO: make node configurable and detected via ./configure
|
||||||
javascript_run_node:
|
javascript_run_node:
|
||||||
|
|
@ -741,7 +741,7 @@ javascript_clean:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
rm -f *_wrap* runme
|
rm -f *_wrap* runme
|
||||||
rm -f core @EXTRA_CLEAN@
|
rm -f core @EXTRA_CLEAN@
|
||||||
rm -f *.@OBJEXT@ *@JSSO@ *.bundle
|
rm -f *.@OBJEXT@ *@JSSO@ *.$(SO)
|
||||||
(cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean)
|
(cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ check: build
|
||||||
else
|
else
|
||||||
|
|
||||||
check: build
|
check: build
|
||||||
$(MAKE) -f $(EXAMPLES_TOP)/Makefile JSENGINE='$(JSENGINE)' javascript_run
|
$(MAKE) -f $(EXAMPLES_TOP)/Makefile JSENGINE='$(JSENGINE)' TARGET='$(TARGET)' javascript_run
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ CC = @CC@
|
||||||
# with 'c++' it works... probably some missing flags?
|
# with 'c++' it works... probably some missing flags?
|
||||||
CXX = @JSINTERPRETERCXX@
|
CXX = @JSINTERPRETERCXX@
|
||||||
CFLAGS = @BOOST_CPPFLAGS@ @PLATFLAGS@
|
CFLAGS = @BOOST_CPPFLAGS@ @PLATFLAGS@
|
||||||
|
LINKFLAGS = @JSINTERPRETERLINKFLAGS@
|
||||||
|
|
||||||
ROOT_DIR = @ROOT_DIR@
|
ROOT_DIR = @ROOT_DIR@
|
||||||
JSCFLAGS = @JSCFLAGS@
|
JSCFLAGS = @JSCFLAGS@
|
||||||
|
|
@ -32,24 +33,24 @@ JSCENABLED = @JSCENABLED@
|
||||||
# These settings are provided by 'configure' (see '/configure.in')
|
# These settings are provided by 'configure' (see '/configure.in')
|
||||||
ifeq (1, $(JSV8ENABLED))
|
ifeq (1, $(JSV8ENABLED))
|
||||||
JS_INTERPRETER_SRC_V8 = v8_shell.cxx
|
JS_INTERPRETER_SRC_V8 = v8_shell.cxx
|
||||||
JS_INTERPRETER_CXXFLAGS_V8 = -DENABLE_V8
|
JS_INTERPRETER_ENABLE_V8 = -DENABLE_V8
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq (1, $(JSCENABLED))
|
ifeq (1, $(JSCENABLED))
|
||||||
JS_INTERPRETER_SRC_JSC = jsc_shell.cxx
|
JS_INTERPRETER_SRC_JSC = jsc_shell.cxx
|
||||||
JS_INTERPRETER_CXXFLAGS_JSC = -DENABLE_JSC
|
JS_INTERPRETER_ENABLE_JSC = -DENABLE_JSC
|
||||||
endif
|
endif
|
||||||
|
|
||||||
JS_INTERPRETER_CXXFLAGS = $(JS_INTERPRETER_CXXFLAGS_JSC) $(JS_INTERPRETER_CXXFLAGS_V8)
|
JS_INTERPRETER_DEFINES = $(JS_INTERPRETER_ENABLE_JSC) $(JS_INTERPRETER_ENABLE_V8)
|
||||||
JS_INTERPRETER_SRC = javascript.cxx js_shell.cxx $(JS_INTERPRETER_SRC_JSC) $(JS_INTERPRETER_SRC_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)
|
JS_INTERPRETER_OBJS = $(JS_INTERPRETER_SRC:.cxx=.o)
|
||||||
|
|
||||||
%.o: %.cxx
|
%.o: %.cxx
|
||||||
$(CXX) $(JS_INTERPRETER_CXXFLAGS) -g $(JSINCLUDES) -o $@ -c $<
|
$(CXX) $(JS_INTERPRETER_DEFINES) -g $(JSINCLUDES) -o $@ -c $<
|
||||||
|
|
||||||
javascript: $(JS_INTERPRETER_OBJS)
|
javascript: $(JS_INTERPRETER_OBJS)
|
||||||
$(CXX) -g -Wl,-search_paths_first -Wl,-headerpad_max_install_names $^ $(CFLAGS) -o javascript $(JSDYNAMICLINKING)
|
$(CXX) $(LINKFLAGS) $^ $(CFLAGS) -o javascript $(JSDYNAMICLINKING)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,18 @@ int main(int argc, char* argv[]) {
|
||||||
bool interactive = false;
|
bool interactive = false;
|
||||||
JSShell* shell = 0;
|
JSShell* shell = 0;
|
||||||
|
|
||||||
|
std::vector<std::string> modulePath;
|
||||||
|
modulePath.push_back(".");
|
||||||
|
|
||||||
for (int idx = 1; idx < argc; ++idx) {
|
for (int idx = 1; idx < argc; ++idx) {
|
||||||
if(strcmp(argv[idx], "-v8") == 0) {
|
if(strcmp(argv[idx], "-v8") == 0) {
|
||||||
shell = JSShell::Create(JSShell::V8);
|
shell = JSShell::Create(JSShell::V8);
|
||||||
} else if(strcmp(argv[idx], "-jsc") == 0) {
|
} else if(strcmp(argv[idx], "-jsc") == 0) {
|
||||||
shell = JSShell::Create(JSShell::JSC);
|
shell = JSShell::Create(JSShell::JSC);
|
||||||
} else if(strcmp(argv[idx], "-i") == 0) {
|
} else if(strcmp(argv[idx], "-i") == 0) {
|
||||||
interactive = true;
|
interactive = true;
|
||||||
|
} else if(strcmp(argv[idx], "-L") == 0) {
|
||||||
|
modulePath.push_back(argv[++idx]);
|
||||||
} else {
|
} else {
|
||||||
scriptPath = argv[idx];
|
scriptPath = argv[idx];
|
||||||
}
|
}
|
||||||
|
|
@ -39,6 +44,8 @@ int main(int argc, char* argv[]) {
|
||||||
shell = JSShell::Create();
|
shell = JSShell::Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shell->setModulePath(modulePath);
|
||||||
|
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
|
|
||||||
if(interactive) {
|
if(interactive) {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ std::string JSShell::LoadModule(const std::string& name, HANDLE* library) {
|
||||||
|
|
||||||
std::string lib_name;
|
std::string lib_name;
|
||||||
std::string module_name;
|
std::string module_name;
|
||||||
|
|
||||||
if (pathIdx == std::string::npos) {
|
if (pathIdx == std::string::npos) {
|
||||||
module_name = name;
|
module_name = name;
|
||||||
lib_name = std::string(name).append(LIBRARY_EXT);
|
lib_name = std::string(name).append(LIBRARY_EXT);
|
||||||
|
|
@ -50,9 +51,18 @@ std::string JSShell::LoadModule(const std::string& name, HANDLE* library) {
|
||||||
lib_name = path.append(module_name).append(LIBRARY_EXT);
|
lib_name = path.append(module_name).append(LIBRARY_EXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE handle = LOAD_LIBRARY(lib_name.c_str());
|
std::string lib_path;
|
||||||
|
HANDLE handle = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < module_path.size(); ++i) {
|
||||||
|
lib_path = module_path[i] + "/" + lib_name;
|
||||||
|
if (access( lib_path.c_str(), F_OK ) != -1) {
|
||||||
|
handle = LOAD_LIBRARY(lib_path.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(handle == 0) {
|
if(handle == 0) {
|
||||||
std::cerr << "Could not load library " << lib_name << ":"
|
std::cerr << "Could not find module " << lib_path << ":"
|
||||||
<< std::endl << LIBRARY_ERROR() << std::endl;
|
<< std::endl << LIBRARY_ERROR() << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@ public:
|
||||||
|
|
||||||
virtual bool RunShell();
|
virtual bool RunShell();
|
||||||
|
|
||||||
|
void setModulePath(const std::vector<std::string>& modulePath) {
|
||||||
|
module_path = modulePath;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual bool InitializeEngine() = 0;
|
virtual bool InitializeEngine() = 0;
|
||||||
|
|
@ -42,6 +46,7 @@ protected:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std::vector<HANDLE> loaded_modules;
|
std::vector<HANDLE> loaded_modules;
|
||||||
|
std::vector<std::string> module_path;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1137,12 +1137,14 @@ else
|
||||||
JSCXXSHARED='$(CXX) -dynamiclib'
|
JSCXXSHARED='$(CXX) -dynamiclib'
|
||||||
# HACK: didn't manage to get dynamic module loading working with a g++ compiled interpreter
|
# HACK: didn't manage to get dynamic module loading working with a g++ compiled interpreter
|
||||||
JSINTERPRETERCXX='c++'
|
JSINTERPRETERCXX='c++'
|
||||||
|
JSINTERPRETERLINKFLAGS='-g -Wl,-search_paths_first -Wl,-headerpad_max_install_names'
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
JSSO=$SO
|
JSSO=$SO
|
||||||
JSLDSHARED='$(LDSHARED)'
|
JSLDSHARED='$(LDSHARED)'
|
||||||
JSCXXSHARED='$(CXXSHARED)'
|
JSCXXSHARED='$(CXXSHARED)'
|
||||||
JSINTERPRETERCXX='$(CXX)'
|
JSINTERPRETERCXX='$(CXX)'
|
||||||
|
JSINTERPRETERLINKFLAGS='-ldl'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
@ -1309,7 +1311,9 @@ AC_SUBST(JSLIBRARYPREFIX)
|
||||||
AC_SUBST(JSSO)
|
AC_SUBST(JSSO)
|
||||||
AC_SUBST(JSLDSHARED)
|
AC_SUBST(JSLDSHARED)
|
||||||
AC_SUBST(JSCXXSHARED)
|
AC_SUBST(JSCXXSHARED)
|
||||||
|
|
||||||
AC_SUBST(JSINTERPRETERCXX)
|
AC_SUBST(JSINTERPRETERCXX)
|
||||||
|
AC_SUBST(JSINTERPRETERLINKFLAGS)
|
||||||
|
|
||||||
AC_SUBST(JSCOREINC)
|
AC_SUBST(JSCOREINC)
|
||||||
AC_SUBST(JSCOREDYNAMICLINKING)
|
AC_SUBST(JSCOREDYNAMICLINKING)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue