mirror of
https://github.com/ONLYOFFICE/build_tools.git
synced 2026-02-10 20:45:38 +08:00
Refactoring sysroots
This commit is contained in:
@ -691,13 +691,19 @@ def git_dir():
|
||||
if ("windows" == host_platform()):
|
||||
return run_command("git --info-path")['stdout'] + "/../../.."
|
||||
|
||||
def get_prefix_cross_compiler_arm64():
|
||||
directory = config.option("arm64-toolchain-bin")
|
||||
if is_file(directory + "/aarch64-linux-gnu-g++") and is_file(directory + "/aarch64-linux-gnu-gcc"):
|
||||
return "aarch64-linux-gnu-"
|
||||
if is_file(directory + "/aarch64-unknown-linux-gnu-g++") and is_file(directory + "/aarch64-unknown-linux-gnu-gcc"):
|
||||
return "aarch64-unknown-linux-gnu-"
|
||||
return ""
|
||||
def get_compiler_gcc_prefix(platform):
|
||||
directory = "/usr/bin"
|
||||
|
||||
if config.option("sysroot") != "":
|
||||
use_platform = platform
|
||||
if ("linux_arm64" == platform and not is_os_arm()):
|
||||
use_platform = "linux_64"
|
||||
directory = config.option("sysroot_" + use_platform) + "/usr/bin"
|
||||
|
||||
if ("linux_arm64" == platform and not is_os_arm()):
|
||||
return directory + "/aarch64-linux-gnu-"
|
||||
|
||||
return directory + "/"
|
||||
|
||||
def get_gcc_version():
|
||||
# if use sysroot - fix gcc version
|
||||
@ -753,13 +759,6 @@ def qt_setup(platform):
|
||||
set_env("QT_QMAKE_ADDON", "-spec win32-arm64-msvc2017")
|
||||
|
||||
set_env("QT_DEPLOY", qt_dir + "/bin")
|
||||
|
||||
if ("linux_arm64" == platform):
|
||||
cross_compiler_arm64 = config.option("arm64-toolchain-bin")
|
||||
if ("" != cross_compiler_arm64):
|
||||
set_env("ARM64_TOOLCHAIN_BIN", cross_compiler_arm64)
|
||||
set_env("ARM64_TOOLCHAIN_BIN_PREFIX", get_prefix_cross_compiler_arm64())
|
||||
|
||||
return qt_dir
|
||||
|
||||
def qt_version():
|
||||
@ -1898,15 +1897,26 @@ def set_sysroot_env(platform):
|
||||
ENV_BEFORE_SYSROOT = dict(os.environ)
|
||||
if "linux" != host_platform():
|
||||
return
|
||||
if config.option("sysroot") == "":
|
||||
return
|
||||
|
||||
path = config.option("sysroot_" + platform)
|
||||
if path != "":
|
||||
os.environ['PATH'] = path + "/usr/bin:" + get_env("PATH")
|
||||
os.environ['LD_LIBRARY_PATH'] = config.get_custom_sysroot_lib(platform)
|
||||
os.environ['CC'] = config.get_custom_sysroot_bin(platform) + "/gcc"
|
||||
os.environ['CXX'] = config.get_custom_sysroot_bin(platform) + "/g++"
|
||||
os.environ['CFLAGS'] = "--sysroot=" + path
|
||||
os.environ['CXXFLAGS'] = "--sysroot=" + path
|
||||
check_python()
|
||||
sysroot_path_bin = config.get_custom_sysroot_bin(platform)
|
||||
compiler_gcc_prefix = get_compiler_gcc_prefix(platform)
|
||||
|
||||
os.environ['PATH'] = sysroot_path_bin + ":" + get_env("PATH")
|
||||
os.environ['LD_LIBRARY_PATH'] = config.get_custom_sysroot_lib(platform)
|
||||
|
||||
os.environ['CC'] = compiler_gcc_prefix + "gcc"
|
||||
os.environ['CXX'] = compiler_gcc_prefix + "g++"
|
||||
os.environ['AR'] = compiler_gcc_prefix + "ar"
|
||||
os.environ['RANLIB'] = compiler_gcc_prefix + "ranlib"
|
||||
|
||||
os.environ['CFLAGS'] = "--sysroot=" + path
|
||||
os.environ['CXXFLAGS'] = "--sysroot=" + path
|
||||
os.environ['LDFLAGS'] = "--sysroot=" + path
|
||||
|
||||
check_python()
|
||||
|
||||
def restore_sysroot_env():
|
||||
os.environ.clear()
|
||||
|
||||
@ -125,11 +125,6 @@ def parse():
|
||||
if not "sdkjs-plugin-server" in options:
|
||||
options["sdkjs-plugin-server"] = "default"
|
||||
|
||||
if not "arm64-toolchain-bin" in options and not "sysroot" in options:
|
||||
options["arm64-toolchain-bin"] = "/usr/bin"
|
||||
else:
|
||||
options["arm64-toolchain-bin"] = get_custom_sysroot_bin("linux_arm64")
|
||||
|
||||
if check_option("platform", "ios"):
|
||||
if not check_option("config", "no_bundle_xcframeworks"):
|
||||
if not check_option("config", "bundle_xcframeworks"):
|
||||
@ -230,12 +225,22 @@ def is_mobile_platform():
|
||||
return False
|
||||
|
||||
def get_custom_sysroot_bin(platform):
|
||||
return option("sysroot_" + platform) + "/usr/bin"
|
||||
use_platform = platform
|
||||
if "linux_arm64" == platform and not base.is_os_arm():
|
||||
# use cross compiler
|
||||
use_platform = "linux_64"
|
||||
|
||||
def get_custom_sysroot_lib(platform):
|
||||
if ("linux_64" == platform):
|
||||
return option("sysroot_" + use_platform) + "/usr/bin"
|
||||
|
||||
def get_custom_sysroot_lib(platform, isNatural=False):
|
||||
use_platform = platform
|
||||
if "linux_arm64" == platform and not base.is_os_arm() and not isNatural:
|
||||
# use cross compiler
|
||||
use_platform = "linux_64"
|
||||
|
||||
if ("linux_64" == use_platform):
|
||||
return option("sysroot_linux_64") + "/usr/lib/x86_64-linux-gnu"
|
||||
if ("linux_arm64" == platform):
|
||||
if ("linux_arm64" == use_platform):
|
||||
return option("sysroot_linux_arm64") + "/usr/lib/aarch64-linux-gnu"
|
||||
return ""
|
||||
|
||||
|
||||
@ -14,16 +14,12 @@ def make(src_dir, modules, build_platform="android", qmake_addon=""):
|
||||
|
||||
print("boost-headers...")
|
||||
|
||||
base.cmd("./bootstrap.sh", ["--with-libraries=system"])
|
||||
# for b2 checks
|
||||
if config.option("sysroot") != "":
|
||||
base.set_sysroot_env(build_platform)
|
||||
sysroot_path = config.option("sysroot_" + build_platform)
|
||||
b2_addon = "cflags=\"--sysroot=" + sysroot_path + "\""
|
||||
b2_addon = "cxxflags=\"--sysroot=" + sysroot_path + "\""
|
||||
b2_addon = "linkflags=\"--sysroot=" + sysroot_path + "\""
|
||||
|
||||
base.cmd("./bootstrap.sh", ["--with-libraries=system"])
|
||||
base.cmd("./b2", ["--prefix=./../build/" + build_platform, "headers", "install", b2_addon])
|
||||
base.cmd("./b2", ["--prefix=./../build/" + build_platform, "headers", "install"])
|
||||
|
||||
if config.option("sysroot") != "":
|
||||
base.restore_sysroot_env()
|
||||
|
||||
@ -21,7 +21,7 @@ def make():
|
||||
os.chdir(base_dir)
|
||||
|
||||
base.check_module_version("2", clear_module)
|
||||
platforms = ["win_64", "win_32", "win_64_xp", "win_32_xp", "linux_64", "linux_32", "mac_64", "mac_arm64", "win_arm64"]
|
||||
platforms = ["win_64", "win_32", "win_64_xp", "win_32_xp", "linux_64", "linux_32", "mac_64", "mac_arm64", "win_arm64", "linux_arm64"]
|
||||
|
||||
for platform in platforms:
|
||||
if not config.check_option("platform", platform):
|
||||
|
||||
@ -26,30 +26,6 @@ LINUX_CUSTOM_SYSROOT_TOOLCHAIN_FILE = base.get_script_dir() + "/../tools/linux/s
|
||||
|
||||
OLD_ENV = dict()
|
||||
|
||||
# get custom sysroot vars as str
|
||||
def setup_custom_sysroot_env(platform) -> str:
|
||||
sysroot_path = config.option("sysroot_" + platform)
|
||||
sysroot_path_bin = config.get_custom_sysroot_bin(platform)
|
||||
|
||||
env_vars = []
|
||||
env_vars += ['LD_LIBRARY_PATH=\"' + config.get_custom_sysroot_lib(platform) + "\""]
|
||||
env_vars += ['PATH=\"' + sysroot_path + "/usr/bin:" + base.get_env("PATH") + "\""]
|
||||
|
||||
env_vars += ['CC=\"' + sysroot_path_bin + "/gcc\""]
|
||||
env_vars += ['CXX=\"' + sysroot_path_bin + "/g++\""]
|
||||
env_vars += ['AR=\"' + sysroot_path_bin + "/ar\""]
|
||||
env_vars += ['RABLIB=\"' + sysroot_path_bin + "/ranlib\""]
|
||||
|
||||
env_vars += ['CFLAGS=\"' + "--sysroot=" + sysroot_path + "\""]
|
||||
env_vars += ['CXXFLAGS=\"' + "--sysroot=" + sysroot_path + "\""]
|
||||
env_vars += ['LDFLAGS=\"' + "--sysroot=" + sysroot_path + "\""]
|
||||
|
||||
env_str = ""
|
||||
for env_var in env_vars:
|
||||
env_str += env_var + " "
|
||||
|
||||
return env_str
|
||||
|
||||
def get_vs_version():
|
||||
vs_version = "14 2015"
|
||||
if config.option("vs-version") == "2019":
|
||||
@ -132,16 +108,20 @@ def build_with_cmake(platform, cmake_args, build_type):
|
||||
cmake_args_ext += get_cmake_args_android("x86_64", "21")
|
||||
|
||||
# env setup for custom sysroot
|
||||
env_str = setup_custom_sysroot_env(platform) if config.option("sysroot") != "" else ""
|
||||
if config.option("sysroot") != "":
|
||||
base.set_sysroot_env("linux_arm64")
|
||||
|
||||
# run cmake
|
||||
base.cmd(env_str + "cmake", cmake_args + cmake_args_ext)
|
||||
base.cmd("cmake", cmake_args + cmake_args_ext)
|
||||
|
||||
# build
|
||||
if "Unix Makefiles" in cmake_args_ext:
|
||||
base.cmd(env_str + "make", ["-j4"])
|
||||
base.cmd("make", ["-j4"])
|
||||
else:
|
||||
base.cmd("cmake", ["--build", ".", "--config", build_type])
|
||||
|
||||
if config.option("sysroot") != "":
|
||||
base.restore_sysroot_env()
|
||||
return
|
||||
|
||||
# general make function that calls `build_func` callback for configured platform(s) with specified cmake arguments
|
||||
|
||||
@ -163,9 +163,11 @@ def make():
|
||||
if config.check_option("platform", "linux_arm64") and not base.is_dir(base_dir + "/linux_arm64") and not base.is_os_arm():
|
||||
base.create_dir(base_dir + "/icu/linux_arm64")
|
||||
os.chdir(base_dir + "/icu/linux_arm64")
|
||||
base_arm_tool_dir = config.option('arm64-toolchain-bin') + '/' + base.get_prefix_cross_compiler_arm64()
|
||||
compiler_gcc_prefix = base.get_compiler_gcc_prefix("linux_arm64")
|
||||
if config.option("sysroot") != "":
|
||||
base.set_sysroot_env("linux_arm64")
|
||||
base.cmd("./../source/configure", ["--host=arm-linux", "--prefix=" + base_dir + "/icu/linux_arm64_install", "--with-cross-build=" + base_dir + "/icu/cross_build",
|
||||
"CC=" + base_arm_tool_dir + "gcc", "CXX=" + base_arm_tool_dir + "g++", "AR=" + base_arm_tool_dir + "ar", "RANLIB=" + base_arm_tool_dir + "ranlib"])
|
||||
"CC=" + compiler_gcc_prefix + "gcc", "CXX=" + compiler_gcc_prefix + "g++", "AR=" + compiler_gcc_prefix + "ar", "RANLIB=" + compiler_gcc_prefix + "ranlib"])
|
||||
base.cmd("make", ["-j4"])
|
||||
base.cmd("make", ["install"], True)
|
||||
base.create_dir(base_dir + "/linux_arm64")
|
||||
@ -173,6 +175,8 @@ def make():
|
||||
base.copy_file(base_dir + "/icu/linux_arm64_install/lib/libicudata.so." + icu_major + "." + icu_minor, base_dir + "/linux_arm64/build/libicudata.so." + icu_major)
|
||||
base.copy_file(base_dir + "/icu/linux_arm64_install/lib/libicuuc.so." + icu_major + "." + icu_minor, base_dir + "/linux_arm64/build/libicuuc.so." + icu_major)
|
||||
base.copy_dir(base_dir + "/icu/linux_arm64_install/include", base_dir + "/linux_arm64/build/include")
|
||||
if config.option("sysroot") != "":
|
||||
base.restore_sysroot_env()
|
||||
|
||||
os.chdir("../..")
|
||||
|
||||
|
||||
@ -118,15 +118,15 @@ def make():
|
||||
if (base.is_os_arm()):
|
||||
base.copy_dir("../build/linux_64", "../build/linux_arm64")
|
||||
else:
|
||||
cross_compiler_arm64 = config.option("arm64-toolchain-bin")
|
||||
if ("" == cross_compiler_arm64):
|
||||
cross_compiler_arm64 = "/usr/bin"
|
||||
cross_compiler_arm64_prefix = cross_compiler_arm64 + "/" + base.get_prefix_cross_compiler_arm64()
|
||||
base.cmd("./Configure", ["linux-aarch64", "--cross-compile-prefix=" + cross_compiler_arm64_prefix, "enable-md2", "no-shared", "no-asm", "no-tests", "--prefix=" + old_cur_dir + "/build/linux_arm64", "--openssldir=" + old_cur_dir + "/build/linux_arm64"])
|
||||
if config.option("sysroot") != "":
|
||||
base.set_sysroot_env("linux_arm64")
|
||||
base.cmd("./Configure", ["linux-aarch64", "enable-md2", "no-shared", "no-asm", "no-tests", "--prefix=" + old_cur_dir + "/build/linux_arm64", "--openssldir=" + old_cur_dir + "/build/linux_arm64"])
|
||||
base.replaceInFile("./Makefile", "CFLAGS=-Wall -O3", "CFLAGS=-Wall -O3 -fvisibility=hidden")
|
||||
base.replaceInFile("./Makefile", "CXXFLAGS=-Wall -O3", "CXXFLAGS=-Wall -O3 -fvisibility=hidden")
|
||||
base.cmd("make", [], True)
|
||||
base.cmd("make", ["install"], True)
|
||||
if config.option("sysroot") != "":
|
||||
base.restore_sysroot_env()
|
||||
|
||||
if (-1 != config.option("platform").find("mac")) and not base.is_dir("../build/mac_64"):
|
||||
base.cmd("./Configure", ["enable-md2", "no-shared", "no-asm", "darwin64-x86_64-cc", "--prefix=" + old_cur_dir + "/build/mac_64", "--openssldir=" + old_cur_dir + "/build/mac_64", "-mmacosx-version-min=10.11"])
|
||||
|
||||
@ -102,8 +102,11 @@ def make(platform, project, qmake_config_addon="", is_no_errors=False):
|
||||
build_params.append("linux-clang-libc++")
|
||||
|
||||
if "" != config.option("sysroot"):
|
||||
os.environ['QMAKE_CUSTOM_SYSROOT'] = config.option("sysroot_" + platform)
|
||||
#os.environ['PKG_CONFIG_PATH'] = config.get_custom_sysroot_lib(platform) + "/pkgconfig"
|
||||
sysroot_path = config.option("sysroot_" + platform)
|
||||
os.environ['QMAKE_CUSTOM_SYSROOT'] = sysroot_path
|
||||
os.environ['QMAKE_CUSTOM_SYSROOT_BIN'] = config.get_custom_sysroot_bin(platform)
|
||||
os.environ['PKG_CONFIG_PATH'] = config.get_custom_sysroot_lib(platform, True) + "/pkgconfig"
|
||||
os.environ['PKG_CONFIG_SYSROOT_DIR'] = sysroot_path
|
||||
|
||||
base.cmd_exe(qmake_app, build_params)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user