android: build mainui_cpp through CMake

This commit is contained in:
Alibek Omarov
2026-03-24 21:05:56 +05:00
parent 88d8115306
commit f523f04ee2
5 changed files with 22 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
[versions]
acraHttp = "5.12.0"
agp = "9.0.0"
agp = "9.0.1"
appcompat = "1.7.1"
material = "1.12.0"
navigationRuntimeKtx = "2.9.1"

View File

@@ -62,6 +62,7 @@ def main():
# build SDL2 and hlsdk-portable with cmake
sdl_bin_path = os.path.join(args.out_dir, "SDL")
hlsdk_bin_path = os.path.join(args.out_dir, "hlsdk-portable")
mainui_bin_path = os.path.join(args.out_dir, "mainui")
abi = args.waflock.replace(".lock-waf_android_", "").replace("_build", "")
inst_path = os.path.join(args.top_dir, "android", "app", "src", "main", "jniLibs", abi)
@@ -71,6 +72,7 @@ def main():
run_cmake(sdl_bin_path, ["libSDL2.so"], inst_path)
run_cmake(hlsdk_bin_path, None, inst_path)
run_cmake(mainui_bin_path, None, inst_path)
process = subprocess.Popen(waf_exec, env=env)
process.communicate()

View File

@@ -29,12 +29,15 @@ def check_repo(name, branch, url, path):
def run_cmake(root, out, toolchain, abi, build_type, ndk_root, min_sdk, *args):
cmake_exec = ["cmake", "-H{}".format(root), "-DCMAKE_BUILD_TYPE={}".format(build_type),
"-DCMAKE_TOOLCHAIN_FILE={}".format(toolchain), "-DANDROID_ABI={}".format(abi),
cmake_exec = ["cmake", "-H{}".format(root),
"-DCMAKE_BUILD_TYPE={}".format(build_type),
"-DCMAKE_TOOLCHAIN_FILE={}".format(toolchain),
"-DANDROID_ABI={}".format(abi),
"-DANDROID_NDK={}".format(ndk_root),
"-DANDROID_PLATFORM=android-{}".format(min_sdk),
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DCMAKE_SYSTEM_NAME=Android", "-DCMAKE_SYSTEM_VERSION={}".format(min_sdk),
"-DCMAKE_SYSTEM_NAME=Android",
"-DCMAKE_SYSTEM_VERSION={}".format(min_sdk),
"-B{}".format(out), "-GNinja"]
cmake_exec.extend(args)
@@ -79,6 +82,13 @@ def main():
run_cmake(hlsdk_path, hlsdk_out_path, cmake_toolchain_path, abi, cmake_build_type, args.ndk_root,
args.min_sdk_version, "-DANDROID_APK=ON")
# configure mainui_cpp
mainui_path = os.path.join(args.wscript_path, "3rdparty", "mainui")
mainui_out_path = os.path.join(args.configuration_dir, "mainui")
run_cmake(mainui_path, mainui_out_path, cmake_toolchain_path, abi, cmake_build_type, args.ndk_root,
args.min_sdk_version, "-DBUILD_AS_PART_OF_ENGINE=ON")
# waf configure
waf_path = os.path.join(args.wscript_path, "waf")
out_path = os.path.join(args.configuration_dir, "xash3d-fwgs")

View File

@@ -100,7 +100,7 @@ SUBDIRS = [
Subproject('3rdparty/vorbis', lambda x: x.env.CLIENT and (not x.env.HAVE_SYSTEM_VORBIS or not x.env.HAVE_SYSTEM_VORBISFILE)),
Subproject('3rdparty/opusfile', lambda x: x.env.CLIENT and not x.env.HAVE_SYSTEM_OPUSFILE),
Subproject('3rdparty/maintui', lambda x: x.env.CLIENT and x.env.TUI),
Subproject('3rdparty/mainui', lambda x: x.env.CLIENT),
Subproject('3rdparty/mainui', lambda x: x.env.CLIENT and x.env.DEST_OS != 'android'),
Subproject('3rdparty/vgui_support', lambda x: x.env.CLIENT),
Subproject('3rdparty/MultiEmulator',lambda x: x.env.CLIENT),
# Subproject('3rdparty/freevgui', lambda x: x.env.CLIENT),