1#!/bin/bash 2#Copyright (c) 2023 Huawei Device Co., Ltd. 3#Licensed under the Apache License, Version 2.0 (the "License"); 4#you may not use this file except in compliance with the License. 5#You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8 9#Unless required by applicable law or agreed to in writing, software 10#distributed under the License is distributed on an "AS IS" BASIS, 11#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12#See the License for the specific language governing permissions and 13#limitations under the License. 14set -e 15WORKING_DIR=$(cd "$(dirname "$0")"; pwd) 16PROJECT_ROOT=${WORKING_DIR%/foundation*} 17compile_shader() 18{ 19 OPENHARMONY_DIR=$1 20 if [ ! -n "$1" ] ;then 21 echo "==================orig source shader==================" 22 else 23 echo "==================copy source shader==================" 24 25 cp -r $OPENHARMONY_DIR/foundation/graphic/graphic_3d/lume/Lume_3D/assets/3d/* 3d_source 26 cp -r $OPENHARMONY_DIR/foundation/graphic/graphic_3d/lume/Lume_3D/api/* 3d_api 27 cp -r $OPENHARMONY_DIR/foundation/graphic/graphic_3d/lume/LumeRender/assets/render/* render_source 28 cp -r $OPENHARMONY_DIR/foundation/graphic/graphic_3d/lume/LumeRender/api/* render_api 29 cp -r $OPENHARMONY_DIR/foundation/graphic/graphic_3d/lume/LumeEngine/assets/render/* render_source 30 fi 31 32 rm -rf 3d_dest 33 rm -rf render_dest 34 rm -rf engine_dest 35 36 cp -r 3d_source 3d_dest 37 cp -r render_source render_dest 38 cp -r engine_source engine_dest 39 40 echo "==================build render Shader==================" 41 #./LumeShaderCompiler --optimize --source render_dest/shaders --include render_api 42 ./LumeShaderCompiler --optimize --source $PROJECT_ROOT/foundation/graphic/graphic_3d/lume/LumeRender/assets/render/shaders --include $PROJECT_ROOT/foundation/graphic/graphic_3d/lume/LumeRender/api/ 43 echo "==================build 3d Shader==================" 44 ./LumeShaderCompiler --optimize --source $PROJECT_ROOT/foundation/graphic/graphic_3d/lume/Lume_3D/assets/3d/shaders --include $PROJECT_ROOT/foundation/graphic/graphic_3d/lume/Lume_3D/api/ --include $PROJECT_ROOT/foundation/graphic/graphic_3d/lume/LumeRender/api/ 45} 46 47compile_rofs() 48{ 49 echo "==================build engine rofs==================" 50 ./LumeAssetCompiler -linux -arm64-v8a -extensions ".spv;.json;.lsb;.shader;.shadergs;.shadervid;.shaderpl;.rng;.gl;.gles" engine_dest / BINARYDATAFORCORE SIZEOFDATAFORCORE CORE_ROFS 51 mv CORE_ROFS_64.o engine_dest 52 53 echo "==================build render rofs==================" 54 ./LumeAssetCompiler -linux -arm64-v8a -extensions ".spv;.json;.lsb;.shader;.shadergs;.shadervid;.shaderpl;.rng;.gl;.gles" render_dest / BINARYDATAFORRENDER SIZEOFDATAFORRENDER RENDER_ROFS 55 mv RENDER_ROFS_64.o render_dest 56 57 echo "==================build 3d rofs==================" 58 ./LumeAssetCompiler -linux -arm64-v8a -extensions ".spv;.json;.lsb;.shader;.shadergs;.shadervid;.shaderpl;.rng;.gl;.gles" 3d_dest / BINARY_DATA_FOR_3D SIZE_OF_DATA_FOR_3D CORE3D_ROFS 59 mv CORE3D_ROFS_64.o 3d_dest 60 61} 62 63main() 64{ 65 if [ "$1" == "shader" ] ;then 66 compile_shader $2 67 return 68 fi 69 70 if [ "$1" == "rofs" ] ;then 71 compile_rofs 72 return 73 fi 74 75 if [ "$1" == "all" ] ;then 76 compile_shader $2 77 compile_rofs 78 else 79 compile_shader 80 compile_rofs 81 fi 82} 83 84main $1 85