Skip to content

Conversation

@levydsa
Copy link
Contributor

@levydsa levydsa commented Jan 10, 2025

Build scripts shouldn't write to anything but OUT_DIR. So, instead of copying sqlite3.c to sqlite3mc in source, copy it to OUT_DIR and build from there.

https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script

Build scripts may save any output files or intermediate artifacts in the directory specified in the OUT_DIR environment variable. Scripts should not modify any files outside of that directory.

On some environments, Nix derivations, the permissions of source files are limited, and get copied over using the standard fs::copy. To prevent this, cp --no-preserve=mode,ownership is needed. Inside a Nix derivation, some coreutils are overridden and this is fine to use even on a MacOS device. To make this more reliable, if the cp command fails, do a normal copy with fs functions.

Some CMake configuration was added to allow cross-compilation of sqlite3mc for more targets.

@levydsa
Copy link
Contributor Author

levydsa commented Jan 10, 2025

The copy_with_cp name is a bit misleading, but should be fine. Maybe changing it to just copy is better?

@levydsa levydsa force-pushed the fix_cross_mac branch 2 times, most recently from b94cac7 to 41ca300 Compare February 14, 2025 18:13
@penberg
Copy link
Collaborator

penberg commented Mar 18, 2025

Hey @levydsa, I opened a draft pull request to update libsql-js.git to this, which is a good test if build breaks on some platform: tursodatabase/libsql-js#173

@penberg penberg changed the title Fix cross compilation and build for sandboxes enviroments. Fix cross compilation and build for sandboxes enviroments Mar 18, 2025
@penberg penberg added this pull request to the merge queue Mar 18, 2025
Merged via the queue into tursodatabase:main with commit b3f2a1d Mar 18, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants