diff --git a/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py b/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py index 9a4509911acc85f89ee02aa65b13545f91422500..447ec4cd4ce3a9b13bf30afc8154b81f51c8a4d3 100644 --- a/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py +++ b/tools/download_and_deploy/src/pipeline_script_generator/gitlab_generator.py @@ -31,6 +31,10 @@ variables: # BC文件路径 MEMORY_BC_FILE: "" + # BC文件生成 + # BC文件源码路径 + BC_SOURCE_FILE: "" + # 向量化检查参数 # BC文件路径 VECTORIZED_BC_FILE: "" @@ -127,6 +131,17 @@ byte-alignment-check: paths: - byte-alignment-check.html name: addr-align +""" + bc_file_template = """ +# BC文件生成 +generate-bc-file: + stage: affinity-analysis + tags: + - kunpeng_scanner # 对应gitlab-runner注册时的标签,可选择多个 + script: + - echo '====== BC文件生成 ======' + - devkit advisor bc-gen -i $BC_SOURCE_FILE -c $SOURCE_CODE_COMMAND -o $MEMORY_BC_FILE + # - devkit advisor bc-gen -i $BC_SOURCE_FILE -c $SOURCE_CODE_COMMAND -o $VECTORIZED_BC_FILE """ memory_consistency_template = """ # 内存一致性检查 @@ -159,6 +174,21 @@ vectorized-check: paths: - vectorized-check.html name: vec-check +""" + affinity_check_template = """ +# 构建亲和 +affinity-check: + stage: affinity-analysis + tags: + - kunpeng_scanner # 对应gitlab-runner注册时的标签,可选择多个 + script: + - echo '====== 构建亲和 ======' + - devkit advisor affi-check -i ./ -c $SOURCE_CODE_COMMAND -r html + - mv ./affi-check*.html ./affinity-check.html + artifacts: + paths: + - affinity-check.html + name: affi-check """ gcc_template = """ # 普通编译 diff --git a/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py b/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py index f58167f9fba19e98c00364e5a694adcc69f8dfe0..791c1ecb076d8bd2f49eff69db615d9fcf9d043b 100644 --- a/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py +++ b/tools/download_and_deploy/src/pipeline_script_generator/jenkins_generator.py @@ -47,6 +47,10 @@ pipeline { // 内存一致性检查参数 // BC文件路径 MEMORY_BC_FILE = "" + + // BC文件生成 + // BC文件源码路径 + BC_SOURCE_FILE = "" // 向量化检查参数 // BC文件路径 @@ -324,6 +328,22 @@ pipeline { } } """ + bc_file_template = """ + // BC文件生成 + stage('generate-bc-file') { + agent { + label 'kunpeng_scanner' + } + steps { + echo '====== 生成bc文件 ======' + get_code("${GIT_BRANCH}", "${GIT_TARGET_DIR_NAME}", "${GIT_URL}") + sh ''' + devkit advisor bc-gen -i "${BC_SOURCE_FILE}" -c "${SOURCE_CODE_COMMAND}" -o "${MEMORY_BC_FILE}" + # devkit advisor bc-gen -i "${BC_SOURCE_FILE}" -c "${SOURCE_CODE_COMMAND}" -o "${VECTORIZED_BC_FILE}" + ''' + } + } + """ memory_consistency_template = """ // 内存一致性检查 stage('memory-consistency-check') { @@ -434,6 +454,61 @@ pipeline { } } """ + affinity_check_template = """ + // 亲和构建检查 + stage('affinity-check') { + agent { + label 'kunpeng_scanner' + } + steps { + get_code("${GIT_BRANCH}", "${GIT_TARGET_DIR_NAME}", "${GIT_URL}") + sh ''' + /usr/bin/rm -rf ./report_dir/*.html + ''' + script{ + def STATUS_CODE = sh(returnStatus: true, script: ''' + devkit advisor affi-check -i "./${GIT_TARGET_DIR_NAME}" -c "${SOURCE_CODE_COMMAND}" -r html -o ./report_dir + + ''') + sh ''' + html_file_name=$(find ./report_dir -name affi-check*.html) + if [[ ${html_file_name} ]]; then + mv ${html_file_name} ./report_dir/affinity-check.html + fi + ''' + switch(STATUS_CODE) { + case 0: + echo '【构建亲和检查】--> 无扫描建议 <--' + break + case 4: + currentBuild.result = 'ABORTED' + echo '【构建亲和检查】--> 扫描命令错误 <--' + break + case 5: + currentBuild.result = 'FAILURE' + echo '【构建亲和检查】--> 扫描结果存在必须修改项 <--' + error('【构建亲和检查】--> 扫描结果存在必须修改项 <--') + break + default: + currentBuild.result = 'ABORTED' + echo '【构建亲和检查】--> 扫描失败<--' + break + } + } + } + post { + always { + publishHTML(target: [allowMissing: false, + alwaysLinkToLastBuild: false, + keepAll : true, + reportDir : './report_dir', + reportFiles : 'affinity-check.html', + reportName : 'affinity-check Report'] + ) + } + } + } + """ java8_build_template = """ // 普通编译 stage('java8-build') { diff --git a/tools/download_and_deploy/src/pipeline_script_generator/script_generator.py b/tools/download_and_deploy/src/pipeline_script_generator/script_generator.py index 77835eaf4d464f65a2a03ca87bf7ccf850dfc51b..0bb3f2f391afa55ea54f15c20cc581b072362ca9 100644 --- a/tools/download_and_deploy/src/pipeline_script_generator/script_generator.py +++ b/tools/download_and_deploy/src/pipeline_script_generator/script_generator.py @@ -9,8 +9,10 @@ class ScriptGenerator: package_migration_template = "" mode_check_template = "" byte_alignment_template = "" + bc_file_template = "" memory_consistency_template = "" vector_check_template = "" + affinity_check_template = "" gcc_template = "" bisheng_compiler_template = "" java8_build_template = "" @@ -28,8 +30,10 @@ class ScriptGenerator: self.package_migration_template, self.mode_check_template, self.byte_alignment_template, + self.bc_file_template, self.memory_consistency_template, - self.vector_check_template + self.vector_check_template, + self.affinity_check_template ], C_BUILDER_GCC: [self.gcc_template, self.a_fot_template], C_BUILDER_BISHENG_COMPILER: [self.bisheng_compiler_template],