4 Star 4 Fork 50

xliu/Ark-workload

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
run_swift.sh 11.97 KB
一键复制 编辑 原始数据 按行查看 历史
lixingfu 提交于 2024-01-11 18:31 . update
#!/bin/bash
swift_path=ts-swift-workload
arg_name=""
true="true"
false="false"
run_count=1
date=$(date +'%Y%m%d%H%M%S')
swift_sdk=~/tools/swift-5.7.3-RELEASE-ubuntu22.04/usr/bin
android_ndk=~/tools/android-ndk-r25c
toolspath=./toolspath.txt
Ninja_ReleaseAssert=~/apple/build/Ninja-ReleaseAssert
current_path=$(pwd)
echo $current_path
if [ -s "$toolspath" ]; then
while IFS= read -r line; do
case $line in
*--ts-tools-path\ *)
sdk_path="${line#*--ts-tools-path\ }"
;;
*--ark_js_vm\ *)
ark_js_vm="${line#*--ark_js_vm\ }"
;;
*--es2abc\ *)
es2abc="${line#*--es2abc\ }"
;;
*--ark_aot_compiler\ *)
ark_aot_compiler="${line#*--ark_aot_compiler\ }"
;;
*--tools-type\ *)
tools_type="${line#*--tools-type\ }"
;;
esac
done < "toolspath.txt"
fi
arg_name=""
true="true"
false="false"
run_count=1
aarch64=""
date=$(date +'%Y%m%d%H%M%S')
swift2path="${current_path}/swift_build/${date}"
function help_explain(){
echo "[--help,--h]"
echo "[--run-count <count>]"
echo "[--case <case-name>]"
echo "[--date <date>]"
echo "[--build]"
echo "[--excel]"
echo "[--aarch64]"
echo "[--code-v] <code_path>"
}
if [ -z "$1" ]; then
echo "No input provided."
else
for arg in "$@"; do
case $arg_name in
"--case")
arg_name=""
case_name=$arg
;;
"--date")
arg_name=""
date=$arg
;;
"--run-count")
arg_name=""
run_count=$arg
;;
"--code-v")
arg_name=""
echo $arg
swift_path=$arg
swift2path="${current_path}/swift_build-${swift_path}/${date}"
case $arg in
"0")
swift_path=daily
swift2path="${current_path}/swift_build-${swift_path}/${date}"
;;
"1")
swift_path=ts-swift-workload
swift2path="${current_path}/swift_build/${date}"
;;
"ts-swift-workload")
swift_path=ts-swift-workload
swift2path="${current_path}/swift_build/${date}"
;;
"2")
swift_path=mix-case
swift2path="${current_path}/swift_build-${swift_path}/${date}"
;;
"3")
swift_path=weekly_workload
swift2path="${current_path}/swift_build-${swift_path}/${date}"
;;
esac
;;
esac
case $arg in
"--h")
help_explain
exit
;;
"--help")
help_explain
exit
;;
"--build")
build="true"
;;
"--case")
arg_name=$arg
;;
"--date")
arg_name=$arg
;;
"--excel")
excel="true"
;;
"--run-count")
arg_name=$arg
;;
"--aarch64")
aarch64="true"
;;
"--code-v")
arg_name=$arg
;;
esac
done
fi
if [ ! -d $swift2path ];then
mkdir -p $swift2path
fi
case_id=0
code_swift_filesInfo_files=($(find ${swift_path} -type f -name "main.swift" -exec dirname {} \;))
for build_file in "${code_swift_filesInfo_files[@]}"; do
is_swift=($(echo ${build_file} | grep "swift"))
if [[ $is_swift == $build_file ]];then
echo ${build_file} 111
directory_name=$(basename $is_swift)
# mkdir -p ${swift2path}/${directory_name}
echo ${directory_name} 222
# continue
cd ${is_swift}
echo $(pwd)
((case_id++))
echo "-----------------------------------------------------------" >> ${swift2path}/log.log
echo case name: ${directory_name}, case_id: ${case_id} >> ${swift2path}/log.log
echo "-----------------------------swift_build------------------------------" >> ${swift2path}/log.log
if [ "${aarch64}" = "true" ]; then
case ${directory_name} in
"box2d")
swiftc -O -whole-module-optimization \
main.swift \
Benchmark.swift \
Collision/*.swift \
Collision/Shapes/*.swift \
Common/*.swift \
Dynamics/*.swift \
Dynamics/Contacts/*.swift \
Dynamics/Joints/*.swift \
Rope/*.swift \
-o ${swift2path}/${directory_name}/${directory_name}
# -o ${directory_name}
echo "swiftc -O -whole-module-optimization \
main.swift \
Benchmark.swift \
Collision/*.swift \
Collision/Shapes/*.swift \
Common/*.swift \
Dynamics/*.swift \
Dynamics/Contacts/*.swift \
Dynamics/Joints/*.swift \
Rope/*.swift \
-o ${swift2path}/${directory_name}" \
>> ${swift2path}/log.log
;;
"mandreel")
swiftc -O -whole-module-optimization \
*.swift \
mandreel-part1/Class/*.swift \
-o ${swift2path}/${directory_name}
# -o ${directory_name}
echo "swiftc -O -whole-module-optimization \
*.swift \
mandreel-part1/Class/*.swift \
-o ${swift2path}/${directory_name}" \
>> ${swift2path}/log.log
;;
*)
swiftc -O -whole-module-optimization \
*.swift \
-o ${swift2path}/${directory_name}
# -o ${directory_name}
echo "swiftc -O -whole-module-optimization \
*.swift \
-o ${swift2path}/${directory_name}" \
>> ${swift2path}/log.log
;;
esac
else
case ${directory_name} in
"box2d")
swiftc -O -whole-module-optimization \
Benchmark.swift \
Collision/*.swift \
Collision/Shapes/*.swift \
Common/*.swift \
Dynamics/*.swift \
Dynamics/Contacts/*.swift \
Dynamics/Joints/*.swift \
Rope/*.swift \
main.swift \
-o ${swift2path}/${directory_name}
# -o ${directory_name}
# mv ${directory_name} ${swift2path}/${directory_name}/
echo "swiftc -O -whole-module-optimization \
main.swift \
Benchmark.swift \
Collision/*.swift \
Collision/Shapes/*.swift \
Common/*.swift \
Dynamics/*.swift \
Dynamics/Contacts/*.swift \
Dynamics/Joints/*.swift \
Rope/*.swift \
-o ${swift2path}/${directory_name}" \
>> ${swift2path}/log.log
;;
"mandreel")
swiftc -O -whole-module-optimization \
*.swift \
mandreel-part1/Class/*.swift \
-o ${swift2path}/${directory_name}
# -o ${directory_name}
# -o ${swift2path}/${directory_name}/${directory_name}
echo "swiftc -O -whole-module-optimization \
*.swift \
mandreel-part1/Class/*.swift \
-o ${swift2path}/${directory_name}" \
>> ${swift2path}/log.log
;;
*)
swiftc -O -whole-module-optimization \
*.swift \
-o ${swift2path}/${directory_name}
# -o ${directory_name}
# mv ${directory_name} ${swift2path}/${directory_name}/
echo "swiftc -O -whole-module-optimization \
*.swift \
-o ${swift2path}/${directory_name}" \
>> ${swift2path}/log.log
;;
esac
fi
cd ${current_path}
fi
done
# exit
function build_swift(){
local swift_file=$1
local file_name=$2
for build_file in "${code_swift_filesInfo_files[@]}"; do
is_ts=($(echo ${build_file} | grep "swift"))
if echo "$ts_dir" | grep -q "$file";then
directory_name=$(basename $is_ts)
return 1
fi
done
echo "-----------------------------------------------------------" >> ${swift2path}/log.log
echo "build : ${swift_file} to ${swift2path}"
if [ "${aarch64}" = "true" ]; then
echo "swiftc -O -whole-module-optimization \
-tools-directory ${android_ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/\
-target aarch64-unknown-linux-android21\
-sdk ${android_ndk}/toolchains/llvm/prebuilt/linux-x86_64/sysroot\
-resource-dir ${Ninja_ReleaseAssert}/swift-linux-x86_64/lib/swift ${swift_file}\
-o ${swift2path}/${file_name}"
swiftc -O -whole-module-optimization \
-tools-directory ${android_ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin\
-target aarch64-unknown-linux-android21\
-sdk ${android_ndk}/toolchains/llvm/prebuilt/linux-x86_64/sysroot\
-resource-dir ${Ninja_ReleaseAssert}/swift-linux-x86_64/lib/swift ${swift_file}\
-o ${swift2path}/${file_name}
else
swiftc -O -whole-module-optimization ${swift_file} -o ${swift2path}/${file_name}
fi
}
function run_swift(){
local file_name=$1
local swift_file=$swift2path/${file_name}
echo ${file_name}
$swift_file
}
function run(){
if [[ "$build" = "true" ]]; then
if [ ! -d $swift2path ];then
mkdir -p $swift2path
fi
if [ -z "$case_name" ]; then
txt_files=($(find $swift_path -type f -name "*.swift"))
for file in "${txt_files[@]}"; do
echo "Content of $file:"
local swift_file_path=$file
local file_name=$(basename "${file}" | cut -f1 -d'.')
build_swift ${swift_file_path} ${file_name}
if [[ "$excel" = "true" ]]; then
python swift2excel.py --case-dir $swift2path --run-case $file_name --run-count $run_count
fi
done
else
local swift_file_path=$(find ${swift_path} -name "${case_name}.swift")
local file_name=$(basename "$swift_file_path" | cut -f1 -d'.')
if [ -f "${swift_file_path}" ]; then
build_swift ${swift_file_path} ${file_name}
if [[ "$excel" = "true" ]]; then
python swift2excel.py --case-dir $swift2path --run-case $file_name --run-count $run_count
fi
fi
fi
fi
if [ ! -d $swift2path ];then
echo "${swift2path} No such file or directory"
exit
fi
}
run
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/xliu-huanwei/ark-workload.git
git@gitee.com:xliu-huanwei/ark-workload.git
xliu-huanwei
ark-workload
Ark-workload
master

搜索帮助