-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile
65 lines (52 loc) · 2.6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile
working_directory = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
croaring_source = $(working_directory)/croaring-sys/CRoaring
release:
cargo build --release
lint:
cargo fmt --all -- --check
cargo clippy
test:
cargo test
croaring_release_url_base = https://github.com/RoaringBitmap/CRoaring/releases/download
# Fetch the c source amalgamation from a tagged CRoaring release (like `make version=0.9.3 update_croaring`)
update_croaring: download_croaring bindgen update_readme_croaring_version update_croaring_sys_version
download_croaring:
rm -f '$(croaring_source)/roaring.c' '$(croaring_source)/roaring.h' '$(croaring_source)/roaring.hh'
curl -L --output-dir '$(croaring_source)' \
-O '$(croaring_release_url_base)/v$(version)/roaring.c' \
-O '$(croaring_release_url_base)/v$(version)/roaring.h' \
-O '$(croaring_release_url_base)/v$(version)/roaring.hh'
# Regenerate bindgen bindings
bindgen:
cd '$(croaring_source)' && \
bindgen --generate-inline-functions \
--allowlist-item '(?i-u:roaring|bitset).*' \
--allowlist-var '(?i-u:roaring|bitset).*' \
--no-layout-tests \
--use-core \
-o bindgen_bundled_version.rs \
roaring.h
# sed -i is a GNU extension, so we use a temporary file explicitly
update_readme_croaring_version:
@echo "Updating README.md with CRoaring version $(version)"
@sed -r -e 's_\[CRoaring version `[0-9]+\.[0-9]+\.[0-9]+`\]\([^\)]+\)_[CRoaring version `$(version)`](https://github.com/RoaringBitmap/CRoaring/releases/tag/v$(version))_' README.md > README.md.tmp
@mv README.md.tmp README.md
# We don't always want to update the version of croaring-sys dependency in croaring, but we always want to update croaring-sys
update_croaring_sys_version:
@echo "Updating croaring-sys version in Cargo.toml to $(version)"
@sed -r -e 's/^version = ".*"/version = "$(version)"/' croaring-sys/Cargo.toml > croaring-sys/Cargo.toml.tmp
@mv croaring-sys/Cargo.toml.tmp croaring-sys/Cargo.toml
# Build a c program to (re)generate the example serialized files for testing
test_serialization_files:
cd croaring/tests/data/ && \
cc create_serialization.c '$(croaring_source)/roaring.c' -I '$(croaring_source)' -Wall -o create_serialization && \
./create_serialization
_get_cargo_fuzz:
command -v cargo-fuzz >/dev/null 2>&1 || cargo install cargo-fuzz
fuzz: _get_cargo_fuzz
cd fuzz && \
cargo fuzz check && \
ASAN_OPTIONS="detect_leaks=1 detect_stack_use_after_return=1" \
CC=clang CFLAGS=-fsanitize=address \
cargo fuzz run fuzz_ops -s address -- -max_len=10000 -rss_limit_mb=4096