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*} 17echo ${PROJECT_ROOT} 18CMAKE_ROOT=$PROJECT_ROOT/prebuilts/cmake/linux-x86/bin 19echo $CMAKE_ROOT 20 21OHOS_NDK=$PROJECT_ROOT/prebuilts/clang/ohos/linux-x86_64/llvm 22LLVM_DIR=$PROJECT_ROOT/prebuilts/clang/ohos/linux-x86_64/llvm 23echo $LLVM_DIR 24 25NINJA_HOME=$PROJECT_ROOT/prebuilts/build-tools/linux-x86/bin 26echo $NINJA_HOME 27export PATH="$NINJA_HOME:$PATH" 28 29DEST_GEN_PATH=$1 30 31compile() 32{ 33 PROJECT_DIR=$DEST_GEN_PATH 34 if [ ! -d "$PROJECT_DIR" ]; then 35 mkdir -p $PROJECT_DIR 36 if [ $? -eq 0 ]; then 37 echo "lume shader compiler mkdir successfully" 38 else 39 echo "lume shader compiler mkdir failed" 40 fi 41 chmod -R 775 $PROJECT_DIR 42 mkdir $PROJECT_DIR/Strip 43 if [ $? -eq 0 ]; then 44 echo "lume shader compiler mkdir strip successfully" 45 else 46 echo "lume shader compiler mkdir strip failed" 47 fi 48 fi 49 $CMAKE_ROOT/cmake --version 50 51 $CMAKE_ROOT/cmake -H$WORKING_DIR -B$PROJECT_DIR -DCMAKE_CXX_FLAGS_RELEASE=-O2 \ 52 -DCMAKE_SYSTEM_NAME=Linux \ 53 -DOHOS_NDK=${LLVM_DIR} -DCMAKE_TOOLCHAIN_FILE=$WORKING_DIR/shader.compile.toolchain.cmake \ 54 -G Ninja 55#-DCMAKE_SYSROOT=$LLVM_DIR/lib/x86_64-unknow-linux-gnu 56 ninja -C $PROJECT_DIR -f build.ninja 57 58 chmod 775 $PROJECT_DIR/LumeShaderCompiler 59 cp -r $PROJECT_DIR/LumeShaderCompiler $PROJECT_DIR/Strip 60 #$LLVM_DIR/bin/llvm-strip -s $PROJECT_DIR/Strip/LumeShaderCompiler 61} 62 63echo "compile start shader x86_64" 64 65compile 66