-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Improved checking for uninstalled tools for unsupported linux distributions. #2887
Conversation
- Support for linux platforms not providing apt or dnf. Installation script searches for required tools and list missing. - Better support for installing outside "/opt". esp and rp2040 tools are not installed in "/opt" if Sming isn't.
PR Summary
|
Fix build warnings/errors in C++20 (SmingHub#2883)
I will rework my pull request taking into account the failed CI run. |
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.
Thank you for this. I do have some reservations though...
Tools/install.sh
Outdated
@@ -99,12 +99,34 @@ elif [ -n "$(command -v dnf)" ]; then | |||
DIST=fedora | |||
PKG_INSTALL="sudo dnf install -y" | |||
else | |||
_OK=1 |
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.
OK
is a bit terse. TOOLS_MISSING
would be better.
Please don't use _ idenfiers - follow the style of existing script.
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 will rework this.
Tools/install.sh
Outdated
_REQUIRED_TOOLS=( | ||
ccache \ | ||
cmake \ | ||
curl \ | ||
git \ | ||
make \ | ||
ninja \ | ||
unzip \ | ||
g++ \ | ||
python3 \ | ||
pip3 \ | ||
wget \ | ||
) | ||
for _TOOL in "${_REQUIRED_TOOLS[@]}"; do | ||
if ! [ -x $(command -v "${_TOOL}") ]; then | ||
_OK=0 | ||
echo "Install required tool ${_TOOL}" | ||
fi | ||
done |
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.
This is a good idea. I'm wondering if this could be added as a general step earlier in the script as a pre-check
for all platforms?
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.
AND provide some generic script functions which can be called from the esp32 install.sh with a list.
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 will look into implementing the pre-check
function.
Sming/Arch/Esp32/Tools/install.sh
Outdated
*) | ||
_OK=1 | ||
_COMMANDS=(dfu-util bison flex gperf) | ||
for _COMMAND in "${_COMMANDS[@]}"; do | ||
if ! [ -x $(command -v "${_COMMAND}") ]; then | ||
_OK=0 | ||
echo "Install programm ${_COMMAND}" | ||
fi | ||
done | ||
_INCLUDES=("/usr/include/ffi.h" "/usr/include/ssl/ssl.h") | ||
for _INCLUDE in "${_INCLUDES[@]}"; do | ||
if ! [ -f "${_INCLUDE}" ]; then | ||
_OK=0 | ||
echo "Install development package providing ${_INCLUDE}" | ||
fi | ||
done | ||
if [ $_OK != 1 ]; then | ||
echo "ABORTING" | ||
exit 1 | ||
fi | ||
PACKAGES=() | ||
;; | ||
|
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.
Seems reasonable, though is an awful lot of script for an edge case. How does Espressif handle non-standard installs of their IDF?
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 environment variables ESP_HOME
, IDF_PATH
, and IDF_TOOLS_PATH
should be used for non-standard installs of Expressif IDF (ESP32 and ESP8266).
Tools/export.sh
Outdated
|
||
# Rp2040 | ||
export PICO_TOOLCHAIN_PATH=${PICO_TOOLCHAIN_PATH:=/opt/rp2040} | ||
export PICO_TOOLCHAIN_PATH=${PICO_TOOLCHAIN_PATH:=${_SMIG_BASE}/rp2040} | ||
|
||
# Provide non-apple CLANG (e.g. for rbpf library) | ||
if [ -n "$GITHUB_ACTIONS" ] && [ "$(uname)" = "Darwin" ]; then |
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.
No. Using the Sming
install location is worse than using /opt
. Whilst there are permissions issues with /opt
I do believe it is the most sensible default. See https://www.baeldung.com/linux/opt-directory and https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard.
Incidentally I never install Sming
in /opt but use sandboxes on a separate ZFS volume. I specifically never put bloatey tool installations (or the IDF) there. Thus the locations of toolchains should be decoupled from the location for Sming.
The procedure for customising install directories is outlined here https://sming.readthedocs.io/en/stable/getting-started/config.html. That should meet your needs. In particular, the ESP32 stuff has separate IDF_PATH
for the framework (which needs to be writeable) and IDF_TOOLS_PATH
for the toolchains.
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 reverted these changes.
I handle the non-standart tools installation using direnv
now.
With Sming checked out to my home directory, and adding a small .envrc
to this directory (and every directory with projects using Sming):
layout Sming
and adding
layout_Sming() {
_SMIG_BASE=${HOME}/Sming
_SMIG_TOOLS=${_SMIG_BASE}/.tools
export ESP_HOME=${_SMIG_TOOLS}/esp-quick-toolchain
export IDF_PATH=${_SMIG_TOOLS}/esp-idf
export IDF_TOOLS_PATH=${_SMIG_TOOLS}/esp32
export PICO_TOOLCHAIN_PATH=${_SMIG_TOOLS}/rp2040
. ${_SMIG_BASE}/Tools/export.sh
}
to ~/.config/direnv/direnvrc
which handles the required path settings.
Well, it's not really forced as you get a prompt to enter password. But yes I agree this aspect could be improved. Maybe just add some more messages to let the user know what's going on? |
Also, I note there are no additional checks for rp2040 / esp8266 ? Does this mean they install as-is or that you don't use them? |
Implemented comments regarding shell variable names I will handle tool installatin paths via direnv. My .envrc is simple: layout Sming With Sming extracte in my home directory my `~/.config/direnv/direnvrc` then contains: layout_Sming() { _SMIG_BASE=${HOME}/Sming _SMIG_TOOLS=${_SMIG_BASE}/.tools export ESP_HOME=${_SMIG_TOOLS}/esp-quick-toolchain export IDF_PATH=${_SMIG_TOOLS}/esp-idf export IDF_TOOLS_PATH=${_SMIG_TOOLS}/esp32 export PICO_TOOLCHAIN_PATH=${_SMIG_TOOLS}/rp2040 . ${_SMIG_BASE}/Tools/export.sh }
Both rp2040 and esp8266 install as they are when ESP_HOME and PICO_TOOLCHAIN_PATH are set to writable paths. |
The new shell function `check_for_installed_tools` can be used to check for installed tools. the function takes a list of required executables for argument. Shell process is aborted if any of the tools is missing. All tools missing in the list are reported. Similar the the shell function `check_for_installed_files` checks for installed files, here used to make sure header files are installed.
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.
Sorry for being finicky, but this is good work. Thank you.
That's what code reviews are for 👍
|
Support for linux platforms not providing apt or dnf. Installation script searches for required tools and list missing.
Better support for installing outside "/opt". esp and rp2040 tools are not installed in "/opt" if Sming isn't.
I tried to install Sming on my OpenSuse Tumbleseed system. For one, I did not like the forced usage of "sudo" without knowing what was going on (I had a wrapper installed that provided "apt", using zypper in the background).
I would have liked code better that checks for required tools and asks the user to install them to install them if missing.
Second installing the tools to "/opt" did not work for me with user install. I don't want "/opt" to be user writable, and even installing the tools using "sudo" lead to fails later, when I tried to compile a project for ESP32.
My patch simply looks for required tools if neither apt nor dnf are found and lets the tools install in the Base directory Sming is installed.