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
|
|
@ -683,43 +683,6 @@ JSSO =@JSSO@
|
|||
JSLDSHARED = @JSLDSHARED@
|
||||
JSCXXSHARED = @JSCXXSHARED@
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# 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').
|
||||
#
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
JS_INTERPRETER_SRC_DIR = $(ROOT_DIR)/Tools/javascript
|
||||
|
||||
# These settings are provided by 'configure' (see '/configure.in')
|
||||
ifeq (1, @JSV8ENABLED@)
|
||||
JS_INTERPRETER_SRC_V8 = $(JS_INTERPRETER_SRC_DIR)/v8_shell.cxx
|
||||
JS_INTERPRETER_CXXFLAGS_V8 = -DENABLE_V8
|
||||
endif
|
||||
|
||||
ifeq (1, @JSCENABLED@)
|
||||
JS_INTERPRETER_SRC_JSC = $(JS_INTERPRETER_SRC_DIR)/jsc_shell.cxx
|
||||
JS_INTERPRETER_CXXFLAGS_JSC = -DENABLE_JSC
|
||||
endif
|
||||
|
||||
JS_INTERPRETER_CXXFLAGS = $(JS_INTERPRETER_CXXFLAGS_JSC) $(JS_INTERPRETER_CXXFLAGS_V8)
|
||||
JS_INTERPRETER_SRC = \
|
||||
$(JS_INTERPRETER_SRC_DIR)/javascript.cxx $(JS_INTERPRETER_SRC_DIR)/js_shell.cxx $(JS_INTERPRETER_SRC_JSC) $(JS_INTERPRETER_SRC_V8)
|
||||
|
||||
# TODO: improve:
|
||||
# - exe suffix
|
||||
# - '-ldl' should come from configure
|
||||
javascript_custom_interpreter: $(JS_INTERPRETER_SRC)
|
||||
$(CXX) $(CXXFLAGS) $(JS_INTERPRETER_CXXFLAGS) $(JSINCLUDES) $(JS_INTERPRETER_SRC) -ldl $(LIBS) $(JSDYNAMICLINKING) -o $(JS_INTERPRETER_SRC_DIR)/javascript
|
||||
|
||||
SWIGJS = $(SWIG) -javascript
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
|
@ -760,8 +723,11 @@ javascript_cpp: $(SRCS) javascript_custom_interpreter
|
|||
# Running a javascript example
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
javascript_run: $(JS_INTERPRETER_SRC_DIR)/javascript
|
||||
$(JS_INTERPRETER_SRC_DIR)/javascript -$(JSENGINE) runme.js
|
||||
javascript_custom_interpreter:
|
||||
(cd $(ROOT_DIR)/Tools/javascript && $(MAKE) JSENGINE='$(JSENGINE)')
|
||||
|
||||
javascript_run: javascript_custom_interpreter
|
||||
$(ROOT_DIR)/Tools/javascript/javascript -$(JSENGINE) runme.js
|
||||
|
||||
# TODO: make node configurable and detected via ./configure
|
||||
javascript_run_node:
|
||||
|
|
@ -775,9 +741,8 @@ javascript_clean:
|
|||
rm -rf build
|
||||
rm -f *_wrap* runme
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@JSSO@
|
||||
rm -f $(JS_INTERPRETER_SRC_DIR)/javascript
|
||||
|
||||
rm -f *.@OBJEXT@ *@JSSO@ *.bundle
|
||||
(cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean)
|
||||
|
||||
|
||||
##################################################################
|
||||
|
|
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -1135,11 +1135,14 @@ else
|
|||
JSSO=".dylib"
|
||||
JSLDSHARED='$(CC) -dynamiclib'
|
||||
JSCXXSHARED='$(CXX) -dynamiclib'
|
||||
# HACK: didn't manage to get dynamic module loading working with a g++ compiled interpreter
|
||||
JSINTERPRETERCXX='c++'
|
||||
;;
|
||||
*)
|
||||
JSSO=$SO
|
||||
JSLDSHARED='$(LDSHARED)'
|
||||
JSCXXSHARED='$(CXXSHARED)'
|
||||
JSINTERPRETERCXX='$(CXX)'
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
@ -1219,6 +1222,7 @@ else
|
|||
;;
|
||||
*-*-darwin*)
|
||||
JSCOREDYNAMICLINKING="-framework JavaScriptCore"
|
||||
JSCENABLED=1
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
|
|
@ -1305,6 +1309,7 @@ AC_SUBST(JSLIBRARYPREFIX)
|
|||
AC_SUBST(JSSO)
|
||||
AC_SUBST(JSLDSHARED)
|
||||
AC_SUBST(JSCXXSHARED)
|
||||
AC_SUBST(JSINTERPRETERCXX)
|
||||
|
||||
AC_SUBST(JSCOREINC)
|
||||
AC_SUBST(JSCOREDYNAMICLINKING)
|
||||
|
|
@ -2650,6 +2655,7 @@ AC_CONFIG_FILES([ \
|
|||
Examples/test-suite/r/Makefile \
|
||||
Examples/test-suite/go/Makefile \
|
||||
Examples/test-suite/javascript/Makefile \
|
||||
Tools/javascript/Makefile \
|
||||
Lib/ocaml/swigp4.ml
|
||||
])
|
||||
AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig])
|
||||
|
|
|
|||
153
swig-v8/swig-v8.xcodeproj/project.pbxproj
Normal file
153
swig-v8/swig-v8.xcodeproj/project.pbxproj
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
A7E4F27918BDF64900ED77C7 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXLegacyTarget section */
|
||||
A7E4F28018BDF64900ED77C7 /* swig-v8 */ = {
|
||||
isa = PBXLegacyTarget;
|
||||
buildArgumentsString = "$(ACTION)";
|
||||
buildConfigurationList = A7E4F28318BDF64900ED77C7 /* Build configuration list for PBXLegacyTarget "swig-v8" */;
|
||||
buildPhases = (
|
||||
);
|
||||
buildToolPath = /usr/bin/make;
|
||||
dependencies = (
|
||||
);
|
||||
name = "swig-v8";
|
||||
passBuildSettingsInEnvironment = 1;
|
||||
productName = "swig-v8";
|
||||
};
|
||||
/* End PBXLegacyTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
A7E4F27B18BDF64900ED77C7 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0450;
|
||||
ORGANIZATIONNAME = "Oliver Buchtala";
|
||||
};
|
||||
buildConfigurationList = A7E4F27E18BDF64900ED77C7 /* Build configuration list for PBXProject "swig-v8" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = A7E4F27918BDF64900ED77C7;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
A7E4F28018BDF64900ED77C7 /* swig-v8 */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
A7E4F28118BDF64900ED77C7 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.8;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
A7E4F28218BDF64900ED77C7 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.8;
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
A7E4F28418BDF64900ED77C7 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
DEBUGGING_SYMBOLS = YES;
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
OTHER_CFLAGS = "";
|
||||
OTHER_LDFLAGS = "";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
A7E4F28518BDF64900ED77C7 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
OTHER_CFLAGS = "";
|
||||
OTHER_LDFLAGS = "";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
A7E4F27E18BDF64900ED77C7 /* Build configuration list for PBXProject "swig-v8" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
A7E4F28118BDF64900ED77C7 /* Debug */,
|
||||
A7E4F28218BDF64900ED77C7 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
A7E4F28318BDF64900ED77C7 /* Build configuration list for PBXLegacyTarget "swig-v8" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
A7E4F28418BDF64900ED77C7 /* Debug */,
|
||||
A7E4F28518BDF64900ED77C7 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = A7E4F27B18BDF64900ED77C7 /* Project object */;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue