Skip to content

Commit 27ccb5f

Browse files
committed
Exclude unused frameworks
1 parent a7a88cc commit 27ccb5f

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

op-sqlite.podspec

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,35 @@ log_message = lambda do |message|
55
puts "\e[34m#{message}\e[0m"
66
end
77

8+
# In the sample app the dir is not inside of node_modules
89
is_user_app = __dir__.include?("node_modules")
910
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
10-
parent_folder_name = File.basename(__dir__)
1111
app_package = nil
1212
package_json_path = nil
1313

1414
# When installed on user node_modules lives inside node_modules/@op-engineering/op-sqlite
15+
# Find the users package.json by searching up through parent directories
1516
if is_user_app
16-
current_dir = File.expand_path(__dir__)
17-
# Move one level up to the parent directory
18-
current_dir = File.dirname(current_dir)
17+
current_dir = File.dirname(File.expand_path(__dir__))
1918

20-
# Find the package.json by searching up through parent directories
2119
loop do
2220
package_path = File.join(current_dir, "package.json")
2321
if File.exist?(package_path)
2422
package_json_path = package_path
2523
break
2624
end
2725

28-
parent_dir = File.dirname(current_dir)
29-
break if parent_dir == current_dir # reached filesystem root
26+
break if File.dirname(current_dir) == current_dir # reached filesystem root
3027
current_dir = parent_dir
3128
end
3229

33-
raise "package.json not found" if package_json_path.nil?
34-
35-
app_package = JSON.parse(File.read(package_json_path))
30+
raise "package.json not found? It's needed to read any op-sqlite config (if available)" if package_json_path.nil?
3631
else
37-
# When running on the example app
3832
package_json_path = File.join(__dir__, "example", "package.json")
39-
app_package = JSON.parse(File.read(File.join(__dir__, "example", "package.json")))
4033
end
4134

35+
app_package = JSON.parse(File.read(package_json_path))
36+
4237
op_sqlite_config = app_package["op-sqlite"]
4338
use_sqlcipher = false
4439
use_crsqlite = false
@@ -127,15 +122,24 @@ Pod::Spec.new do |s|
127122

128123
if use_sqlcipher then
129124
log_message.call("[OP-SQLITE] using SQLCipher")
130-
exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h", "cpp/libsql/bridge.cpp", "cpp/libsql/libsql.h"]
125+
exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h", "cpp/libsql/bridge.cpp", "cpp/libsql/libsql.h", "ios/libsql.xcframework/**/*"]
131126
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_SQLCIPHER=1 HAVE_FULLFSYNC=1 SQLITE_HAS_CODEC SQLITE_TEMP_STORE=3 SQLITE_EXTRA_INIT=sqlcipher_extra_init SQLITE_EXTRA_SHUTDOWN=sqlcipher_extra_shutdown"
132127
s.dependency "OpenSSL-Universal"
133128
elsif use_libsql then
134129
log_message.call("[OP-SQLITE] using libsql. Please contact turso (via Discord) for libsql issues")
135130
exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/bridge.h", "cpp/bridge.cpp"]
136131
else
137-
log_message.call("[OP-SQLITE] using pure SQLite from CocoaPods with performance optimizations")
138-
exclude_files += ["cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h", "cpp/libsql/bridge.cpp", "cpp/libsql/libsql.h"]
132+
log_message.call("[OP-SQLITE] using pure SQLite")
133+
exclude_files += ["cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h", "cpp/libsql/bridge.cpp", "cpp/libsql/libsql.h", "ios/libsql.xcframework/**/*"]
134+
end
135+
136+
# Exclude xcframeworks that aren't being used
137+
if !use_crsqlite then
138+
exclude_files += ["ios/crsqlite.xcframework/**/*"]
139+
end
140+
141+
if !use_sqlite_vec then
142+
exclude_files += ["ios/sqlitevec.xcframework/**/*"]
139143
end
140144

141145
other_cflags = '$(inherited) -DSQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION=1 -DHAVE_USLEEP=1 -DSQLITE_ENABLE_LOCKING_STYLE=0'

0 commit comments

Comments
 (0)