diff --git a/acsl-parser/Makefile b/acsl-parser/Makefile index 2b0969d..51a2a20 100644 --- a/acsl-parser/Makefile +++ b/acsl-parser/Makefile @@ -1,6 +1,7 @@ PARSER_BASEDIR=$(shell pwd) +CCPARSER_BASEDIR=$(PARSER_BASEDIR)/../cc-parser +PARSER_LIBDIR=$(CCPARSER_BASEDIR)/lib PARSER_BINDIR=$(PARSER_BASEDIR)/bin -PARSER_LIBDIR = $(PARSER_BASEDIR)/../cc-parser/lib CUP = java_cup.Main CUPFLAGS = -expect 7 -locations @@ -23,36 +24,9 @@ JAVA:=java JAVA_FLAGS:= .PHONY: all -all: $(CUP_JAR) $(JFLEX_PLUGIN_JAR) acsl-parser.jar tricera/acsl/Test.class - -$(PARSER_LIBDIR): - @mkdir -p $@ - -$(CUP_JAR): | $(PARSER_LIBDIR) - @echo "Looking for cup jar at $(CUP_JAR)" - @if [ ! -f $(CUP_JAR) ]; then \ - echo "not found, downloading..."; \ - mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \ - -DremoteRepositories=https://repo.maven.apache.org/maven2/ \ - -Dartifact=com.github.vbmacher:java-cup:11b-20160615-2 \ - -Dtransitive=false \ - -Ddest=$(CUP_JAR); \ - else \ - echo "found, skipping download."; \ - fi - -$(JFLEX_PLUGIN_JAR): | $(PARSER_LIBDIR) - @echo "Looking for JFlex plugin jar at $(JFLEX_PLUGIN_JAR)" - @if [ ! -f $(JFLEX_PLUGIN_JAR) ]; then \ - echo "not found, downloading..."; \ - mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \ - -DremoteRepositories=https://repo.maven.apache.org/maven2/ \ - -Dartifact=de.jflex:jflex:1.9.1 \ - -Dtransitive=false \ - -Ddest=$(JFLEX_PLUGIN_JAR); \ - else \ - echo "found, skipping download."; \ - fi +all: download-jars acsl-parser.jar tricera/acsl/Test.class + +include $(CCPARSER_BASEDIR)/download_jars.mk acsl-parser.jar: $(PARSER_BINDIR) $(PARSER_BINDIR)/tricera/acsl/Absyn/acsl.class $(PARSER_BINDIR)/tricera/acsl/sym.class $(PARSER_BINDIR)/tricera/acsl/Yylex.class $(PARSER_BINDIR)/tricera/acsl/PrettyPrinterNonStatic.class $(PARSER_BINDIR)/tricera/acsl/parser.class cd $(PARSER_BINDIR) && jar cf $(PARSER_BASEDIR)/acsl-parser.jar tricera @@ -60,6 +34,7 @@ acsl-parser.jar: $(PARSER_BINDIR) $(PARSER_BINDIR)/tricera/acsl/Absyn/acsl.class $(PARSER_BINDIR): mkdir $(PARSER_BINDIR) +.PHONY: clean clean: # rm -rf parser.jar rm -rf $(PARSER_BINDIR) diff --git a/build.sbt b/build.sbt index f9e369c..8f6aac0 100644 --- a/build.sbt +++ b/build.sbt @@ -25,12 +25,19 @@ lazy val parserSettings = Seq( ) // Parser generation +val downloadJarsTask = taskKey[Unit]("Downloads the necessary JAR files using make.") lazy val ccParser = (project in file("cc-parser")). settings(commonSettings: _*). settings(parserSettings: _*). settings( name := "TriCera-CC-parser", + downloadJarsTask := { + val s: TaskStreams = streams.value + s.log.info("Downloading parser dependencies...") + Process("make download-jars", baseDirectory.value).! + }, + (compile in Compile) := ((compile in Compile) dependsOn downloadJarsTask).value, packageBin in Compile := baseDirectory.value / "cc-parser.jar", unmanagedJars in Compile += baseDirectory.value / "cc-parser.jar" ).disablePlugins(AssemblyPlugin) diff --git a/cc-parser/Makefile b/cc-parser/Makefile index b2b1263..a420595 100644 --- a/cc-parser/Makefile +++ b/cc-parser/Makefile @@ -1,6 +1,6 @@ -PARSER_BASEDIR=$(shell pwd) -PARSER_BINDIR=$(PARSER_BASEDIR)/bin -PARSER_LIBDIR = $(PARSER_BASEDIR)/lib +CCPARSER_BASEDIR=$(shell pwd) +PARSER_BINDIR=$(CCPARSER_BASEDIR)/bin +PARSER_LIBDIR = $(CCPARSER_BASEDIR)/lib CUP = java_cup.Main CUPFLAGS = -expect 100 -locations @@ -23,44 +23,18 @@ JAVA:=java JAVA_FLAGS:= .PHONY: all -all: $(CUP_JAR) $(JFLEX_PLUGIN_JAR) cc-parser.jar tricera/concurrency/concurrent_c/Test.class - -$(PARSER_LIBDIR): - @mkdir -p $@ - -$(CUP_JAR): | $(PARSER_LIBDIR) - @echo "Looking for cup jar at $(CUP_JAR)" - @if [ ! -f $(CUP_JAR) ]; then \ - echo "not found, downloading..."; \ - mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \ - -DremoteRepositories=https://repo.maven.apache.org/maven2/ \ - -Dartifact=com.github.vbmacher:java-cup:11b-20160615-2 \ - -Dtransitive=false \ - -Ddest=$(CUP_JAR); \ - else \ - echo "found, skipping download."; \ - fi - -$(JFLEX_PLUGIN_JAR): | $(PARSER_LIBDIR) - @echo "Looking for JFlex plugin jar at $(JFLEX_PLUGIN_JAR)" - @if [ ! -f $(JFLEX_PLUGIN_JAR) ]; then \ - echo "not found, downloading..."; \ - mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \ - -DremoteRepositories=https://repo.maven.apache.org/maven2/ \ - -Dartifact=de.jflex:jflex:1.9.1 \ - -Dtransitive=false \ - -Ddest=$(JFLEX_PLUGIN_JAR); \ - else \ - echo "found, skipping download."; \ - fi +all: download-jars cc-parser.jar tricera/concurrency/concurrent_c/Test.class + +include $(CCPARSER_BASEDIR)/download_jars.mk cc-parser.jar: $(PARSER_BINDIR) $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/Absyn/concurrent_c.class $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/sym.class $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/Yylex.class $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/PrettyPrinterNonStatic.class $(PARSER_BINDIR)/tricera/concurrency/concurrent_c/parser.class - cd $(PARSER_BINDIR) && jar cf $(PARSER_BASEDIR)/cc-parser.jar tricera + cd $(PARSER_BINDIR) && jar cf $(CCPARSER_BASEDIR)/cc-parser.jar tricera $(PARSER_BINDIR): mkdir $(PARSER_BINDIR) +.PHONY: clean clean: # rm -rf parser.jar rm -rf $(PARSER_BINDIR) diff --git a/cc-parser/download_jars.mk b/cc-parser/download_jars.mk new file mode 100644 index 0000000..312d1fc --- /dev/null +++ b/cc-parser/download_jars.mk @@ -0,0 +1,50 @@ +PARSER_LIBDIR = $(CCPARSER_BASEDIR)/lib + +CUP_JAR = $(PARSER_LIBDIR)/java-cup-11b.jar +CUP_RUNTIME_JAR = $(PARSER_LIBDIR)/java-cup-runtime-11b.jar +JFLEX_PLUGIN_JAR = $(PARSER_LIBDIR)/jflex-1.9.1.jar + +.PHONY: download-jars +download-jars: $(CUP_JAR) $(CUP_RUNTIME_JAR) $(JFLEX_PLUGIN_JAR) + +$(PARSER_LIBDIR): + @mkdir -p $@ + +$(CUP_JAR): | $(PARSER_LIBDIR) + @echo "Looking for CUP JAR at $(CUP_JAR)..." + @if [ ! -f $(CUP_JAR) ]; then \ + echo "CUP JAR not found, downloading..."; \ + mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \ + -DremoteRepositories=https://repo.maven.apache.org/maven2/ \ + -Dartifact=com.github.vbmacher:java-cup:11b-20160615-2 \ + -Dtransitive=false \ + -Ddest=$(CUP_JAR); \ + else \ + echo "CUP JAR found, skipping download."; \ + fi + +$(CUP_RUNTIME_JAR): | $(PARSER_LIBDIR) + @echo "Looking for CUP Runtime JAR at $(CUP_RUNTIME_JAR)..." + @if [ ! -f $(CUP_RUNTIME_JAR) ]; then \ + echo "CUP Runtime JAR not found, downloading..."; \ + mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \ + -DremoteRepositories=https://repo.maven.apache.org/maven2/ \ + -Dartifact=com.github.vbmacher:java-cup-runtime:11b-20160615-2 \ + -Dtransitive=false \ + -Ddest=$(CUP_RUNTIME_JAR); \ + else \ + echo "CUP Runtime JAR found, skipping download."; \ + fi + +$(JFLEX_PLUGIN_JAR): | $(PARSER_LIBDIR) + @echo "Looking for JFlex plugin JAR at $(JFLEX_PLUGIN_JAR)..." + @if [ ! -f $(JFLEX_PLUGIN_JAR) ]; then \ + echo "JFlex plugin JAR not found, downloading..."; \ + mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get \ + -DremoteRepositories=https://repo.maven.apache.org/maven2/ \ + -Dartifact=de.jflex:jflex:1.9.1 \ + -Dtransitive=false \ + -Ddest=$(JFLEX_PLUGIN_JAR); \ + else \ + echo "JFlex plugin JAR found, skipping download."; \ + fi