Skip to content

Commit

Permalink
Add a Cargo workspace (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
emwalker authored Nov 28, 2023
1 parent c81302c commit 5b00c12
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 1,839 deletions.
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

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

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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5b00c12

Please sign in to comment.