diff --git a/images/ubuntu/scripts/build/install-ninja.sh b/images/ubuntu/scripts/build/install-ninja.sh new file mode 100644 index 00000000..3943505d --- /dev/null +++ b/images/ubuntu/scripts/build/install-ninja.sh @@ -0,0 +1,17 @@ +#!/bin/bash -e +################################################################################ +## File: install-ninja.sh +## Desc: Install ninja-build +################################################################################ + +# Source the helpers for use with the script +source $HELPER_SCRIPTS/install.sh + +# Install ninja +download_url=$(resolve_github_release_asset_url "ninja-build/ninja" "endswith(\"ninja-linux.zip\")" "latest") +ninja_binary_path=$(download_with_retry "${download_url}") + +# Unzip the ninja binary +unzip -qq "$ninja_binary_path" -d /usr/local/bin + +invoke_tests "Tools" "Ninja" diff --git a/images/ubuntu/scripts/docs-gen/Generate-SoftwareReport.ps1 b/images/ubuntu/scripts/docs-gen/Generate-SoftwareReport.ps1 index 96226233..9cbd1954 100644 --- a/images/ubuntu/scripts/docs-gen/Generate-SoftwareReport.ps1 +++ b/images/ubuntu/scripts/docs-gen/Generate-SoftwareReport.ps1 @@ -156,6 +156,7 @@ if ((Test-IsUbuntu20) -or (Test-IsUbuntu22)) { $tools.AddToolVersion("yamllint", $(Get-YamllintVersion)) $tools.AddToolVersion("yq", $(Get-YqVersion)) $tools.AddToolVersion("zstd", $(Get-ZstdVersion)) +$tools.AddToolVersion("Ninja", $(Get-NinjaVersion)) # CLI Tools $cliTools = $installedSoftware.AddHeader("CLI Tools") diff --git a/images/ubuntu/scripts/docs-gen/SoftwareReport.Tools.psm1 b/images/ubuntu/scripts/docs-gen/SoftwareReport.Tools.psm1 index b4656b77..33f4306a 100644 --- a/images/ubuntu/scripts/docs-gen/SoftwareReport.Tools.psm1 +++ b/images/ubuntu/scripts/docs-gen/SoftwareReport.Tools.psm1 @@ -275,6 +275,10 @@ function Get-ZstdVersion { return "$zstdVersion" } +function Get-NinjaVersion { + return $(ninja --version) +} + function Get-YqVersion { $yqVersion = $(yq -V) | Get-StringPart -Part 3 return $yqVersion.TrimStart("v").Trim() diff --git a/images/ubuntu/scripts/tests/Tools.Tests.ps1 b/images/ubuntu/scripts/tests/Tools.Tests.ps1 index 54f02e72..7b3da134 100644 --- a/images/ubuntu/scripts/tests/Tools.Tests.ps1 +++ b/images/ubuntu/scripts/tests/Tools.Tests.ps1 @@ -411,3 +411,25 @@ Describe "Kotlin" { "kotlinc-js -version" | Should -ReturnZeroExitCode } } + +Describe "Ninja" { + New-item -Path "/tmp/ninjaproject" -ItemType Directory -Force + Set-Location '/tmp/ninjaproject' +@' +cmake_minimum_required(VERSION 3.10) +project(NinjaTest NONE) +'@ | Out-File -FilePath "./CMakeLists.txt" + + It "Make a simple ninja project" { + "cmake -GNinja /tmp/ninjaproject" | Should -ReturnZeroExitCode + } + + It "build.ninja file should exist" { + $buildFilePath = Join-Path "/tmp/ninjaproject" "build.ninja" + $buildFilePath | Should -Exist + } + + It "Ninja" { + "ninja --version" | Should -ReturnZeroExitCode + } +} diff --git a/images/ubuntu/templates/ubuntu-20.04.pkr.hcl b/images/ubuntu/templates/ubuntu-20.04.pkr.hcl index 8839e11c..2025c727 100644 --- a/images/ubuntu/templates/ubuntu-20.04.pkr.hcl +++ b/images/ubuntu/templates/ubuntu-20.04.pkr.hcl @@ -328,7 +328,8 @@ build { "${path.root}/../scripts/build/install-android-sdk.sh", "${path.root}/../scripts/build/install-pypy.sh", "${path.root}/../scripts/build/install-python.sh", - "${path.root}/../scripts/build/install-zstd.sh" + "${path.root}/../scripts/build/install-zstd.sh", + "${path.root}/../scripts/build/install-ninja.sh" ] } diff --git a/images/ubuntu/templates/ubuntu-22.04.pkr.hcl b/images/ubuntu/templates/ubuntu-22.04.pkr.hcl index 0af16d28..eb96bd31 100644 --- a/images/ubuntu/templates/ubuntu-22.04.pkr.hcl +++ b/images/ubuntu/templates/ubuntu-22.04.pkr.hcl @@ -324,7 +324,8 @@ build { "${path.root}/../scripts/build/install-android-sdk.sh", "${path.root}/../scripts/build/install-pypy.sh", "${path.root}/../scripts/build/install-python.sh", - "${path.root}/../scripts/build/install-zstd.sh" + "${path.root}/../scripts/build/install-zstd.sh", + "${path.root}/../scripts/build/install-ninja.sh" ] } diff --git a/images/ubuntu/templates/ubuntu-24.04.pkr.hcl b/images/ubuntu/templates/ubuntu-24.04.pkr.hcl index 9e2ba381..f67b7f33 100644 --- a/images/ubuntu/templates/ubuntu-24.04.pkr.hcl +++ b/images/ubuntu/templates/ubuntu-24.04.pkr.hcl @@ -313,7 +313,8 @@ provisioner "shell" { "${path.root}/../scripts/build/install-android-sdk.sh", "${path.root}/../scripts/build/install-pypy.sh", "${path.root}/../scripts/build/install-python.sh", - "${path.root}/../scripts/build/install-zstd.sh" + "${path.root}/../scripts/build/install-zstd.sh", + "${path.root}/../scripts/build/install-ninja.sh" ] }