Building SQLPage with customized SQLite #477
pchemguy
started this conversation in
Show and tell
Replies: 2 comments
-
I have never tried it myself, but I think you can do this more easily using the |
Beta Was this translation helpful? Give feedback.
0 replies
-
I see. Well, I still need to read Rust docs. I have never used before SQLPage. I am planning to read the docs sometime. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Some time ago, I played quite a bit with the SQLite build system, developing a few custom scripts. Naturally, I was curious to see how difficult it would be to hack into the SQLPage build process to integrate custom SQLite builds. It took me a few days, as I had no previous experience with Rust and its toolchain. But it does work now.
Briefly, SQLPage uses the sqlx-oldapi package that, in turn, talks to database-specific Rust bindings. For SQLite, sqlx-oldapi uses rusqlite bindings, and its component, libsqlite3-sys. libsqlite3-sys includes a copy of SQLite amalgamation, and depending on the build configuration, can integrate binaries built from these sources or link to a standalone SQLite binary (for more details, see this SO question). Because libsqlite3-sys is a build dependency for sqlx-oldapi, which is a dependency for SQLPage, as far as I can tell, there is no way to control the libsqlite3-sys build process via the command line. At the same time, I would not want to mess with build files.
A hack, which I came up with, follows a different approach and is briefly described in an answer to the mentioned SO question. (The described procedure is specific to the MSVC toolchain, though similar options might be available with other tools as well.) First of all. I figured out the location of the particular SQLite amalgamation file in the local cargo/crate cache. This file can be replaced with a custom copy before building. Luckily, there are no integrity control features, which could complicate the process. The second important part was to figure out how to pass the necessary compiler/linker options when using the regular
cargo build
initiated process. This task was possible via MSVC-specific environment variables. The final piece of the puzzle was to copy the dll dependencies (when SQLite was dynamically linked to third-party libraries, such as zlib and ICU, installed in non-system locations not in the system path) not only to the directory containing the SQLPage executable but also to the directory containing intermediately built dependencies (and the latter needed to be done before starting the build process). And because I already used a specialized script to build custom SQLite binaries (by hacking into the SQLite build process :) ), I just added a section that automated all three tasks.Beta Was this translation helpful? Give feedback.
All reactions