Skip to content

Commit

Permalink
Add missing cup runtime dependency, refactor parser makefiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
zafer-esen committed Nov 20, 2023
1 parent bd8cbb7 commit 18a1d27
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 65 deletions.
37 changes: 6 additions & 31 deletions acsl-parser/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,43 +24,17 @@ 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

$(PARSER_BINDIR):
mkdir $(PARSER_BINDIR)

.PHONY: clean
clean:
# rm -rf parser.jar
rm -rf $(PARSER_BINDIR)
Expand Down
7 changes: 7 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 8 additions & 34 deletions cc-parser/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
50 changes: 50 additions & 0 deletions cc-parser/download_jars.mk
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 18a1d27

Please sign in to comment.