add ohos
Change-Id: I00a99b2b7e437c9b4b27a2cc426052929cc23f9e
This commit is contained in:
106
ohos/BUILD.gn
Executable file
106
ohos/BUILD.gn
Executable file
@@ -0,0 +1,106 @@
|
||||
# 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.
|
||||
|
||||
import("//build/config/clang/clang.gni")
|
||||
|
||||
# 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("//build/ohos.gni")
|
||||
import("dependency_inputs.gni")
|
||||
mesa3d_libs_dir = "$root_build_dir/packages/phone/mesa3d"
|
||||
|
||||
mesa3d_gallium_symlinks = [ "panfrost_dri.so" ]
|
||||
|
||||
mesa3d_all_lib_items = [
|
||||
[
|
||||
"libEGL.so.1.0.0",
|
||||
[
|
||||
"libEGL.so",
|
||||
"libEGL.so.1",
|
||||
"libEGL_impl.so",
|
||||
],
|
||||
],
|
||||
[
|
||||
"libgbm.so.1.0.0",
|
||||
[
|
||||
"libgbm.so",
|
||||
"libgbm.so.1",
|
||||
],
|
||||
],
|
||||
[
|
||||
"libglapi.so.0.0.0",
|
||||
[
|
||||
"libglapi.so",
|
||||
"libglapi.so.0",
|
||||
],
|
||||
],
|
||||
[
|
||||
"libGLESv1_CM.so.1.1.0",
|
||||
[
|
||||
"libGLESv1_CM.so",
|
||||
"libGLESv1_CM.so.1",
|
||||
"libGLESv1_impl.so",
|
||||
],
|
||||
],
|
||||
[
|
||||
"libGLESv2.so.2.0.0",
|
||||
[
|
||||
"libGLESv2.so",
|
||||
"libGLESv2.so.2",
|
||||
"libGLESv3.so",
|
||||
"libGLESv2_impl.so",
|
||||
"libGLESv3_impl.so",
|
||||
],
|
||||
],
|
||||
[
|
||||
"libgallium_dri.so",
|
||||
mesa3d_gallium_symlinks,
|
||||
],
|
||||
]
|
||||
|
||||
action("mesa3d_build") {
|
||||
inputs = deps_inputs
|
||||
script = "build_mesa3d.py"
|
||||
deps = [ "//third_party/expat:expat" ]
|
||||
external_deps = [ "graphic_surface:surface" ]
|
||||
outputs = []
|
||||
foreach(item, mesa3d_all_lib_items) {
|
||||
name = item[0]
|
||||
outputs += [ "$mesa3d_libs_dir/$name" ]
|
||||
}
|
||||
args = [ rebase_path(root_build_dir) ]
|
||||
}
|
||||
|
||||
mesa3d_all_lib_deps = []
|
||||
|
||||
foreach(item, mesa3d_all_lib_items) {
|
||||
name = item[0]
|
||||
ohos_prebuilt_shared_library(name) {
|
||||
source = "$mesa3d_libs_dir/$name"
|
||||
deps = [ ":mesa3d_build" ]
|
||||
symlink_target_name = item[1]
|
||||
install_enable = true
|
||||
install_images = [ system_base_dir ]
|
||||
subsystem_name = "rockchip_products"
|
||||
part_name = "rockchip_products"
|
||||
}
|
||||
mesa3d_all_lib_deps += [ ":$name" ]
|
||||
}
|
||||
|
||||
group("mesa3d_all_libs") {
|
||||
deps = mesa3d_all_lib_deps
|
||||
}
|
41
ohos/README_zh.md
Normal file
41
ohos/README_zh.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_ohos.py ~/openharmony rk3568 ~/mesa3d
|
||||
|
||||
```
|
90
ohos/build_mesa3d.py
Executable file
90
ohos/build_mesa3d.py
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2022 Institute of Software, CAS
|
||||
# Author: xiaofan@iscas.ac.cn
|
||||
|
||||
# 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 os
|
||||
import os.path
|
||||
import subprocess
|
||||
import multiprocessing
|
||||
import glob
|
||||
import shutil
|
||||
from meson_cross_process import prepare_environment
|
||||
|
||||
# input /path/to/openharmony/out/rk3568
|
||||
|
||||
nproc = multiprocessing.cpu_count()
|
||||
out_dir = sys.argv[1]
|
||||
mesa3d_install_dir = os.path.join(out_dir, 'packages', 'phone', 'mesa3d')
|
||||
product = os.path.basename(out_dir)
|
||||
project_dir = os.path.dirname(os.path.dirname(out_dir))
|
||||
project_dir = os.path.abspath(project_dir)
|
||||
mesa3d_dir = os.path.dirname(os.path.dirname(__file__))
|
||||
mesa3d_dir = os.path.abspath(mesa3d_dir)
|
||||
pkgconf_dir = os.path.join(mesa3d_dir, './pkgconfig')
|
||||
os.environ['PKG_CONFIG_PATH'] = pkgconf_dir
|
||||
|
||||
# workaround: using system python instead of prebuilt python
|
||||
path_old = os.environ['PATH'].split(':')
|
||||
path_filter = lambda p: not p.endswith('/prebuilts/python/linux-x86/3.8.5/bin')
|
||||
path_new = ':'.join(filter(path_filter, path_old))
|
||||
os.environ['PATH'] = path_new
|
||||
|
||||
os.chdir(mesa3d_dir)
|
||||
prepare_environment(project_dir, product)
|
||||
|
||||
meson_cmd = [
|
||||
'meson',
|
||||
'setup',
|
||||
mesa3d_dir,
|
||||
'build-ohos',
|
||||
'-Dplatforms=ohos',
|
||||
'-Degl-native-platform=ohos',
|
||||
'-Ddri-drivers=',
|
||||
'-Dgallium-drivers=panfrost',
|
||||
'-Dvulkan-drivers=',
|
||||
'-Dgbm=enabled',
|
||||
'-Degl=enabled',
|
||||
'-Dcpp_rtti=false',
|
||||
'-Dglx=disabled',
|
||||
'-Dtools=panfrost',
|
||||
'-Ddri-search-path=/system/lib',
|
||||
'--cross-file=cross_file',
|
||||
F'--prefix={mesa3d_dir}/build-ohos/install',
|
||||
]
|
||||
|
||||
subprocess.run(meson_cmd, check=True)
|
||||
subprocess.run(F'ninja -C build-ohos -j{nproc}', shell=True, check=True)
|
||||
subprocess.run(F'ninja -C build-ohos install', shell=True, check=True)
|
||||
|
||||
build_lib = os.path.join(mesa3d_dir, 'build-ohos', 'install', 'lib')
|
||||
build_lib_dri = os.path.join(build_lib, 'dri')
|
||||
|
||||
# install to out/rk3568/packages/phone/mesa3d
|
||||
shutil.rmtree(mesa3d_install_dir, ignore_errors=True)
|
||||
os.makedirs(mesa3d_install_dir, exist_ok=True)
|
||||
for item in glob.glob(os.path.join(build_lib, 'lib*.so.*.*.*')):
|
||||
shutil.copy(item, mesa3d_install_dir)
|
||||
for item in glob.glob(os.path.join(build_lib_dri, '*_dri.so')):
|
||||
# all *_dir.so are same file, we need only copy one and rename it to libgallium_dri.so
|
||||
shutil.copy(item, os.path.join(mesa3d_install_dir, 'libgallium_dri.so')) # consider create symlink or hardlink
|
||||
break
|
43
ohos/build_ohos.py
Normal file
43
ohos/build_ohos.py
Normal 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.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=panfrost \
|
||||
-Dvulkan-drivers= -Dgbm=enabled -Degl=enabled -Dcpp_rtti=false -Dglx=disabled -Dtools=panfrost -Ddri-search-path=/system/lib '
|
||||
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')
|
43
ohos/build_ohos_arm64.py
Normal file
43
ohos/build_ohos_arm64.py
Normal 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_arm64.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=panfrost \
|
||||
-Dvulkan-drivers= -Dgbm=enabled -Degl=enabled -Dgles1=enabled -Dgles2=enabled -Dcpp_rtti=false -Dglx=disabled -Dtools=panfrost -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 -j126')
|
||||
os.system('ninja -C build-ohos install')
|
43
ohos/build_ohos_x86.py
Normal file
43
ohos/build_ohos_x86.py
Normal 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 -Dgallium-drivers=crocus,iris \
|
||||
-Dvulkan-drivers= -Dgbm=enabled -Degl=enabled -Dcpp_rtti=false -Dglx=disabled -Dtools=intel '
|
||||
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')
|
44
ohos/build_wayland_and_gbm.py
Normal file
44
ohos/build_wayland_and_gbm.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/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.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')
|
6980
ohos/dependency_inputs.gni
Normal file
6980
ohos/dependency_inputs.gni
Normal file
File diff suppressed because it is too large
Load Diff
134
ohos/meson_cross_process.py
Normal file
134
ohos/meson_cross_process.py
Normal file
@@ -0,0 +1,134 @@
|
||||
#!/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=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_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])
|
129
ohos/meson_cross_process_arm64.py
Normal file
129
ohos/meson_cross_process_arm64.py
Normal file
@@ -0,0 +1,129 @@
|
||||
#!/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 = [
|
||||
'--target=aarch64-linux-ohosmusl',
|
||||
'--sysroot=sysroot_stub',
|
||||
'-fno-emulated-tls',
|
||||
'-fPIC']
|
||||
|
||||
cpp_args = [
|
||||
'--target=aarch64-linux-ohosmusl',
|
||||
'--sysroot=sysroot_stub',
|
||||
'-fno-emulated-tls',
|
||||
'-fPIC']
|
||||
|
||||
c_link_args = [
|
||||
'--target=aarch64-linux-ohosmusl',
|
||||
'-fPIC',
|
||||
'--sysroot=sysroot_stub',
|
||||
'-Lsysroot_stub/usr/lib/aarch64-linux-ohos',
|
||||
'-Lproject_stub/prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/current/lib/aarch64-linux-ohos',
|
||||
'-Lproject_stub/prebuilts/clang/ohos/linux-x86_64/llvm/lib/aarch64-linux-ohos/c++',
|
||||
'--rtlib=compiler-rt',
|
||||
]
|
||||
|
||||
cpp_link_args = [
|
||||
'--target=aarch64-linux-ohosmusl',
|
||||
'--sysroot=sysroot_stub',
|
||||
'-Lsysroot_stub/usr/lib/aarch64-linux-ohos',
|
||||
'-Lproject_stub/prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/current/lib/aarch64-linux-ohos',
|
||||
'-Lproject_stub/prebuilts/clang/ohos/linux-x86_64/llvm/lib/aarch64-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 = 'armv8'
|
||||
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)
|
||||
raw_content = raw_content.replace("ohos-arm", "ohos-arm64")
|
||||
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])
|
219
ohos/meson_cross_process_x86.py
Normal file
219
ohos/meson_cross_process_x86.py
Normal 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/tools/llvm-project-llvmorg-18.1.8/build/bin/llvm-strip'
|
||||
llvm-config = 'project_stub/tools/llvm-project-llvmorg-18.1.8/build/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])
|
112
ohos/modifyDtsi.py
Executable file
112
ohos/modifyDtsi.py
Executable file
@@ -0,0 +1,112 @@
|
||||
#!/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.
|
||||
|
||||
from ast import Delete
|
||||
import sys, os
|
||||
|
||||
class Modify():
|
||||
def __init__(self, filePath) -> None:
|
||||
self.filePath = filePath
|
||||
self.lines = []
|
||||
|
||||
fp = open(self.filePath, 'r')
|
||||
for line in fp:
|
||||
self.lines.append(line)
|
||||
fp.close()
|
||||
|
||||
def saveAndClose(self):
|
||||
s = ''.join(self.lines)
|
||||
self.lines.clear()
|
||||
fp = open(self.filePath, 'w')
|
||||
fp.write(s)
|
||||
fp.close()
|
||||
|
||||
def positionSearch(self, positionText, startLineNum = 0):
|
||||
linesLen = len(self.lines)
|
||||
for lineNum in range(startLineNum + 1, linesLen):
|
||||
if(positionText in self.lines[lineNum]):
|
||||
return lineNum
|
||||
return -1
|
||||
|
||||
def addItem(self, newText, positionInedx, rowNume):
|
||||
assert rowNume >= 0,"rowNum含义为“要将newText添加到positionSearch所定位的条目下的第几行”,可以等于0及添加到当前行,将当前行往下挤,但不可以为负数,如需要在positionSearch所定位的条目上方添加复数行,请按顺序调用addItem函数,且rowNum都填入0"
|
||||
item = ''
|
||||
if("is not set" in newText):
|
||||
item = newText[2:-11]
|
||||
else:
|
||||
item = newText[:-2]
|
||||
|
||||
# 如果要添加的内容已经存在则直接返回
|
||||
for line in self.lines:
|
||||
if(item in line):
|
||||
if ((item + "=y" in line) or (item + " is not set" in line)):
|
||||
print("Already has this item: " + item)
|
||||
return
|
||||
|
||||
assert positionInedx >= 0, "If want to add an item, first 'positionInedx' must be >= 0"
|
||||
lineNum = positionInedx + rowNume
|
||||
self.lines.insert(lineNum, newText+'\n')
|
||||
if(rowNume <= 0):
|
||||
positionInedx += 1
|
||||
print("Add item: "+item)
|
||||
|
||||
def deleteLines(self, startLineIndex, endLineIndex):
|
||||
for i in range(endLineIndex - startLineIndex):
|
||||
self.lines.pop(startLineIndex)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
path = sys.argv[1]
|
||||
modify = Modify(path)
|
||||
print("Start to modifying file", sys.argv[1])
|
||||
|
||||
test = [' compatible = "rockchip, rk3568-mali", "arm,mali-bifrost";',
|
||||
' reg = <0x0 0xfde60000 0x0 0x20000>;',
|
||||
'',
|
||||
' interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,',
|
||||
' <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,',
|
||||
' <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;',
|
||||
' interrupt-names = "job", "mmu", "gpu";',
|
||||
' clocks = <&scmi_clk 1>, <&cru CLK_GPU>;',
|
||||
' clock-names = "core", "bus";',
|
||||
' operating-points-v2 = <&gpu_opp_table>;',
|
||||
'',
|
||||
' #cooling-cells = <2>;',
|
||||
' power-domains = <&power RK3568_PD_GPU>;',
|
||||
' status = "disabled";']
|
||||
|
||||
if(modify.positionSearch("gpu_power_model: power-model",0) == -1):
|
||||
print("rk3568.dtsi arealy modified")
|
||||
exit()
|
||||
|
||||
positionInedx1 = modify.positionSearch("gpu: gpu@fde60000",0)
|
||||
if(positionInedx1 >= 0):
|
||||
positionInedx2 = modify.positionSearch("};",positionInedx1)
|
||||
modify.deleteLines(positionInedx1 + 1, positionInedx2 + 1)
|
||||
|
||||
for i in range(len(test)):
|
||||
modify.addItem(test[i], positionInedx1, i + 1)
|
||||
|
||||
modify.saveAndClose()
|
||||
|
||||
print("Succese")
|
10
ohos/pkgconfig_template/expat.pc
Normal file
10
ohos/pkgconfig_template/expat.pc
Normal file
@@ -0,0 +1,10 @@
|
||||
ohos_project_dir=ohos_project_directory_stub
|
||||
libdir=${ohos_project_dir}/out/ohos-arm-release/obj/third_party/skia/third_party/expat
|
||||
includedir=${ohos_project_dir}/third_party/skia/third_party/externals/expat/expat/lib
|
||||
|
||||
Name: expat
|
||||
Version: 2.4.1
|
||||
Description: expat XML parser
|
||||
Libs: -L${libdir} -lexpat
|
||||
Cflags: -I${includedir}
|
||||
expat
|
9
ohos/pkgconfig_template/gbm.pc
Normal file
9
ohos/pkgconfig_template/gbm.pc
Normal 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
|
9
ohos/pkgconfig_template/libdrm.pc
Normal file
9
ohos/pkgconfig_template/libdrm.pc
Normal file
@@ -0,0 +1,9 @@
|
||||
ohos_project_dir=ohos_project_directory_stub
|
||||
libdir=${ohos_project_dir}/out/ohos-arm-release/thirdparty/libdrm/
|
||||
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/
|
9
ohos/pkgconfig_template/libdrm_amdgpu.pc
Normal file
9
ohos/pkgconfig_template/libdrm_amdgpu.pc
Normal 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
|
9
ohos/pkgconfig_template/libdrm_radeon.pc
Normal file
9
ohos/pkgconfig_template/libdrm_radeon.pc
Normal 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
|
9
ohos/pkgconfig_template/libelf.pc
Normal file
9
ohos/pkgconfig_template/libelf.pc
Normal 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}
|
9
ohos/pkgconfig_template/libhilog.pc
Normal file
9
ohos/pkgconfig_template/libhilog.pc
Normal file
@@ -0,0 +1,9 @@
|
||||
ohos_project_dir=ohos_project_directory_stub
|
||||
libdir=${ohos_project_dir}/out/ohos-arm-release/hiviewdfx/hilog
|
||||
includedir=${ohos_project_dir}/base/hiviewdfx/hilog/interfaces/native/innerkits/include
|
||||
|
||||
Name: libhilog
|
||||
Version: 2.4.1
|
||||
Description: libhilog
|
||||
Libs: -L${libdir} -lhilog
|
||||
Cflags: -I${includedir}
|
9
ohos/pkgconfig_template/libjpeg.pc
Normal file
9
ohos/pkgconfig_template/libjpeg.pc
Normal file
@@ -0,0 +1,9 @@
|
||||
ohos_project_dir=ohos_project_directory_stub
|
||||
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
|
||||
Version: 2.5.109
|
||||
Libs: -L${libdir} -ljpeg_static
|
||||
Cflags: -I${includedir}
|
9
ohos/pkgconfig_template/libpng.pc
Normal file
9
ohos/pkgconfig_template/libpng.pc
Normal file
@@ -0,0 +1,9 @@
|
||||
ohos_project_dir=ohos_project_directory_stub
|
||||
libdir=${ohos_project_dir}/out/ohos-arm-release/thirdparty/libpng/
|
||||
includedir=${ohos_project_dir}/third_party/libpng
|
||||
|
||||
Name: png
|
||||
Description: png
|
||||
Version: 2.5.109
|
||||
Libs: -L${libdir} -lpng.z
|
||||
Cflags: -I${includedir}
|
9
ohos/pkgconfig_template/libsurface.pc
Normal file
9
ohos/pkgconfig_template/libsurface.pc
Normal file
@@ -0,0 +1,9 @@
|
||||
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-x86_64/graphic_surface/surface/include/
|
||||
|
||||
Name: libsurface
|
||||
Version: 2.4.1
|
||||
Description: libsurface
|
||||
Libs: -L${libdir} -lsurface.z
|
||||
Cflags: -I${includedir} -I${ohos_project_dir}/drivers/peripheral/display/interfaces/include -I${ohos_project_dir}/drivers/peripheral/base
|
9
ohos/pkgconfig_template/libudev.pc
Normal file
9
ohos/pkgconfig_template/libudev.pc
Normal file
@@ -0,0 +1,9 @@
|
||||
ohos_project_dir=ohos_project_directory_stub
|
||||
libdir=${ohos_project_dir}/out/ohos-arm-release/obj/foundation/multimodalinput/input/libudev/
|
||||
includedir=${ohos_project_dir}/foundation/multimodalinput/input/libudev/include/
|
||||
|
||||
Name: udev
|
||||
Description: udev
|
||||
Version: 2.5.109
|
||||
Libs: -L${libdir} -lmmi_libudev
|
||||
Cflags: -I${includedir}
|
9
ohos/pkgconfig_template/libxml2.pc
Normal file
9
ohos/pkgconfig_template/libxml2.pc
Normal 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}
|
11
ohos/pkgconfig_template/wayland-client.pc
Normal file
11
ohos/pkgconfig_template/wayland-client.pc
Normal file
@@ -0,0 +1,11 @@
|
||||
prefix=ohos_project_directory_stub
|
||||
datarootdir=${prefix}/share
|
||||
pkgdatadir=${datarootdir}/wayland
|
||||
libdir=${prefix}/out/ohos-arm-release/graphic/graphic_2d
|
||||
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
|
9
ohos/pkgconfig_template/wayland-cursor.pc
Normal file
9
ohos/pkgconfig_template/wayland-cursor.pc
Normal 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}
|
9
ohos/pkgconfig_template/wayland-egl-backend.pc
Normal file
9
ohos/pkgconfig_template/wayland-egl-backend.pc
Normal 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}
|
||||
|
11
ohos/pkgconfig_template/wayland-egl.pc
Normal file
11
ohos/pkgconfig_template/wayland-egl.pc
Normal file
@@ -0,0 +1,11 @@
|
||||
prefix=ohos_project_directory_stub
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/out/ohos-arm-release/graphic/graphic_2d/
|
||||
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}
|
9
ohos/pkgconfig_template/wayland-protocols.pc
Normal file
9
ohos/pkgconfig_template/wayland-protocols.pc
Normal 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
|
||||
|
10
ohos/pkgconfig_template/wayland-scanner.pc
Normal file
10
ohos/pkgconfig_template/wayland-scanner.pc
Normal 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_2d/wayland_scanner
|
||||
|
||||
Name: Wayland Scanner
|
||||
Description: Wayland scanner
|
||||
Version: 1.19.0
|
||||
|
12
ohos/pkgconfig_template/wayland-server.pc
Normal file
12
ohos/pkgconfig_template/wayland-server.pc
Normal 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_2d
|
||||
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
|
13
ohos/pkgconfig_template/zlib.pc
Normal file
13
ohos/pkgconfig_template/zlib.pc
Normal 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}
|
Reference in New Issue
Block a user