From 83374aa635690a3a7cd6607b6f40095d323a733a Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Wed, 20 Aug 2025 17:53:19 +0300 Subject: [PATCH] Refactoring win_arm64 build --- scripts/base.py | 16 +++++++++++++++- scripts/build_js.py | 4 ---- scripts/config.py | 3 +++ scripts/deploy_desktop.py | 6 +----- scripts/qmake.py | 18 +++++++----------- tools/win/arm64/fetch_qt.py | 4 ++-- 6 files changed, 28 insertions(+), 23 deletions(-) diff --git a/scripts/base.py b/scripts/base.py index 88298c6..d8738f1 100644 --- a/scripts/base.py +++ b/scripts/base.py @@ -737,6 +737,14 @@ def qt_setup(platform): if ("gcc_arm" == compiler_platform): qt_dir = config.option("qt-dir") + "/gcc" + # OVERRIDE IF NEEDED + set_env("QT_QMAKE_ADDON", "") + if platform == "win_arm64" and not is_dir(qt_dir): + override_qt_directory = os.path.abspath(os.path.dirname(__file__) + "/../tools/win/arm64/qt_build/Qt-5.15.2/win_arm64") + if is_dir(override_qt_directory): + qt_dir = os.path.abspath(override_qt_directory).replace("\\", "/") + set_env("QT_QMAKE_ADDON", "-spec win32-arm64-msvc2017") + set_env("QT_DEPLOY", qt_dir + "/bin") if ("linux_arm64" == platform): @@ -858,6 +866,12 @@ def qt_config_as_param(value): def qt_copy_lib(lib, dir): qt_dir = get_env("QT_DEPLOY") + + # TODO: remove version from library name + qt_major = qt_major_version() + if ("5" != qt_major): + lib = lib.replace("Qt5", "Qt" + qt_major) + if ("windows" == host_platform()): if ("" == qt_dst_postfix()): copy_lib(qt_dir, dir, lib) @@ -866,7 +880,7 @@ def qt_copy_lib(lib, dir): else: src_file = qt_dir + "/../lib/lib" + lib + ".so." + qt_version() if (is_file(src_file)): - copy_file(src_file, dir + "/lib" + lib + ".so." + qt_major_version()) + copy_file(src_file, dir + "/lib" + lib + ".so." + qt_major) else: libFramework = lib libFramework = libFramework.replace("Qt5", "Qt") diff --git a/scripts/build_js.py b/scripts/build_js.py index 5405e73..ed3d6c6 100644 --- a/scripts/build_js.py +++ b/scripts/build_js.py @@ -65,10 +65,6 @@ def make(): deldirs = ['ie', 'mobile', 'embed'] [base.delete_dir(root + "/" + d) for root, dirs, f in os.walk(out_dir + "/desktop/web-apps/apps") for d in dirs if d in deldirs] - # for bug 62528. remove empty folders - walklist = list(os.walk(out_dir + "/desktop/sdkjs")) - [os.remove(p) for p, _, _ in walklist[::-1] if len(os.listdir(p)) == 0] - base.copy_file(base_dir + "/../web-apps/apps/api/documents/index.html.desktop", out_dir + "/desktop/web-apps/apps/api/documents/index.html") build_interface(base_dir + "/../desktop-apps/common/loginpage/build") diff --git a/scripts/config.py b/scripts/config.py index a0993ee..6a80cda 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -143,6 +143,9 @@ def check_compiler(platform): if (0 == platform.find("win")): compiler["compiler"] = "msvc" + options["vs-version"] compiler["compiler_64"] = "msvc" + options["vs-version"] + "_64" + if (0 == platform.find("win_arm")): + compiler["compiler"] = "msvc" + options["vs-version"] + "_arm" + compiler["compiler_64"] = "msvc" + options["vs-version"] + "_arm64" elif (0 == platform.find("linux")): compiler["compiler"] = "gcc" compiler["compiler_64"] = "gcc_64" diff --git a/scripts/deploy_desktop.py b/scripts/deploy_desktop.py index 1642779..80b2e19 100644 --- a/scripts/deploy_desktop.py +++ b/scripts/deploy_desktop.py @@ -132,11 +132,7 @@ def make(): base.copy_dir(core_build_dir + "/bin/" + platform_postfix + "/editors_helper.app", root_dir + "/editors_helper.app") else: base.copy_exe(core_build_dir + "/bin/" + platform_postfix + ("/xp" if isWindowsXP else ""), root_dir, "editors_helper") - - qt_win_arm64_dir = os.path.abspath(os.path.dirname(__file__) + "/../tools/win/arm64/qt_build/Qt-5.15.2/win_arm64/bin") - if platform == "win_arm64" and base.is_dir(qt_win_arm64_dir): - os.environ["QT_DEPLOY"] = qt_win_arm64_dir - + if isUseQt: base.qt_copy_lib("Qt5Core", root_dir) base.qt_copy_lib("Qt5Gui", root_dir) diff --git a/scripts/qmake.py b/scripts/qmake.py index bdede49..886b925 100644 --- a/scripts/qmake.py +++ b/scripts/qmake.py @@ -25,7 +25,7 @@ def get_j_num(): def check_support_platform(platform): qt_dir = base.qt_setup(platform) - if not base.is_file(qt_dir + "/bin/qmake") and not base.is_file(qt_dir + "/bin/qmake.exe"): + if not base.is_file(qt_dir + "/bin/qmake") and not base.is_file(qt_dir + "/bin/qmake.exe") and not base.is_file(qt_dir + "/bin/qmake.bat"): return False return True @@ -91,11 +91,7 @@ def make(platform, project, qmake_config_addon="", is_no_errors=False): build_params = ["-nocache", file_pro] + base.qt_config_as_param(config_param) + qmake_addon qmake_app = qt_dir + "/bin/qmake" - - qt_win_arm64_dir = os.path.abspath(os.path.dirname(__file__) + "/../tools/win/arm64/qt_build/Qt-5.15.2/win_arm64") - if platform == "win_arm64" and base.is_dir(qt_win_arm64_dir): - qmake_app = os.path.abspath(qt_win_arm64_dir + "/bin/qmake.exe") - + # non windows platform if not base.is_windows(): if base.is_file(qt_dir + "/onlyoffice_qt.conf"): @@ -122,16 +118,16 @@ def make(platform, project, qmake_config_addon="", is_no_errors=False): qmake_addon_string = " " + qmake_addon_string vcvarsall_arch = ("x86" if base.platform_is_32(platform) else "x64") - qmake_spec = "" - if platform == "win_arm64": - vcvarsall_arch += "_arm64" - qmake_spec = "-spec win32-arm64-msvc2017 " + qmake_env_addon = base.get_env("QT_QMAKE_ADDON") + if (qmake_env_addon != ""): + qmake_env_addon += " " + qmake_bat = [] qmake_bat.append("call \"" + config.option("vs-path") + "/vcvarsall.bat\" " + vcvarsall_arch) qmake_addon_string = "" if ("" != config.option("qmake_addon")): qmake_addon_string = " " + (" ").join(["\"" + addon + "\"" for addon in qmake_addon]) - qmake_bat.append("call \"" + qmake_app + "\" -nocache " + qmake_spec + file_pro + config_params_string + qmake_addon_string) + qmake_bat.append("call \"" + qmake_app + "\" -nocache " + qmake_env_addon + file_pro + config_params_string + qmake_addon_string) if ("1" == config.option("clean")): qmake_bat.append("call nmake " + " ".join(clean_params)) qmake_bat.append("call nmake " + " ".join(distclean_params)) diff --git a/tools/win/arm64/fetch_qt.py b/tools/win/arm64/fetch_qt.py index 4b6b78d..e3b7994 100644 --- a/tools/win/arm64/fetch_qt.py +++ b/tools/win/arm64/fetch_qt.py @@ -4,7 +4,6 @@ sys.path.append('../../../scripts') import base - def make(): qt_build_path = os.path.dirname(os.path.abspath(__file__)) + "/qt_build/Qt-5.15.2" qt_binary_url = "https://github.com/ONLYOFFICE-data/build_tools_data/raw/refs/heads/master/qt/qt_binary_win_arm64.7z" @@ -14,7 +13,8 @@ def make(): if not base.is_dir(qt_build_path): os.makedirs(qt_build_path) - base.cmd("tar", ["-xf", "./qt_binary_win_arm64.7z", "-C", qt_build_path]) + base.extract("./qt_binary_win_arm64.7z", qt_build_path) if __name__ == "__main__": + base.configure_common_apps() make() \ No newline at end of file