Created some shell scripts for testing
This commit is contained in:
57
test_script/sysyll.sh
Normal file
57
test_script/sysyll.sh
Normal file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 定义输入和输出路径
|
||||
input_dir="../test/"
|
||||
output_dir="./"
|
||||
|
||||
# 默认不生成可执行文件
|
||||
generate_executable=false
|
||||
|
||||
# 解析命令行参数
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
--executable|-e)
|
||||
generate_executable=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown parameter: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# 确保输出目录存在
|
||||
mkdir -p "$output_dir"
|
||||
|
||||
# 遍历输入路径中的所有 .sy 文件
|
||||
for sy_file in "$input_dir"*.sy; do
|
||||
# 获取文件名(不带路径和扩展名)
|
||||
base_name=$(basename "$sy_file" .sy)
|
||||
|
||||
# 定义输出文件路径
|
||||
output_file="${base_name}_sysyc.ll"
|
||||
|
||||
# 使用 sysyc 编译 .sy 文件为 .ll 文件
|
||||
../build/bin/sysyc -s llvmir "$sy_file" > "$output_file"
|
||||
|
||||
# 检查是否成功
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Compiled $sy_file -> $output_file"
|
||||
else
|
||||
echo "Failed to compile $sy_file"
|
||||
continue
|
||||
fi
|
||||
|
||||
# 如果指定了 --executable 或 -e 参数,则进一步编译为可执行文件
|
||||
if $generate_executable; then
|
||||
executable_file="${base_name}_sysyc"
|
||||
clang "$output_file" -o "$executable_file"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Generated executable: $executable_file"
|
||||
else
|
||||
echo "Failed to generate executable from $output_file"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user