forked from OP-Engineering/op-sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
op-sqlite.podspec
159 lines (132 loc) · 5.78 KB
/
op-sqlite.podspec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
require "json"
log_message = lambda do |message|
puts "\e[34m#{message}\e[0m"
end
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
parent_folder_name = File.basename(__dir__)
app_package = nil
# for development purposes on user machines the podspec should be able to read the package.json from the root folder
# since it lives inside node_modules/@op-engineering/op-sqlite
if __dir__.include?("node_modules")
app_package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "package.json")))
else
app_package = JSON.parse(File.read(File.join(__dir__, "example", "package.json")))
end
op_sqlite_config = app_package["op-sqlite"]
use_sqlcipher = false
use_crsqlite = false
use_libsql = false
performance_mode = "0"
phone_version = false
sqlite_flags = ""
fts5 = false
use_sqlite_vec = false
if(op_sqlite_config != nil)
use_sqlcipher = op_sqlite_config["sqlcipher"] == true
use_crsqlite = op_sqlite_config["crsqlite"] == true
use_libsql = op_sqlite_config["libsql"] == true
performance_mode = op_sqlite_config["performanceMode"] || "0"
phone_version = op_sqlite_config["iosSqlite"] == true
sqlite_flags = op_sqlite_config["sqliteFlags"] || ""
fts5 = op_sqlite_config["fts5"] == true
use_sqlite_vec = op_sqlite_config["sqliteVec"] == true
end
if phone_version && use_sqlcipher
raise "Cannot use phone embedded version and SQLCipher. SQLCipher needs to be compiled from sources with the project."
end
Pod::Spec.new do |s|
s.name = "op-sqlite"
s.version = package["version"]
s.summary = package["description"]
s.homepage = package["homepage"]
s.license = package["license"]
s.authors = package["author"]
s.platforms = { :ios => "13.0", :osx => "10.15", :visionos => "1.0" }
s.source = { :git => "https://github.com/op-engineering/op-sqlite.git", :tag => "#{s.version}" }
s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{h,cpp,c}"
xcconfig = {
:GCC_PREPROCESSOR_DEFINITIONS => "HAVE_FULLFSYNC=1",
:WARNING_CFLAGS => "-Wno-shorten-64-to-32 -Wno-comma -Wno-unreachable-code -Wno-conditional-uninitialized -Wno-deprecated-declarations",
:USE_HEADERMAP => "No",
:CLANG_CXX_LANGUAGE_STANDARD => "c++17",
}
log_message.call("[OP-SQLITE] Configuration:")
if use_sqlcipher then
log_message.call("[OP-SQLITE] using SQLCipher 🔒")
s.exclude_files = "cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h"
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_SQLCIPHER=1 HAVE_FULLFSYNC=1 SQLITE_HAS_CODEC SQLITE_TEMP_STORE=2"
s.dependency "OpenSSL-Universal"
elsif use_libsql then
log_message.call("[OP-SQLITE] using libsql 📘")
s.exclude_files = "cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/bridge.h", "cpp/bridge.cpp"
else
log_message.call("[OP-SQLITE] using vanilla SQLite 📦")
s.exclude_files = "cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h"
end
s.dependency "React-callinvoker"
s.dependency "React"
if fabric_enabled then
install_modules_dependencies(s)
else
s.dependency "React-Core"
end
other_cflags = '-DSQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION=1'
optimizedCflags = other_cflags + '$(inherited) -DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DEPRECATED=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 -DSQLITE_OMIT_SHARED_CACHE=1 -DSQLITE_USE_ALLOCA=1'
frameworks = []
if fts5 && !phone_version then
log_message.call("[OP-SQLITE] FTS5 enabled 🔎")
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " SQLITE_ENABLE_FTS5=1"
end
if phone_version then
if use_sqlcipher then
raise "SQLCipher is not supported with phone version"
end
if use_crsqlite then
raise "CRSQLite is not supported with phone version"
end
if fts5 then
raise "FTS5 is not supported with phone version"
end
log_message.call("[OP-SQLITE] using iOS embedded SQLite 📱")
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_PHONE_VERSION=1"
s.exclude_files = "cpp/sqlite3.c", "cpp/sqlite3.h"
s.library = "sqlite3"
end
if performance_mode == '1' then
log_message.call("[OP-SQLITE] Thread unsafe (1) performance mode enabled. Use only transactions! 🚀🚀")
xcconfig[:OTHER_CFLAGS] = optimizedCflags + ' -DSQLITE_THREADSAFE=0 '
end
if performance_mode == '2' then
log_message.call("[OP-SQLITE] Thread safe (2) performance mode enabled 🚀")
xcconfig[:OTHER_CFLAGS] = optimizedCflags + ' -DSQLITE_THREADSAFE=1 '
end
if use_crsqlite then
log_message.call("[OP-SQLITE] using CRQSQLite 🤖")
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_CRSQLITE=1"
frameworks.push("ios/crsqlite.xcframework")
end
if use_sqlite_vec then
log_message.call("[OP-SQLITE] using Sqlite Vec ↗️")
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_SQLITE_VEC=1"
frameworks.push("ios/sqlitevec.xcframework")
end
if use_libsql then
if use_sqlcipher then
raise "Cannot use SQLCipher and libsql at the same time"
end
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_LIBSQL=1"
if use_crsqlite then
frameworks = ["ios/libsql.xcframework", "ios/crsqlite.xcframework"]
else
frameworks = ["ios/libsql.xcframework"]
end
end
if sqlite_flags != "" then
log_message.call("[OP-SQLITE] Custom SQLite flags: #{sqlite_flags}")
xcconfig[:OTHER_CFLAGS] += " #{sqlite_flags}"
end
s.pod_target_xcconfig = xcconfig
s.vendored_frameworks = frameworks
end