make_skm.sh 2.49 KB
## Keep track of where we are now
if [ "$#" -lt 1 ]; then
    echo -e "Illegal number of parameters!!\n"
    echo -e "Usage: $0 {Release|Debug} where the second parameter is the build type (Release or Debug)"
    exit 1
fi
pwkdir=$(pwd)

build_type=$1

echo -e "Build type is ${build_type^}\n"
echo -e "-- Present working directory is ${pwkdir}"
if [ -d ../../metadata ]
then
    echo -e "-- Moved to `pwd` in order to generate build info"
    echo -e "-- ======================= GENERATING CURRENT BUILD DATA ========================="
    cd ../../metadata

    if [ -f run.sh ]
    then
    ./run.sh
    else
        file="../common/core/build_data.h"
        if [ -f $file ]; then
            contents="`cat $file`"
            echo -e "\nPrevious build key: $contents \n"
        fi

        # if there was any previous build directory, clean it up
        if [ -d build ]
            then
                echo -e "\n>>Cleaning previous builds"
                rm -Rfd build
                echo -e "Clean up completed\n"
        fi

        echo -e "\n>>Building the make file. Please wait..."
        mkdir _build && cd _build && cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release >>output.txt
        echo -e "\n>>Creating the executable. Please wait.."
        make >> output.txt
        echo -e "\n>>Running the executable"
        ./metadata

        cd ..
        if [ ! -d build ]; then
        mkdir build
        fi
        cp _build/metadata build/

        if [ -d _build ]
            then
                #echo -e "\n>>Cleaning previous builds"
                rm -Rf _build
                #echo -e "Clean up completed\n"
        fi

        if [ -f $file ]; then
            contents="`cat $file`"
            echo -e "\nCurrent build key: ${contents} \n"
        fi
    fi
    echo -e "-- ========================== BUILD DATA COMPLETE ======================\n"
fi

# Move back to where we are comming from [Android root directory]
cd $pwkdir

echo -e "-- Back in ${pwkdir} to generate the libskm\n"

if [ ! -d "${build_type,,}"_build ]
then mkdir "${build_type,,}"_build
fi
cd "${build_type,,}"_build

echo -e "-- Now in ${pwkdir} to generate the libskm in ${build_type^} \n"

cmake .. -G Ninja -DCMAKE_ANDROID_ARCH_ABI:STRING="arm64-v8a"  -DANDROID_ABI:STRING="arm64-v8a" \
 -DANDROID_PLATFORM:STRING="android-29"  -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
 -DSELF_BUILD:BOOL=True -DCMAKE_BUILD_TYPE="${build_type^}" -D_UNITY_BUILD_=True && ninja -j8 && cp libskm.a ../libskm.a