Skip to content

Commit 03f0008

Browse files
uaelhchataing
authored andcommitted
Switch to a workspace based project architecture
This complete the migration to a workspace based project architecture.
1 parent bf4c5c8 commit 03f0008

12 files changed

+48
-36
lines changed

.github/workflows/build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ jobs:
8686
python3 -m pip install typing_extensions
8787
8888
- name: Install pdlc
89-
run: cargo install --path .
89+
run: cargo install --path pdl-compiler/
9090

9191
- name: Run CXX generator tests
92-
run: tests/run_cxx_generator_tests.sh
92+
run: pdl-compiler/tests/run_cxx_generator_tests.sh
9393

9494
- name: Run Python generator tests
95-
run: tests/run_python_generator_tests.sh
95+
run: pdl-compiler/tests/run_python_generator_tests.sh

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
Cargo.lock
2-
scripts/pdl/__pycache__/
2+
**/__pycache__/
3+
out/
34
target/
5+
venv/

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[workspace]
2+
members = [
3+
"pdl-compiler",
4+
]

doc/cxx-generated-code-guide.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Example invocation:
2424
.. sourcecode:: bash
2525

2626
cargo run my-protocol.pdl --output-format json | \
27-
./scripts/generate_cxx_backend.py > my-protocol.h
27+
./pdl-compiler/scripts/generate_cxx_backend.py > my-protocol.h
2828

2929
Language bindings
3030
-----------------

doc/python-generated-code-guide.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Example invocation:
2020
.. sourcecode:: bash
2121

2222
cargo run my-protocol.pdl --output-format json | \
23-
./scripts/generate_python_backend.py > my-protocol.py
23+
./pdl-compiler/scripts/generate_python_backend.py > my-protocol.py
2424

2525
Language bindings
2626
-----------------
File renamed without changes.

pdl-compiler-fuzz/Cargo.toml fuzz/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cargo-fuzz = true
1111
libfuzzer-sys = "0.4"
1212

1313
[dependencies.pdl-compiler]
14-
path = ".."
14+
path = "../pdl-compiler"
1515

1616
# Prevent this from interfering with workspaces
1717
[workspace]

pdl-compiler/Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@ edition = "2021"
55
description = "Parser and serializer generator for protocol binary packets"
66
repository = "https://github.com/google/pdl/"
77
license = "Apache-2.0"
8-
readme = "README.md"
8+
readme = "../README.md"
99
keywords = ["pdl", "parser", "serializer", "grammar"]
1010
authors = [
1111
"Henri Chataing <henrichataing@google.com>",
1212
"David de Jesus Duarte <licorne@google.com>",
1313
"Martin Geisler <mgeisler@google.com>"
1414
]
15-
exclude = [".github/*", "editors/*"]
15+
exclude = ["editors/*"]
1616
categories = ["parsing"]
1717
default-run = "pdlc"
1818

1919
[[bin]]
2020
name = "pdlc"
2121
path = "src/main.rs"
2222

23-
[workspace]
24-
2523
[features]
2624
default = ["serde"]
2725

pdl-compiler/tests/run_cxx_generator_tests.sh

+21-17
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,48 @@
33
set -euxo pipefail
44

55
mkdir -p out/
6+
OUT_DIR="$(pwd)/out"
7+
8+
# move to `pdl-compiler` directory
9+
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &> /dev/null
610

711
sed -e 's/little_endian_packets/big_endian_packets/' \
812
-e '/Start: little_endian_only/,/End: little_endian_only/d' \
9-
< tests/canonical/le_test_file.pdl > out/be_test_file.pdl
13+
< tests/canonical/le_test_file.pdl > "$OUT_DIR"/be_test_file.pdl
1014

11-
pdlc tests/canonical/le_test_file.pdl > out/le_test_file.json
12-
pdlc out/be_test_file.pdl > out/be_test_file.json
15+
pdlc tests/canonical/le_test_file.pdl > "$OUT_DIR"/le_test_file.json
16+
pdlc "$OUT_DIR"/be_test_file.pdl > "$OUT_DIR"/be_test_file.json
1317

1418
python3 scripts/generate_cxx_backend.py \
15-
--input out/le_test_file.json \
16-
--output out/le_backend.h \
19+
--input "$OUT_DIR"/le_test_file.json \
20+
--output "$OUT_DIR"/le_backend.h \
1721
--namespace le_backend
1822
python3 scripts/generate_cxx_backend.py \
19-
--input out/be_test_file.json \
20-
--output out/be_backend.h \
23+
--input "$OUT_DIR"/be_test_file.json \
24+
--output "$OUT_DIR"/be_backend.h \
2125
--namespace be_backend
2226

2327
python3 scripts/generate_cxx_backend_tests.py \
24-
--input out/le_test_file.json \
25-
--output out/le_backend_tests.cc \
28+
--input "$OUT_DIR"/le_test_file.json \
29+
--output "$OUT_DIR"/le_backend_tests.cc \
2630
--test-vectors tests/canonical/le_test_vectors.json \
2731
--namespace le_backend \
2832
--parser-test-suite le_backend_parser_test \
2933
--serializer-test-suite le_backend_serializer_test \
3034
--include-header le_backend.h
3135
python3 scripts/generate_cxx_backend_tests.py \
32-
--input out/be_test_file.json \
33-
--output out/be_backend_tests.cc \
36+
--input "$OUT_DIR"/be_test_file.json \
37+
--output "$OUT_DIR"/be_backend_tests.cc \
3438
--test-vectors tests/canonical/be_test_vectors.json \
3539
--namespace be_backend \
3640
--parser-test-suite be_backend_parser_test \
3741
--serializer-test-suite be_backend_serializer_test \
3842
--include-header be_backend.h
3943

40-
g++ -Iscripts -Iout \
41-
out/le_backend_tests.cc \
42-
out/be_backend_tests.cc \
43-
-lgtest -lgtest_main -o out/cxx_backend_tests
44+
g++ -Iscripts -I"$OUT_DIR" \
45+
"$OUT_DIR"/le_backend_tests.cc \
46+
"$OUT_DIR"/be_backend_tests.cc \
47+
-lgtest -lgtest_main -o "$OUT_DIR"/cxx_backend_tests
4448

45-
./out/cxx_backend_tests \
46-
--gtest_output="xml:out/cxx_backend_tests_detail.xml"
49+
"$OUT_DIR"/cxx_backend_tests \
50+
--gtest_output="xml:$OUT_DIR/cxx_backend_tests_detail.xml"

pdl-compiler/tests/run_python_generator_tests.sh

+12-8
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@
33
set -euxo pipefail
44

55
mkdir -p out/
6+
OUT_DIR="$(pwd)/out"
7+
8+
# move to `pdl-compiler` directory
9+
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &> /dev/null
610

711
sed -e 's/little_endian_packets/big_endian_packets/' \
812
-e '/Start: little_endian_only/,/End: little_endian_only/d' \
9-
< tests/canonical/le_test_file.pdl > out/be_test_file.pdl
13+
< tests/canonical/le_test_file.pdl > "$OUT_DIR"/be_test_file.pdl
1014

11-
pdlc tests/canonical/le_test_file.pdl > out/le_test_file.json
12-
pdlc out/be_test_file.pdl > out/be_test_file.json
15+
pdlc tests/canonical/le_test_file.pdl > "$OUT_DIR"/le_test_file.json
16+
pdlc "$OUT_DIR"/be_test_file.pdl > "$OUT_DIR"/be_test_file.json
1317

1418
python3 scripts/generate_python_backend.py \
15-
--input out/le_test_file.json \
16-
--output out/le_backend.py \
19+
--input "$OUT_DIR"/le_test_file.json \
20+
--output "$OUT_DIR"/le_backend.py \
1721
--custom-type-location tests.custom_types
1822
python3 scripts/generate_python_backend.py \
19-
--input out/be_test_file.json \
20-
--output out/be_backend.py \
23+
--input "$OUT_DIR"/be_test_file.json \
24+
--output "$OUT_DIR"/be_backend.py \
2125
--custom-type-location tests.custom_types
2226

23-
export PYTHONPATH="./out:.:${PYTHONPATH:-}"
27+
export PYTHONPATH="$OUT_DIR:.:${PYTHONPATH:-}"
2428
python3 tests/python_generator_test.py

0 commit comments

Comments
 (0)