77ENV [ "CC" ] = RbConfig ::CONFIG [ "CC" ]
88
99cross_build_p = enable_config ( "cross-build" )
10-
11- MiniPortile . new ( "sqlite3" , "3.38.5" ) . tap do |recipe |
12- # checksum verified by first checking the published sha3(256) checksum:
13- #
14- # $ sha3sum -a 256 sqlite-autoconf-3380500.tar.gz
15- # ab649fea76f49a6ec7f907f001d87b8bd76dec0679c783e3992284c5a882a98c sqlite-autoconf-3380500.tar.gz
16- # $ sha256sum sqlite-autoconf-3380500.tar.gz
17- # 5af07de982ba658fd91a03170c945f99c971f6955bc79df3266544373e39869c sqlite-autoconf-3380500.tar.gz
18- #
19- recipe . files = [ {
20- url : "https://www.sqlite.org/2022/sqlite-autoconf-3380500.tar.gz" ,
21- sha256 : "5af07de982ba658fd91a03170c945f99c971f6955bc79df3266544373e39869c" ,
22- } ]
23- recipe . target = File . join ( package_root_dir , "ports" )
24- recipe . patch_files = Dir [ File . join ( package_root_dir , "patches" , "*.patch" ) ] . sort
25-
26- recipe . configure_options += [ "--enable-shared=no" , "--enable-static=yes" ]
27- ENV . to_h . tap do |env |
28- env [ "CFLAGS" ] = [ env [ "CFLAGS" ] , "-fPIC" ] . join ( " " ) # needed for linking the static library into a shared library
29- recipe . configure_options += env
30- . select { |k , v | [ "CC" , "CFLAGS" , "LDFLAGS" , "LIBS" , "CPPFLAGS" , "LT_SYS_LIBRARY_PATH" , "CPP" ] . include? ( k ) }
31- . map { |key , value | "#{ key } =#{ value . strip } " }
32- end
33-
34- unless File . exist? ( File . join ( recipe . target , recipe . host , recipe . name , recipe . version ) )
35- recipe . cook
36- end
37- recipe . activate
38-
39- ENV [ "PKG_CONFIG_ALLOW_SYSTEM_CFLAGS" ] = "t" # on macos, pkg-config will not return --cflags without this
40- pcfile = File . join ( recipe . path , "lib" , "pkgconfig" , "sqlite3.pc" )
41- if pkg_config ( pcfile )
42- # see https://bugs.ruby-lang.org/issues/18490
43- libs = xpopen ( [ "pkg-config" , "--libs" , "--static" , pcfile ] , err : [ :child , :out ] , &:read )
44- libs . split . each { |lib | append_ldflags ( lib ) } if $?. success?
45- else
46- message ( "Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n " )
10+ system_libraries_p = enable_config ( "system-libraries" )
11+ sqlcipher_p = with_config ( "sqlcipher" )
12+
13+ if system_libraries_p
14+ # if sqlcipher_p # TODO test and document this
15+ # message "Building sqlite3-ruby using system sqlcipher.\n"
16+ # pkg_config("sqlcipher") # TODO test and document this
17+ # else
18+ message "Building sqlite3-ruby using system sqlite3.\n "
19+ pkg_config ( "sqlite3" ) # TODO document
20+ # end
21+ else
22+ message "Building sqlite3-ruby using packaged sqlite3.\n "
23+ MiniPortile . new ( "sqlite3" , "3.38.5" ) . tap do |recipe |
24+ # checksum verified by first checking the published sha3(256) checksum:
25+ #
26+ # $ sha3sum -a 256 sqlite-autoconf-3380500.tar.gz
27+ # ab649fea76f49a6ec7f907f001d87b8bd76dec0679c783e3992284c5a882a98c sqlite-autoconf-3380500.tar.gz
28+ # $ sha256sum sqlite-autoconf-3380500.tar.gz
29+ # 5af07de982ba658fd91a03170c945f99c971f6955bc79df3266544373e39869c sqlite-autoconf-3380500.tar.gz
30+ #
31+ recipe . files = [ {
32+ url : "https://www.sqlite.org/2022/sqlite-autoconf-3380500.tar.gz" ,
33+ sha256 : "5af07de982ba658fd91a03170c945f99c971f6955bc79df3266544373e39869c" ,
34+ } ]
35+ recipe . target = File . join ( package_root_dir , "ports" )
36+ recipe . patch_files = Dir [ File . join ( package_root_dir , "patches" , "*.patch" ) ] . sort
37+
38+ recipe . configure_options += [ "--enable-shared=no" , "--enable-static=yes" ]
39+ ENV . to_h . tap do |env |
40+ env [ "CFLAGS" ] = [ env [ "CFLAGS" ] , "-fPIC" ] . join ( " " ) # needed for linking the static library into a shared library
41+ recipe . configure_options += env
42+ . select { |k , v | [ "CC" , "CFLAGS" , "LDFLAGS" , "LIBS" , "CPPFLAGS" , "LT_SYS_LIBRARY_PATH" , "CPP" ] . include? ( k ) }
43+ . map { |key , value | "#{ key } =#{ value . strip } " }
44+ end
45+
46+ unless File . exist? ( File . join ( recipe . target , recipe . host , recipe . name , recipe . version ) )
47+ recipe . cook
48+ end
49+ recipe . activate
50+
51+ ENV [ "PKG_CONFIG_ALLOW_SYSTEM_CFLAGS" ] = "t" # on macos, pkg-config will not return --cflags without this
52+ pcfile = File . join ( recipe . path , "lib" , "pkgconfig" , "sqlite3.pc" )
53+ if pkg_config ( pcfile )
54+ # see https://bugs.ruby-lang.org/issues/18490
55+ libs = xpopen ( [ "pkg-config" , "--libs" , "--static" , pcfile ] , err : [ :child , :out ] , &:read )
56+ libs . split . each { |lib | append_ldflags ( lib ) } if $?. success?
57+ else
58+ message ( "Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n " )
59+ end
4760 end
4861end
4962
50- # ldflags = cppflags = nil
51- # if RbConfig::CONFIG["host_os"] =~ /darwin/
52- # begin
53- # if with_config('sqlcipher')
54- # brew_prefix = `brew --prefix sqlcipher`.chomp
55- # ldflags = "#{brew_prefix}/lib"
56- # cppflags = "#{brew_prefix}/include/sqlcipher"
57- # pkg_conf = "#{brew_prefix}/lib/pkgconfig"
58- # else
59- # brew_prefix = `brew --prefix sqlite3`.chomp
60- # ldflags = "#{brew_prefix}/lib"
61- # cppflags = "#{brew_prefix}/include"
62- # pkg_conf = "#{brew_prefix}/lib/pkgconfig"
63- # end
64-
65- # # pkg_config should be less error prone than parsing compiler
66- # # commandline options, but we need to set default ldflags and cpp flags
67- # # in case the user doesn't have pkg-config installed
68- # ENV['PKG_CONFIG_PATH'] ||= pkg_conf
69- # rescue
70- # end
71- # end
72-
73- # if with_config('sqlcipher')
74- # pkg_config("sqlcipher")
75- # else
76- # pkg_config("sqlite3")
77- # end
78-
79- # # --with-sqlite3-{dir,include,lib}
80- # if with_config('sqlcipher')
81- # $CFLAGS << ' -DUSING_SQLCIPHER'
82- # dir_config("sqlcipher", cppflags, ldflags)
83- # else
84- # dir_config("sqlite3", cppflags, ldflags)
85- # end
86-
8763# if RbConfig::CONFIG["host_os"] =~ /mswin/
8864# $CFLAGS << ' -W3'
8965# end
9066
9167append_cflags ( "-DTAINTING_SUPPORT" ) if Gem ::Requirement . new ( "< 2.7" ) . satisfied_by? ( Gem ::Version . new ( RUBY_VERSION ) )
9268
93- def asplode missing
69+ def abort_could_not_find_library ( missing )
9470 if RUBY_PLATFORM =~ /mingw|mswin/
9571 abort "#{ missing } is missing. Install SQLite3 from " +
9672 "http://www.sqlite.org/ first."
@@ -104,13 +80,14 @@ def asplode missing
10480 end
10581end
10682
107- asplode ( 'sqlite3.h' ) unless find_header 'sqlite3.h'
83+ abort_could_not_find_library ( 'sqlite3.h' ) unless find_header 'sqlite3.h'
10884
10985# TODO sqlcipher support
11086# if with_config('sqlcipher')
111- # asplode('sqlcipher') unless find_library 'sqlcipher', 'sqlite3_libversion_number'
87+ # append_cflags("-DUSING_SQLCIPHER")
88+ # abort_could_not_find_library('sqlcipher') unless find_library 'sqlcipher', 'sqlite3_libversion_number'
11289# else
113- asplode ( 'sqlite3' ) unless find_library ( "sqlite3" , "sqlite3_libversion_number" , "sqlite3.h" )
90+ abort_could_not_find_library ( 'sqlite3' ) unless find_library ( "sqlite3" , "sqlite3_libversion_number" , "sqlite3.h" )
11491# end
11592
11693# Functions defined in 1.9 but not 1.8
0 commit comments