Skip to content

Commit

Permalink
Merge pull request #352 from ucam-department-of-psychiatry/qt-android…
Browse files Browse the repository at this point in the history
…-x86-64-emulator

Fix the Qt build for Android 32 and 64-bit emulators
  • Loading branch information
martinburchell committed May 14, 2024
2 parents e4c6f7c + ca54659 commit 43706c3
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 106 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/python-package-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ jobs:
python -m pip install safety
echo checking packages for vulnerabilities
# All of these vulnerabilities look either harmless or very low risk
# 51668 sqlalchemy fix in 2.0 beta, we don't log Engine.URL()
# 51668 sqlalchemy. Fix in 2.0 beta. We don't log Engine.URL()
# https://github.com/sqlalchemy/sqlalchemy/issues/8567
# 52495 setuptools fix in 65.5.1, we'll be careful not to
# 52495 setuptools. Fix in 65.5.1. We'll be careful not to
# install malicious packages.
safety check --full-report --ignore=51668 --ignore=52495
# 67599 pip. Disputed and only relevant if using --extra-index-url,
# which we're not.
safety check --full-report --ignore=51668 --ignore=52495 --ignore=67599
2 changes: 2 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3904,3 +3904,5 @@ Current C++/SQLite client, Python/SQLAlchemy server
- Fix undefined behaviour if a task in a taskchain was aborted due to e.g. a missing
IP setting. Sometimes the tasks would be displayed if the back button was pressed.
https://github.com/ucam-department-of-psychiatry/camcops/issues/350

- Fix the Qt build for 32-bit and 64-bit Android emulator.
14 changes: 9 additions & 5 deletions docs/source/developer/_build_qt_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ usage: build_qt.py [-h] [--show_config_only] [--root_dir ROOT_DIR]
[--force] [--force_ffmpeg] [--force_openssl] [--force_qt]
[--force_sqlcipher] [--tee TEE] [--verbose {0,1,2}]
[--inherit_os_env] [--no_inherit_os_env] [--build_all]
[--build_android_x86_32] [--build_android_arm_v7_32]
[--build_android_arm_v8_64] [--build_linux_x86_64]
[--build_macos_x86_64] [--build_windows_x86_64]
[--build_windows_x86_32] [--build_ios_arm_v7_32]
[--build_ios_arm_v8_64] [--build_ios_simulator_x86_32]
[--build_android_x86_32] [--build_android_x86_64]
[--build_android_arm_v7_32] [--build_android_arm_v8_64]
[--build_linux_x86_64] [--build_macos_x86_64]
[--build_windows_x86_64] [--build_windows_x86_32]
[--build_ios_arm_v7_32] [--build_ios_arm_v8_64]
[--build_ios_simulator_x86_32]
[--build_ios_simulator_x86_64]
[--qt_build_type {debug,release,release_w_symbols}]
[--qt_src_dirname QT_SRC_DIRNAME] [--qt_openssl_static]
Expand Down Expand Up @@ -57,6 +58,9 @@ Architecture:
--build_android_x86_32
An architecture target (Android under an Intel x86
32-bit emulator) (default: False)
--build_android_x86_64
An architecture target (Android under an Intel x86
64-bit emulator) (default: False)
--build_android_arm_v7_32
An architecture target (Android with a 32-bit ARM
processor) (default: False)
Expand Down
70 changes: 59 additions & 11 deletions docs/source/developer/building_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ Non-default options are marked in bold and/or as "[non-default]".
``-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}``
``-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}``

**Custom_Android_x86** -- NOT FULLY TESTED
**Custom_Android_x86**

.. list-table::
:header-rows: 1
Expand All @@ -548,32 +548,80 @@ Non-default options are marked in bold and/or as "[non-default]".
- **[non-default]** ``Custom_Android_x86``
* - File system name
-
* - Device type
* - Run device type
- Android Device
* - Device
- Run on Android (default for Android)
* - Sysroot
-
* - Run device
- Pixel_3a_API_30_x86
* - Build device
- Desktop (default for Desktop)
* - Compiler: C
- <No compiler>
- Android Clang (C, i686, NDK 25.1.8937393)
* - Compiler: C++
- Android GCC (i686-4.9)
- Android Clang (C++, i686, NDK 25.1.8937393)
* - Environment
- [not editable: "No changes to apply."]
* - Debugger
- Android Debugger for Android GCC (i686-4.9)
- Android Debugger (Multi-Abi, NDK 25.1.8937393)
* - Sysroot
-
* - Qt version
- **THE "ANDROID EMULATOR" ONE FROM QT VERSIONS, ABOVE**
* - Qt mkspec
-
* - Additional Qbs Profile Settings
-
* - CMake Tool
- System CMake at ``/usr/bin/cmake``
- CMake 3.24.2 (Qt)
* - CMake Generator
- CodeBlocks - Unix Makefiles
- Ninja
* - CMake Configuration
- [not editable]
* - Python
- None

**Custom_Android_x86_64**

.. list-table::
:header-rows: 1
:stub-columns: 1

* - Option
- Setting
* - Name
- **[non-default]** ``Custom_Android_x86_64``
* - File system name
-
* - Run device type
- Android Device
* - Run device
- Pixel_3a_API_34
* - Build device
- Desktop (default for Desktop)
* - Compiler: C
- Android Clang (C, x86_64, NDK 25.1.8937393)
* - Compiler: C++
- Android Clang (C++, x86_64, NDK 25.1.8937393)
* - Environment
- [not editable: "No changes to apply."]
* - Debugger
- Android Debugger (Multi-Abi, NDK 25.1.8937393)
* - Sysroot
-
* - Qt version
- **THE "ANDROID EMULATOR" ONE FROM QT VERSIONS, ABOVE**
* - Qt mkspec
-
* - Additional Qbs Profile Settings
-
* - CMake Tool
- CMake 3.24.2 (Qt)
* - CMake Generator
- Ninja
* - CMake Configuration
- [not editable]
* - Python
- None


**Custom_Windows_x86_64**

Expand Down
79 changes: 31 additions & 48 deletions docs/source/user_client/_camcops_client_help.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,34 @@
Usage: /path/to/camcops/client/executable [options]

Options:
-h, --help Displays this help.
-v, --version Displays version
information.
--dbdir <DBDIR> Specify the database
directory, in which the
databases
"camcops_data.sqlite"
and
"camcops_sys.sqlite"
are used or created.
Order of precedence
(highest to lowest) is
(1) this argument, (2)
the
CAMCOPS_DATABASE_DIRECT
ORY environment
variable, and (3) the
default, on this
particular system, of
"/path/to/client/databa
se/dir".
--default_single_user_mode <DEFAULT_SINGLE_USER_MODE> If no mode has
previously been
selected, do not
display the mode
selection dialog and
default to single user
mode.
--default_server_location <DEFAULT_SERVER_LOCATION> If no server has been
registered, default to
this URL e.g.
https://server.example.
com/camcops/api
--default_access_key <DEFAULT_ACCESS_KEY> If no patient has been
registered, default to
this access key e.g.
abcde-fghij-klmno-pqrst
-uvwxy-zabcd-efghi-jklm
n-o
--print_icd9_codes Print ICD-9-CM
(DSM-IV) codes used by
CamCOPS, and quit.
--print_icd10_codes Print ICD-10 codes
used by CamCOPS, and
quit.
--print_terms_conditions Print terms and
conditions applicable
to CamCOPS, and quit.
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific
options.
-v, --version Displays version information.
--dbdir <DBDIR> Specify the database directory, in which
the databases "camcops_data.sqlite" and
"camcops_sys.sqlite" are used or created.
Order of precedence (highest to lowest) is
(1) this argument, (2) the
CAMCOPS_DATABASE_DIRECTORY environment
variable, and (3) the default, on this
particular system, of
"/path/to/client/database/dir".
--default_single_user_mode <MODE> If no mode has previously been selected,
do not display the mode selection dialog
and default to single user mode.
--default_server_location <URL> If no server has been registered, default
to this URL e.g.
https://server.example.com/camcops/api
--default_access_key <KEY> If no patient has been registered, default
to this access key e.g.
abcde-fghij-klmno-pqrst-uvwxy-zabcd-efghi-j
klmn-o
--print_icd9_codes Print ICD-9-CM (DSM-IV) codes used by
CamCOPS, and quit.
--print_icd10_codes Print ICD-10 codes used by CamCOPS, and
quit.
--print_tasks Print tasks supported in this version of
CamCOPS, and quit.
--print_terms_conditions Print terms and conditions applicable to
CamCOPS, and quit.
2 changes: 1 addition & 1 deletion server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
# FHIR export, our fork until https://github.com/smart-on-fhir/client-py/pull/105 is merged # noqa
"fhirclient @ git+https://github.com/ucam-department-of-psychiatry/client-py@128bbe3c2194a51ba6ff8cf880ef2fdb9bfcc2d6#egg=fhirclient-4.0.0.1", # noqa: E501
"flower==2.0.1", # monitor for Celery
"gunicorn==21.2.0", # web server (Unix only)
"gunicorn==22.0.0", # web server (Unix only)
"hl7==0.3.5", # For HL7 export
# Celery dependency for Python <= 3.7; workaround import error
# https://github.com/celery/celery/issues/7783; scheduled to be fixed in
Expand Down
8 changes: 6 additions & 2 deletions tablet_qt/camcops.pro
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,12 @@ android {
CAMCOPS_OPENSSL_LINKAGE = "dynamic"

contains(ANDROID_TARGET_ARCH, x86) {
message("Building for Android/x86 (e.g. Android emulator)")
CAMCOPS_ARCH_TAG = "android_x86"
message("Building for Android/x86_32 (e.g. Android emulator)")
CAMCOPS_ARCH_TAG = "android_x86_32"
}
contains(ANDROID_TARGET_ARCH, x86_64) {
message("Building for Android/x86_64 (e.g. Android emulator)")
CAMCOPS_ARCH_TAG = "android_x86_64"
}
contains(ANDROID_TARGET_ARCH, armeabi-v7a) {
message("Building for Android/ARMv7 32-bit architecture")
Expand Down
59 changes: 23 additions & 36 deletions tablet_qt/tools/build_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,7 @@ def __init__(self, args: argparse.Namespace) -> None:
# Architectures
self.build_all = args.build_all # type: bool
self.build_android_x86_32 = args.build_android_x86_32 # type: bool
self.build_android_x86_64 = args.build_android_x86_64 # type: bool
self.build_android_arm_v7_32 = (
args.build_android_arm_v7_32
) # type: bool # noqa
Expand Down Expand Up @@ -1926,7 +1927,7 @@ def _set_android_env(
env["ANDROID_API_VERSION"] = self.android_api
env["ANDROID_ARCH"] = target_platform.android_arch_full
env["ANDROID_DEV"] = join(android_sysroot, "usr")
env["ANDROID_EABI"] = self._android_eabi(target_platform)
env["ANDROID_EABI"] = "llvm"
env["ANDROID_NDK_ROOT"] = self.android_ndk_root
env["ANDROID_SDK_ROOT"] = self.android_sdk_root
env["ANDROID_SYSROOT"] = android_sysroot
Expand Down Expand Up @@ -1961,35 +1962,6 @@ def _set_android_env(

# TODO: should this be in Platform or Config?

def _android_eabi(self, target_platform: Platform) -> str:
"""
Get the name of the Android Embedded Application Binary Interface
for ARM processors, used for the Android SDK.
ABIs:
- https://developer.android.com/ndk/guides/abis.html
ARM supports two ABI types, one of which is the Embedded ABI:
- https://kanj.github.io/elfs/book/armMusl/cross-tools/abi.html
- https://www.eecs.umich.edu/courses/eeecs373/readings/ARM-AAPCS-EABI-v2.08.pdf
= Procedure Call Standard for the ARM Architecture
""" # noqa
if target_platform.cpu_x86_family:
return "{}-{}".format(
target_platform.android_arch_short,
self.android_toolchain_version,
) # e.g. x86-4.9
# For toolchain version: ls $ANDROID_NDK_ROOT/toolchains
# ... "-android-arch" and "-android-toolchain-version" get
# concatenated, I think; for example, this gives the toolchain
# "x86_64-4.9"
elif target_platform.cpu_arm_family:
return "llvm"
else:
raise NotImplementedError("Unknown CPU family for Android")

def android_sysroot(self, target_platform: Platform) -> str:
"""
Get the Android sysroot (e.g. where system #include files live) for a
Expand Down Expand Up @@ -2025,7 +1997,7 @@ def android_toolchain_root_dir(self, target_platform: Platform) -> str:
return join(
self.android_ndk_root,
"toolchains",
self._android_eabi(target_platform),
"llvm",
"prebuilt",
self.android_ndk_host,
)
Expand Down Expand Up @@ -3456,6 +3428,8 @@ def configure_qt(cfg: Config, target_platform: Platform) -> None:
# version; see android_compilation.txt
if target_platform.cpu == Cpu.X86_32:
android_abi = "x86"
elif target_platform.cpu == Cpu.X86_64:
android_abi = "x86_64"
elif target_platform.cpu == Cpu.ARM_V7_32:
android_abi = "armeabi-v7a"
elif target_platform.cpu == Cpu.ARM_V8_64:
Expand Down Expand Up @@ -4118,11 +4092,15 @@ def build_ffmpeg(cfg: Config, target_platform: Platform) -> None:
ar = cfg.android_ar(target_platform)
ranlib = cfg.android_ranlib(target_platform)

if target_platform.cpu == Cpu.ARM_V7_32:
cpu = "armv7-a"
elif target_platform.cpu == Cpu.ARM_V8_64:
cpu = "armv8-a"
else:
cpu_dict = {
Cpu.ARM_V7_32: "armv7-a",
Cpu.ARM_V8_64: "armv8-a",
Cpu.X86_32: "i686",
Cpu.X86_64: "x86_64",
}

cpu = cpu_dict.get(target_platform.cpu)
if cpu is None:
raise NotImplementedError(
"Don't know how to build FFmpeg for Android "
f"with CPU {target_platform.cpu}"
Expand Down Expand Up @@ -4352,6 +4330,9 @@ def build_for(os: str, cpu: str) -> None:
if cfg.build_android_x86_32: # for x86 Android emulator
build_for(Os.ANDROID, Cpu.X86_32)

if cfg.build_android_x86_64: # for x86_64 Android emulator
build_for(Os.ANDROID, Cpu.X86_64)

if cfg.build_android_arm_v7_32: # for native Android, 32-bit ARM
build_for(Os.ANDROID, Cpu.ARM_V7_32)

Expand Down Expand Up @@ -4531,6 +4512,12 @@ def main() -> None:
help="An architecture target (Android under an "
"Intel x86 32-bit emulator)",
)
archgroup.add_argument(
"--build_android_x86_64",
action="store_true",
help="An architecture target (Android under an "
"Intel x86 64-bit emulator)",
)
archgroup.add_argument(
"--build_android_arm_v7_32",
action="store_true",
Expand Down

0 comments on commit 43706c3

Please sign in to comment.