build without lipo merging, comapt with openssl3
This commit is contained in:
parent
d7c2f45edd
commit
4c0d4d0e7e
5 changed files with 28 additions and 34 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,6 +1,3 @@
|
||||||
[submodule "lipo-dir-merge"]
|
|
||||||
path = lipo-dir-merge
|
|
||||||
url = https://github.com/faaxm/lipo-dir-merge.git
|
|
||||||
[submodule "sqlcipher"]
|
[submodule "sqlcipher"]
|
||||||
path = sqlcipher
|
path = sqlcipher
|
||||||
url = https://github.com/sqlcipher/sqlcipher.git
|
url = https://github.com/sqlcipher/sqlcipher.git
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ include LICENSE
|
||||||
include setup.py
|
include setup.py
|
||||||
recursive-include src *.h
|
recursive-include src *.h
|
||||||
recursive-include src *.c
|
recursive-include src *.c
|
||||||
include lipo-dir-merge/*.py
|
|
||||||
include conanfile.py
|
include conanfile.py
|
||||||
|
|
||||||
global-exclude *~ *.pyc
|
global-exclude *~ *.pyc
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,4 @@ from conan import ConanFile
|
||||||
class OpensslRecipe(ConanFile):
|
class OpensslRecipe(ConanFile):
|
||||||
def requirements(self):
|
def requirements(self):
|
||||||
self.requires("openssl/1.1.1w")
|
self.requires("openssl/1.1.1w")
|
||||||
|
# self.requires("openssl/3.2.1")
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 45fb925fd44345986696f5f901ee1eafdaddd260
|
|
||||||
54
setup.py
54
setup.py
|
|
@ -22,6 +22,7 @@ CONAN_ARCHS = {
|
||||||
# define sqlite sources
|
# define sqlite sources
|
||||||
sources = glob("src/*.c") + ["src/sqlcipher/sqlite3.c"]
|
sources = glob("src/*.c") + ["src/sqlcipher/sqlite3.c"]
|
||||||
|
|
||||||
|
library_dirs = []
|
||||||
include_dirs = ["./src"]
|
include_dirs = ["./src"]
|
||||||
|
|
||||||
# Work around clang raising hard error for unused arguments
|
# Work around clang raising hard error for unused arguments
|
||||||
|
|
@ -54,7 +55,7 @@ def get_arch() -> str:
|
||||||
def install_openssl(arch: str) -> dict:
|
def install_openssl(arch: str) -> dict:
|
||||||
"""Install openssl using Conan.
|
"""Install openssl using Conan.
|
||||||
"""
|
"""
|
||||||
settings = []
|
settings: list[str] = []
|
||||||
|
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
settings.append("os=Windows")
|
settings.append("os=Windows")
|
||||||
|
|
@ -90,13 +91,25 @@ def install_openssl(arch: str) -> dict:
|
||||||
|
|
||||||
return conan_info
|
return conan_info
|
||||||
|
|
||||||
def fetch_openssl_dir(conan_info: dict) -> str:
|
def add_deps(conan_info: dict, library_dirs: list, include_dirs: list):
|
||||||
"""Find directory of openssl.
|
"""Find directories of dependencies.
|
||||||
"""
|
"""
|
||||||
for dep in conan_info["graph"]["nodes"].values():
|
for dep in conan_info["graph"]["nodes"].values():
|
||||||
if dep.get("name") == "openssl":
|
package_folder = dep.get("package_folder")
|
||||||
return dep.get("package_folder")
|
if package_folder is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
library_dirs.append(os.path.join(package_folder, "lib"))
|
||||||
|
include_dirs.append(os.path.join(package_folder, "include"))
|
||||||
|
|
||||||
|
def check_zlib_required(conan_info: dict) -> bool:
|
||||||
|
"""Check if zlib is required (openssl3)
|
||||||
|
"""
|
||||||
|
for dep in conan_info["graph"]["nodes"].values():
|
||||||
|
if dep.get("name") == "zlib":
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def quote_argument(arg):
|
def quote_argument(arg):
|
||||||
q = '\\"' if sys.platform == "win32" and sys.version_info < (3, 7) else '"'
|
q = '\\"' if sys.platform == "win32" and sys.version_info < (3, 7) else '"'
|
||||||
|
|
@ -124,36 +137,19 @@ define_macros = [
|
||||||
# Additional nice-to-have.
|
# Additional nice-to-have.
|
||||||
("SQLITE_DEFAULT_PAGE_SIZE", "4096"),
|
("SQLITE_DEFAULT_PAGE_SIZE", "4096"),
|
||||||
("SQLITE_DEFAULT_CACHE_SIZE", "-8000"),
|
("SQLITE_DEFAULT_CACHE_SIZE", "-8000"),
|
||||||
|
("inline", "__inline"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Configure the compiler
|
||||||
arch = get_arch()
|
arch = get_arch()
|
||||||
if arch == "universal2":
|
if arch == "universal2":
|
||||||
conan_info_x64 = install_openssl("x86_64")
|
conan_info_x64 = install_openssl("x86_64")
|
||||||
openssl_dir_x64 = fetch_openssl_dir(conan_info_x64)
|
add_deps(conan_info_x64, library_dirs, include_dirs)
|
||||||
conan_info_arm = install_openssl("armv8")
|
conan_info_arm = install_openssl("armv8")
|
||||||
openssl_dir_arm = fetch_openssl_dir(conan_info_arm)
|
add_deps(conan_info_arm, library_dirs, include_dirs)
|
||||||
openssl_dir_universal2 = openssl_dir_arm.replace("armv8", "universal2")
|
|
||||||
subprocess.run(
|
|
||||||
[
|
|
||||||
"python3",
|
|
||||||
"./lipo-dir-merge/lipo-dir-merge.py",
|
|
||||||
openssl_dir_x64,
|
|
||||||
openssl_dir_arm,
|
|
||||||
openssl_dir_universal2
|
|
||||||
]
|
|
||||||
)
|
|
||||||
shutil.rmtree(openssl_dir_x64)
|
|
||||||
shutil.move(openssl_dir_universal2, openssl_dir_x64)
|
|
||||||
openssl_dir = openssl_dir_x64
|
|
||||||
else:
|
else:
|
||||||
conan_info = install_openssl(arch)
|
conan_info = install_openssl(arch)
|
||||||
openssl_dir = fetch_openssl_dir(conan_info)
|
add_deps(conan_info, library_dirs, include_dirs)
|
||||||
|
|
||||||
openssl_lib_path = os.path.join(openssl_dir, "lib")
|
|
||||||
|
|
||||||
# Configure the compiler
|
|
||||||
include_dirs.append(os.path.join(openssl_dir, "include"))
|
|
||||||
define_macros.append(("inline", "__inline"))
|
|
||||||
|
|
||||||
# Configure the linker
|
# Configure the linker
|
||||||
extra_link_args = []
|
extra_link_args = []
|
||||||
|
|
@ -164,6 +160,8 @@ if sys.platform == "win32":
|
||||||
extra_link_args.append("ADVAPI32.LIB")
|
extra_link_args.append("ADVAPI32.LIB")
|
||||||
extra_link_args.append("CRYPT32.LIB")
|
extra_link_args.append("CRYPT32.LIB")
|
||||||
extra_link_args.append("USER32.LIB")
|
extra_link_args.append("USER32.LIB")
|
||||||
|
if check_zlib_required(conan_info):
|
||||||
|
extra_link_args.append("zlib.lib")
|
||||||
extra_link_args.append("libcrypto.lib")
|
extra_link_args.append("libcrypto.lib")
|
||||||
else:
|
else:
|
||||||
# Include math library, required for fts5, and crypto.
|
# Include math library, required for fts5, and crypto.
|
||||||
|
|
@ -173,7 +171,7 @@ module = Extension(
|
||||||
name="sqlcipher3._sqlite3",
|
name="sqlcipher3._sqlite3",
|
||||||
sources=sources,
|
sources=sources,
|
||||||
define_macros=define_macros,
|
define_macros=define_macros,
|
||||||
library_dirs=[openssl_lib_path],
|
library_dirs=library_dirs,
|
||||||
include_dirs=include_dirs,
|
include_dirs=include_dirs,
|
||||||
extra_link_args=extra_link_args,
|
extra_link_args=extra_link_args,
|
||||||
language="c",
|
language="c",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue