Skip to content

Commit

Permalink
Move Bazel WORKSPACE to the root directory. (#440)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
regisd authored Oct 12, 2018
1 parent fa2db88 commit a2cdc9f
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 32 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/
File renamed without changes.
13 changes: 13 additions & 0 deletions cup/BUILD
Original file line number Diff line number Diff line change
@@ -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"],
)
15 changes: 15 additions & 0 deletions jflex/BUILD
Original file line number Diff line number Diff line change
@@ -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"],
)
23 changes: 0 additions & 23 deletions jflex/examples/BUILD

This file was deleted.

3 changes: 2 additions & 1 deletion jflex/examples/simple/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
2 changes: 1 addition & 1 deletion jflex/examples/simple/src/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ java_test(
"data/test.txt",
],
deps = [
"//simple",
"//jflex/examples/simple",
"//third_party/com/google/truth",
],
)
2 changes: 1 addition & 1 deletion jflex/examples/simple/src/test/java/YylexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
6 changes: 0 additions & 6 deletions scripts/bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a2cdc9f

Please sign in to comment.