-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #369 from akv-platform/v-ivnosa/add-gcc-gfort-clang
Add `gcc`, `gfortran` and `clang` on Windows and Ubuntu images
- Loading branch information
Showing
5 changed files
with
118 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,31 +1,61 @@ | ||
#!/bin/bash | ||
################################################################################ | ||
## File: example.sh | ||
## Desc: This is an example script that can be copied to add a new software | ||
## installer to the image | ||
## File: clang.sh | ||
## Desc: Installs Clang compiler (versions: 6, 8 and 9) | ||
################################################################################ | ||
|
||
# Source the helpers for use with the script | ||
source $HELPER_SCRIPTS/document.sh | ||
source $HELPER_SCRIPTS/apt.sh | ||
|
||
function InstallClang { | ||
version=$1 | ||
|
||
echo "Installing clang-$version..." | ||
# Clang 6.0 is not supported by automatic installation script (`llvm.sh`) | ||
# Thus we have to install it explicitly | ||
if [[ $version == 6* ]]; then | ||
apt-get install -y "clang-$version" "lldb-$version" "lld-$version" | ||
else | ||
./llvm.sh $version | ||
fi | ||
|
||
# Run tests to determine that the software installed as expected | ||
echo "Testing to make sure that script performed as expected, and basic scenarios work" | ||
for cmd in clang-$version clang++-$version; do | ||
if ! command -v $cmd; then | ||
echo "$cmd was not installed" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Document what was added to the image | ||
echo "Documenting clang-$version..." | ||
DocumentInstalledItem "Clang $version ($(clang-$version --version | head -n 1 | cut -d ' ' -f 3 | cut -d '-' -f 1))" | ||
} | ||
|
||
# Install Clang compiler | ||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - | ||
apt-add-repository "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-6.0 main" | ||
apt-get update | ||
apt-get install -y clang-6.0 lldb-6.0 lld-6.0 | ||
|
||
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-6.0 100 | ||
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 100 | ||
|
||
# Run tests to determine that the software installed as expected | ||
echo "Testing to make sure that script performed as expected, and basic scenarios work" | ||
for cmd in clang clang++ clang-6.0 clang++-6.0; do | ||
if ! command -v $cmd; then | ||
echo "$cmd was not installed" | ||
exit 1 | ||
fi | ||
apt-get update -y | ||
|
||
# Download script for automatic installation | ||
wget https://apt.llvm.org/llvm.sh | ||
chmod +x llvm.sh | ||
|
||
versions=( | ||
"6.0" | ||
"8" | ||
"9" | ||
) | ||
|
||
for version in ${versions[*]} | ||
do | ||
InstallClang $version | ||
done | ||
|
||
# Document what was added to the image | ||
echo "Lastly, documenting what we added to the metadata file" | ||
DocumentInstalledItem "Clang 6.0 ($(clang-6.0 --version | head -n 1 | sed 's/~/\\~/g'))" | ||
rm llvm.sh | ||
|
||
# Make Clang 9 default | ||
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-9 100 | ||
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-9 100 |
This file contains 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 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,40 @@ | ||
#!/bin/bash | ||
################################################################################ | ||
## File: gfortran.sh | ||
## Desc: Installs GNU Fortran | ||
################################################################################ | ||
|
||
# Source the helpers for use with the script | ||
source $HELPER_SCRIPTS/document.sh | ||
|
||
function InstallFortran { | ||
version=$1 | ||
|
||
echo "Installing $version..." | ||
apt-get install $version -y | ||
|
||
# Run tests to determine that the software installed as expected | ||
echo "Testing to make sure that script performed as expected, and basic scenarios work" | ||
if ! command -v $version; then | ||
echo "$version was not installed" | ||
exit 1 | ||
fi | ||
|
||
# Document what was added to the image | ||
echo "Documenting $version..." | ||
DocumentInstalledItem "GNU Fortran $($version --version | head -n 1 | cut -d ' ' -f 5)" | ||
} | ||
|
||
# Install GNU Fortran compiler | ||
add-apt-repository ppa:ubuntu-toolchain-r/test -y | ||
apt-get update -y | ||
|
||
versions=( | ||
"gfortran-8" | ||
"gfortran-9" | ||
) | ||
|
||
for version in ${versions[*]} | ||
do | ||
InstallFortran $version | ||
done |
This file contains 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 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