Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initialize repository

A basic CMake configuration is available which currently works only for Windows Visual Studio.
  • Loading branch information...
commit 70c6349e73970988f463b695c6a4c62c18e4fd81 0 parents
@oliver---- oliver---- authored
20 src/swig/CMakeLists.txt
@@ -0,0 +1,20 @@
+
+#
+# V8 Swig Module:
+#
+
+get_directory_property(SWIG_INCLUDES DIRECTORY ${SWIG_SOURCE_DIR} INCLUDE_DIRECTORIES)
+
+include_directories(${SWIG_INCLUDES})
+
+add_library(swig_v8 v8/jsv8.cxx)
+
+#
+# swig.exe
+#
+
+add_executable(swig_exe swigmain.cxx)
+
+target_link_libraries(swig_exe
+ swig_cparse swig_preprocessor swig_doh swiglib swig_modules
+ swig_v8)
210 src/swig/swigmain.cxx
@@ -0,0 +1,210 @@
+/* -----------------------------------------------------------------------------
+ * This file is part of SWIG, which is licensed as a whole under version 3
+ * (or any later version) of the GNU General Public License. Some additional
+ * terms also apply to certain portions of SWIG. The full details of the SWIG
+ * license and copyrights can be found in the LICENSE and COPYRIGHT files
+ * included with the SWIG source code as distributed by the SWIG developers
+ * and at http://www.swig.org/legal.html.
+ *
+ * swigmain.cxx
+ *
+ * Simplified Wrapper and Interface Generator (SWIG)
+ *
+ * This file is the main entry point to SWIG. It collects the command
+ * line options, registers built-in language modules, and instantiates
+ * a module for code generation. If adding new language modules
+ * to SWIG, you would modify this file.
+ * ----------------------------------------------------------------------------- */
+
+char cvsroot_swigmain_cxx[] = "$Id: swigmain.cxx 11876 2010-02-27 23:53:33Z wsfulton $";
+
+#include "swigmod.h"
+#include <ctype.h>
+
+/* Module factories. These functions are used to instantiate
+ the built-in language modules. If adding a new language
+ module to SWIG, place a similar function here. Make sure
+ the function has "C" linkage. This is required so that modules
+ can be dynamically loaded in future versions. */
+
+extern "C" {
+ Language *swig_tcl(void);
+ Language *swig_python(void);
+ Language *swig_perl5(void);
+ Language *swig_ruby(void);
+ Language *swig_guile(void);
+ Language *swig_modula3(void);
+ Language *swig_mzscheme(void);
+ Language *swig_java(void);
+ Language *swig_php(void);
+ Language *swig_php4(void);
+ Language *swig_ocaml(void);
+ Language *swig_octave(void);
+ Language *swig_pike(void);
+ Language *swig_sexp(void);
+ Language *swig_xml(void);
+ Language *swig_chicken(void);
+ Language *swig_csharp(void);
+ Language *swig_allegrocl(void);
+ Language *swig_lua(void);
+ Language *swig_clisp(void);
+ Language *swig_cffi(void);
+ Language *swig_uffi(void);
+ Language *swig_r(void);
+ Language *swig_jsv8(void);
+}
+
+struct swig_module {
+ const char *name;
+ ModuleFactory fac;
+ const char *help;
+};
+
+/* Association of command line options to language modules.
+ Place an entry for new language modules here, keeping the
+ list sorted alphabetically. */
+
+static swig_module modules[] = {
+ {"-allegrocl", swig_allegrocl, "ALLEGROCL"},
+ {"-chicken", swig_chicken, "CHICKEN"},
+ {"-clisp", swig_clisp, "CLISP"},
+ {"-cffi", swig_cffi, "CFFI"},
+ {"-csharp", swig_csharp, "C#"},
+ {"-guile", swig_guile, "Guile"},
+ {"-java", swig_java, "Java"},
+ {"-lua", swig_lua, "Lua"},
+ {"-modula3", swig_modula3, "Modula 3"},
+ {"-mzscheme", swig_mzscheme, "Mzscheme"},
+ {"-ocaml", swig_ocaml, "Ocaml"},
+ {"-octave", swig_octave, "Octave"},
+ {"-perl", swig_perl5, "Perl"},
+ {"-perl5", swig_perl5, 0},
+ {"-php", swig_php, "PHP"},
+ {"-php4", swig_php4, 0},
+ {"-php5", swig_php, 0},
+ {"-pike", swig_pike, "Pike"},
+ {"-python", swig_python, "Python"},
+ {"-r", swig_r, "R (aka GNU S)"},
+ {"-ruby", swig_ruby, "Ruby"},
+ {"-sexp", swig_sexp, "Lisp S-Expressions"},
+ {"-tcl", swig_tcl, "Tcl"},
+ {"-tcl8", swig_tcl, 0},
+ {"-uffi", swig_uffi, "Common Lisp / UFFI"},
+ {"-xml", swig_xml, "XML"},
+ {"-jsv8", swig_jsv8, "JavaScript (V8)"},
+ {NULL, NULL, NULL}
+};
+
+#ifdef MACSWIG
+#include <console.h>
+#include <SIOUX.h>
+#endif
+
+#ifndef SWIG_LANG
+#define SWIG_LANG "-python"
+#endif
+
+//-----------------------------------------------------------------
+// main()
+//
+// Main program. Initializes the files and starts the parser.
+//-----------------------------------------------------------------
+
+void SWIG_merge_envopt(const char *env, int oargc, char *oargv[], int *nargc, char ***nargv) {
+ if (!env) {
+ *nargc = oargc;
+ *nargv = oargv;
+ return;
+ }
+
+ int argc = 1;
+ int arge = oargc + 1024;
+ char **argv = (char **) malloc(sizeof(char *) * (arge));
+ char *buffer = (char *) malloc(2048);
+ char *b = buffer;
+ char *be = b + 1023;
+ const char *c = env;
+ while ((b != be) && *c && (argc < arge)) {
+ while (isspace(*c) && *c)
+ ++c;
+ if (*c) {
+ argv[argc] = b;
+ ++argc;
+ }
+ while ((b != be) && *c && !isspace(*c)) {
+ *(b++) = *(c++);
+ }
+ *b++ = 0;
+ }
+
+ argv[0] = oargv[0];
+ for (int i = 1; (i < oargc) && (argc < arge); ++i, ++argc) {
+ argv[argc] = oargv[i];
+ }
+
+ *nargc = argc;
+ *nargv = argv;
+}
+
+int main(int margc, char **margv) {
+
+ int i;
+ Language *dl = 0;
+ ModuleFactory fac = 0;
+
+ int argc;
+ char **argv;
+
+ SWIG_merge_envopt(getenv("SWIG_FEATURES"), margc, margv, &argc, &argv);
+
+#ifdef MACSWIG
+ SIOUXSettings.asktosaveonclose = false;
+ argc = ccommand(&argv);
+#endif
+
+ /* Register built-in modules */
+ for (i = 0; modules[i].name; i++) {
+ Swig_register_module(modules[i].name, modules[i].fac);
+ }
+
+ Swig_init_args(argc, argv);
+
+ /* Get options */
+ for (i = 1; i < argc; i++) {
+ if (argv[i]) {
+ fac = Swig_find_module(argv[i]);
+ if (fac) {
+ dl = (fac) ();
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i], "-nolang") == 0) {
+ dl = new Language;
+ Swig_mark_arg(i);
+ } else if ((strcmp(argv[i], "-dnone") == 0) ||
+ (strcmp(argv[i], "-dhtml") == 0) ||
+ (strcmp(argv[i], "-dlatex") == 0) || (strcmp(argv[i], "-dascii") == 0) || (strcmp(argv[i], "-stat") == 0)) {
+ Printf(stderr, "swig: Warning. %s option deprecated.\n", argv[i]);
+ Swig_mark_arg(i);
+ } else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) {
+ if (strcmp(argv[i], "--help") == 0)
+ strcpy(argv[i], "-help");
+ Printf(stdout, "Target Language Options\n");
+ for (int j = 0; modules[j].name; j++) {
+ if (modules[j].help) {
+ Printf(stdout, " %-15s - Generate %s wrappers\n", modules[j].name, modules[j].help);
+ }
+ }
+ // Swig_mark_arg not called as the general -help options also need to be displayed later on
+ }
+ }
+ }
+ if (!dl) {
+ fac = Swig_find_module(SWIG_LANG);
+ if (fac) {
+ dl = (fac) ();
+ }
+ }
+
+ int res = SWIG_main(argc, argv, dl);
+
+ return res;
+}
874 src/swig/v8/jsv8.cxx
@@ -0,0 +1,874 @@
+/* -----------------------------------------------------------------------------
+* This file is part of SWIG, which is licensed as a whole under version 3
+* (or any later version) of the GNU General Public License. Some additional
+* terms also apply to certain portions of SWIG. The full details of the SWIG
+* license and copyrights can be found in the LICENSE and COPYRIGHT files
+* included with the SWIG source code as distributed by the SWIG developers
+* and at http://www.swig.org/legal.html.
+*
+* jsv8.cxx
+*
+* JavaScript (V8) language module for SWIG.
+* ----------------------------------------------------------------------------- */
+
+char cvsroot_jsv8_cxx[] = "$Id: jsv8.cxx xxxxx xxxx-xx-xx xx:xx:xxx xxx $";
+
+#include "swigmod.h"
+#include "cparse.h"
+static int treduce = SWIG_cparse_template_reduce(0);
+
+#include <ctype.h>
+#include <string.h>
+#include <limits.h> /* for INT_MAX */
+
+#include <iostream>
+#include <conio.h>
+
+static const char *usage = "\
+ JavaScript Options (available with -jsv8)\n\
+ ";
+
+int JSV8_DOH_EndsWith(String* s, String* suffix) {
+ if (s == 0 || suffix == 0)
+ return 0;
+
+ int s_len = Len(s);
+ int suffix_len = Len(suffix);
+
+ if(s_len < suffix_len)
+ return 0;
+
+ char* s_str = Char(s);
+ char* s_suffix = Char(suffix);
+
+ s_str += s_len - suffix_len;
+ return (strcmp(s_str, s_suffix) == 0);
+}
+
+#define EndsWith JSV8_DOH_EndsWith
+
+void JSV8_GetClassTemplStr(Node* classNode, String* out) {
+ String* clazzName = Getattr(classNode, "name");
+ Printv(out, clazzName, "_class_templ", NIL);
+}
+#define GetClassTemplStr JSV8_GetClassTemplStr
+
+class JavaScriptV8: public Language {
+private:
+
+ String *module;
+ String *modvar;
+ String *feature;
+ String *prefix;
+ int current;
+
+ File *f_directors;
+ File *f_directors_h;
+ File *f_directors_helpers;
+ File *f_begin;
+ File *f_runtime;
+ File *f_runtime_h;
+ File *f_header;
+ File *f_wrappers;
+ File *f_init;
+ File *f_initbeforefunc;
+
+ // Wrap modes
+ enum WrapperMode {
+ NO_CPP,
+ MEMBER_FUNC,
+ CONSTRUCTOR,
+ CONSTRUCTOR_ALLOCATE,
+ CONSTRUCTOR_INITIALIZE,
+ DESTRUCTOR,
+ MEMBER_VAR,
+ CLASS_CONST,
+ STATIC_FUNC,
+ STATIC_VAR
+ };
+
+public:
+
+ /* ---------------------------------------------------------------------
+ * JavaScriptV8()
+ *
+ * Initialize member data
+ * --------------------------------------------------------------------- */
+
+ JavaScriptV8() {
+ module = 0;
+ modvar = 0;
+ feature = 0;
+ prefix = 0;
+ current = NO_CPP;
+ f_begin = 0;
+ f_runtime = 0;
+ f_header = 0;
+ f_wrappers = 0;
+ f_init = 0;
+ f_initbeforefunc = 0;
+ director_multiple_inheritance = 0;
+ director_language = 0;
+ }
+
+ /* ---------------------------------------------------------------------
+ * validate_identifier()
+ *
+ * Is this a valid identifier in the scripting language?
+ * js method names can include any combination of letters, numbers
+ * and underscores.
+ *
+ * --------------------------------------------------------------------- */
+
+ virtual int validate_identifier(String *s) {
+ char *c = Char(s);
+ while (*c) {
+ if (!( isalnum(*c) || (*c == '_') ))
+ return 0;
+ c++;
+ }
+ return 1;
+ }
+
+ /* ---------------------------------------------------------------------
+ * validate_const_name(char *name)
+ *
+ * Validate constant name.
+ * --------------------------------------------------------------------- */
+
+ char *validate_const_name(char *name, const char *reason) {
+ if (!name || name[0] == '\0')
+ return name;
+
+ if (isupper(name[0]))
+ return name;
+
+ if (islower(name[0])) {
+ name[0] = (char)toupper(name[0]);
+ Swig_warning(WARN_RUBY_WRONG_NAME, input_file, line_number, "Wrong %s name (corrected to `%s')\n", reason, name);
+ return name;
+ }
+
+ Swig_warning(WARN_RUBY_WRONG_NAME, input_file, line_number, "Wrong %s name %s\n", reason, name);
+
+ return name;
+ }
+
+
+ /* ---------------------------------------------------------------------
+ * top()
+ * TODO(019): set a better name wrapper attribute, s. Java
+ * --------------------------------------------------------------------- */
+
+ virtual int top(Node *n) {
+
+ /**
+ * See if any Ruby module options have been specified as options
+ * to the %module directive.
+ */
+ Node *swigModule = Getattr(n, "module");
+
+ /* Initialize all of the output files */
+ String *outfile = Getattr(n, "outfile");
+ String *outfile_h = Getattr(n, "outfile_h");
+
+ if (!outfile) {
+ Printf(stderr, "Unable to determine outfile\n");
+ SWIG_exit(EXIT_FAILURE);
+ }
+
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
+ FileErrorDisplay(outfile);
+ SWIG_exit(EXIT_FAILURE);
+ }
+
+ f_runtime = NewString("");
+ f_init = NewString("");
+ f_header = NewString("");
+ f_wrappers = NewString("");
+ f_directors_h = NewString("");
+ f_directors = NewString("");
+ f_directors_helpers = NewString("");
+ f_initbeforefunc = NewString("");
+
+ /* Register file targets with the SWIG file handler */
+ Swig_register_filebyname("header", f_header);
+ Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
+ Swig_register_filebyname("runtime", f_runtime);
+ Swig_register_filebyname("init", f_init);
+ Swig_register_filebyname("director", f_directors);
+ Swig_register_filebyname("director_h", f_directors_h);
+ Swig_register_filebyname("director_helpers", f_directors_helpers);
+ Swig_register_filebyname("initbeforefunc", f_initbeforefunc);
+
+ modvar = 0;
+ current = NO_CPP;
+
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGJSV8\n");
+ Printf(f_runtime, "\n");
+
+ /* Set module name */
+ module = (Char(Getattr(n, "name")));
+ // TODO(20): is this redundant?
+ feature = (Char(Getattr(n, "name")));
+
+ /* Start generating the initialization function */
+ Printf(f_init, "\n", "#ifdef __cplusplus\n", "extern \"C\"\n", "#endif\n");
+ Printv(f_init, "SWIGEXPORT void Init_", feature, "(void) {\n\n", NIL);
+
+ Printf(f_init, "SWIG_InitializeModule(0);\n");
+
+ Printf(f_init, "v8::Local<v8::Object> global = v8::Context::GetCurrent()->Global();\n\n", NIL);
+
+ Language::top(n);
+
+ /* Finish off our init function */
+ Printf(f_init, "}\n");
+
+ SwigType_emit_type_table(f_runtime, f_wrappers);
+
+ /* Close all of the files */
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Dump(f_initbeforefunc, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
+
+ Delete(f_header);
+ Delete(f_wrappers);
+ Delete(f_init);
+ Delete(f_initbeforefunc);
+ Close(f_begin);
+ Delete(f_runtime);
+ Delete(f_begin);
+
+ return SWIG_OK;
+ }
+
+ /* -----------------------------------------------------------------------------
+ * importDirective()
+ * ----------------------------------------------------------------------------- */
+ virtual int importDirective(Node *n) {
+ return Language::importDirective(n);
+ }
+
+ /* --------------------------------------------------------------------------
+ * nativeWrapper()
+ * -------------------------------------------------------------------------- */
+ //TODO(012): what is this native thingie?
+ virtual int nativeWrapper(Node *n) {
+ return Language::nativeWrapper(n);
+ }
+
+ /* ---------------------------------------------------------------------
+ * applyInputTypemap()
+ *
+ * Look up the appropriate "in" typemap for this parameter (p),
+ * substitute the correct strings for the $target and $input typemap
+ * parameters, and dump the resulting code to the wrapper file.
+ * --------------------------------------------------------------------- */
+
+ void applyInputTypemap(Parm *p, String *ln, String *source, Wrapper *f, String *symname) {
+ String *tm;
+ SwigType *pt = Getattr(p, "type");
+ if ((tm = Getattr(p, "tmap:in"))) {
+ Replaceall(tm, "$target", ln);
+ Replaceall(tm, "$source", source);
+ Replaceall(tm, "$input", source);
+ Replaceall(tm, "$symname", symname);
+
+ if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) {
+ Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN");
+ } else {
+ Replaceall(tm, "$disown", "0");
+ }
+
+ Setattr(p, "emit:input", Copy(source));
+ Printf(f->code, "%s\n", tm);
+ } else {
+ Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
+ }
+ }
+
+ Parm *skipIgnoredArgs(Parm *p) {
+ while (checkAttribute(p, "tmap:in:numinputs", "0")) {
+ p = Getattr(p, "tmap:in:next");
+ }
+ return p;
+ }
+
+ ///* ---------------------------------------------------------------------
+ //* insertCleanupCode(ParmList *l, String *cleanup)
+ //*
+ //* Checks each of the parameters in the parameter list for a "freearg"
+ //* typemap and (if it finds one) inserts the typemapping code into
+ //* the function wrapper.
+ //* --------------------------------------------------------------------- */
+
+ //void insertCleanupCode(ParmList *l, String *cleanup) {
+ // String *tm;
+ // for (Parm *p = l; p;) {
+ // if ((tm = Getattr(p, "tmap:freearg"))) {
+ // if (Len(tm) != 0) {
+ // Replaceall(tm, "$source", Getattr(p, "lname"));
+ // Printv(cleanup, tm, "\n", NIL);
+ // }
+ // p = Getattr(p, "tmap:freearg:next");
+ // } else {
+ // p = nextSibling(p);
+ // }
+ // }
+ //}
+
+ void insertFunctionDefinition(Node *node, Wrapper* wrapper) {
+ String *iname = Getattr(node, "sym:name");
+ String *wname = Swig_name_wrapper(iname);
+
+ String *nodeType = Getattr(node, "nodeType");
+
+ if(current == MEMBER_VAR) {
+ if(EndsWith(wname, "_get")) {
+ Printv(wrapper->def, "v8::Handle<v8::Value> ", wname, "(v8::Local<v8::String> property, const v8::AccessorInfo& info) {\n", NIL);
+ } else {
+ Printv(wrapper->def, "void ", wname, "(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {\n", NIL);
+ }
+ } else {
+ Printv(wrapper->def, "v8::Handle<v8::Value> ", wname, "(const v8::Arguments& args) {\n", NIL);
+ }
+ Printv(wrapper->def, tab4, "v8::HandleScope scope;\n", NIL);
+ }
+
+ void insertInputParamMarshalling(Node* n, Wrapper* wrapper) {
+ ParmList *parms = Getattr(n,"parms");
+ Parm *p;
+
+ p = parms;
+ for (int i=0; p; p = nextSibling(p), i++) {
+ String *name = Getattr(p,"name");
+ String *value = Getattr(p,"value");
+ String *type = Getattr(p,"type");
+
+ String *lvalue = NewString("");
+ String *rvalue = NewString("");
+
+ Printf(lvalue, "arg%d", i+1, NIL);
+
+ if( Strcmp(name, "self") == 0 ) {
+ SwigType *selfType = Copy(type);
+ SwigType_del_pointer(selfType);
+
+ if( current == MEMBER_VAR ) {
+ Printv(rvalue, "v8_unwrap_this_pointer<", selfType, ">(info.Holder())", NIL);
+ } else {
+ Printv(rvalue, "v8_unwrap_this_pointer<", selfType, ">(args.Holder())", NIL);
+ }
+ Printv(wrapper->locals, lvalue, " = ", rvalue, ";\n", NIL);
+ } else {
+ if( current == MEMBER_VAR ) {
+ Printf(rvalue, "value");
+ } else if (current == CONSTRUCTOR) {
+ Printf(rvalue, "args[%d]", i);
+ } else {
+ Printf(rvalue, "args[%d]", i-1);
+ }
+ applyInputTypemap(p, lvalue, rvalue, wrapper, Getattr(n, "name"));
+ }
+
+ Delete(lvalue);
+ Delete(rvalue);
+ }
+ }
+
+ void insertFunctionBody(Node *n, Wrapper* wrapper) {
+ String *iname = Getattr(n, "sym:name");
+ String *nodeType = Getattr(n, "nodeType");
+ String *type = Getattr(n, "type");
+ ParmList *parms = Getattr(n,"parms");
+
+ if (current == CONSTRUCTOR_INITIALIZE) {
+ Printf(wrapper->code, "self->SetInternalField(0, v8::External::New(result);\n");
+ }
+ }
+
+ void insertFunctionReturn(Node *n, Wrapper* f, String* actioncode) {
+
+ int is_memberset = EndsWith(Getattr(n, "sym:name"), "_set");
+ ParmList *parms = Getattr(n,"parms");
+
+ // failing can happen on marshalling
+ int nparams = ParmList_len(parms);
+ int can_fail = ((current == MEMBER_VAR || current == MEMBER_FUNC) && nparams>1)
+ || (current == CONSTRUCTOR && nparams>0);
+
+ if(!is_memberset) {
+ /* Return the function value */
+ String* tm = NewString("");
+ if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
+ Replaceall(tm, "$self", "obj0");
+ Replaceall(tm, "$source", "result");
+ Replaceall(tm, "$target", "resultobj");
+ Replaceall(tm, "$result", "resultobj");
+ if (GetFlag(n, "feature:new")) {
+ Replaceall(tm, "$owner", "SWIG_POINTER_OWN");
+ } else {
+ Replaceall(tm, "$owner", "0");
+ }
+ }
+ Printf(f->code, "%s\n", tm);
+ Delete(tm);
+
+ Printv(f->code, "return scope.Close(resultobj);\n", NIL);
+
+ // insert a 'fail'
+ if(can_fail) {
+ Printf(f->code, "fail:\n");
+ Printf(f->code, "return v8::Undefined();\n");
+ }
+ Printf(f->code, "}\n");
+ } else {
+ if(can_fail) {
+ Printf(f->code, "fail:\n");
+ }
+ Printv(f->code, "return;\n", "}\n", NIL);
+ }
+ }
+
+ /* ---------------------------------------------------------------------
+ * functionWrapper()
+ *
+ * Create a function declaration and register it with the interpreter.
+ * --------------------------------------------------------------------- */
+
+ virtual int functionWrapper(Node *n) {
+
+ String *name = Getattr(n, "name");
+ String *iname = Getattr(n, "sym:name");
+ SwigType *type = Getattr(n,"type");
+ ParmList *parms = Getattr(n,"parms");
+ Setattr(n, "wrap:name", iname);
+
+ int numarg = emit_num_arguments(parms);
+ int numreq = emit_num_required(parms);
+ int varargs = emit_isvarargs(parms);
+
+ int is_memberset = EndsWith(Getattr(n, "sym:name"), "_set");
+
+ Wrapper *wrapper = NewWrapper();
+
+ /* create the functions wrappered name */
+ String *wname = Swig_name_wrapper(iname);
+ String *nodeType = Getattr(n, "nodeType");
+
+ // Function header
+ // ----------------
+ insertFunctionDefinition(n, wrapper);
+
+ // Input parameters
+ // ------------------
+ emit_parameter_variables(parms, wrapper);
+ emit_attach_parmmaps(parms, wrapper);
+ /* Insert argument output code */
+ String *outarg = NewString("");
+ String* tm;
+ for (Parm* p = parms; p;) {
+ if ((tm = Getattr(p, "tmap:argout"))) {
+ Replaceall(tm, "$source", Getattr(p, "lname"));
+ Replaceall(tm, "$target", "resultobj");
+ Replaceall(tm, "$arg", Getattr(p, "emit:input"));
+ Replaceall(tm, "$input", Getattr(p, "emit:input"));
+ Printv(outarg, "//TEST", tm, "\n", NIL);
+ p = Getattr(p, "tmap:argout:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
+ emit_return_variable(n, type, wrapper);
+ Append(wrapper->code, outarg);
+ Delete(outarg);
+
+
+
+ // Extra local vars
+ // ------------------
+ insertInputParamMarshalling(n, wrapper);
+
+ if(! is_memberset ) {
+ Wrapper_add_local(wrapper, "resultobj", "VALUE resultobj");
+ }
+
+ // Function body
+ // ---------------
+
+ String *actioncode = emit_action(n);
+ insertFunctionBody(n, wrapper);
+
+ // Return value
+ // -------------
+ insertFunctionReturn(n, wrapper, actioncode);
+ //Note: don't call this it seems that this is not allowed but done by Swig_typemap_lookup_out???
+ //Append(wrapper->code, actioncode);
+
+ /* Dump the function out */
+ Wrapper_print(wrapper, f_wrappers);
+
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------
+ * variableWrapper()
+ * --------------------------------------------------------------------- */
+
+ virtual int variableWrapper(Node *n) {
+ char *iname = GetChar(n, "sym:name");
+ String *getname = Swig_name_get(NSPACE_TODO, iname);
+ String *getfname = Swig_name_wrapper(getname);
+ Setattr(n, "wrap:name", getfname);
+ return SWIG_OK;
+ }
+
+
+ /* ---------------------------------------------------------------------
+ * constantWrapper()
+ * --------------------------------------------------------------------- */
+
+ virtual int constantWrapper(Node *n) {
+ return Language::constantWrapper(n);
+ }
+
+ /* -----------------------------------------------------------------------------
+ * classDeclaration()
+ *
+ * Records information about classes---even classes that might be defined in
+ * other modules referenced by %import.
+ * ----------------------------------------------------------------------------- */
+
+ virtual int classDeclaration(Node *n) {
+ return Language::classDeclaration(n);
+ }
+
+ /* ----------------------------------------------------------------------
+ * classHandler()
+ * ---------------------------------------------------------------------- */
+
+ virtual int classHandler(Node *n) {
+
+ String *clazz_init = NewString("");
+ String *name = Getattr(n, "name");
+ String *abstract = Getattr(n, "abstract");
+ char* abstract_ = Char(abstract);
+
+ String* clazz_templ = NewString("");
+ GetClassTemplStr(n, clazz_templ);
+
+ char* define_class_templ = "v8::Persistent<v8::FunctionTemplate> %s;\n";
+ char* create_class_templ = "\n%s = v8_create_class_template(\"%s\");\n";
+ char* set_client_data = "SWIGTYPE_p_%s->clientdata = reinterpret_cast<void*>(&%s);\n";
+
+ Printf(f_wrappers, define_class_templ, clazz_templ);
+ Printf(clazz_init, create_class_templ, clazz_templ, name);
+ Printf(clazz_init, set_client_data, name, clazz_templ);
+
+
+ Append(f_init, clazz_init);
+
+ Language::classHandler(n);
+
+ char* add_class_symbol = "global->Set(v8::String::NewSymbol(\"%s\"), %s->GetFunction());\n";
+ Printf(f_init, add_class_symbol, name, clazz_templ);
+
+ Delete(clazz_templ);
+ Delete(clazz_init);
+
+ return SWIG_OK;
+ }
+
+ /* ----------------------------------------------------------------------
+ * memberfunctionHandler()
+ *
+ * Method for adding C++ member function
+ *
+ * By default, we're going to create a function of the form :
+ *
+ * Foo_bar(this,args)
+ *
+ * Where Foo is the classname, bar is the member name and the this pointer
+ * is explicitly attached to the beginning.
+ *
+ * The renaming only applies to the member function part, not the full
+ * classname.
+ *
+ * --------------------------------------------------------------------- */
+
+ virtual int memberfunctionHandler(Node *n) {
+ current = MEMBER_FUNC;
+ Language::memberfunctionHandler(n);
+
+ Node* clazz = parentNode(n);
+ String* clazzName = Getattr(clazz, "name");
+ String* name = Getattr(n, "name");
+ String* iname = Getattr(n, "sym:name");
+ String* type = Getattr(n, "type");
+
+ String* memFuncInit = NewString("");
+ String* clazz_templ = NewString("");
+ GetClassTemplStr(clazz, clazz_templ);
+
+ String* wrapper_name = NewString("");
+ char* method_wrapper = "_wrap_%s_%s";
+ Printf(wrapper_name, method_wrapper, clazzName, name);
+
+ char* add_class_method = "v8_add_class_method(%s, \"%s\", %s);\n";
+
+ Printf(memFuncInit, add_class_method, clazz_templ, name, wrapper_name);
+
+ Append(f_init, memFuncInit);
+
+ Delete(memFuncInit);
+ Delete(clazz_templ);
+ Delete(wrapper_name);
+
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------
+ * constructorHandler()
+ *
+ * Method for adding C++ member constructor
+ * -------------------------------------------------------------------- */
+
+ virtual int constructorHandler(Node *n) {
+ current = CONSTRUCTOR;
+
+ Language::constructorHandler(n);
+
+ Node* clazz = parentNode(n);
+ String* clazzName = Getattr(clazz, "name");
+ String* name = Getattr(n, "name");
+ String* iname = Getattr(n, "sym:name");
+
+ String* ctorInit = NewString("");
+
+ String* class_templ = NewString("");
+ GetClassTemplStr(clazz, class_templ);
+
+ char* alloc_func_str = "_wrap_new_%s";
+ String* alloc_func = NewString("");
+ Printf(alloc_func, alloc_func_str, clazzName);
+
+ char* set_ctor_handler = "v8_set_allocate_handler(%s, %s);\n";
+ Printf(ctorInit, set_ctor_handler, class_templ, alloc_func);
+
+ Delete(class_templ);
+ Delete(alloc_func);
+
+ Append(f_init, ctorInit);
+ Delete(ctorInit);
+
+ return SWIG_OK;
+ }
+
+ virtual int copyconstructorHandler(Node *n) {
+ return Language::copyconstructorHandler(n);
+ }
+
+ /* ---------------------------------------------------------------------
+ * destructorHandler()
+ * -------------------------------------------------------------------- */
+
+ virtual int destructorHandler(Node *n) {
+ current = DESTRUCTOR;
+ return Language::destructorHandler(n);
+ }
+
+ /* ---------------------------------------------------------------------
+ * membervariableHandler()
+ *
+ * This creates a pair of functions to set/get the variable of a member.
+ * -------------------------------------------------------------------- */
+
+ virtual int membervariableHandler(Node *n) {
+ current = MEMBER_VAR;
+
+ String* varFuncInit = NewString("");
+
+ Node* clazz = parentNode(n);
+ String* clazzName = Getattr(clazz, "name");
+ String* varName = Getattr(n, "name");
+ String* iName = Getattr(n, "sym:name");
+ String* wName = Swig_name_wrapper(iName);
+
+ String* v8_class_template = NewString("");
+ String* wName_get = NewString("");
+ String* wName_set = NewString("");
+
+ //TODO(010): use the same method that is used to get the wrapper name for the
+ // getter and setter function handler
+ char* swig_getter = "_wrap_%s_%s_get";
+ char* swig_setter = "_wrap_%s_%s_set";
+ Printf(wName_get, swig_getter, clazzName, varName);
+ Printf(wName_set, swig_setter, clazzName, varName);
+
+ // TODO(011): handle read_only by adding a throwing setter function
+ char* v8_add_gettersetter = "v8_add_class_member_getters_setters(%s, \"%s\", %s, %s);\n";
+ GetClassTemplStr(clazz, v8_class_template);
+ Printf(varFuncInit, v8_add_gettersetter, v8_class_template, varName, wName_get, wName_set);
+
+ Delete(v8_class_template);
+ Delete(wName_get);
+ Delete(wName_set);
+
+ char* varFuncInit_ = Char(varFuncInit);
+
+ Append(f_init, varFuncInit);
+ Delete(varFuncInit);
+
+ return Language::membervariableHandler(n);
+ }
+
+ /* -----------------------------------------------------------------------
+ * staticmemberfunctionHandler()
+ *
+ * Wrap a static C++ function
+ * ---------------------------------------------------------------------- */
+
+ virtual int staticmemberfunctionHandler(Node *n) {
+ return Language::staticmemberfunctionHandler(n);
+ }
+
+ /* ----------------------------------------------------------------------
+ * memberconstantHandler()
+ *
+ * Create a C++ constant
+ * --------------------------------------------------------------------- */
+
+ virtual int memberconstantHandler(Node *n) {
+ return Language::memberconstantHandler(n);
+ }
+
+ /* ---------------------------------------------------------------------
+ * staticmembervariableHandler()
+ * --------------------------------------------------------------------- */
+
+ virtual int staticmembervariableHandler(Node *n) {
+ return Language::staticmembervariableHandler(n);
+ }
+
+
+ /* ------------------------------------------------------------
+ * director support
+ * ------------------------------------------------------------ */
+ virtual int classDirector(Node *n) {
+ return Language::classDirector(n);
+ }
+
+ virtual int classDirectorInit(Node *n) {
+ return Language::classDirectorInit(n);
+ }
+
+ virtual int classDirectorEnd(Node *n) {
+ return Language::classDirectorEnd(n);
+ }
+
+ virtual int classDirectorConstructor(Node *n) {
+ return Language::classDirectorConstructor(n);
+ }
+
+ virtual int classDirectorDefaultConstructor(Node *n) {
+ return Language::classDirectorDefaultConstructor(n);
+ }
+
+ virtual int classDirectorMethod(Node *n, Node *parent, String *super) {
+ return Language::classDirectorMethod(n, parent, super);
+ }
+
+ virtual int classDirectorConstructors(Node *n) {
+ return Language::classDirectorConstructors(n);
+ }
+
+ virtual int classDirectorMethods(Node *n) {
+ return Language::classDirectorMethods(n);
+ }
+
+ virtual int classDirectorDisown(Node *n) {
+ return Language::classDirectorDisown(n);
+ }
+
+ String *runtimeCode() {
+
+ String *s = NewString("");
+ String *shead = Swig_include_sys("jsv8head.swg");
+ if (!shead) {
+ Printf(stderr, "*** Unable to open 'jsv8head.swg'\n");
+ } else {
+ Append(s, shead);
+ Delete(shead);
+ }
+ // TODO(016) implement jsv8errors.swg
+ //String *serrors = Swig_include_sys("jsv8errors.swg");
+ //if (!serrors) {
+ // Printf(stderr, "*** Unable to open 'jsv8errors.swg'\n");
+ //} else {
+ // Append(s, serrors);
+ // Delete(serrors);
+ //}
+ String *sapi = Swig_include_sys("jsv8api.swg");
+ if (!sapi) {
+ Printf(stderr, "*** Unable to open 'jsv8api.swg'\n");
+ } else {
+ Append(s, sapi);
+ Delete(sapi);
+ }
+ String *srun = Swig_include_sys("jsv8run.swg");
+ if (!srun) {
+ Printf(stderr, "*** Unable to open 'jsv8run.swg'\n");
+ } else {
+ Append(s, srun);
+ Delete(srun);
+ }
+ return s;
+ }
+
+ String *defaultExternalRuntimeFilename() {
+ return NewString("swigjsv8run.h");
+ }
+
+ /* ---------------------------------------------------------------------
+ * main()
+ *
+ * Parse command line options and initializes variables.
+ * --------------------------------------------------------------------- */
+
+ virtual void main(int argc, char *argv[]) {
+
+ /* Set location of SWIG library */
+ SWIG_library_directory("jsv8");
+
+ /* Turn on cppcast mode */
+ Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
+
+ /* Add a symbol to the parser for conditional compilation */
+ Preprocessor_define("SWIGJSV8 1", 0);
+
+ SWIG_typemap_lang("jsv8");
+ SWIG_config_file("jsv8.swg");
+
+ allow_overloading();
+ }
+
+}; /* class JSV8 */
+
+/* -----------------------------------------------------------------------------
+* swig_jsv8() - Instantiate module
+* ----------------------------------------------------------------------------- */
+
+static Language *new_swig_jsv8() {
+ return new JavaScriptV8();
+}
+extern "C" Language *swig_jsv8(void) {
+ return new_swig_jsv8();
+}
33 third_party/CMakeLists.txt
@@ -0,0 +1,33 @@
+#
+# FireBreath
+# ==========
+#
+
+add_subdirectory(FireBreath)
+
+set_target_properties(NpapiCore PluginCore ScriptingCore ActiveXCore
+ PROPERTIES FOLDER third_party/FireBreath
+)
+set_target_properties(UnitTest++ UnitTest_ActiveXCore UnitTest_ScriptingCore NPAPIHost
+ PROPERTIES FOLDER third_party/FireBreath/UnitTests
+)
+set_target_properties(boost_thread boost_system
+ PROPERTIES FOLDER third_party/boost
+)
+
+#
+# Swig
+# ==========
+#
+
+add_subdirectory(swig)
+set_target_properties(swig_cparse swig_preprocessor swig_doh swiglib swig_modules
+ PROPERTIES FOLDER third_party/swig
+)
+
+#
+# v8
+# ==
+#
+
+add_subdirectory(v8)
124 third_party/swig/CMakeLists.txt
@@ -0,0 +1,124 @@
+
+if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/swig")
+ message("Creating swig folder.")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/swig"
+ )
+endif()
+
+if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/swig/.svn")
+
+ if( ${SVN_EXECUTABLE-NOTFOUND} )
+ message(FATAL_ERROR "svn is necessary to checkout" )
+ endif()
+
+ set(SWIG_SVN_COMMAND
+ ${Subversion_SVN_EXECUTABLE}
+ co https://swig.svn.sourceforge.net/svnroot/swig/tags/rel-2.0.2
+ ${CMAKE_CURRENT_SOURCE_DIR}/swig
+ )
+
+ message("Checking out swig 2.0.2: ${SWIG_SVN_COMMAND}")
+ execute_process(
+ COMMAND ${SWIG_SVN_COMMAND}
+ )
+
+endif()
+
+
+set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/swig/Source/CParse"
+ "${CMAKE_CURRENT_SOURCE_DIR}/swig/Source/Include"
+ "${CMAKE_CURRENT_SOURCE_DIR}/swig/Source/DOH"
+ "${CMAKE_CURRENT_SOURCE_DIR}/swig/Source/Swig"
+ "${CMAKE_CURRENT_SOURCE_DIR}/swig/Source/Preprocessor"
+ "${CMAKE_CURRENT_SOURCE_DIR}/swig/Source/Modules"
+)
+
+# include_directories(
+# "swig/Source/CParse"
+# "swig/Source/Include"
+# "swig/Source/DOH"
+# "swig/Source/Swig"
+# "swig/Source/Preprocessor"
+# "swig/Source/Modules")
+
+# add the command to generate the source code
+add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/swig/Source/CParse/parser.c
+ COMMAND bison -o ${CMAKE_CURRENT_SOURCE_DIR}/swig/Source/CParse/parser.c --defines=${CMAKE_CURRENT_SOURCE_DIR}/swig/Source/CParse/parser.h ${CMAKE_CURRENT_SOURCE_DIR}/swig/Source/CParse/parser.y
+ )
+
+add_library(swig_modules "swig/Source/Modules/allegrocl.cxx"
+ "swig/Source/Modules/allocate.cxx"
+ "swig/Source/Modules/browser.cxx"
+ "swig/Source/Modules/cffi.cxx"
+ "swig/Source/Modules/chicken.cxx"
+ "swig/Source/Modules/clisp.cxx"
+ "swig/Source/Modules/contract.cxx"
+ "swig/Source/Modules/csharp.cxx"
+ "swig/Source/Modules/directors.cxx"
+ "swig/Source/Modules/emit.cxx"
+ "swig/Source/Modules/guile.cxx"
+ "swig/Source/Modules/java.cxx"
+ "swig/Source/Modules/lang.cxx"
+ "swig/Source/Modules/lua.cxx"
+ "swig/Source/Modules/main.cxx"
+ "swig/Source/Modules/modula3.cxx"
+ "swig/Source/Modules/module.cxx"
+ "swig/Source/Modules/mzscheme.cxx"
+ "swig/Source/Modules/ocaml.cxx"
+ "swig/Source/Modules/octave.cxx"
+ "swig/Source/Modules/overload.cxx"
+ "swig/Source/Modules/perl5.cxx"
+ "swig/Source/Modules/php.cxx"
+ "swig/Source/Modules/pike.cxx"
+ "swig/Source/Modules/python.cxx"
+ "swig/Source/Modules/r.cxx"
+ "swig/Source/Modules/ruby.cxx"
+ "swig/Source/Modules/s-exp.cxx"
+ "swig/Source/Modules/tcl8.cxx"
+ "swig/Source/Modules/typepass.cxx"
+ "swig/Source/Modules/uffi.cxx"
+ "swig/Source/Modules/utils.cxx"
+ "swig/Source/Modules/xml.cxx"
+)
+
+add_library(swig_cparse "swig/Source/CParse/cscanner.c"
+ "swig/Source/CParse/templ.c"
+ "swig/Source/CParse/util.c"
+ "swig/Source/CParse/parser.c"
+)
+
+add_library(swig_preprocessor "swig/Source/Preprocessor/cpp.c"
+ "swig/Source/Preprocessor/expr.c"
+)
+
+add_library(swig_doh "swig/Source/DOH/base.c"
+ "swig/Source/DOH/file.c"
+ "swig/Source/DOH/fio.c"
+ "swig/Source/DOH/hash.c"
+ "swig/Source/DOH/list.c"
+ "swig/Source/DOH/memory.c"
+ "swig/Source/DOH/string.c"
+ "swig/Source/DOH/void.c"
+)
+
+add_library(swiglib "swig/Source/Swig/cwrap.c"
+ "swig/Source/Swig/deprecate.c"
+ "swig/Source/Swig/error.c"
+ "swig/Source/Swig/fragment.c"
+ "swig/Source/Swig/getopt.c"
+ "swig/Source/Swig/include.c"
+ "swig/Source/Swig/misc.c"
+ "swig/Source/Swig/naming.c"
+ "swig/Source/Swig/parms.c"
+ "swig/Source/Swig/scanner.c"
+ "swig/Source/Swig/stype.c"
+ "swig/Source/Swig/symbol.c"
+ "swig/Source/Swig/tree.c"
+ "swig/Source/Swig/typemap.c"
+ "swig/Source/Swig/typeobj.c"
+ "swig/Source/Swig/typesys.c"
+ "swig/Source/Swig/wrapfunc.c"
+)
94 third_party/swig/swigconfig.h.win32
@@ -0,0 +1,94 @@
+/* Source/Include/swigconfig.h. Generated from swigconfig.h.in by configure. */
+/* Source/Include/swigconfig.h.in. Generated from configure.in by autoheader. */
+
+/* Define to 1 if the system has the type `bool'. */
+#define HAVE_BOOL 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `dl' library (-ldl). */
+#define HAVE_LIBDL 1
+
+/* Define to 1 if you have the `dld' library (-ldld). */
+/* #undef HAVE_LIBDLD */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define if popen is available */
+#define HAVE_POPEN 1
+
+/* Define if rxspencer is available */
+/* #undef HAVE_RXSPENCER */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+/* #undef NO_MINUS_C_MINUS_O */
+
+/* Name of package */
+#define PACKAGE "swig"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "http://www.swig.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "swig"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "swig 2.0.0"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "swig"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "2.0.0"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Compiler that built SWIG */
+#define SWIG_CXX "g++"
+
+/* Directory for SWIG system-independent libraries */
+#define SWIG_LIB "/usr/local/share/swig/2.0.0"
+
+/* Directory for SWIG system-independent libraries (Unix install on native
+ Windows) */
+#define SWIG_LIB_WIN_UNIX "C:/cygwin/usr/local/share/swig/2.0.0"
+
+/* Platform that SWIG is built for */
+#define SWIG_PLATFORM "i686-pc-cygwin"
+
+/* Version number of package */
+#define VERSION "2.0.0"
+
+
+/* Default language */
+#define SWIG_LANG "-tcl"
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
88 third_party/v8/CMakeLists.txt
@@ -0,0 +1,88 @@
+#
+# Checkout v8
+# ===========
+
+if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/v8/.svn")
+
+ if( ${SVN_EXECUTABLE-NOTFOUND} )
+ message(FATAL_ERROR "svn is necessary to checkout" )
+ endif()
+
+ set(V8_SVN_COMMAND
+ ${Subversion_SVN_EXECUTABLE}
+ co http://v8.googlecode.com/svn/tags/3.2.4
+ ${CMAKE_CURRENT_SOURCE_DIR}/v8
+ )
+
+ message("Checking out v8 3.2.4: ${V8_SVN_COMMAND}")
+ execute_process(
+ COMMAND ${V8_SVN_COMMAND}
+ )
+
+endif()
+
+
+
+#
+# Prepare options for v8 scons build
+# ==================================
+
+# if(V8_SNAPSHOT)
+# set(v8_snapshot snapshot=on)
+# endif()
+
+# if(V8_OPROFILE)
+# set(v8_oprofile prof=on)
+# endif()
+
+# if(V8_GDBJIT)
+ # if(NOT WIN32)
+ # set(v8_gdbjit gdbjit=on)
+ # endif()
+# endif()
+
+#if(OFF)
+#set(v8_parallel_jobs "-j ${parallel_jobs}")
+#endif()
+
+if(NOT ${CMAKE_BUILD_TYPE} EQUAL "")
+ string(TOLOWER ${CMAKE_BUILD_TYPE} v8mode)
+else()
+ set(v8mode "release")
+endif()
+
+if(${v8mode} STREQUAL "debug")
+ if(WIN32)
+ set(_V8_LIB ${CMAKE_CURRENT_SOURCE_DIR}/v8/v8_g.lib)
+ else()
+ message(FATAL_ERROR "Not yet implemented: what is the output of v8 build under posix?")
+ endif()
+elseif(${v8mode} STREQUAL "release")
+ if(WIN32)
+ set(_V8_LIB ${CMAKE_CURRENT_SOURCE_DIR}/v8/v8.lib)
+ else()
+ message(FATAL_ERROR "Not yet implemented: what is the output of v8 build under posix?")
+ endif()
+else()
+ message(FATAL_ERROR "Illegal build mode for v8: ${v8mode}")
+endif()
+
+
+if(MSVC90)
+ # HACK: default settings does not work for vc9
+ set(SCONS_ARGS ${SCONS_ARGS} "env=\"PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%\"")
+endif()
+
+add_custom_command(
+ OUTPUT BUILD_V8.rule
+ COMMAND ${Scons_EXECUTABLE} ${SCONS_ARGS} mode=${v8mode} verbose=on
+ COMMAND ${CMAKE_COMMAND} -E touch BUILD_V8.rule
+ COMMENT "Building v8 using scons: ${Scons_EXECUTABLE} ${SCONS_ARGS} mode=${v8mode} verbose=on"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/v8
+)
+
+add_custom_target(v8 DEPENDS BUILD_V8.rule)
+
+set_target_properties(v8
+ PROPERTIES FOLDER third_party
+)
Please sign in to comment.
Something went wrong with that request. Please try again.