-
Notifications
You must be signed in to change notification settings - Fork 698
Install libcpp from release package other than apt-get #11832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
40f581b
Install libcpp from release package other than apt-get
cccclai e2350e2
Update on "Install libcpp from release package other than apt-get"
cccclai db5eeda
Update on "Install libcpp from release package other than apt-get"
cccclai 4eefd95
Update on "Install libcpp from release package other than apt-get"
cccclai 0b691e4
Update on "Install libcpp from release package other than apt-get"
cccclai 1e30b88
Update on "Install libcpp from release package other than apt-get"
cccclai aef98ee
Update on "Install libcpp from release package other than apt-get"
cccclai e88d5f1
Update on "Install libcpp from release package other than apt-get"
cccclai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| #!/bin/bash | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| set -ex | ||
|
|
||
| # Get the absolute path of this script | ||
| SCRIPT_DIR="$( cd -- "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 ; pwd -P )" | ||
|
|
||
| # Source QNN configuration from the same directory | ||
| source "${SCRIPT_DIR}/qnn_config.sh" | ||
|
|
||
| # Function to install Android NDK (only if not already set) | ||
| setup_android_ndk() { | ||
| # Check if ANDROID_NDK_ROOT is already set and valid | ||
| if [ -n "${ANDROID_NDK_ROOT}" ] && [ -d "${ANDROID_NDK_ROOT}" ]; then | ||
| echo "Android NDK already set to ${ANDROID_NDK_ROOT} - skipping installation" | ||
| return | ||
| fi | ||
|
|
||
| NDK_VERSION="r25c" | ||
cccclai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| NDK_INSTALL_DIR="/tmp/android-ndk" | ||
|
|
||
| if [ -d "${NDK_INSTALL_DIR}/ndk" ]; then | ||
| echo "Android NDK already installed at ${NDK_INSTALL_DIR}/ndk" | ||
| export ANDROID_NDK_ROOT="${NDK_INSTALL_DIR}/ndk" | ||
| return | ||
| fi | ||
|
|
||
| echo "Installing Android NDK ${NDK_VERSION}" | ||
| mkdir -p "${NDK_INSTALL_DIR}" | ||
| NDK_ZIP="android-ndk-${NDK_VERSION}-linux.zip" | ||
|
|
||
| curl -Lo "/tmp/${NDK_ZIP}" "https://dl.google.com/android/repository/${NDK_ZIP}" | ||
| unzip -q "/tmp/${NDK_ZIP}" -d "${NDK_INSTALL_DIR}" | ||
| mv "${NDK_INSTALL_DIR}/android-ndk-${NDK_VERSION}" "${NDK_INSTALL_DIR}/ndk" | ||
|
|
||
| export ANDROID_NDK_ROOT="${NDK_INSTALL_DIR}/ndk" | ||
| echo "Android NDK installed to ${ANDROID_NDK_ROOT}" | ||
| } | ||
|
|
||
| verify_pkg_installed() { | ||
| dpkg-query -W --showformat='${Status}\n' "$1" | grep -q "install ok installed" | ||
| } | ||
|
|
||
| install_qnn() { | ||
| # Check if QNN_SDK_ROOT is already set and valid | ||
| if [ -n "${QNN_SDK_ROOT}" ] && [ -d "${QNN_SDK_ROOT}" ]; then | ||
| echo "QNN SDK already set to ${QNN_SDK_ROOT} - skipping installation" | ||
| return | ||
| fi | ||
|
|
||
| echo "Start installing qnn v${QNN_VERSION}" | ||
| QNN_INSTALLATION_DIR="/tmp/qnn" | ||
|
|
||
| # Clean up any previous installation | ||
| if [ -d "${QNN_INSTALLATION_DIR}" ]; then | ||
| echo "Removing previous QNN installation at ${QNN_INSTALLATION_DIR}" | ||
| rm -rf "${QNN_INSTALLATION_DIR}" | ||
| fi | ||
|
|
||
| mkdir -p "${QNN_INSTALLATION_DIR}" | ||
|
|
||
| QNN_ZIP_FILE="v${QNN_VERSION}.zip" | ||
| curl -Lo "/tmp/${QNN_ZIP_FILE}" "${QNN_ZIP_URL}" | ||
| echo "Finishing downloading qnn sdk." | ||
| unzip -qo "/tmp/${QNN_ZIP_FILE}" -d /tmp | ||
| echo "Finishing unzip qnn sdk." | ||
|
|
||
| # Print the content for manual verification | ||
| echo "Contents of /tmp/qairt:" | ||
| ls -lah "/tmp/qairt" | ||
|
|
||
| # Move the specific version directory | ||
| if [ -d "/tmp/qairt/${QNN_VERSION}" ]; then | ||
| mv "/tmp/qairt/${QNN_VERSION}" "${QNN_INSTALLATION_DIR}" | ||
| else | ||
| mv "/tmp/qairt"/* "${QNN_INSTALLATION_DIR}" | ||
| fi | ||
|
|
||
| echo "Finishing installing qnn '${QNN_INSTALLATION_DIR}' ." | ||
| echo "Final QNN installation contents:" | ||
| ls -lah "${QNN_INSTALLATION_DIR}" | ||
|
|
||
| # Set QNN_SDK_ROOT environment variable | ||
| export QNN_SDK_ROOT="${QNN_INSTALLATION_DIR}" | ||
| echo "Set QNN_SDK_ROOT=${QNN_SDK_ROOT}" | ||
| } | ||
|
|
||
| setup_libcpp() { | ||
cccclai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| clang_version=$1 | ||
| LLVM_VERSION="12.0.0" | ||
cccclai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| INSTALL_DIR="/usr/local/libcxx-${LLVM_VERSION}" | ||
|
|
||
| # Check if libc++ is already installed | ||
| if [ -d "/usr/include/c++/v1" ] && \ | ||
| [ -f "/usr/lib/libc++.so.1" ] && \ | ||
| [ -f "/usr/lib/libc++abi.so.1" ]; then | ||
| echo "libc++-${clang_version}-dev is already installed - skipping" | ||
| return | ||
| fi | ||
|
|
||
| echo "Installing libc++-${clang_version}-dev manually from LLVM releases" | ||
|
|
||
| # Create temporary directory | ||
| TEMP_DIR=$(mktemp -d) | ||
| pushd "${TEMP_DIR}" | ||
|
|
||
| # Download and extract LLVM binaries | ||
| LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-20.04.tar.xz" | ||
| curl -LO "${LLVM_URL}" | ||
| tar -xf "clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-20.04.tar.xz" | ||
|
|
||
| # Create necessary directories | ||
| sudo mkdir -p "${INSTALL_DIR}/include" | ||
| sudo mkdir -p "${INSTALL_DIR}/lib" # FIX: Create lib directory | ||
|
|
||
| # Copy libc++ headers and libraries | ||
| sudo cp -r clang+llvm*/include/c++/v1/* "${INSTALL_DIR}/include/" | ||
| sudo cp -r clang+llvm*/lib/*.so* "${INSTALL_DIR}/lib/" | ||
|
|
||
| # Create system symlinks | ||
| sudo mkdir -p /usr/include/c++ | ||
| sudo ln -sf "${INSTALL_DIR}/include" /usr/include/c++/v1 | ||
| sudo ln -sf "${INSTALL_DIR}/lib/libc++.so.1.0" /usr/lib/libc++.so.1 | ||
| sudo ln -sf "${INSTALL_DIR}/lib/libc++.so.1" /usr/lib/libc++.so | ||
| sudo ln -sf "${INSTALL_DIR}/lib/libc++abi.so.1.0" /usr/lib/libc++abi.so.1 | ||
| sudo ln -sf "${INSTALL_DIR}/lib/libc++abi.so.1" /usr/lib/libc++abi.so | ||
|
|
||
| # Update library cache | ||
| sudo ldconfig | ||
|
|
||
| # Cleanup | ||
| popd | ||
| rm -rf "${TEMP_DIR}" | ||
|
|
||
| echo "libc++-${clang_version}-dev installed to ${INSTALL_DIR}" | ||
| } | ||
|
|
||
| setup_libcpp 12 | ||
| setup_android_ndk | ||
| install_qnn | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| # QNN SDK Configuration | ||
| QNN_VERSION="2.28.0.241029" | ||
| QNN_ZIP_URL="https://softwarecenter.qualcomm.com/api/download/software/qualcomm_neural_processing_sdk/v${QNN_VERSION}.zip" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you like to change the script permission such as 755?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share what I need to change? This line means it's bash script, should I do something different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops, Sorry for the confusion—I meant this script, not this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, does it mean I need to add instructions in readme to change the permission for this script? Just trying to understand your intention better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it would be better for general user :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or I think you can change this file permission and push again.
https://stackoverflow.com/questions/10516201/updating-and-committing-only-a-files-permissions-using-git-version-control
https://stackoverflow.com/questions/59160266/git-and-permissions/59163100#59163100
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually maybe let me try not requiring the permission
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR without requiring permission