mirror of
https://gitee.com/openharmony/third_party_mesa3d
synced 2025-02-22 03:03:39 +00:00
add build script
Signed-off-by: lhl <linhongliang@hisilicon.com>
This commit is contained in:
parent
5d28c1a49e
commit
b4adc23fe0
41
ohos/README.md
Normal file
41
ohos/README.md
Normal file
@ -0,0 +1,41 @@
|
||||
### 编译环境依赖:
|
||||
1. meson
|
||||
mesa是使用meson进行编译的并要求版本>= 0.52,可执行以下命令安装meson
|
||||
```
|
||||
sudo apt-get install python3 python3-pip ninja-build
|
||||
pip3 install --user meson
|
||||
```
|
||||
2. pkg-config
|
||||
meson配置编译环境时会使用pkg-config查找依赖库和头文件,可以执行以下命令安装
|
||||
```
|
||||
sudo apt-get install pkg-config
|
||||
```
|
||||
|
||||
### 编译步骤如下:
|
||||
1. 下载openharmony整个工程代码,并完成编译
|
||||
2. 因为有些依赖库是静态库,整编后会被删除需要执行以下命令单独编译以rk3568为例
|
||||
```
|
||||
./build.sh --product-name=rk3568 --build-target=expat
|
||||
./build.sh --product-name=rk3568 --build-target=libwayland_server.0
|
||||
./build.sh --product-name=rk3568 --build-target=libwayland_client.0
|
||||
./build.sh --product-name=rk3568 --build-target=libwayland_server
|
||||
./build.sh --product-name=rk3568 --build-target=libwayland_client
|
||||
```
|
||||
|
||||
3. 编译mesa
|
||||
编译鸿蒙系统下的mesa库时,需要配置鸿蒙的交叉编译链和依赖的库,相关配置和编译步骤已经封装到ohos目录下的python脚本中,编译时只需执行 build_wayland_and_gbm.py 脚本即可,执行命名需要输入三个参数
|
||||
|
||||
| 参数 | 说明 |
|
||||
| ---- | ---- |
|
||||
| arg1 | openharmony代码路径 |
|
||||
| arg2 | 产品名字,实际上为out目录下存放系统编译结果的那个目录 如hi3516dv300 或则 rk3568, 注: LTS3.0 的版本必须是 ohos-arm-release|
|
||||
| arg3 | mesa 源码路径|
|
||||
|
||||
示例如下:
|
||||
~/openharmony 是openharmony源码路径, rk3568是对应的产品输出目录,~/mesa3d为mesa源码路径, 执行完命令后会生成一个名叫builddir的文件夹,该文件夹是mesa的编译目录. 编译完成后相关的库存放在builddir/install/lib 下
|
||||
|
||||
```
|
||||
cd ~/mesa3d
|
||||
python ohos/build_wayland_and_gbm.py ~/openharmony rk3568 ~/mesa3d
|
||||
|
||||
```
|
36
ohos/build_wayland_and_gbm.py
Normal file
36
ohos/build_wayland_and_gbm.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/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 expressor implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
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.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] + ' builddir '
|
||||
run_build_cmd += '-Dvulkan-drivers= -Ddri-drivers= -Dgallium-drivers=panfrost \
|
||||
-Dplatforms=wayland -Dglx=disabled -Dtools=panfrost --buildtype=release '
|
||||
run_build_cmd += '--cross-file=cross_file '
|
||||
run_build_cmd += '--prefix=' + os.getcwd() + '/builddir/install'
|
||||
print("build command: %s" %run_build_cmd)
|
||||
os.system(run_build_cmd)
|
||||
os.system('ninja -C builddir -j26')
|
||||
os.system('ninja -C builddir install')
|
60
ohos/cross_file
Normal file
60
ohos/cross_file
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
[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=2/out/3/obj/third_party/musl',
|
||||
'-fPIC']
|
||||
|
||||
cpp_args = [
|
||||
'-march=armv7-a',
|
||||
'--target=arm-linux-ohosmusl',
|
||||
'--sysroot=2/out/3/obj/third_party/musl',
|
||||
'-fPIC']
|
||||
|
||||
c_link_args = [
|
||||
'-march=armv7-a',
|
||||
'--target=arm-linux-ohosmusl',
|
||||
'-fPIC',
|
||||
'--sysroot=2/out/3/obj/third_party/musl',
|
||||
'-L2/out/3/obj/third_party/musl/usr/lib/arm-linux-ohos',
|
||||
'-L2/prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/10.0.1/lib/arm-linux-ohos',
|
||||
'-L2/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=2/out/3/obj/third_party/musl',
|
||||
'-L2/out/3/obj/third_party/musl/usr/lib/arm-linux-ohos',
|
||||
'-L2/prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/10.0.1/lib/arm-linux-ohos',
|
||||
'-L2/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 = '2/prebuilts/clang/ohos/linux-x86_64/llvm/bin/llvm-ar'
|
||||
c = ['ccache', '2/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang']
|
||||
cpp = ['ccache', '2/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang++']
|
||||
c_ld= 'lld'
|
||||
cpp_ld = 'lld'
|
||||
strip = '2/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'
|
@ -91,6 +91,8 @@ def generate_cross_file(project_stub, sysroot_stub):
|
||||
|
||||
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 file:
|
||||
@ -101,10 +103,11 @@ def generate_pc_file(file_raw, project_dir, product_name):
|
||||
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")
|
||||
template_dir = os.path.split(os.path.abspath( __file__))[0] + r"/pkgconfig_template"
|
||||
files = os.listdir(template_dir)
|
||||
for file in files:
|
||||
if not os.path.isdir(file):
|
||||
generate_pc_file(r"pkgconfig_template/" + file, project_dir, product_name)
|
||||
generate_pc_file(template_dir + '/' + file, project_dir, product_name)
|
||||
print("process_pkgconfig")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
x
Reference in New Issue
Block a user