Skip to content

Instantly share code, notes, and snippets.

@Wevah
Last active April 20, 2021 23:55
Show Gist options
  • Save Wevah/2188ee165aa9edee22f5e100d1523021 to your computer and use it in GitHub Desktop.
Save Wevah/2188ee165aa9edee22f5e100d1523021 to your computer and use it in GitHub Desktop.
Build an SQLite dylib from an amalgamation directory, automatically parsing out the version
#!/usr/bin/env perl
# Run from inside an SQLite amalgamation directory
# (i.e., extracted from an amalgamation archive).
use warnings;
use strict;
use Cwd;
my $macosxminversion = "10.12";
my ($dir) = getcwd() =~ m#([^/]+)$#;
if (my ($major, $minor, $patch) = $dir =~ m#sqlite-amalgamation-(\d)(\d{2})(\d{2})#) {
$major = int($major);
$minor = int($minor);
$patch = int($patch);
my $version = "$major.$minor.$patch";
print "SQLite version $version\n";
my @args = ('clang', '-dynamiclib', '-Os',
'-arch', 'x86_64',
'-arch', 'arm64',
"-Wl,-install_name,\@rpath/libsqlite3.dylib,-current_version,$version,-compatibility_version,$major",
"-mmacosx-version-min=$macosxminversion",
'-o', 'libsqlite3.dylib',
'sqlite3.c');
system(@args);
} else {
print qq("$dir" is not an SQLite amalgamation directory.\n)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment