From f24bd1cb38db2b30f7eaf1f2df8b6961e4811dbd Mon Sep 17 00:00:00 2001 From: zleoyu Date: Thu, 17 Feb 2022 12:12:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8Dohos=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zleoyu --- meson.build | 17 +-- ohos/meson_cross_process.py | 117 ++++++++++++++++++ ohos/pkgconfig_template/expat.pc | 10 ++ ohos/pkgconfig_template/gbm.pc | 9 ++ ohos/pkgconfig_template/libdrm.pc | 9 ++ ohos/pkgconfig_template/libjpeg.pc | 9 ++ ohos/pkgconfig_template/libpng.pc | 9 ++ ohos/pkgconfig_template/libudev.pc | 9 ++ ohos/pkgconfig_template/wayland-client.pc | 11 ++ ohos/pkgconfig_template/wayland-cursor.pc | 9 ++ .../pkgconfig_template/wayland-egl-backend.pc | 9 ++ ohos/pkgconfig_template/wayland-egl.pc | 11 ++ ohos/pkgconfig_template/wayland-protocols.pc | 9 ++ ohos/pkgconfig_template/wayland-scanner.pc | 10 ++ ohos/pkgconfig_template/wayland-server.pc | 12 ++ ohos/pkgconfig_template/zlib.pc | 13 ++ 16 files changed, 257 insertions(+), 16 deletions(-) create mode 100644 ohos/meson_cross_process.py create mode 100644 ohos/pkgconfig_template/expat.pc create mode 100644 ohos/pkgconfig_template/gbm.pc create mode 100644 ohos/pkgconfig_template/libdrm.pc create mode 100644 ohos/pkgconfig_template/libjpeg.pc create mode 100644 ohos/pkgconfig_template/libpng.pc create mode 100644 ohos/pkgconfig_template/libudev.pc create mode 100644 ohos/pkgconfig_template/wayland-client.pc create mode 100644 ohos/pkgconfig_template/wayland-cursor.pc create mode 100644 ohos/pkgconfig_template/wayland-egl-backend.pc create mode 100644 ohos/pkgconfig_template/wayland-egl.pc create mode 100644 ohos/pkgconfig_template/wayland-protocols.pc create mode 100644 ohos/pkgconfig_template/wayland-scanner.pc create mode 100644 ohos/pkgconfig_template/wayland-server.pc create mode 100644 ohos/pkgconfig_template/zlib.pc diff --git a/meson.build b/meson.build index 0aea31260bb..faf681fa419 100644 --- a/meson.build +++ b/meson.build @@ -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' diff --git a/ohos/meson_cross_process.py b/ohos/meson_cross_process.py new file mode 100644 index 00000000000..426f8ee735c --- /dev/null +++ b/ohos/meson_cross_process.py @@ -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()) diff --git a/ohos/pkgconfig_template/expat.pc b/ohos/pkgconfig_template/expat.pc new file mode 100644 index 00000000000..9d5e46e32e9 --- /dev/null +++ b/ohos/pkgconfig_template/expat.pc @@ -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 diff --git a/ohos/pkgconfig_template/gbm.pc b/ohos/pkgconfig_template/gbm.pc new file mode 100644 index 00000000000..b3e52530e01 --- /dev/null +++ b/ohos/pkgconfig_template/gbm.pc @@ -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 diff --git a/ohos/pkgconfig_template/libdrm.pc b/ohos/pkgconfig_template/libdrm.pc new file mode 100644 index 00000000000..397a27b9442 --- /dev/null +++ b/ohos/pkgconfig_template/libdrm.pc @@ -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/ diff --git a/ohos/pkgconfig_template/libjpeg.pc b/ohos/pkgconfig_template/libjpeg.pc new file mode 100644 index 00000000000..3ef5838d2fc --- /dev/null +++ b/ohos/pkgconfig_template/libjpeg.pc @@ -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} \ No newline at end of file diff --git a/ohos/pkgconfig_template/libpng.pc b/ohos/pkgconfig_template/libpng.pc new file mode 100644 index 00000000000..7103a4332c8 --- /dev/null +++ b/ohos/pkgconfig_template/libpng.pc @@ -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} \ No newline at end of file diff --git a/ohos/pkgconfig_template/libudev.pc b/ohos/pkgconfig_template/libudev.pc new file mode 100644 index 00000000000..2ec44585492 --- /dev/null +++ b/ohos/pkgconfig_template/libudev.pc @@ -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} \ No newline at end of file diff --git a/ohos/pkgconfig_template/wayland-client.pc b/ohos/pkgconfig_template/wayland-client.pc new file mode 100644 index 00000000000..6752ff87ca1 --- /dev/null +++ b/ohos/pkgconfig_template/wayland-client.pc @@ -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 diff --git a/ohos/pkgconfig_template/wayland-cursor.pc b/ohos/pkgconfig_template/wayland-cursor.pc new file mode 100644 index 00000000000..4f09e7f2cde --- /dev/null +++ b/ohos/pkgconfig_template/wayland-cursor.pc @@ -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} diff --git a/ohos/pkgconfig_template/wayland-egl-backend.pc b/ohos/pkgconfig_template/wayland-egl-backend.pc new file mode 100644 index 00000000000..cad6b287bca --- /dev/null +++ b/ohos/pkgconfig_template/wayland-egl-backend.pc @@ -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} + diff --git a/ohos/pkgconfig_template/wayland-egl.pc b/ohos/pkgconfig_template/wayland-egl.pc new file mode 100644 index 00000000000..7b8188fd4ff --- /dev/null +++ b/ohos/pkgconfig_template/wayland-egl.pc @@ -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} diff --git a/ohos/pkgconfig_template/wayland-protocols.pc b/ohos/pkgconfig_template/wayland-protocols.pc new file mode 100644 index 00000000000..c0a7cb5557d --- /dev/null +++ b/ohos/pkgconfig_template/wayland-protocols.pc @@ -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 + diff --git a/ohos/pkgconfig_template/wayland-scanner.pc b/ohos/pkgconfig_template/wayland-scanner.pc new file mode 100644 index 00000000000..483d28d71de --- /dev/null +++ b/ohos/pkgconfig_template/wayland-scanner.pc @@ -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 + diff --git a/ohos/pkgconfig_template/wayland-server.pc b/ohos/pkgconfig_template/wayland-server.pc new file mode 100644 index 00000000000..baa53fb3569 --- /dev/null +++ b/ohos/pkgconfig_template/wayland-server.pc @@ -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 diff --git a/ohos/pkgconfig_template/zlib.pc b/ohos/pkgconfig_template/zlib.pc new file mode 100644 index 00000000000..c0bbf7772b2 --- /dev/null +++ b/ohos/pkgconfig_template/zlib.pc @@ -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} \ No newline at end of file