From a2cdc9f821d03bda4384a5ccac882a4aeb81b584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20D=C3=A9camps?= Date: Sat, 13 Oct 2018 01:29:29 +0200 Subject: [PATCH] Move Bazel WORKSPACE to the root directory. (#440) - The Bazel workspace should generally be the root. This is what we want for building the docs (#429) or the whole project (#304) - This allows to reference the jflex.jar and the cup.jar directly; the Bazel script doesn't have to copy them anymore. --- README.md | 2 ++ jflex/examples/WORKSPACE => WORKSPACE | 0 cup/BUILD | 13 +++++++++++ jflex/BUILD | 15 ++++++++++++ jflex/examples/BUILD | 23 ------------------- jflex/examples/simple/BUILD | 3 ++- jflex/examples/simple/src/test/BUILD | 2 +- .../simple/src/test/java/YylexTest.java | 2 +- scripts/bazel.sh | 6 ----- .../third_party => third_party}/README.md | 0 .../com/google/guava/BUILD | 0 .../com/google/truth/BUILD | 0 12 files changed, 34 insertions(+), 32 deletions(-) rename jflex/examples/WORKSPACE => WORKSPACE (100%) create mode 100644 cup/BUILD create mode 100644 jflex/BUILD delete mode 100644 jflex/examples/BUILD rename {jflex/examples/third_party => third_party}/README.md (100%) rename {jflex/examples/third_party => third_party}/com/google/guava/BUILD (100%) rename {jflex/examples/third_party => third_party}/com/google/truth/BUILD (100%) diff --git a/README.md b/README.md index 23868b74b..fef8dc2cf 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ The top level directory of the JFLex git repository contains: * **jflex-maven-plugin** the JFlex maven plugin, that helps to integrate JFlex in your project * **jflex-unicode-plugin** the JFlex unicode maven plugin, used for compiling JFlex * **testsuite** the regression test suite for JFlex, + * **third_party** third-party librairies used by examples of the [Bazel build system][bazel] ## Usage @@ -132,3 +133,4 @@ See the [Contributing][contrib] page for instructions. [example-simple]: https://github.com/jflex-de/jflex/tree/master/jflex/examples/simple [examples]: https://github.com/jflex-de/jflex/tree/master/jflex/examples/ [contrib]: https://github.com/jflex-de/jflex/wiki/Contributing +[bazel]: http://bazel.build/ diff --git a/jflex/examples/WORKSPACE b/WORKSPACE similarity index 100% rename from jflex/examples/WORKSPACE rename to WORKSPACE diff --git a/cup/BUILD b/cup/BUILD new file mode 100644 index 000000000..67f322bff --- /dev/null +++ b/cup/BUILD @@ -0,0 +1,13 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # GPL-compatible + +java_import( + name = "cup", + jars = ["cup/target/cup-11b.jar"], +) + +java_import( + name = "cup_runtime", + jars = ["cup_runtime/target/cup_runtime-11b.jar"], +) diff --git a/jflex/BUILD b/jflex/BUILD new file mode 100644 index 000000000..00945921f --- /dev/null +++ b/jflex/BUILD @@ -0,0 +1,15 @@ +package(default_visibility = ["//visibility:public"]) + +java_binary( + name = "jflex_bin", + main_class = "jflex.Main", + runtime_deps = [ + ":jflex", + "//cup:cup_runtime", + ], +) + +java_import( + name = "jflex", + jars = ["target/jflex-1.7.1-SNAPSHOT.jar"], +) diff --git a/jflex/examples/BUILD b/jflex/examples/BUILD deleted file mode 100644 index 24f311140..000000000 --- a/jflex/examples/BUILD +++ /dev/null @@ -1,23 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # BSD - -java_binary( - name = "jflex_bin", - main_class = "jflex.Main", - runtime_deps = [":jflex"], -) - -# The snapshots are: -# - built by Maven -# - copied in this directort by bazel.sh -java_import( - name = "jflex", - jars = ["jflex.jar"], - deps = [":cup_runtime"], -) - -java_import( - name = "cup_runtime", - jars = ["cup_runtime.jar"], -) diff --git a/jflex/examples/simple/BUILD b/jflex/examples/simple/BUILD index 519cd0b31..83f0d765b 100644 --- a/jflex/examples/simple/BUILD +++ b/jflex/examples/simple/BUILD @@ -19,11 +19,12 @@ java_library( name = "simple", # glob is not a best practice, but it's good enough for this example srcs = glob(["src/main/java/**/*.java"]) + [":gen_lexer"], + deps = ["//cup:cup_runtime"], ) jflex( name = "gen_lexer", srcs = ["src/main/jflex/simple.flex"], - jflex_bin = "//:jflex_bin", + jflex_bin = "//jflex:jflex_bin", outputs = ["Yylex.java"], ) diff --git a/jflex/examples/simple/src/test/BUILD b/jflex/examples/simple/src/test/BUILD index 6b98b25e2..16e157848 100644 --- a/jflex/examples/simple/src/test/BUILD +++ b/jflex/examples/simple/src/test/BUILD @@ -6,7 +6,7 @@ java_test( "data/test.txt", ], deps = [ - "//simple", + "//jflex/examples/simple", "//third_party/com/google/truth", ], ) diff --git a/jflex/examples/simple/src/test/java/YylexTest.java b/jflex/examples/simple/src/test/java/YylexTest.java index 70da54115..420097521 100644 --- a/jflex/examples/simple/src/test/java/YylexTest.java +++ b/jflex/examples/simple/src/test/java/YylexTest.java @@ -84,7 +84,7 @@ private File openFile(String pathName) throws IOException { File pwd = new File(".").getCanonicalFile(); assertThat(pwd.isDirectory()).isTrue(); if (Objects.equal(pwd.getName(), "__main__")) { - path = "simple/" + path; + path = "jflex/examples/simple/" + path; } File file = new File(path); if (!file.isFile()) { diff --git a/scripts/bazel.sh b/scripts/bazel.sh index db008a69d..01cc7937e 100755 --- a/scripts/bazel.sh +++ b/scripts/bazel.sh @@ -14,12 +14,6 @@ else BAZEL='bazel' fi -logi "Copy JFlex jar in examples" -logi "==========================" -# NB This will fail if there are multiple versions of the jflex jar. -cp "$BASEDIR"/jflex/target/jflex-1.*.jar "$BASEDIR"/jflex/examples/jflex.jar -cp "$BASEDIR"/cup/cup_runtime/target/cup_runtime-*.jar "$BASEDIR"/jflex/examples/cup_runtime.jar - logi "Start Bazel" logi "===========" cd "$BASEDIR"/jflex/examples diff --git a/jflex/examples/third_party/README.md b/third_party/README.md similarity index 100% rename from jflex/examples/third_party/README.md rename to third_party/README.md diff --git a/jflex/examples/third_party/com/google/guava/BUILD b/third_party/com/google/guava/BUILD similarity index 100% rename from jflex/examples/third_party/com/google/guava/BUILD rename to third_party/com/google/guava/BUILD diff --git a/jflex/examples/third_party/com/google/truth/BUILD b/third_party/com/google/truth/BUILD similarity index 100% rename from jflex/examples/third_party/com/google/truth/BUILD rename to third_party/com/google/truth/BUILD