Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate repo to a Cargo workspace #284

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ local/
settings.db

# C API tests (ignore everything but source files)
gosub-bindings/tests/*
!gosub-bindings/tests/*.c
*/gosub-bindings/tests/*
!*/gosub-bindings/tests/*.c
*.dSYM
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ repository = "https://github.com/gosub-browser/gosub-engine"
readme = "README.md"
keywords = ["html5", "parser", "browser", "Rust", "DOM"]

[workspace]
members = [
"crates/*"
]

[[example]]
name = "html5-parser"

[[test]]
name = "tokenizer"
path = "tests/tokenizer.rs"
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ bench: ## Benchmark the project
build: ## Build the project
source test-utils.sh ;\
section "Cargo build" ;\
cargo build
cargo build --all
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the --all flag now to pick up gosub-bindings. So perhaps good to use make build now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could add a target to build only one specific. But it might make sense to do this as a seperate PR


fix: ## Fix formatting and clippy errors (deprecated)
echo "Use 'make format' instead"

format: ## Fix formatting and clippy errors
cargo fmt
cargo clippy --fix --allow-dirty --allow-staged
cargo fmt --all
cargo clippy --all --fix --allow-dirty --allow-staged

test_unit:
source test-utils.sh ;\
section "Cargo test" ;\
cargo test --features debug_parser
cargo test --all --all-features

test_clippy:
source test-utils.sh ;\
Expand All @@ -34,12 +34,14 @@ test_clippy:
test_fmt:
source test-utils.sh ;\
section "Cargo fmt" ;\
cargo fmt -- --check
cargo fmt --all -- --check

test_commands:
cargo run --bin html5-parser-test >/dev/null
cargo run --bin parser-test >/dev/null
cargo run --bin config-store list >/dev/null
cargo run --bin gosub-parser ./tests/data/tree_iterator/stackoverflow.html >/dev/null
cargo run --example html5-parser >/dev/null
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're here, let's add two more binaries to the CI run.


help: ## Display available commands
echo "Available make commands:"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
gosub-engine = { path = "../" }
gosub-engine = { path = "../../" }

[lib]
crate-type = ["staticlib"]
7 changes: 4 additions & 3 deletions gosub-bindings/Makefile → crates/gosub-bindings/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ CFLAGS_DEBUG := -std=c99 -g -Wall -Wextra -O0
CFLAGS_RELEASE := -std=c99 -Wall -Wextra -O2
CFLAGS := $(CFLAGS_DEBUG)
CC := gcc
TARGET_DIR := ../../target/debug

LDFLAGS := -L./target/debug
LDFLAGS := -L$(TARGET_DIR)
NODE_SRC_DIR := $(SRC_DIR)/nodes
bindings: # build gosub static library to be used externally
$(CC) $(CFLAGS) $(CPPFLAGS) -c $(SRC_DIR)/gosub_api.c $(SRC_DIR)/nodes.c $(NODE_SRC_DIR)/text.c
ar rcs libgosub.a gosub_api.o nodes.o text.o
rm *.o
test -d lib || mkdir lib
cp ./target/debug/libgosub_bindings.a lib/
cp $(TARGET_DIR)/libgosub_bindings.a lib/
cp ./libgosub.a lib/

TEST_SRC_DIR := tests
test: # build and run tests for bindings
$(CC) $(TEST_SRC_DIR)/render_tree_test.c -L./ -lgosub -L./target/debug -lgosub_bindings -lsqlite3 -lm -o $(TEST_SRC_DIR)/render_tree_test $(CPPFLAGS) $(CFLAGS)
$(CC) $(TEST_SRC_DIR)/render_tree_test.c -L./ -lgosub $(LDFLAGS) -lgosub_bindings -lsqlite3 -lm -o $(TEST_SRC_DIR)/render_tree_test $(CPPFLAGS) $(CFLAGS)
./$(TEST_SRC_DIR)/render_tree_test

format:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading