From 9f6403e96b7bf1aa37434d97928c91e5d34f75d9 Mon Sep 17 00:00:00 2001 From: jamikxu Date: Thu, 14 Oct 2021 18:10:33 +0800 Subject: [PATCH] checkAtom support clang and clangwarning --- .../src/main/kotlin/com/tencent/devops/docker/Build.kt | 2 +- .../kotlin/com/tencent/devops/docker/utils/CodeccConfig.kt | 7 +++++++ .../kotlin/com/tencent/devops/docker/utils/CodeccWeb.kt | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/backend/core/src/main/kotlin/com/tencent/devops/docker/Build.kt b/src/backend/core/src/main/kotlin/com/tencent/devops/docker/Build.kt index 2132b3f..0adf09e 100644 --- a/src/backend/core/src/main/kotlin/com/tencent/devops/docker/Build.kt +++ b/src/backend/core/src/main/kotlin/com/tencent/devops/docker/Build.kt @@ -131,7 +131,7 @@ object Build { // runCompileTools = false //just for test if (runCompileTools) { // 编译型工具,串行 - CodeccWeb.downloadAnyUnzip(commandParam) + //CodeccWeb.downloadAnyUnzip(commandParam) executor.execute { var curTool = "" try { diff --git a/src/backend/core/src/main/kotlin/com/tencent/devops/docker/utils/CodeccConfig.kt b/src/backend/core/src/main/kotlin/com/tencent/devops/docker/utils/CodeccConfig.kt index 68d64ea..521b3f4 100644 --- a/src/backend/core/src/main/kotlin/com/tencent/devops/docker/utils/CodeccConfig.kt +++ b/src/backend/core/src/main/kotlin/com/tencent/devops/docker/utils/CodeccConfig.kt @@ -13,6 +13,7 @@ import com.tencent.devops.docker.tools.LogUtils import com.tencent.devops.pojo.OSType import com.tencent.devops.pojo.exception.CodeccUserConfigException import com.tencent.devops.utils.CodeccEnvHelper +import com.tencent.devops.utils.script.CommandLineUtils import com.tencent.devops.utils.script.ScriptUtils import java.io.File import java.util.* @@ -191,6 +192,9 @@ object CodeccConfig { @Synchronized fun downloadToolZip(commandParam: CommandParam, toolName: String) { val softwareRootPath = "/data/codecc_software" + if (!File(softwareRootPath).exists()) { + File(softwareRootPath).mkdirs() + } var toolSourceName = "" var toolBinaryName = "" var suffix = "" @@ -201,7 +205,10 @@ object CodeccConfig { toolSourceName = "clang_scan.zip" toolBinaryName = "clang-${getConfig("CLANG_NEW_VERSION")}" suffix = "tar.xz" + val clangVersion = toolBinaryName.replace(Regex("\\.\\d*"), "") commandParam.clangHomeBin = CodeccWeb.downloadCompileTool(toolName, toolSourceName, toolBinaryName, suffix) + CommandLineUtils.execute("chmod -R 755 ${commandParam.clangHomeBin}", File("."), true) + ScriptUtils.execute("ln -s -f $clangVersion clang;ln -s -f clang clang++", File("$softwareRootPath/clang_scan/$toolBinaryName/bin")) }else if(ToolConstants.CLANGWARNING == toolName) { toolSourceName = "clangwarning_scan.zip" CodeccWeb.downloadCompileTool(toolName, toolSourceName, toolBinaryName, suffix) diff --git a/src/backend/core/src/main/kotlin/com/tencent/devops/docker/utils/CodeccWeb.kt b/src/backend/core/src/main/kotlin/com/tencent/devops/docker/utils/CodeccWeb.kt index 47cad9f..dc00200 100644 --- a/src/backend/core/src/main/kotlin/com/tencent/devops/docker/utils/CodeccWeb.kt +++ b/src/backend/core/src/main/kotlin/com/tencent/devops/docker/utils/CodeccWeb.kt @@ -83,7 +83,7 @@ object CodeccWeb : BaseApi() { var conn: HttpURLConnection? var inputStream: InputStream? var rootPath = "/data/codecc_software" - var url = "https://github.com/TencentBlueKing/codeccScan/raw/master/${toolName}_scan/$toolSourceZip" + var url = "https://hub.fastgit.org/TencentBlueKing/codeccScan/raw/master/${toolName}_scan/$toolSourceZip" val toolHome = "$rootPath/${toolName}_scan" if (File(toolHome).exists() && File(toolHome).list()?.isNotEmpty() == true) { if (File("$toolHome/$toolBinaryName").exists()) { @@ -118,6 +118,7 @@ object CodeccWeb : BaseApi() { bis.close() conn.disconnect() + LogUtils.printLog("start to unzip tool and tool source zip") FileUtil.unzipFile(toolFullPath, toolHome) if (toolBinaryName != ""){ if ("tar.gz" == suffix) { @@ -132,6 +133,7 @@ object CodeccWeb : BaseApi() { e.printStackTrace() throw CodeccDependentException("get the download file $toolName failed! please check it!: ${e.message}") } + LogUtils.printLog("download tool zip done.") return if (File("$toolHome/$toolBinaryName").exists()) { return "$toolHome/$toolBinaryName" } else {