• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2024 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.
14
15set -e
16WORKING_DIR=$(cd "$(dirname "$0")"; pwd)
17PROJECT_ROOT=${WORKING_DIR%/LumeEngine*}
18echo ${PROJECT_ROOT}
19
20TOOL_PATH=$3
21SHADER_PATH=$4
22INCLUDE_PATH=$5
23
24DEST_GEN_PATH=$1
25ASSETS_PATH=$2
26
27RENDER_INCLUDE_PATH=""
28
29if [ $# -eq 6 ];
30then
31    RENDER_INCLUDE_PATH=$6
32fi
33
34compile_shader()
35{
36    echo "Lume4 Compile shader $1 $2 $3 $4"
37    if [ -d "$DEST_GEN_PATH" ]; then
38        rm -rf $DEST_GEN_PATH
39        echo "Clean Output"
40    fi
41    TEST_TOOL_PATH=$TOOL_PATH
42    mkdir -p $DEST_GEN_PATH
43    chmod -R 775 $DEST_GEN_PATH
44
45    cp -r ${ASSETS_PATH}/* $DEST_GEN_PATH
46
47    if [ ! -f "$TEST_TOOL_PATH"/LumeShaderCompiler ]; then
48         echo "lume engine shader compiler not exist"
49    fi
50
51    if [ -z "$RENDER_INCLUDE_PATH" ];
52    then
53        $TEST_TOOL_PATH/LumeShaderCompiler --optimize --source $SHADER_PATH --include $PROJECT_ROOT/LumeRender/api/
54    else
55        $TEST_TOOL_PATH/LumeShaderCompiler --optimize --source $SHADER_PATH --include $PROJECT_ROOT/Lume_3D/api/ --include $PROJECT_ROOT/LumeRender/api/
56    fi
57}
58
59compile_shader
60