feature: adapt x86 build

Change-Id: Ia07adacad7f2af149b3bf195162194101e486f53
This commit is contained in:
2025-05-08 17:56:49 +08:00
parent 61dad57c0c
commit 0e1bca32e6
41 changed files with 501 additions and 110 deletions

43
ohos/build_ohos_x86.py Normal file
View File

@@ -0,0 +1,43 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import sys
import ntpath
import os
if __name__ == '__main__':
if len(sys.argv) < 4:
print("must input the OpenHarmony directory and the product name and the source dir")
exit(-1)
script_dir = os.path.split(os.path.abspath( __file__))[0]
run_cross_pross_cmd = 'python3 ' + script_dir + '/meson_cross_process_x86.py ' + sys.argv[1] + ' ' + sys.argv[2]
os.system(run_cross_pross_cmd)
run_build_cmd = 'PKG_CONFIG_PATH=./pkgconfig '
run_build_cmd += 'meson setup '+ sys.argv[3] + ' build-ohos '
run_build_cmd += '-Dplatforms=ohos -Degl-native-platform=ohos -Ddri-drivers= -Dgallium-drivers=crocus,iris \
-Dvulkan-drivers= -Dgbm=enabled -Degl=enabled -Dcpp_rtti=false -Dglx=disabled -Dtools=intel -Ddri-search-path=/vendor/lib64/chipsetsdk '
run_build_cmd += '--cross-file=cross_file '
run_build_cmd += '--prefix=' + os.getcwd() + '/build-ohos/install'
print("build command: %s" %run_build_cmd)
os.system(run_build_cmd)
os.system('ninja -C build-ohos -j26')
os.system('ninja -C build-ohos install')

View File

@@ -0,0 +1,219 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import sys
import ntpath
import os
sysroot_stub = 'sysroot_stub'
project_stub = 'project_stub'
corss_file_content='''
[properties]
needs_exe_wrapper = true
c_args = [
'-march=x86-64',
'--target=x86_64-linux-ohosmusl',
'--sysroot=sysroot_stub',
'-fPIC',
'-fno-emulated-tls']
cpp_args = [
'-march=x86-64',
'--target=x86_64-linux-ohosmusl',
'--sysroot=sysroot_stub',
'-fPIC',
'-fno-emulated-tls']
c_link_args = [
'-march=x86-64',
'--target=x86_64-linux-ohosmusl',
'-fPIC',
'--sysroot=sysroot_stub',
'-Lsysroot_stub/usr/lib/x86_64-linux-ohos',
'-Lproject_stub/prebuilts/clang/ohos/linux-x86_64/15.0.4/lib/x86_64-linux-ohos',
'-Lproject_stub/prebuilts/clang/ohos/linux-x86_64/15.0.4/llvm/include/x86_64-linux-ohos/c++',
'--rtlib=compiler-rt',
]
cpp_link_args = [
'-march=x86-64',
'--target=x86_64-linux-ohosmusl',
'--sysroot=sysroot_stub',
'-fPIC',
'-Lsysroot_stub/usr/lib/x86_64-linux-ohos',
'-Lproject_stub/prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/15.0.4/lib/x86_64-linux-ohos',
'-Lproject_stub/prebuilts/clang/ohos/linux-x86_64/llvm/lib/include/x86_64-linux-ohos/c++',
'-Wl,--exclude-libs=libunwind_llvm.a',
'-Wl,--exclude-libs=libc++_static.a',
'-Wl,--warn-shared-textrel',
'--rtlib=compiler-rt',
'-Lproject_stub/third_party/mesa3d/subprojects/llvm',
'-lLLVMMCDisassembler',
'-lLLVMSelectionDAG',
'-lLLVMExtensions',
'-lLLVMRemarks',
'-lLLVMRuntimeDyld',
'-lLLVMDemangle',
'-lLLVMBinaryFormat',
'-lLLVMAsmParser',
'-lLLVMTarget',
'-lLLVMX86Disassembler',
'-lLLVMInterfaceStub',
'-lLLVMX86Info',
'-lLLVMLTO',
'-lLLVMMCA',
'-lLLVMOption',
'-lLLVMFuzzerCLI',
'-lLLVMDlltoolDriver',
'-lLLVMDebugInfoPDB',
'-lLLVMTextAPI',
'-lLLVMMCJIT',
'-lLLVMAggressiveInstCombine',
'-lLLVMCore',
'-lLLVMOrcTargetProcess',
'-lLLVMAnalysis',
'-lLLVMBitWriter',
'-lLLVMObjCopy',
'-lLLVMBitstreamReader',
'-lLLVMTransformUtils',
'-lLLVMExecutionEngine',
'-lLLVMObjCARCOpts',
'-lLLVMAMDGPUCodeGen',
'-lLLVMFrontendOpenACC',
'-lLLVMAMDGPUInfo',
'-lLLVMDWARFLinker',
'-lLLVMTableGen',
'-lLLVMX86Desc',
'-lLLVMMCParser',
'-lLLVMInstrumentation',
'-lLLVMOrcShared',
'-lLLVMInstCombine',
'-lLLVMSupport',
'-lLLVMAsmPrinter',
'-lLLVMWindowsManifest',
'-lLLVMLineEditor',
'-lLLVMAMDGPUDisassembler',
'-lLLVMDebugInfoGSYM',
'-lLLVMDebugInfoCodeView',
'-lLLVMInterpreter',
'-lLLVMVectorize',
'-lLLVMX86CodeGen',
'-lLLVMAMDGPUUtils',
'-lLLVMParts',
'-lLLVMDebugInfoMSF',
'-lLLVMXRay',
'-lLLVMPasses',
'-lLLVMTableGenGlobalISel',
'-lLLVMGlobalISel',
'-lLLVMBitReader',
'-lLLVMipo',
'-lLLVMLinker',
'-lLLVMX86TargetMCA',
'-lLLVMProfileData',
'-lLLVMCoroutines',
'-lLLVMScalarOpts',
'-lLLVMCodeGen',
'-lLLVMObject',
'-lLLVMWindowsDriver',
'-lLLVMCFGuard',
'-lLLVMDebugInfoDWARF',
'-lLLVMAMDGPUAsmParser',
'-lLLVMFrontendOpenMP',
'-lLLVMJITLink',
'-lLLVMIRReader',
'-lLLVMX86AsmParser',
'-lLLVMMC',
'-lLLVMSymbolize',
'-lLLVMLibDriver',
'-lLLVMObjectYAML',
'-lLLVMFileCheck',
'-lLLVMDWP',
'-lLLVMAMDGPUTargetMCA',
'-lLLVMMIRParser',
'-lLLVMAMDGPUDesc',
'-lLLVMFuzzMutate',
'-lLLVMCoverage',
'-lLLVMOrcJIT',
]
[binaries]
ar = 'project_stub/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ar'
c = ['ccache', 'project_stub/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang']
cpp = ['ccache', 'project_stub/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang++']
c_ld= 'lld'
cpp_ld = 'lld'
strip = 'project_stub/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-strip'
llvm-config = 'project_stub/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-config'
pkgconfig = '/usr/bin/pkg-config'
[host_machine]
system = 'linux'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
'''
def generate_cross_file(project_stub_in, sysroot_stub_in):
with open("cross_file", 'w+') as file:
result = corss_file_content.replace("project_stub", project_stub_in)
result = result.replace("sysroot_stub", sysroot_stub_in)
file.write(result)
print("generate_cross_file")
def generate_pc_file(file_raw, project_dir, product_name):
print(file_raw)
if not os.path.exists('pkgconfig'):
os.makedirs('pkgconfig')
filename = 'pkgconfig/'+ ntpath.basename(file_raw)
with open(file_raw, 'r+') as file_raw:
with open(filename, "w+") as pc_file:
raw_content = file_raw.read()
raw_content = raw_content.replace("ohos_project_directory_stub", project_dir)
raw_content = raw_content.replace("ohos-arm-release", product_name)
pc_file.write(raw_content)
print("generate_pc_file")
def process_pkgconfig(project_dir, product_name):
template_dir = os.path.split(os.path.abspath( __file__))[0] + r"/pkgconfig_template"
templates = os.listdir(template_dir)
for template in templates:
if not os.path.isdir(template):
generate_pc_file(template_dir + '/' + template, project_dir, product_name)
print("process_pkgconfig")
def prepare_environment(project_path, product):
global project_stub
global sysroot_stub
product = product.lower()
project_stub = project_path
sysroot_stub = os.path.join(project_stub, "out", product, "obj", "third_party", "musl")
generate_cross_file(project_path, sysroot_stub)
process_pkgconfig(project_path, product)
if __name__ == '__main__':
if len(sys.argv) < 3:
print("must input the OpenHarmony directory and the product name")
exit(-1)
prepare_environment(sys.argv[1], sys.argv[2])

View File

@@ -0,0 +1,9 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/out/ohos-arm-release/vortexnova_soc_products/vortexnova_x86_general/
includedir=${ohos_project_dir}/third_party/libdrm
Name: libdrm_amdgpu
Description: Userspace interface to kernel DRM services
Version: 2.5.109
Libs: -L${libdir} -ldrm_amdgpu
Cflags: -I${includedir} -I${includedir}/include/drm/ -I${includedir}/amdgpu

View File

@@ -0,0 +1,9 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/out/ohos-arm-release/vortexnova_soc_products/vortexnova_x86_general/
includedir=${ohos_project_dir}/third_party/libdrm
Name: libdrm_radeon
Description: Userspace interface to kernel DRM services
Version: 2.5.109
Libs: -L${libdir} -ldrm_radeon
Cflags: -I${includedir} -I${includedir}/include/drm/ -I${includedir}/radeon

View File

@@ -0,0 +1,9 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/out/ohos-arm-release/vortexnova_soc_products/vortexnova_x86_general/
includedir=${ohos_project_dir}/third_party/elfutils/libelf/
Name: libelf
Description: elfutils libelf library to read and write ELF files
Version: 0.185
Libs: -L${libdir} -lelf
Cflags: -I${includedir}

View File

@@ -1,6 +1,6 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/out/ohos-arm-release/obj/third_party/libjpeg/
includedir=${ohos_project_dir}/third_party/libjpeg
libdir=${ohos_project_dir}/out/ohos-arm-release/obj/third_party/libjpeg-turbo/
includedir=${ohos_project_dir}/third_party/libjpeg-turbo
Name: jpeg
Description: jpeg

View File

@@ -1,5 +1,5 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/out//ohos-arm-release/common/graphic_2d/
libdir=${ohos_project_dir}/out/ohos-arm-release/thirdparty/libpng/
includedir=${ohos_project_dir}/third_party/libpng
Name: png

View File

@@ -1,6 +1,6 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/out/ohos-arm-release/graphic/graphic_surface/
includedir=${ohos_project_dir}/out/ohos-arm-release/innerkits/ohos-arm/graphic_surface/surface/include/
includedir=${ohos_project_dir}/out/ohos-arm-release/innerkits/ohos-x86_64/graphic_surface/surface/include/
Name: libsurface
Version: 2.4.1

View File

@@ -1,9 +1,9 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/out/ohos-arm-release/packages/phone/system/lib/
includedir=${ohos_project_dir}/third_party/eudev/export_include
libdir=${ohos_project_dir}/out/ohos-arm-release/obj/foundation/multimodalinput/input/libudev/
includedir=${ohos_project_dir}/foundation/multimodalinput/input/libudev/include/
Name: eudev
Description: eudev
Name: udev
Description: udev
Version: 2.5.109
Libs: -L${libdir} -ludev.z
Libs: -L${libdir} -lmmi_libudev
Cflags: -I${includedir}

View File

@@ -0,0 +1,9 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/out/ohos-arm-release/thirdparty/libxml2/
includedir=${ohos_project_dir}/third_party/libxml2/include
Name: xml2
Description: xml2
Version: 2.9.13
Libs: -L${libdir} -lxml2.z
Cflags: -I${includedir}