-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add wkdev-setup-default-clang script #65
Open
TingPing
wants to merge
1
commit into
main
Choose a base branch
from
pgriffis/set-default-clang
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 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,67 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2024 Igalia S.L. | ||
# SPDX-License: MIT | ||
|
||
if [ -f "${WKDEV_SDK}/.wkdev-sdk-root" ]; then | ||
source "${WKDEV_SDK}/utilities/application.sh" | ||
else | ||
echo "Please set \${WKDEV_SDK} to point to the root of the wkdev-sdk checkout." | ||
exit 1 | ||
fi | ||
|
||
min_clang_version=14 | ||
max_clang_version=18 | ||
|
||
init_application "${0}" "Installs and creates symlinks to set default clang executables" container-only | ||
|
||
argsparse_use_option "=version:" "The clang version between ${min_clang_version}-${max_clang_version}" "mandatory" "type:uint" | ||
|
||
|
||
argsparse_usage_description="$(cat <<EOF | ||
<< Purpose >> | ||
|
||
Provides an easy way to install and switch between clang toolchains. | ||
|
||
<< Examples >> | ||
|
||
$ ${application_name} --version=17 | ||
EOF | ||
)" | ||
|
||
run() { | ||
|
||
argsparse_parse_options "${@}" | ||
local version="${program_options["version"]}" | ||
|
||
_log_ "" | ||
|
||
# Sanity check versions Ubuntu actually has. | ||
if (( ${version} < ${min_clang_version} )) || (( ${version} > ${max_clang_version})); then | ||
_log_ "${version} is not a valid value (between ${min_clang_version}-${max_clang_version})." | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f "/usr/bin/clang-${version}" ]; then | ||
_log_ "Installing clang toolchain version ${version}" | ||
_log_ "" | ||
if ! sudo apt-get install "clang-tools-${version}" "clangd-${version}" "clang-format-${version}" "clang-tidy-${version}" "lld-${version}" "lldb-${version}"; then | ||
_log_ "" | ||
_log_ "Failed to install clang toolchain" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
local output_path | ||
if [ "$EUID" -eq 0 ]; then | ||
output_path="/usr/local/bin" | ||
else | ||
output_path="${HOME}/.local/bin" | ||
fi | ||
_log_ "Creating symlinks in ${output_path}" | ||
for binary in /usr/bin/*-"${version}"; do | ||
local binary_name="$(basename ${binary})" | ||
ln --symbolic --force "${binary}" "${output_path}/${binary_name::-3}" | ||
done | ||
} | ||
|
||
run "${@}" |
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.
We should be able to invoke this script from here, no? Maybe at a later point in the script, but still..
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.
The wkdev-sdk scripts are not in the image. We could copy them and then remove them, feels not great either.
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.
As long as you copy and remove in the same layer, there is no increase an image size -- I agree looks odd, but helps reducing code duplication...