Permalink
Browse files

successful integration

  • Loading branch information...
0 parents commit ee97b7073f5be052a81e00bc14ef92053e4c6b82 @antoniogarrote committed Feb 27, 2011
@@ -0,0 +1,23 @@
+# export CPLUS_INCLUDE_PATH=/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Headers/
+INCLUDES = -I../v8-read-only/include
+LIBS = -L/opt/local/lib
+DYLIB = -arch x86_64 libv8.a
+INSTALL_PATH = -install_name /usr/local/lib/libSparqlParserWrapper.dylib
+CC = g++
+
+all: SparqlParserWrapper
+
+SparqlParserWrapper: SparqlParser.o
+ $(CC) $(DYLIB) sparql_parser.o SparqlParser.o $(LIBS) -dynamiclib -o libSparqlParserWrapper.dylib
+
+SparqlParser.o: sparql_parser.o
+ $(CC) $(INCLUDES) -c src/SparqlParser.c
+
+sparql_parser.o:
+ $(CC) $(INCLUDES) -c src/sparql_parser.cc
+
+clean_obj:
+ rm -rf *.o
+
+clean: clean_obj
+ rm -rf hello_world
50 README
@@ -0,0 +1,50 @@
+Clojure wrapper for a SPARQL 1.1 parser written in Javascript, using an embedded V8 interpreter
+
+= Dependencies
+
+ - V8 Javascript engine, instructions to build and install can be found here: http://code.google.com/apis/v8/build.html
+ - A sample building command for OSX 64 bits generating a static lib is:
+
+ v8-read-only $ scons mode=release library=static snapshot=on arch=x64
+
+= Building & running
+
+ 1) Build C++ dynamic lib
+
+ sparql-clj-v8-integration$ export CPLUS_INCLUDE_PATH=/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Headers/
+ sparql-clj-v8-integration$ make
+
+ 2) Build Java JNI wrapper
+
+ sparql-clj-v8-integration$ cd java
+ sparql-clj-v8-integration/java$ javac sparqltest/SparqlParser.java
+ sparql-clj-v8-integration/java$ jar cf SparqlParser.jar sparqltest/SparqlParser.class
+
+ 3) Set up Clojure project
+
+ sparql-clj-v8-integration/java$ cd ../clj-sparql-test
+ sparql-clj-v8-integration/clj-sparql-test$ lein deps
+ sparql-clj-v8-integration/clj-sparql-test$ cp ../js/sparql_parser.js .
+ sparql-clj-v8-integration/clj-sparql-test$ cp ../java/SparqlParser.jar ./lib/
+ sparql-clj-v8-integration/clj-sparql-test$ cp ./libSparqlParserWrapper.dylib .
+
+ 4) Test the library from Slime
+
+ sparql-clj-v8-integration/clj-sparql-test$ lein swank
+
+ user> (use 'clj-sparql-test.core)
+ nil
+ user> (parse-sparql "SELECT * { ?s ?p ?o }")
+ [{:token "prologue",
+ :base "",
+ :prefixes []}
+ {:kind "select",
+ :token "executableunit",
+ :dataset [],
+ :projection [{:token "variable", :kind "*"}],
+ :pattern {:token "groupgraphpattern",
+ :patterns [{:token "basicgraphpattern",
+ :triplesContext [{:subject {:token "var", :value "s"},
+ :predicate {:token "var", :value "p"},
+ :object {:token "var", :value "o"}}]}],
+ :filters []}}]
@@ -0,0 +1,4 @@
+pom.xml
+*jar
+lib
+classes
@@ -0,0 +1,13 @@
+# clj-sparql-test
+
+FIXME: write description
+
+## Usage
+
+FIXME: write
+
+## License
+
+Copyright (C) 2010 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
Binary file not shown.
@@ -0,0 +1,6 @@
+(defproject clj-sparql-test "0.0.1-SNAPSHOT"
+ :description "Testing the SPARQL parser"
+ :native-path "."
+ :dependencies [[org.clojure/clojure "1.2.0"]
+ [org.clojure/clojure-contrib "1.2.0"]]
+ :dev-dependencies [[leiningen/lein-swank "1.2.0-SNAPSHOT"]])
Oops, something went wrong.

0 comments on commit ee97b70

Please sign in to comment.