Skip to content

Merge gdspx#548

Merged
JiepengTan merged 1 commit intogoplus:devfrom
JiepengTan:pr_merge_gdspx
Apr 2, 2025
Merged

Merge gdspx#548
JiepengTan merged 1 commit intogoplus:devfrom
JiepengTan:pr_merge_gdspx

Conversation

@JiepengTan
Copy link
Copy Markdown
Contributor

No description provided.

@JiepengTan JiepengTan requested review from nighca and removed request for nighca April 1, 2025 01:08
@JiepengTan JiepengTan changed the title Merge gdspx 【WIP】Merge gdspx Apr 1, 2025
@JiepengTan JiepengTan marked this pull request as draft April 1, 2025 01:10
@JiepengTan JiepengTan force-pushed the pr_merge_gdspx branch 4 times, most recently from cd69cc3 to 9a1f938 Compare April 1, 2025 11:25
local godot_path="$GODOT_PATH"
local platform=$1
shift 1
local scons_args=$@
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate. [SC2124]

Details

lint 解释

这个lint结果表明在脚本中将一个数组赋值给了一个字符串。这通常会导致意外的行为,因为数组和字符串是不同的数据类型。

错误用法

以下是一个错误的示例代码:

my_array=("apple" "banana" "cherry")
my_string=$my_array  # 这里会将整个数组赋值给一个字符串

在这个例子中,my_array 是一个包含三个元素的数组,而 my_string 被错误地赋值为这个数组。这会导致 my_string 包含整个数组的内容,而不是预期的单个字符串。

正确用法

正确的做法是将数组作为数组处理,或者使用适当的符号来连接数组元素。以下是两种正确的示例:

  1. 将数组作为数组处理:
my_array=("apple" "banana" "cherry")
for item in "${my_array[@]}"; do
  echo "$item"
done
  1. 使用 * 符号将数组连接成一个字符串:
my_array=("apple" "banana" "cherry")
my_string="${my_array[*]}"  # 这里会将数组元素用空格连接成一个字符串
echo "$my_string"

在第二个示例中,${my_array[*]} 会将数组中的所有元素用空格连接成一个字符串,并赋值给 my_string


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

echo "----------------------------------------"

# ios
IOSP1="IOS_SDK_PATH='/root/ioscross/arm64/SDK/iPhoneOS17.0.sdk'"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Quotes/backslashes will be treated literally. Use an array. [SC2089]

Details

lint 解释

这个lint结果表明在脚本中使用了单引号或反斜杠,这些字符会被解释为字面量而不是变量或命令替换。建议使用数组来处理这种情况。

错误用法

# 错误示例:使用单引号和反斜杠
echo 'This is a string with a backslash: \'

在这个错误示例中,反斜杠被解释为字面量,而不是转义字符。

正确用法

# 正确示例:使用数组
echo "This is a string with a backslash: \\"

在这个正确示例中,双反斜杠被解释为一个反斜杠。如果你需要处理更复杂的字符串,可以考虑使用数组:

# 使用数组处理复杂字符串
array=("This is a string" "with a backslash: \\\\")
echo "${array[@]}"

这样可以确保反斜杠和其他特殊字符被正确解释。


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

IOSP1="IOS_SDK_PATH='/root/ioscross/arm64/SDK/iPhoneOS17.0.sdk'"
IOSP2="IOS_TOOLCHAIN_PATH='/root/ioscross/arm64'"
IOSP3="ios_triple='arm-apple-darwin11-'"
build_platform ios target=template_debug ios_simulator=no $IOSP1 $IOSP2 $IOSP3
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Quotes/backslashes in this variable will not be respected. [SC2090]

Details

lint 解释

这个lint结果表明在脚本中使用了变量,但该变量中的引号或反斜杠没有被正确处理。这通常是因为变量的引用方式不正确,导致脚本无法正确解析其中的内容。

错误用法

以下是一个错误的示例代码:

#!/bin/bash

my_var="Hello, \"World\""
echo $my_var

在这个例子中,my_var 变量中的引号没有被正确处理,导致 echo 命令无法正确输出 Hello, "World"

正确用法

以下是一个正确的示例代码:

#!/bin/bash

my_var="Hello, \"World\""
echo "$my_var"

在这个例子中,使用了双引号来引用变量 my_var,这样脚本就能正确解析其中的引号,并输出 Hello, "World"


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

echo "VERSION=$VERSION"

echo "Detecting platform..."
echo "$(uname)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. [SC2005]

Details

lint 解释

这个lint结果提示你使用了不必要的echo命令。在Shell脚本中,如果你只是想执行一个命令并获取其输出,直接使用命令本身即可,不需要通过echo来包装。

错误用法

echo $(ls)

在这个例子中,echo $(ls)会先执行ls命令,然后将结果传递给echo。虽然这个例子看起来没有错误,但它展示了不必要的使用方式。

正确用法

ls

正确的做法是直接使用ls命令,这样脚本会直接输出目录内容,而不需要通过额外的echo来包装。


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

# Set up environment variables based on platform
if [[ "$(uname -o 2>/dev/null)" == "Msys" ]] || [[ "$(uname -o 2>/dev/null)" == "Cygwin" ]]; then
# Windows
source ./emsdk_env.sh
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Not following: ./emsdk_env.sh was not specified as input (see shellcheck -x). [SC1091]

Details

lint 解释

这个lint结果表明在脚本中引用了./emsdk_env.sh文件,但该文件没有被指定为输入。ShellCheck工具(shellcheck)通过-x选项来检查脚本的执行情况,并且会提示未指定的输入文件。

错误用法

source ./emsdk_env.sh

在这个示例中,./emsdk_env.sh被引用但没有被指定为输入。

正确用法

要解决这个问题,可以使用ShellCheck提供的-x选项来指定输入文件。例如:

shellcheck -x ./emsdk_env.sh

这样,ShellCheck会检查./emsdk_env.sh文件的执行情况,并提供相应的lint结果。


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

@JiepengTan JiepengTan marked this pull request as ready for review April 1, 2025 11:45
@JiepengTan JiepengTan changed the title 【WIP】Merge gdspx Merge gdspx Apr 1, 2025
PROJ_DIR=$SCRIPT_DIR/..
ENGINE_DIR=$PROJ_DIR/godot

cd $PROJ_DIR
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. [SC2164]

Details

lint 解释

这个lint结果表明在脚本中使用了cd ...命令,但没有处理可能的失败情况。如果cd命令执行失败,脚本将继续执行后续的命令,这可能会导致意外的行为。

错误用法

cd /path/to/directory
# 如果 cd 失败,脚本会继续执行
echo "Directory changed"

正确用法

cd /path/to/directory || exit 1
# 或者
cd /path/to/directory || return 1
# 如果 cd 失败,脚本会退出或返回错误码
echo "Directory changed"

💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

elif [[ "$(uname -o 2>/dev/null)" == "Msys" ]] || [[ "$(uname -o 2>/dev/null)" == "Cygwin" ]]; then
echo "On Windows, please install JDK 17 manually from: https://adoptium.net/temurin/releases/?version=17"
echo "After installation, ensure JAVA_HOME is set correctly in your environment variables."
read -p "Press Enter to continue once JDK 17 is installed..."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: read without -r will mangle backslashes. [SC2162]

Details

lint 解释

在脚本中使用 read 命令时,如果不带 -r 选项,反斜杠(\)会被解释为转义字符。这可能会导致意外的行为,特别是当需要处理包含反斜杠的字符串时。

错误用法

#!/bin/bash

read var < input.txt

在这个例子中,如果 input.txt 中的内容是 path\to\file,那么 var 的值将会是 path to file,因为反斜杠被解释为转义字符。

正确用法

#!/bin/bash

read -r var < input.txt

在这个例子中,即使 input.txt 中的内容是 path\to\filevar 的值仍然是 path\to\file,因为 -r 选项防止了反斜杠的转义。


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

GODOT_PATH="$PROJ_DIR/godot"

# Check if podman is available
podman=`command -v podman`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Use $(...) notation instead of legacy backticks .... [SC2006]

Details

lint 解释

该lint结果提示在脚本中使用了过时的反引号()来执行命令,建议使用更现代的 $(...)` 语法。

错误用法

# 错误示例:使用反引号执行命令
result=`echo "Hello, World!"`

正确用法

# 正确示例:使用 $() 执行命令
result=$(echo "Hello, World!")

💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

esac
done

source $SCRIPT_DIR/common/setup_env.sh
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Not following: ./common/setup_env.sh was not specified as input (see shellcheck -x). [SC1091]

Details

lint 解释

这个lint结果表明在脚本中引用了./common/setup_env.sh文件,但该文件没有被指定为输入。这可能会导致脚本无法正确地找到和执行该文件。

错误用法

source ./common/setup_env.sh

在这个示例中,脚本尝试通过source命令加载./common/setup_env.sh文件,但没有将其作为输入指定给脚本。

正确用法

要解决这个问题,可以将./common/setup_env.sh文件作为输入传递给脚本。具体方法取决于脚本的运行环境和工具链。以下是一个可能的解决方案:

# 假设使用的是shellcheck工具
shellcheck -x ./common/setup_env.sh

或者,如果需要在脚本中加载该文件,可以确保它被正确地指定为输入:

# 在脚本的开头添加以下行
source ./common/setup_env.sh

# 然后继续执行其他操作

通过这种方式,可以确保./common/setup_env.sh文件被正确地加载和使用。


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

zip -q -9 -r macos.zip macos_template.app

cp macos.zip "$template_dir/macos.zip"
cd ..
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Use a ( subshell ) to avoid having to cd back. [SC2103]

Details

lint 解释

这个lint结果提示你使用子shell(subshell)来避免在执行完命令后需要返回到原来的目录。这样可以保持当前工作目录的整洁,避免不必要的路径切换。

错误用法

cd /path/to/directory
# 执行一些操作
cd -

在这个例子中,cd - 用于返回到之前的工作目录,这可能会导致代码难以维护和理解。

正确用法

(
    cd /path/to/directory
    # 执行一些操作
)

在这个例子中,使用子shell来执行需要改变目录的操作,这样可以避免在脚本结束时返回到原来的目录。


💡 以上内容由 AI 辅助生成,如有疑问欢迎反馈交流

@JiepengTan JiepengTan merged commit a5b91e6 into goplus:dev Apr 2, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants