Skip to content

Commit

Permalink
install ninja prebuilt binaries again (#270)
Browse files Browse the repository at this point in the history
* install ninja prebuilt binaries again

* update ninja version in integration test
  • Loading branch information
trxcllnt authored Apr 18, 2024
1 parent 48b3afd commit d776a3b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 75 deletions.
10 changes: 2 additions & 8 deletions features/src/ninja/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
{
"name": "Ninja build",
"id": "ninja",
"version": "24.6.0",
"version": "24.6.1",
"description": "A feature to install ninja-build",
"options": {
"version": {
"type": "string",
"proposals": [
"latest",
"1.11.1",
"1.11.0",
"1.10.2",
"1.10.1",
"1.10.0",
"1.9.0",
"1.8.2"
"1.12.0"
],
"default": "latest",
"description": "ninja-build version to install."
Expand Down
77 changes: 12 additions & 65 deletions features/src/ninja/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,81 +9,28 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
# install global/common scripts
. ./common/install.sh;

PKG=();
PKG+=("jq");
PKG+=("git");
PKG+=("make");
PKG+=("wget");
PKG+=("file");
PKG+=("unzip");
PKG+=("ca-certificates");
PKG+=("bash-completion");
PKG_TO_REMOVE=();

if ! type gcc >/dev/null 2>&1; then
PKG+=("gcc");
PKG_TO_REMOVE+=("gcc");
fi
if ! type g++ >/dev/null 2>&1; then
PKG+=("g++");
PKG_TO_REMOVE+=("g++");
fi

check_packages ${PKG[@]};

if ! type cmake >/dev/null 2>&1; then
CMAKE_VERSION=latest;
find_version_from_git_tags CMAKE_VERSION https://github.com/Kitware/CMake;

while ! wget --no-hsts -q -O /tmp/cmake_${CMAKE_VERSION}.sh https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$(uname -p).sh; do
echo "(!) cmake version ${CMAKE_VERSION} failed to download. Attempting to fall back one version to retry...";
find_prev_version_from_git_tags CMAKE_VERSION https://github.com/Kitware/CMake;
done

echo "Installing CMake...";

# Install CMake
mkdir -p /tmp/cmake
bash /tmp/cmake_${CMAKE_VERSION}.sh --skip-license --exclude-subdir --prefix=/tmp/cmake;
cmake="/tmp/cmake/bin/cmake";
else
cmake="$(which cmake)";
fi
check_packages jq wget unzip ca-certificates bash-completion;

echo "Installing ninja-build...";

if [ $NINJA_VERSION == latest ]; then
if [ "${NINJA_VERSION}" = latest ]; then
find_version_from_git_tags NINJA_VERSION https://github.com/ninja-build/ninja;
fi

# Clone Ninja
git clone \
-j$(nproc) \
--single-branch \
--shallow-submodules \
--recurse-submodules \
--branch "v$NINJA_VERSION" \
https://github.com/ninja-build/ninja \
/tmp/ninja;
_name="ninja-linux";

if test "$(uname -p)" = "aarch64"; then
_name+="-aarch64";
fi

# Configure Ninja
$cmake -S /tmp/ninja -B /tmp/ninja/build -DCMAKE_BUILD_TYPE=Release;
# Build Ninja
$cmake --build /tmp/ninja/build --parallel --config Release;
# Install Ninja
strip /tmp/ninja/build/ninja;
file /tmp/ninja/build/ninja;
$cmake --install /tmp/ninja/build;
wget --no-hsts -q -O /tmp/ninja-linux.zip \
"https://github.com/ninja-build/ninja/releases/download/v${NINJA_VERSION}/${_name}.zip";
unzip -d /usr/bin /tmp/ninja-linux.zip;
chmod +x /usr/bin/ninja;

# Clean up
# rm -rf /tmp/*;
rm -rf /var/tmp/*;
rm -rf /var/cache/apt/*;
rm -rf /var/lib/apt/lists/*;
rm -rf /tmp/{cmake,ninja};
rm -rf /tmp/cmake_${CMAKE_VERSION}.sh;

if [[ ${#PKG_TO_REMOVE[@]} -gt 0 ]]; then
DEBIAN_FRONTEND=noninteractive apt-get -y remove ${PKG_TO_REMOVE[@]};
DEBIAN_FRONTEND=noninteractive apt-get -y autoremove;
fi
rm -rf /tmp/ninja-linux.zip;
2 changes: 1 addition & 1 deletion features/test/_global/cpp_llvm_cuda_nvhpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ check "cmake exists and is on path" which cmake;
check "version" bash -c "cmake --version | grep '$CMAKE_VERSION'";

# Check ninja
NINJA_VERSION="1.11.1";
NINJA_VERSION="1.12.0";
check "ninja exists and is on path" which ninja;
check "version" bash -c "ninja --version | grep '$NINJA_VERSION'";

Expand Down
2 changes: 1 addition & 1 deletion features/test/_global/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"version": "3.25.2"
},
"ninja": {
"version": "1.11.1"
"version": "1.12.0"
},
"sccache": {
"version": "0.4.0"
Expand Down

0 comments on commit d776a3b

Please sign in to comment.