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

Use commit sha from env and prevent file being replaced every new commit #421

Merged
merged 2 commits into from
Jan 3, 2024
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PYTHONPATH=./py/correctness/src
CRSQLITE_NOPREBUILD=1
CRSQLITE_COMMIT_SHA=dev
18 changes: 8 additions & 10 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ TARGET_TEST=$(prefix)/test
TARGET_FUZZ=$(prefix)/fuzz
TARGET_TEST_ASAN=$(prefix)/test-asan


# js/browser/wa-sqlite/Makefile, deps/sqlite/GNUMakefile, core/binding.gyp, core/Makefile
ext_files=src/crsqlite.c \
src/changes-vtab.c \
Expand Down Expand Up @@ -170,19 +169,23 @@ $(shell.c):
$(sqlite3.c):
cd $(sqlite_src) && make sqlite3.c

$(rs_lib_dbg_static_cpy): FORCE write_sha $(dbg_prefix)
$(rs_lib_dbg_static_cpy): export CRSQLITE_COMMIT_SHA = $(shell git rev-parse HEAD)
$(rs_lib_dbg_static_cpy): FORCE $(dbg_prefix)
cd ./rs/$(bundle) && cargo rustc $(RS_TARGET) --features static,omit_load_extension$(libsql_feature) $(rs_build_flags)
cp $(rs_lib_dbg_static) $(rs_lib_dbg_static_cpy)

$(rs_lib_static_cpy): FORCE write_sha $(prefix)
$(rs_lib_static_cpy): export CRSQLITE_COMMIT_SHA = $(shell git rev-parse HEAD)
$(rs_lib_static_cpy): FORCE $(prefix)
cd ./rs/$(bundle) && cargo rustc $(RS_TARGET) --release --features static,omit_load_extension$(libsql_feature) $(rs_build_flags)
cp $(rs_lib_static) $(rs_lib_static_cpy)

$(rs_lib_loadable_cpy): FORCE write_sha $(prefix)
$(rs_lib_loadable_cpy): export CRSQLITE_COMMIT_SHA = $(shell git rev-parse HEAD)
$(rs_lib_loadable_cpy): FORCE $(prefix)
cd ./rs/$(bundle) && cargo $(rs_ndk) build $(RS_TARGET) --release --features loadable_extension$(libsql_feature) $(rs_build_flags)
cp $(rs_lib_loadable) $(rs_lib_loadable_cpy)

$(rs_lib_dbg_loadable_cpy): FORCE write_sha $(dbg_prefix)
$(rs_lib_dbg_loadable_cpy): export CRSQLITE_COMMIT_SHA = $(shell git rev-parse HEAD)
$(rs_lib_dbg_loadable_cpy): FORCE $(dbg_prefix)
cd ./rs/$(bundle) && cargo rustc $(RS_TARGET) --features loadable_extension$(libsql_feature) $(rs_build_flags)
cp $(rs_lib_dbg_loadable) $(rs_lib_dbg_loadable_cpy)

Expand Down Expand Up @@ -281,8 +284,3 @@ $(TARGET_FUZZ): $(prefix) $(TARGET_SQLITE3_EXTRA_C) src/fuzzer.cc $(ext_files)
ubsan analyzer fuzz asan static

FORCE: ;

write_sha:
@COMMIT_SHA=`git rev-parse HEAD` && \
sed -i.bak "s/\"[^\"]*\"/\"$$COMMIT_SHA\"/" ./rs/core/src/sha.rs && \
rm -f ./rs/core/src/sha.rs.bak
2 changes: 1 addition & 1 deletion core/rs/core/src/sha.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// The sha of the commit that this version of crsqlite was built from.
pub const SHA: &'static str = "da2e95270d76818cd487029ad3786e9463fa341b";
pub const SHA: &'static str = core::env!("CRSQLITE_COMMIT_SHA");