在Windows 10上为高通骁龙8155P板构建Qt

在进行下一步之前,需要设置Green Hills INTEGRITY和高通开发环境。请参阅安装平台依赖项

为Windows 10创建批处理脚本

要为INTEGRITY版的Qt设置开发环境,需要从高通骁龙8155P板的源代码构建Qt。在为INTEGRITY构建Qt之前,需要设置构建环境。这里有一个批处理脚本来自动化这个过程,因为它需要在每次构建之前完成。

对于Windows 10,创建一个新的批处理脚本setEnvironment.bat,并将其保存在您的家目录下。向脚本中添加以下导出变量:

@echo off
set PATH=%PATH%;C:\ghs\comp_202014
set INTEGRITY_DIR=C:\Users\user\ghs_pack\es7_dev_env\hlos_dev_boot\apps\ghs_apps_proc\integrity
set INTEGRITY_BSP=platform-sa8155
set INTEGRITY_BUILD_TARGET=chk
set QC_MULTIMEDIA_INC_DIR=C:\Users\user\ghs_pack\es7_dev_env\hlos_dev_boot\apps\ghs_apps_proc\qc_bsp\include\amss\multimedia
set GL_INC_DIR=C:\Users\user\ghs_pack\es7_dev_env\hlos_dev_boot\apps\ghs_apps_proc\qc_bsp\AMSS\multimedia\graphics\include\public
set GL_LIB_DIR=C:\Users\user\ghs_pack\es7_dev_env\hlos_dev_boot\apps\ghs_apps_proc\qc_bsp\out\rel\libs\base;C:\Users\user\ghs_pack\es7_dev_env\hlos_dev_boot\apps\ghs_apps_proc\qc_bsp\out\rel\libs\multimedia\display;C:\Users\user\ghs_pack\es7_dev_env\hlos_dev_boot\apps\ghs_apps_proc\qc_bsp\out\rel\libs\multimedia\graphics;C:\Users\user\ghs_pack\es7_dev_env\hlos_dev_boot\apps\ghs_apps_proc\qc_bsp\out\rel\libs\platform\;C:\Users\user\ghs_pack\es7_dev_env\hlos_dev_boot\apps\ghs_apps_proc\qc_bsp\AMSS\multimedia\graphics\opengl\esx\build\integrity\prebuilt\
set TARGET_ROOT_PATH="C:\Users\user\ghs_pack\es7_dev_env\hlos_dev_boot"

这些导出路径假定您已将C:\ghs\comp_202014和C:\Users\user\ghs_pack\*使用作为安装MULTI IDE和INTEGRITY的安装目录(请参阅安装平台依赖项)。如果您没有使用默认目录,请相应地调整导出路径。

要初始化您的构建环境,请在Windows CMD终端中运行以下命令:

setEnvironment.bat

注意:每次构建Qt时,请在该Windows CMD终端中运行此命令,或使用qmakeCMake构建系统。

获取Qt源码

您可以从您的Qt帐户下载Qt源代码。

您还可以从Git仓库获取Qt源代码,请参阅获取源代码

注意:Qt源代码版本必须为6.2或更高。

注意:Qt支持INTEGRITY的模块列表,请参阅支持的Qt模块

为交叉编译工具使用构建Qt桌面

交叉编译Qt需要可用的主机Qt构建。在构建过程中,将调用moc、rcc、qmlcachegen、qsb和其他工具。有关更详细的信息,请阅读交叉编译Qt

运行以下命令进行Windows 10主机构建:

mkdir hostbuild
cd hostbuild/
C:/Users/user/qt5/configure -nomake tests -nomake examples -release -prefix C:/Users/user/hostbuild
cmake --build . --parallel 6
cmake --install .

为INTEGRITY创建工具链文件

使用CMake交叉编译项目时,必须指定工具链文件。此CMake语言文件设置平台名称、使用的编译器和链接器以及一系列其他工具链特定值。对于Windows 10上的INTEGRITY构建,创建一个包含以下内容的toolchain.cmake文件:

# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#generic
set(CMAKE_SYSTEM_NAME Integrity)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING True)

#path to installed GHS compiler for WIN10
set(TARGET_ROOT_PATH "C:/Users/user/ghs_pack/es7_dev_env/hlos_dev_boot")
set(CMAKE_BUILD_TYPE "Release")

set(GHS_COMPILER C:/ghs/comp_202014/cxintarm64.exe)
set(CMAKE_C_COMPILER ${GHS_COMPILER})
set(CMAKE_CXX_COMPILER ${GHS_COMPILER})
set(CMAKE_ASM_COMPILER ${GHS_COMPILER})

set(EGL_FOUND True)
set(UNIX True)

set (CMAKE_C_COMPILE_FEATURES c_std_99)
set (CMAKE_CXX_COMPILE_FEATURES
cxx_alias_templates
cxx_alignas
cxx_alignof
cxx_attributes
cxx_auto_type
cxx_constexp
cxx_decltype
cxx_delegating_constructors
cxx_explicit_conversions
cxx_extern_templates
cxx_inheriting_constructors
cxx_lambdas
cxx_noexcept
cxx_nonstatic_member_init
cxx_nullptr
cxx_override
cxx_range_for
cxx_raw_string_literals
cxx_reference_qualified_functions
cxx_rvalue_references
cxx_static_assert
cxx_std_17
cxx_thread_local
cxx_unicode_literals
cxx_uniform_initialization
cxx_unrestricted_unions
cxx_variadic_macros
cxx_variadic_templates)

if (NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
endif()
if (NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
endif()
if (NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
    set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
endif()
if (NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()

set(CMAKE_FIND_ROOT_PATH ${TARGET_ROOT_PATH})

#base
set(CMAKE_C_FLAGS  "-bsp $ENV{INTEGRITY_BSP} -os_dir $ENV{INTEGRITY_DIR} -non_shared -startfile_dir=$ENV{INTEGRITY_DIR}/libs/$ENV{INTEGRITY_BSP}/$ENV{INTEGRITY_BUILD_TARGET} --rtos_library_directory=libs/$ENV{INTEGRITY_BSP}/$ENV{INTEGRITY_BUILD_TARGET} --rtos_library_directory=libs/arm64/$ENV{INTEGRITY_BUILD_TARGET} -bigswitch -DINTEGRITY -llibposix.a")
set(CMAKE_C_FLAGS_DEBUG "-g -Omaxdebug")
set(CMAKE_C_FLAGS_RELEASE "-Ospeed -Olink -Omax -no_uvfd")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --signed_fields --diag_suppress=1,82,228,236,381,611,961,997,1795,1931,1974,3148 --c++17 --thread_local_storage --exceptions --defer_parse_function_templates")

set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -frigor=accurate --signed_fields --no_implicit_include --link_once_templates -non_shared --new_outside_of_constructor --commons -I $ENV{QC_MULTIMEDIA_INC_DIR}")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")

set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")

set(BUILD_SHARED_LIBS OFF)
set(QT_CFLAGS_OPTIMIZE_FULL "-Ospeed -Olink -Omax -no_uvfd")

set(EGL_INCLUDE_DIR $ENV{GL_INC_DIR})
set(PKG_EGL_LIBRARY_DIRS ${TARGET_ROOT_PATH})

set(GLESv2_INCLUDE_DIR $ENV{GL_INC_DIR})
set(OPENGL_INCLUDE_DIR $ENV{GL_INC_DIR})

set(EGL_LIBRARY "${EGL_LIBRARY_GRAPHIC_PATH}/libESXEGL_Adreno.a")

set(GLESv2_INCLUDE_DIR $ENV{GL_INC_DIR})
set(GLESv2_LIBRARY "${EGL_LIBRARY_GRAPHIC_PATH}/libESXGLESv2_Adreno.a")

set(IntegrityPlatformGraphics_INCLUDE_DIR ${GL_INC_DIR})
set(IntegrityPlatformGraphics_LIBRARY "${EGL_LIBRARY_GRAPHIC_PATH}/libadreno_utils.a")
set(IntegrityPlatformGraphics_LIBRARIES_PACK
    "${EGL_LIBRARY_BASE_PATH}/libplanedef.a"
    "${EGL_LIBRARY_BASE_PATH}/libmmosalfile.a"
    "${EGL_LIBRARY_BASE_PATH}/libOSAbstraction.a"
    "${EGL_LIBRARY_OPENWFD_PATH}/libopenwfd.a"
    "${EGL_LIBRARY_GRAPHIC_PATH}/libOSUser.a"
    "${EGL_LIBRARY_GRAPHIC_PATH}/libpanel.a"
    "${EGL_LIBRARY_GRAPHIC_PATH}/libGSLUser.a"
    "${EGL_LIBRARY_PREBUILD_PATH}/libglnext-llvm.a"
    "${EGL_LIBRARY_PLATFORM_PATH}/libpmem.a"
    "${EGL_LIBRARY_CHK_PATH}/libposix.a"
    "${EGL_LIBRARY_CHK_PATH}/libivfs.a"
)

list(APPEND _qt_igy_gui_libs
    "${GLESv2_LIBRARY}"
    "${IntegrityPlatformGraphics_LIBRARY}"
    "${IntegrityPlatformGraphics_LIBRARIES_PACK}")

set(OPENGL_opengl_LIBRARY ${EGL_LIBRARY})

# Command is required to fix CMake WIN bug https://gitlab.kitware.com/cmake/cmake/-/issues/22933
set(CMAKE_CXX_COMPILER_PREDEFINES_COMMAND ${CMAKE_CXX_COMPILER})
list(APPEND CMAKE_CXX_COMPILER_PREDEFINES_COMMAND -bsp $ENV{INTEGRITY_BSP} -os_dir $ENV{INTEGRITY_DIR} -E -dM "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")

# Set format for creating static library
set(CMAKE_CXX_CREATE_STATIC_LIBRARY "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} <LINK_FLAGS> -archive -o <TARGET> <OBJECTS> -keep_objs")
set(CMAKE_C_CREATE_STATIC_LIBRARY   "${CMAKE_CXX_COMPILER} ${CMAKE_C_FLAGS} <LINK_FLAGS> -archive -o <TARGET> <OBJECTS> -keep_objs")

# Set format to create executables
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_C_LINK_EXECUTABLE   "${CMAKE_CXX_COMPILER} ${CMAKE_C_FLAGS} <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")

配置 Qt 以支持 INTEGRITY

使用以下命令配置 Qt 以支持高通 Snapdragon 8155P 板:Windows 10 主机 需要以下配置行

mkdir targetbuild
cd targetbuild/
cmake C:/Users/user/qt5/ -DQT_HOST_PATH=/c/Users/user/hostbuild/qtbase
-DCMAKE_TOOLCHAIN_FILE=/c/Users/user/ghs_pack/es7_dev_env/hlos_dev_boot/toolchain_integrity.cmake
-DQT_QMAKE_TARGET_MKSPEC=devices/integrity-armv8-SA8155P
-DBUILD_qtdoc=OFF -DBUILD_qttranslations=OFF -DFEATURE_printdialog=OFF --debug-trycompile -DFEATURE_dbus=OFF
-DFEATURE_dnslookup=OFF -DFEATURE_glib=OFF -DFEATURE_system_pcre2=OFF -DFEATURE_sql_mysql=OFF
-DQT_FEATURE_harfbuzz=OFF -DFEATURE_pkg_config=OFF -DUNIX=ON -DCMAKE_HOST_WIN32=ON -GNinja -DCMAKE_INSTALL_PREFIX=/c/Users/user/targetbuild/

注意:INTEGRITY 仅支持静态 Qt 构建。

注意:QT_HOST_PATH 变量是在 Qt 6 中引入的。在交叉编译时,此值必须设置为宿主平台 Qt 的安装位置。它用于定位要在宿主上运行的工具(moc、rcc、androiddeployqt 等)。

为 INTEGRITY 构建 Qt

通过在终端中调用 cmake 来构建 Qt。您可以在宿主机器上使用等于所希望核心数的 cmake。在我们的示例中,我们使用了六个核心

cmake --build . --parallel 6

安装 Qt

如果您没有在 配置 Qt 中使用配置选项 -prefix $PWD/qtbase,请在终端运行以下命令

cd <Qt installation directory>
cmake --install .

如果您已使用配置选项 -prefix $PWD/qtbase,则可以从构建目录使用 Qt,无需运行 cmake install 命令。

Qt 现在已配置并构建以支持 sa8155 板。

© 2024 Qt 公司有限公司。本文件中包含的文档贡献是各自所有者的版权。本文档是根据自由软件基金会发布的 GNU 自由文档许可协议版本 1.3 许可的。Qt 和相应的标志是 Qt 公司在芬兰和其他国家/地区的商标。所有其他商标均为其各自所有者的财产。