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

ext: smarter sqlcipher config params, and a user help message #330

Merged
merged 2 commits into from
Aug 9, 2022
Merged
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
84 changes: 83 additions & 1 deletion ext/sqlite3/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def libname
end

def sqlcipher?
with_config("sqlcipher")
with_config("sqlcipher") ||
with_config("sqlcipher-dir") ||
with_config("sqlcipher-include") ||
with_config("sqlcipher-lib")
end

def configure_system_libraries
Expand Down Expand Up @@ -147,10 +150,89 @@ def cross_build?
def download
minimal_recipe.download
end

def print_help
print(<<~TEXT)
USAGE: ruby #{$PROGRAM_NAME} [options]

Flags that are always valid:

--disable-system-libraries
Use the packaged libraries, and ignore the system libraries.
(This is the default behavior.)

--enable-system-libraries
Use system libraries instead of building and using the packaged libraries.

--with-sqlcipher
Use libsqlcipher instead of libsqlite3.
(Implies `--enable-system-libraries`.)

--help
Display this message.


Flags only used when using system libraries:

General (applying to all system libraries):

--with-opt-dir=DIRECTORY
Look for headers and libraries in DIRECTORY.

--with-opt-lib=DIRECTORY
Look for libraries in DIRECTORY.

--with-opt-include=DIRECTORY
Look for headers in DIRECTORY.

Related to sqlcipher:

--with-sqlcipher-dir=DIRECTORY
Look for sqlcipher headers and library in DIRECTORY.
(Implies `--with-sqlcipher` and `--enable-system-libraries`.)

--with-sqlcipher-lib=DIRECTORY
Look for sqlcipher library in DIRECTORY.
(Implies `--with-sqlcipher` and `--enable-system-libraries`.)

--with-sqlcipher-include=DIRECTORY
Look for sqlcipher headers in DIRECTORY.
(Implies `--with-sqlcipher` and `--enable-system-libraries`.)


Flags only used when building and using the packaged libraries:

--enable-cross-build
Enable cross-build mode. (You probably do not want to set this manually.)


Environment variables used for compiling the C extension:

CC
Use this path to invoke the compiler instead of `RbConfig::CONFIG['CC']`


Environment variables passed through to the compilation of packaged libraries:

CC
CPPFLAGS
CFLAGS
LDFLAGS
LIBS
LT_SYS_LIBRARY_PATH
CPP

TEXT
end
end
end
end

if arg_config("--help")
Sqlite3::ExtConf.print_help
exit!(0)
end

if arg_config("--download-dependencies")
Sqlite3::ExtConf.download
exit!(0)
Expand Down