Compare commits
4 Commits
amd-suppor
...
amd-suppor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d28f49bfa1 | ||
|
|
a6856bb630 | ||
|
|
9f40cafada | ||
|
|
c9e652686a |
91
build.sh
91
build.sh
@@ -1,24 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
print_help() {
|
|
||||||
cat << EOF
|
|
||||||
Usage: $0 <backends> [build_type]
|
|
||||||
|
|
||||||
<backends> MANDATORY. Comma-separated list of
|
|
||||||
backends to enable.
|
|
||||||
Valid options: hsa, intel, cuda
|
|
||||||
Example: hsa,cuda
|
|
||||||
|
|
||||||
[build_type] OPTIONAL. Build type. Valid options:
|
|
||||||
debug, release (default: release)
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
$0 hsa,intel debug
|
|
||||||
$0 cuda
|
|
||||||
$0 hsa,intel,cuda release
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
# gpufetch build script
|
# gpufetch build script
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -26,79 +7,19 @@ rm -rf build/ gpufetch
|
|||||||
mkdir build/
|
mkdir build/
|
||||||
cd build/
|
cd build/
|
||||||
|
|
||||||
if [ "$1" == "--help" ]
|
if [ "$1" == "debug" ]
|
||||||
then
|
then
|
||||||
echo "gpufetch build script"
|
BUILD_TYPE="Debug"
|
||||||
echo
|
|
||||||
print_help
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $# -lt 1 ]]; then
|
|
||||||
echo "ERROR: At least one backend must be specified."
|
|
||||||
echo
|
|
||||||
print_help
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Determine if last argument is build type
|
|
||||||
LAST_ARG="${!#}"
|
|
||||||
if [[ "$LAST_ARG" == "debug" || "$LAST_ARG" == "release" ]]; then
|
|
||||||
BUILD_TYPE="$LAST_ARG"
|
|
||||||
BACKEND_ARG="${1}"
|
|
||||||
else
|
else
|
||||||
BUILD_TYPE="release"
|
BUILD_TYPE="Release"
|
||||||
BACKEND_ARG="${1}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Split comma-separated backends into an array
|
|
||||||
IFS=',' read -r -a BACKENDS <<< "$BACKEND_ARG"
|
|
||||||
|
|
||||||
# Validate build type
|
|
||||||
if [[ "$BUILD_TYPE" != "debug" && "$BUILD_TYPE" != "release" ]]
|
|
||||||
then
|
|
||||||
echo "Error: Invalid build type '$BUILD_TYPE'."
|
|
||||||
echo "Valid options are: debug, release"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# From lower to upper case
|
|
||||||
CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=${BUILD_TYPE^}"
|
|
||||||
|
|
||||||
# Validate backends
|
|
||||||
VALID_BACKENDS=("hsa" "intel" "cuda")
|
|
||||||
|
|
||||||
for BACKEND in "${BACKENDS[@]}"; do
|
|
||||||
case "$BACKEND" in
|
|
||||||
hsa)
|
|
||||||
CMAKE_FLAGS+=" -DENABLE_HSA_BACKEND=ON"
|
|
||||||
;;
|
|
||||||
intel)
|
|
||||||
CMAKE_FLAGS+=" -DENABLE_INTEL_BACKEND=ON"
|
|
||||||
;;
|
|
||||||
cuda)
|
|
||||||
CMAKE_FLAGS+=" -DENABLE_CUDA_BACKEND=ON"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "ERROR: Invalid backend '$BACKEND'."
|
|
||||||
echo "Valid options: ${VALID_BACKENDS[*]}"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# You can also manually specify the compilation flags.
|
|
||||||
# If you need to, just run the cmake command directly
|
|
||||||
# instead of using this script.
|
|
||||||
#
|
|
||||||
# Here you will find some help:
|
|
||||||
#
|
|
||||||
# In case you have CUDA installed but it is not detected,
|
# In case you have CUDA installed but it is not detected,
|
||||||
# - set CMAKE_CUDA_COMPILER to your nvcc binary:
|
# - set CMAKE_CUDA_COMPILER to your nvcc binary:
|
||||||
# - set CMAKE_CUDA_COMPILER_TOOLKIT_ROOT to the CUDA root dir
|
# - set CMAKE_CUDA_COMPILER_TOOLKIT_ROOT to the CUDA root dir
|
||||||
# for example:
|
# for example:
|
||||||
# cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DCMAKE_CUDA_COMPILER_TOOLKIT_ROOT=/usr/local/cuda/ ..
|
# cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DCMAKE_CUDA_COMPILER_TOOLKIT_ROOT=/usr/local/cuda/ ..
|
||||||
#
|
|
||||||
# In case you want to explicitely disable a backend, you can:
|
# In case you want to explicitely disable a backend, you can:
|
||||||
# Disable CUDA backend:
|
# Disable CUDA backend:
|
||||||
# cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_CUDA_BACKEND=OFF ..
|
# cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_CUDA_BACKEND=OFF ..
|
||||||
@@ -107,9 +28,7 @@ done
|
|||||||
# Disable Intel backend:
|
# Disable Intel backend:
|
||||||
# cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_INTEL_BACKEND=OFF ..
|
# cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_INTEL_BACKEND=OFF ..
|
||||||
|
|
||||||
echo "$0: Running cmake $CMAKE_FLAGS"
|
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
|
||||||
echo
|
|
||||||
cmake $CMAKE_FLAGS ..
|
|
||||||
|
|
||||||
os=$(uname)
|
os=$(uname)
|
||||||
if [ "$os" == 'Linux' ]; then
|
if [ "$os" == 'Linux' ]; then
|
||||||
|
|||||||
@@ -197,6 +197,8 @@ bool ascii_fits_screen(int termw, struct ascii_logo logo, int lf) {
|
|||||||
void replace_bgbyfg_color(struct ascii_logo* logo) {
|
void replace_bgbyfg_color(struct ascii_logo* logo) {
|
||||||
// Replace background by foreground color
|
// Replace background by foreground color
|
||||||
for(int i=0; i < 2; i++) {
|
for(int i=0; i < 2; i++) {
|
||||||
|
if(logo->color_ascii[i] == NULL) break;
|
||||||
|
|
||||||
if(strcmp(logo->color_ascii[i], C_BG_BLACK) == 0) strcpy(logo->color_ascii[i], C_FG_BLACK);
|
if(strcmp(logo->color_ascii[i], C_BG_BLACK) == 0) strcpy(logo->color_ascii[i], C_FG_BLACK);
|
||||||
else if(strcmp(logo->color_ascii[i], C_BG_RED) == 0) strcpy(logo->color_ascii[i], C_FG_RED);
|
else if(strcmp(logo->color_ascii[i], C_BG_RED) == 0) strcpy(logo->color_ascii[i], C_FG_RED);
|
||||||
else if(strcmp(logo->color_ascii[i], C_BG_GREEN) == 0) strcpy(logo->color_ascii[i], C_FG_GREEN);
|
else if(strcmp(logo->color_ascii[i], C_BG_GREEN) == 0) strcpy(logo->color_ascii[i], C_FG_GREEN);
|
||||||
|
|||||||
Reference in New Issue
Block a user