Skip to content

Commit

Permalink
use commit sha from env and prevent file being replaced every new commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn authored and tantaman committed Jan 3, 2024
1 parent df9c3b4 commit fb366be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
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");

0 comments on commit fb366be

Please sign in to comment.