!2 适配ohos编译链

Merge pull request !2 from zleoyu/master
This commit is contained in:
openharmony_sig_ci 2022-02-17 06:51:53 +00:00 committed by Gitee
commit 5d28c1a49e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
16 changed files with 257 additions and 16 deletions

View File

@ -493,21 +493,6 @@ if with_egl and not _platforms.contains(egl_native_platform)
endif
# Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS.
use_elf_tls = false
if (not ['freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and
(not with_platform_android or get_option('platform-sdk-version') >= 29) and
(not with_platform_windows or not with_shared_glapi))
pre_args += '-DUSE_ELF_TLS'
use_elf_tls = true
if with_platform_android
# By default the NDK compiler, at least, emits emutls references instead of
# ELF TLS, even when building targeting newer API levels. Make it actually do
# ELF TLS instead.
c_args += '-fno-emulated-tls'
cpp_args += '-fno-emulated-tls'
endif
endif
if with_glx != 'disabled'
if not (with_platform_x11 and with_any_opengl)
@ -1973,7 +1958,7 @@ endif
# TODO: symbol mangling
if with_platform_wayland
dep_wl_scanner = dependency('wayland-scanner', native: true)
dep_wl_scanner = dependency('wayland-scanner')
prog_wl_scanner = find_program(dep_wl_scanner.get_pkgconfig_variable('wayland_scanner'))
if dep_wl_scanner.version().version_compare('>= 1.15')
wl_scanner_arg = 'private-code'

117
ohos/meson_cross_process.py Normal file
View File

@ -0,0 +1,117 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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=armv7-a',
'-mfloat-abi=softfp',
'-mtune=generic-armv7-a',
'-mfpu=neon',
'-mthumb',
'--target=arm-linux-ohosmusl',
'--sysroot=sysroot_stub',
'-fPIC']
cpp_args = [
'-march=armv7-a',
'--target=arm-linux-ohosmusl',
'--sysroot=sysroot_stub',
'-fPIC']
c_link_args = [
'-march=armv7-a',
'--target=arm-linux-ohosmusl',
'-fPIC',
'--sysroot=sysroot_stub',
'-Lsysroot_stub/usr/lib/arm-linux-ohos',
'-Lproject_stub/prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/10.0.1/lib/arm-linux-ohos',
'-Lproject_stub/prebuilts/clang/ohos/linux-x87_64/llvm/lib/arm-linux-ohos/c++',
'--rtlib=compiler-rt',
]
cpp_link_args = [
'-march=armv7-a',
'--target=arm-linux-ohosmusl',
'--sysroot=sysroot_stub',
'-Lsysroot_stub/usr/lib/arm-linux-ohos',
'-Lproject_stub/prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/10.0.1/lib/arm-linux-ohos',
'-Lproject_stub/prebuilts/clang/ohos/linux-x87_64/llvm/lib/arm-linux-ohos/c++',
'-fPIC',
'-Wl,--exclude-libs=libunwind_llvm.a',
'-Wl,--exclude-libs=libc++_static.a',
'-Wl,--exclude-libs=libvpx_assembly_arm.a',
'-Wl,--warn-shared-textrel',
'--rtlib=compiler-rt',
]
[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'
pkgconfig = '/usr/bin/pkg-config'
[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7'
endian = 'little'
'''
def generate_cross_file(project_stub, sysroot_stub):
with open("cross_file", 'w+') as file:
result = corss_file_content.replace("project_stub", project_stub)
result = result.replace("sysroot_stub", sysroot_stub)
file.write(result)
print("generate_cross_file")
def generate_pc_file(file_raw, project_dir, product_name):
print(file_raw)
filename = 'pkgconfig/'+ ntpath.basename(file_raw)
with open(file_raw, 'r+') as file_raw:
with open(filename, "w+") as 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)
file.write(raw_content)
print("generate_pc_file")
def process_pkgconfig(project_dir, product_name):
files = os.listdir(os.path.split(os.path.abspath( __file__))[0] + r"/pkgconfig_template")
for file in files:
if not os.path.isdir(file):
generate_pc_file(r"pkgconfig_template/" + file, project_dir, product_name)
print("process_pkgconfig")
if __name__ == '__main__':
if len(sys.argv) < 3:
print("must input the OpenHarmony directory and the product name")
exit(-1)
project_stub = sys.argv[1]
sysroot_stub = sys.argv[1] + r"/out/" + sys.argv[2].lower() + r"/obj/third_party/musl"
generate_cross_file(sys.argv[1], sysroot_stub)
process_pkgconfig(sys.argv[1], sys.argv[2].lower())

View File

@ -0,0 +1,10 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/out/ohos-arm-release/obj/third_party/expat
includedir=${ohos_project_dir}/third_party/expat/lib
Name: expat
Version: 2.4.1
Description: expat XML parser
Libs: -L${libdir} -lexpat
Cflags: -I${includedir}
expat

View File

@ -0,0 +1,9 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/device/rockchip/hardware/gpu
includedir=${ohos_project_dir}/device/rockchip/hardware/gpu/include
Name: gbm
Description: Userspace interface to kernel DRM services
Version: 2.5.109
Libs: -L${libdir} -llibgbm
Cflags: -I${ohos_project_dir}/device/rockchip/hardware/gpu/include

View File

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

View File

@ -0,0 +1,9 @@
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
Name: jpeg
Description: jpeg
Version: 2.5.109
Libs: -L${libdir} -ljpeg_static
Cflags: -I${includedir}

View File

@ -0,0 +1,9 @@
ohos_project_dir=ohos_project_directory_stub
libdir=${ohos_project_dir}/out//ohos-arm-release/common/graphic_standard/
includedir=${ohos_project_dir}/third_party/libpng
Name: png
Description: png
Version: 2.5.109
Libs: -L${libdir} -lpng.z
Cflags: -I${includedir}

View File

@ -0,0 +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
Name: eudev
Description: eudev
Version: 2.5.109
Libs: -L${libdir} -ludev.z
Cflags: -I${includedir}

View File

@ -0,0 +1,11 @@
prefix=ohos_project_directory_stub
datarootdir=${prefix}/share
pkgdatadir=${datarootdir}/wayland
libdir=${prefix}/out/ohos-arm-release/graphic/graphic_standard
includedir=${prefix}/third_party/wayland_standard/src
Name: Wayland Client
Description: Server side implementation of the Wayland protocol
Version: 1.18.0
Cflags: -I${includedir} -I${prefix}/out/ohos-arm-release/gen/third_party/wayland_standard/protocol
Libs: -L${libdir} -lwayland_client.0.z

View File

@ -0,0 +1,9 @@
prefix=ohos_project_directory_stub
libdir=${prefix}/out/ohos-arm-release/obj/third_party/wayland_standard/
includedir=${prefix}/third_party/wayland_standard/cursor
Name: wayland_cursor
Description: Server side implementation of the Wayland cursor
Version: 2.5.109
Libs: -L${libdir} -llibwayland_cursor
Cflags: -I${includedir}

View File

@ -0,0 +1,9 @@
prefix=ohos_project_directory_stub
includedir=${prefix}/third_party/wayland_standard/egl
Name: wayland-egl-backend
Description: Backend wayland-egl interface
Version: 3
Libs:
Cflags: -I${includedir}

View File

@ -0,0 +1,11 @@
prefix=ohos_project_directory_stub
exec_prefix=${prefix}
libdir=${prefix}/out/ohos-arm-release/graphic/graphic_standard/
includedir=${prefix}/third_party/wayland_standard/egl
Name: wayland-egl
Description: Frontend wayland-egl library
Version: 18.1.0
Requires: wayland-client
Libs: -L${libdir} -lwayland_client.0.z
Cflags: -I${includedir}

View File

@ -0,0 +1,9 @@
prefix=ohos_project_directory_stub
datarootdir=${prefix}/third_party
pkgdatadir=${datarootdir}/wayland-protocols_standard
includedir = ${prefix}/out/ohos-arm-release/gen/third_party/wayland_standard/protocol
Name: Wayland Protocols
Description: Wayland protocol files
Version: 1.24
Cflags: -I${includedir} -I${prefix}/third_party/wayland_standard/egl

View File

@ -0,0 +1,10 @@
prefix=ohos_project_directory_stub
exec_prefix=${prefix}
datarootdir=${prefix}/share
pkgdatadir=${datarootdir}/wayland
wayland_scanner=${prefix}/out/ohos-arm-release/clang_x64/graphic/graphic_standard/wayland_scanner
Name: Wayland Scanner
Description: Wayland scanner
Version: 1.19.0

View File

@ -0,0 +1,12 @@
prefix=ohos_project_directory_stub
exec_prefix=${prefix}
datarootdir=${prefix}/share
pkgdatadir=${datarootdir}/wayland
libdir=${prefix}/out/ohos-arm-release/graphic/graphic_standard
includedir=${prefix}/third_party/wayland_standard/src
Name: Wayland Server
Description: Server side implementation of the Wayland protocol
Version: 1.18.0
Cflags: -I${includedir} -I${prefix}/out/ohos-arm-release/gen/third_party/wayland_standard/protocol
Libs: -L${libdir} -lwayland_server.0.z

View File

@ -0,0 +1,13 @@
prefix=ohos_project_directory_stub
exec_prefix=${prefix}
libdir=${prefix}/out/ohos-arm-release/obj/third_party/zlib
sharedlibdir=${libdir}
includedir=${prefix}/third_party/zlib
Name: zlib
Description: zlib compression library
Version: 1.2.12
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags: -I${includedir}