17 Star 11 Fork 15

openEuler/BiShengCLanguage

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ci.sh 7.28 KB
一键复制 编辑 原始数据 按行查看 历史
liuxinyi 提交于 2024-11-04 19:20 . build and test stdcbs when running ci
#!/bin/bash
set -e
ROOT_DIR=$(cd "$(dirname $0)"; pwd)
SUB_LLVM_DIR=${ROOT_DIR}/fe/llvm-project
SUB_LLVM_BUILD_DIR=${SUB_LLVM_DIR}/build
SUB_LLVM_INSTALL_DIR=${SUB_LLVM_DIR}/install
SUB_OAC_DIR=${ROOT_DIR}/compiler/OpenArkCompiler
TARGET=${SUB_OAC_DIR}/tools/clang+llvm-15.0.4-x86_64-linux-gnu-ubuntu-18.04-enhanced
THREADS=$(cat /proc/cpuinfo | grep -c processor) # FIXME: this does not work for macos
access_token=$1
ci_env=$2
LLVM_PRID=""
OAC_PRID=""
LLVM_OWNER=""
LLVM_BRANCH=""
LLVM_COMMITID=""
OAC_OWNER=""
OAC_BRANCH=""
OAC_COMMITID=""
TESTMAPLE=0
TESTAARCH64=0
function build_llvm() {
cd ${SUB_LLVM_DIR}
mkdir -p build
mkdir -p install
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install/ -DLLVM_TARGETS_TO_BUILD="X86;AArch64" -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_USE_LINKER=gold -DLLVM_BUILD_DOCS=Off -DLLVM_ENABLE_BINDINGS=Off -G "Ninja" ../llvm
ninja -j${THREADS} | tee ${ROOT_DIR}/build_llvm.log
ninja install
ninja clang-test -j${THREADS}
if [[ $? -ne 0 ]];then
echo "clang-test failed, please fix failed cases"
exit 1
fi
}
function install_llvm() {
mkdir -p ${TARGET}/bin
cp -r ${SUB_LLVM_DIR}/install/bin/* ${TARGET}/bin/
cp -r ${SUB_LLVM_DIR}/build/bin/FileCheck ${TARGET}/bin/
cp -r ${SUB_LLVM_DIR}/install/include ${TARGET}
cp -r ${SUB_LLVM_DIR}/install/lib ${TARGET}
cp -r ${SUB_LLVM_DIR}/install/libexec ${TARGET}
cp -r ${SUB_LLVM_DIR}/install/share ${TARGET}
}
function build_oac() {
cd ${SUB_OAC_DIR}
source build/envsetup.sh arm release
make setup
make 2>&1 | tee ${ROOT_DIR}/build_oac.log
}
function run_bs_backend_test() {
python3 ${ROOT_DIR}/script/bsc_test_from_clang.py
if [[ $? -ne 0 ]];then
cat make.log
exit 1
fi
}
function copy_output() {
mkdir -p ${ROOT_DIR}/output/
cp -r ${SUB_LLVM_INSTALL_DIR}/* ${ROOT_DIR}/output/
cp -r ${SUB_OAC_DIR}/output/aarch64-clang-release/bin/* ${ROOT_DIR}/output/bin
}
function update_submodule() {
cd ${ROOT_DIR}
git submodule update --init
}
function install_tools() {
sudo yum clean all
sudo yum makecache
sudo yum -y install python3 cmake git g++ dkms dpkg rsync glibc-devel glibc ninja-build --nobest
sudo ln -sf /usr/lib/dkms/lsb_release /usr/bin/lsb_release
sudo cp -rf ${ROOT_DIR}/script/Centos-Base.repo /etc/yum.repos.d/
sudo ln -sf /lib64/libtinfo.so.5.9 /lib64/libtinfo.so.5
if [ "${ci_env}" == "x86-64" ]; then
sudo yum makecache
sudo yum -y install glibc-devel.i686 ncurses-compat-libs
sudo pip install paramiko -i https://repo.huaweicloud.com/repository/pypi/simple
fi
}
function get_branch_code() {
rm -rf ${SUB_LLVM_DIR}
cd ${ROOT_DIR}/fe
if [ "${LLVM_PRID}" != "" ]; then
git clone -b ${LLVM_BRANCH} --depth 30 https://gitee.com/${LLVM_OWNER}/llvm-project.git
cd ${SUB_LLVM_DIR}
git remote add upstream https://gitee.com/bisheng_c_language_dep/llvm-project.git
git fetch upstream bishengc/15.0.4 --depth 1
git rebase upstream/bishengc/15.0.4
else
git clone -b bishengc/15.0.4 --depth 1 https://gitee.com/bisheng_c_language_dep/llvm-project.git
fi
if [ "${ci_env}" == "x86-64" ] && [ ${TESTMAPLE} == 1 ]; then
rm -rf ${SUB_OAC_DIR}
cd ${ROOT_DIR}/compiler
if [ "${OAC_PRID}" != "" ]; then
git clone -b ${OAC_BRANCH} --depth 30 https://gitee.com/${OAC_OWNER}/OpenArkCompiler.git
cd ${SUB_OAC_DIR}
git remote add upstream https://gitee.com/bisheng_c_language_dep/OpenArkCompiler.git
git fetch upstream bsc --depth 1
git rebase upstream/bsc
else
git clone -b bsc --depth 1 https://gitee.com/bisheng_c_language_dep/OpenArkCompiler.git
fi
fi
}
function get_owner_info() {
cd ${ROOT_DIR}
git log > commit.log
tmp=`sed -n '/_llvm_/p' commit.log`
tmp=${tmp#*\_llvm\_}
llvm=${tmp%%\_*}
tmp=`sed -n '/_oac_/p' commit.log`
tmp=${tmp#*\_oac\_}
oac=${tmp%% *}
# Find `testmaple` in commit.log
tmp=`sed -n '/testmaple/p' commit.log`
testmaple=${tmp}
# Find `testaarch64` in commit.log
tmp=`sed -n '/testaarch64$/p' commit.log`
testaarch64=${tmp}
if [ "${ci_env}" == "x86-64" ]; then
if [ "${testmaple}" != "" ]; then
TESTMAPLE=1
echo "testmaple is set, oac will be pulled and build maple backend to run ci"
else
echo "testmaple is not set, only build llvm backend to run ci"
fi
fi
if [ "${ci_env}" == "aarch64" ]; then
if [ "${testaarch64}" != "" ]; then
TESTAARCH64=1
echo "testaarch64 is set, llvm for aarch64 will be tested"
else
echo "testaarch64 is not set, do nothing"
fi
fi
if [ "${llvm}" != "" ]; then
tmp=`sed -n '/^llvm_PRID:/p' commit/llvm.prid_${llvm}`
LLVM_PRID=${tmp#*:}
tmp=`sed -n '/^llvm_owner:/p' commit/llvm.prid_${llvm}`
LLVM_OWNER=${tmp#*:}
tmp=`sed -n '/^llvm_branch:/p' commit/llvm.prid_${llvm}`
LLVM_BRANCH=${tmp#*:}
echo "LLVM_PRID:$LLVM_PRID LLVM_OWNER:$LLVM_OWNER LLVM_BRANCH:$LLVM_BRANCH"
fi
if [ "${oac}" != "" ]; then
tmp=`sed -n '/^oac_PRID:/p' commit/oac.prid_${oac}`
OAC_PRID=${tmp#*:}
tmp=`sed -n '/^oac_owner:/p' commit/oac.prid_${oac}`
OAC_OWNER=${tmp#*:}
tmp=`sed -n '/^oac_branch:/p' commit/oac.prid_${oac}`
OAC_BRANCH=${tmp#*:}
echo "OAC_PRID:$OAC_PRID OAC_OWNER:$OAC_OWNER OAC_BRANCH:$OAC_BRANCH"
fi
}
function start_ci_test() {
cd ${SUB_OAC_DIR}
ls ${SUB_OAC_DIR}/output/aarch64-clang-release/bin/
source build/envsetup.sh arm release
mm c_test
mm bsc_test
mm bsc_auto_test
}
function post_label() {
tmp="python3 script/postlabel.py --token ${access_token} --label $1"
if [ "${LLVM_PRID}" != "" ]; then
tmp="${tmp} --llvm ${LLVM_PRID}"
else
tmp="${tmp} --llvm -1"
fi
if [ "${OAC_PRID}" != "" ]; then
tmp="${tmp} --oac ${OAC_PRID}"
else
tmp="${tmp} --oac -1"
fi
${tmp}
if [[ $? -ne 0 ]];then
cat make.log
exit 1
fi
}
function demo_test() {
cd ${ROOT_DIR}
bash script/gen_toolchain.sh
cd ${ROOT_DIR}/toolchain
source envsetup.sh
maple demo.cbs -o demo -g
qemu-aarch64 demo > output.log 2>&1
if [ $(grep -c "BiShengC Language welcome to your coming!" output.log) -eq '0' ]; then
exit 1
fi
}
function build_and_test_llvm() {
cd ${SUB_LLVM_DIR}
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86;AArch64" -DLLVM_ENABLE_PROJECTS="clang;libcbs" -DLLVM_USE_LINKER=gold -DLLVM_BUILD_DOCS=Off -DLLVM_ENABLE_BINDINGS=Off -G "Ninja" ../llvm
ninja clang -j${THREADS} | tee ${ROOT_DIR}/build_llvm.log
ninja stdcbs -j${THREADS}
ninja clang-test -j${THREADS}
ninja check-stdcbs
if [[ $? -ne 0 ]];then
echo "clang-test failed, please fix failed cases"
exit 1
fi
}
function main() {
echo "Start Building"
install_tools
get_owner_info
cd ${ROOT_DIR}
post_label "ci_processing"
if [ "${ci_env}" == "x86-64" ]; then
get_branch_code
if [ ${TESTMAPLE} == 1 ]; then
build_llvm
install_llvm
build_oac
run_bs_backend_test
start_ci_test
copy_output
cd ${ROOT_DIR}
post_label "ci_successful"
demo_test
else
build_and_test_llvm
cd ${ROOT_DIR}
post_label "ci_successful"
fi
fi
if [ "${ci_env}" == "aarch64" ]; then
if [ ${TESTAARCH64} == 1 ]; then
get_branch_code
build_and_test_llvm
fi
cd ${ROOT_DIR}
post_label "ci_successful"
fi
echo "Built Successfully"
}
main "$@"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openeuler/BiShengCLanguage.git
[email protected]:openeuler/BiShengCLanguage.git
openeuler
BiShengCLanguage
BiShengCLanguage
master

搜索帮助