xref: /aosp_15_r20/external/executorch/.ci/scripts/setup-qnn-deps.sh (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1#!/bin/bash
2# Copyright (c) Meta Platforms, Inc. and affiliates.
3# All rights reserved.
4#
5# This source code is licensed under the BSD-style license found in the
6# LICENSE file in the root directory of this source tree.
7
8set -ex
9
10verify_pkg_installed() {
11  echo $(dpkg-query -W --showformat='${Status}\n' $1|grep "install ok installed")
12}
13
14install_qnn() {
15  echo "Start installing qnn."
16  QNN_INSTALLATION_DIR=/tmp/qnn
17  mkdir -p "${QNN_INSTALLATION_DIR}"
18
19  curl -Lo /tmp/v2.25.0.24.07.28.zip "https://softwarecenter.qualcomm.com/api/download/software/qualcomm_neural_processing_sdk/v2.25.0.240728.zip"
20  echo "Finishing downloading qnn sdk."
21  unzip -qo /tmp/v2.25.0.24.07.28.zip -d /tmp
22  echo "Finishing unzip qnn sdk."
23
24
25  # Print the content for manual verification
26  ls -lah "/tmp/qairt"
27  mv "/tmp/qairt"/* "${QNN_INSTALLATION_DIR}"
28  echo "Finishing installing qnn '${QNN_INSTALLATION_DIR}' ."
29
30  ls -lah "${QNN_INSTALLATION_DIR}"
31}
32
33setup_libc++() {
34  clang_version=$1
35  sudo apt-get update
36  pkgs_to_check=("libc++-${clang_version}-dev")
37  j=0
38  while [ $j -lt ${#pkgs_to_check[*]} ]; do
39    install_status=$(verify_pkg_installed ${pkgs_to_check[$j]})
40    if [ "$install_status" == "" ]; then
41      sudo apt-get install -y ${pkgs_to_check[$j]}
42      if [[ $? -ne 0 ]]; then
43        echo "ERROR: Failed to install required packages for libc++"
44        exit 1
45      fi
46    fi
47    j=$(( $j +1));
48  done
49}
50
51# This needs to match with the clang version from the Docker image
52setup_libc++ 12
53install_qnn
54