1#!/usr/bin/env bash 2# Copyright (c) 2021-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 -eo pipefail 16 17export SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" 18export ARK_ROOT="$SCRIPT_DIR/../.." 19 20export BUILD_TYPE_RELEASE="Release" 21BUILD_TYPE_FAST_VERIFY="FastVerify" 22BUILD_TYPE_DEBUG="Debug" 23 24export OHOS_SDK_NATIVE="$(realpath "$1")" 25export SDK_BUILD_ROOT="$(realpath "$2")" 26export PANDA_SDK_BUILD_TYPE="${3:-"$BUILD_TYPE_RELEASE"}" 27 28function usage() { 29 echo "$(basename "${BASH_SOURCE[0]}") path/to/ohos/sdk/native path/to/panda/sdk/destination build_type:[$BUILD_TYPE_RELEASE,$BUILD_TYPE_FAST_VERIFY,$BUILD_TYPE_DEBUG]" 30 exit 1 31} 32 33case "$PANDA_SDK_BUILD_TYPE" in 34"$BUILD_TYPE_RELEASE" | "$BUILD_TYPE_FAST_VERIFY" | "$BUILD_TYPE_DEBUG") ;; 35*) 36 echo "Invalid build_type option!" 37 usage 38 ;; 39esac 40 41if [ ! -d "$OHOS_SDK_NATIVE" ]; then 42 echo "Error: No such directory: $OHOS_SDK_NATIVE" 43 usage 44fi 45 46if [ -z "$SDK_BUILD_ROOT" ]; then 47 echo "Error: path to panda sdk destination is not provided" 48 usage 49fi 50 51export PANDA_SDK_PATH="$SDK_BUILD_ROOT/sdk" 52 53rm -r -f "$PANDA_SDK_PATH" 54 55source "$SCRIPT_DIR"/build_sdk_lib 56ohos 57linux_arm64_tools 58linux_tools 59windows_tools 60ts_linter 61ets_std_lib 62 63echo "> Packing NPM package..." 64cp "$SCRIPT_DIR"/package.json "$PANDA_SDK_PATH" 65cd "$PANDA_SDK_PATH" 66npm pack --pack-destination "$SDK_BUILD_ROOT" 67