---
title: GitLab流水线编译代码示例
description: "若需要使用毕昇编译器或GCC for openEuler相关能力，请使用以下代码示例。"
url: https://www.hikunpeng.com/document/detail/zh/nativedevp/userguide/pipeline/NativeDevelopment_0068.html
sourcePath: /source/zh/nativedevp/userguide/pipeline/NativeDevelopment_0068.html
indexId: 65c690f23b38ef19534697a9ed85ceb2adb172ad0e3962c3758a054344de36f168
---
# GitLab流水线编译代码示例

若需要使用毕昇编译器或GCC for openEuler相关能力，请使用以下代码示例。

#### A-FOT（配置文件参数优化）

```
stages:
- build
- test
- deploy
source-code-migration:
stage: build
tags:
# 如果想要使用毕昇编译器的相关能力，tags请指定为kunpeng_c_builder_bisheng_compiler
- kunpeng_c_builder_gcc # 对应gitlab-runner注册时的标签，可选择多个
script:
- source "${HOME}"/.local/wrap-bin/devkit_NonInvasiveSwitching.sh
- cd
/home/test/build
- make
#A-FOT只支持GCC for openEuler，若选择毕昇编译器，请删除以下两行代码
- echo '====== GCC for openEuler ======'
a-fot '--config_file a-fot.ini'
```


“/home/test/build”指项目文件路径，编译命令为make，请根据实际情况进行替换。


#### A-FOT（命令行参数优化）

```
stages:
- build
- test
- deploy
source-code-migration:
stage: build
tags:
# 如果想要使用毕昇编译器的相关能力，tags请指定为kunpeng_c_builder_bisheng_compiler
- kunpeng_c_builder_gcc # 对应gitlab-runner注册时的标签，可选择多个
script:
- source "${HOME}"/.local/wrap-bin/devkit_NonInvasiveSwitching.sh
- cd
/home/test/build
- make
#A-FOT只支持GCC for openEuler，若选择毕昇编译器，请删除以下两行代码
- echo '====== GCC for openEuler ======'
a-fot  '--opt_mode AutoFDO --gcc_path
/usr
--run_script
/root/run.sh
--build_script
/root/build.sh
--build_mode Wrapper --work_path
./
--bin_file
/tmp/test
'
```

- “/home/test/build”指项目文件路径，编译命令为make，请根据实际情况进行替换。
- 优化模式为AutoFDO，GCC路径为/usr，应用运行脚本路径为/root/run.sh，应用构建脚本路径为/root/build.sh，构建模式为Wrapper，脚本工作目录为当前目录，可执行二进制文件路径为/tmp/test，请根据实际情况进行替换。
