--add-data must be separated by semicolon

This commit is contained in:
Gabriel Niziolek 2024-01-25 10:31:49 -03:00
parent 0ce759f0a3
commit d224f5c898
2 changed files with 36 additions and 1 deletions

View File

@ -56,7 +56,7 @@ if [ ! -z "$ADD_DATA_DIRS" ]; then
# Process every directory in the ADD_DATA_DIRS string
for dir in $ADD_DATA_DIRS; do
# Add the formatted directory to the output string
ADD_DATA+="--add-data $SRCDIR/$dir:$dir "
ADD_DATA+="--add-data \"$SRCDIR/$dir;$dir\" "
done
# Remove the extra space at the end of the output string

35
test.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
# Fail on errors.
set -e
SRCDIR=$1
DIRS=$2
# DIRS will receive a list of directories to be processed in
# the form of a string, e.g. "dir1 dir2/subdir2 file1.txt dir3/file3.txt"
# those can be separated by comas or newlines.
# the output need to be in the format: "--add-data $SRCDIR/$dir1/:dir1/"
# so that pyinstaller can process it correctly.
# the output will be in the form of a string, e.g.
# "--add-data /src/dir1/:dir1/ --add-data /src/dir2/subdir2/:dir2/subdir2/ --add-data /src/file1.txt:file1.txt"
# A string de saída
OUTPUT=""
# Verifica se DIRS está vazio ou não fornecido
if [ ! -z "$DIRS" ]; then
# Processa cada diretório na string DIRS
for dir in $DIRS; do
# Adiciona o diretório formatado à string de saída
OUTPUT+="--add-data $SRCDIR/$dir:$dir "
done
# Remove o espaço extra no final da string de saída
OUTPUT=${OUTPUT::-1}
fi
# Imprime a string de saída
echo $OUTPUT