18bf80f4bSopenharmony_ci#!/bin/bash
28bf80f4bSopenharmony_ci# Copyright (C) 2024 Huawei Device Co., Ltd.
38bf80f4bSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
48bf80f4bSopenharmony_ci# you may not use this file except in compliance with the License.
58bf80f4bSopenharmony_ci# You may obtain a copy of the License at
68bf80f4bSopenharmony_ci#
78bf80f4bSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
88bf80f4bSopenharmony_ci#
98bf80f4bSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
108bf80f4bSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
118bf80f4bSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128bf80f4bSopenharmony_ci# See the License for the specific language governing permissions and
138bf80f4bSopenharmony_ci# limitations under the License.
148bf80f4bSopenharmony_ci
158bf80f4bSopenharmony_ciset -e
168bf80f4bSopenharmony_ciWORKING_DIR=$(cd "$(dirname "$0")"; pwd)
178bf80f4bSopenharmony_ciPROJECT_ROOT=${WORKING_DIR%/LumeEngine*}
188bf80f4bSopenharmony_ciecho ${PROJECT_ROOT}
198bf80f4bSopenharmony_ci
208bf80f4bSopenharmony_ciTOOL_PATH=$3
218bf80f4bSopenharmony_ciSHADER_PATH=$4
228bf80f4bSopenharmony_ciINCLUDE_PATH=$5
238bf80f4bSopenharmony_ci
248bf80f4bSopenharmony_ciDEST_GEN_PATH=$1
258bf80f4bSopenharmony_ciASSETS_PATH=$2
268bf80f4bSopenharmony_ci
278bf80f4bSopenharmony_ciRENDER_INCLUDE_PATH=""
288bf80f4bSopenharmony_ci
298bf80f4bSopenharmony_ciif [ $# -eq 6 ];
308bf80f4bSopenharmony_cithen
318bf80f4bSopenharmony_ci    RENDER_INCLUDE_PATH=$6
328bf80f4bSopenharmony_cifi
338bf80f4bSopenharmony_ci
348bf80f4bSopenharmony_cicompile_shader()
358bf80f4bSopenharmony_ci{
368bf80f4bSopenharmony_ci	echo "Lume4 Compile shader $1 $2 $3 $4"
378bf80f4bSopenharmony_ci    if [ -d "$DEST_GEN_PATH" ]; then
388bf80f4bSopenharmony_ci        rm -rf $DEST_GEN_PATH
398bf80f4bSopenharmony_ci        echo "Clean Output"
408bf80f4bSopenharmony_ci    fi
418bf80f4bSopenharmony_ci    TEST_TOOL_PATH=$TOOL_PATH/../LumeBinaryCompile/LumeShaderCompiler
428bf80f4bSopenharmony_ci    mkdir -p $DEST_GEN_PATH
438bf80f4bSopenharmony_ci    chmod -R 775 $DEST_GEN_PATH
448bf80f4bSopenharmony_ci
458bf80f4bSopenharmony_ci    cp -r ${ASSETS_PATH}/* $DEST_GEN_PATH
468bf80f4bSopenharmony_ci    if [ -z "$RENDER_INCLUDE_PATH" ];
478bf80f4bSopenharmony_ci    then
488bf80f4bSopenharmony_ci        $TEST_TOOL_PATH/LumeShaderCompiler --optimize --source $SHADER_PATH --include $PROJECT_ROOT/LumeRender/api/
498bf80f4bSopenharmony_ci    else
508bf80f4bSopenharmony_ci        $TEST_TOOL_PATH/LumeShaderCompiler --optimize --source $SHADER_PATH --include $PROJECT_ROOT/Lume_3D/api/ --include $PROJECT_ROOT/LumeRender/api/
518bf80f4bSopenharmony_ci    fi
528bf80f4bSopenharmony_ci}
538bf80f4bSopenharmony_ci
548bf80f4bSopenharmony_cicompile_shader
55