From 12c8d020f38ec1797df6f6bc1581ee3be437f88a Mon Sep 17 00:00:00 2001 From: Georgii Borovinskikh <117642191+georgii-borovinskikh-sonarsource@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:02:19 +0100 Subject: [PATCH] SLVS-1709 Cleanup CFamily build (#5908) [SLVS-1709](https://sonarsource.atlassian.net/browse/SLVS-1709) [SLVS-1709]: https://sonarsource.atlassian.net/browse/SLVS-1709?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --- SonarLint.VisualStudio.Integration.sln | 15 -- .../CFamilyJarPreProcessor.csproj | 19 -- .../CFamilyJarPreProcessor.sln | 25 -- build/tools/CFamilyJarPreProcessor/Common.cs | 251 ------------------ build/tools/CFamilyJarPreProcessor/ILogger.cs | 36 --- .../CFamilyJarPreProcessor/Preprocessor.cs | 126 --------- build/tools/CFamilyJarPreProcessor/Program.cs | 45 ---- build/tools/CFamilyJarPreProcessor/ReadMe.txt | 21 -- .../CFamilyJarPreProcessor/packages.lock.json | 68 ----- src/Integration.Vsix/Integration.Vsix.csproj | 48 +--- tools/CleanRebuild.cmd | 2 +- 11 files changed, 2 insertions(+), 654 deletions(-) delete mode 100644 build/tools/CFamilyJarPreProcessor/CFamilyJarPreProcessor.csproj delete mode 100644 build/tools/CFamilyJarPreProcessor/CFamilyJarPreProcessor.sln delete mode 100644 build/tools/CFamilyJarPreProcessor/Common.cs delete mode 100644 build/tools/CFamilyJarPreProcessor/ILogger.cs delete mode 100644 build/tools/CFamilyJarPreProcessor/Preprocessor.cs delete mode 100644 build/tools/CFamilyJarPreProcessor/Program.cs delete mode 100644 build/tools/CFamilyJarPreProcessor/ReadMe.txt delete mode 100644 build/tools/CFamilyJarPreProcessor/packages.lock.json diff --git a/SonarLint.VisualStudio.Integration.sln b/SonarLint.VisualStudio.Integration.sln index 1957a5be32..23277701b1 100644 --- a/SonarLint.VisualStudio.Integration.sln +++ b/SonarLint.VisualStudio.Integration.sln @@ -5,7 +5,6 @@ VisualStudioVersion = 17.0.31815.197 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Integration.Vsix", "src\Integration.Vsix\Integration.Vsix.csproj", "{FF2AD819-28F4-493A-8E9B-1D3F16BD4689}" ProjectSection(ProjectDependencies) = postProject - {0E50D9A0-693D-4B4E-81E2-8B8028231CFA} = {0E50D9A0-693D-4B4E-81E2-8B8028231CFA} {2BB16C6F-BF06-4225-99A0-F1CFE70CBE44} = {2BB16C6F-BF06-4225-99A0-F1CFE70CBE44} EndProjectSection EndProject @@ -104,10 +103,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Suppressions", "src\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Suppressions.UnitTests", "src\Roslyn.Suppressions\Roslyn.Suppressions.UnitTests\Roslyn.Suppressions.UnitTests.csproj", "{C478DAE7-58BC-4D02-929E-E413B40F2517}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{628A579F-0D27-4F9F-A756-8CC0A67A7B3D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CFamilyJarPreProcessor", "build\tools\CFamilyJarPreProcessor\CFamilyJarPreProcessor.csproj", "{0E50D9A0-693D-4B4E-81E2-8B8028231CFA}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ConnectedMode", "ConnectedMode", "{3B4A8B40-9821-4964-8EAB-1D8A0B078292}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConnectedMode", "src\ConnectedMode\ConnectedMode.csproj", "{0BE551DB-3C46-42A5-BB38-DA80E83F8ABD}" @@ -347,14 +342,6 @@ Global {C478DAE7-58BC-4D02-929E-E413B40F2517}.Release|Any CPU.Build.0 = Release|Any CPU {C478DAE7-58BC-4D02-929E-E413B40F2517}.Release|x86.ActiveCfg = Release|Any CPU {C478DAE7-58BC-4D02-929E-E413B40F2517}.Release|x86.Build.0 = Release|Any CPU - {0E50D9A0-693D-4B4E-81E2-8B8028231CFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0E50D9A0-693D-4B4E-81E2-8B8028231CFA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0E50D9A0-693D-4B4E-81E2-8B8028231CFA}.Debug|x86.ActiveCfg = Debug|Any CPU - {0E50D9A0-693D-4B4E-81E2-8B8028231CFA}.Debug|x86.Build.0 = Debug|Any CPU - {0E50D9A0-693D-4B4E-81E2-8B8028231CFA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0E50D9A0-693D-4B4E-81E2-8B8028231CFA}.Release|Any CPU.Build.0 = Release|Any CPU - {0E50D9A0-693D-4B4E-81E2-8B8028231CFA}.Release|x86.ActiveCfg = Release|Any CPU - {0E50D9A0-693D-4B4E-81E2-8B8028231CFA}.Release|x86.Build.0 = Release|Any CPU {0BE551DB-3C46-42A5-BB38-DA80E83F8ABD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0BE551DB-3C46-42A5-BB38-DA80E83F8ABD}.Debug|Any CPU.Build.0 = Debug|Any CPU {0BE551DB-3C46-42A5-BB38-DA80E83F8ABD}.Debug|x86.ActiveCfg = Debug|Any CPU @@ -489,8 +476,6 @@ Global {30E1FF8F-94BA-4A39-A737-8FFD7B4A0CD3} = {11D4BFC7-C1F2-45AC-888E-25A6A216AD1D} {082D5D8E-F914-4139-9AE3-3F48B679E3DA} = {16BF2D77-AE3B-4218-A3E8-875829D73B00} {C478DAE7-58BC-4D02-929E-E413B40F2517} = {16BF2D77-AE3B-4218-A3E8-875829D73B00} - {628A579F-0D27-4F9F-A756-8CC0A67A7B3D} = {E93C2CF9-69A6-4669-BE8A-6060B18FEDCA} - {0E50D9A0-693D-4B4E-81E2-8B8028231CFA} = {628A579F-0D27-4F9F-A756-8CC0A67A7B3D} {0BE551DB-3C46-42A5-BB38-DA80E83F8ABD} = {3B4A8B40-9821-4964-8EAB-1D8A0B078292} {2BD38A3A-6F0E-452B-A5B2-200113A32184} = {3B4A8B40-9821-4964-8EAB-1D8A0B078292} {67BEB251-4EA5-44EE-92A7-B4F57D9A6867} = {25DE7210-DFC0-448B-894E-84C1C9CA223E} diff --git a/build/tools/CFamilyJarPreProcessor/CFamilyJarPreProcessor.csproj b/build/tools/CFamilyJarPreProcessor/CFamilyJarPreProcessor.csproj deleted file mode 100644 index 7ad4097cb1..0000000000 --- a/build/tools/CFamilyJarPreProcessor/CFamilyJarPreProcessor.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - Exe - net472 - - - true - - - - - - - - - - - diff --git a/build/tools/CFamilyJarPreProcessor/CFamilyJarPreProcessor.sln b/build/tools/CFamilyJarPreProcessor/CFamilyJarPreProcessor.sln deleted file mode 100644 index 56920f123c..0000000000 --- a/build/tools/CFamilyJarPreProcessor/CFamilyJarPreProcessor.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32516.85 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CFamilyJarPreProcessor", "CFamilyJarPreProcessor.csproj", "{CE1DC67B-EEBE-4EAF-B91C-BC622DCBBA39}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CE1DC67B-EEBE-4EAF-B91C-BC622DCBBA39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE1DC67B-EEBE-4EAF-B91C-BC622DCBBA39}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE1DC67B-EEBE-4EAF-B91C-BC622DCBBA39}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE1DC67B-EEBE-4EAF-B91C-BC622DCBBA39}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {EA20A11F-9428-41DA-82A9-3403C09EB81F} - EndGlobalSection -EndGlobal diff --git a/build/tools/CFamilyJarPreProcessor/Common.cs b/build/tools/CFamilyJarPreProcessor/Common.cs deleted file mode 100644 index 4ade790c69..0000000000 --- a/build/tools/CFamilyJarPreProcessor/Common.cs +++ /dev/null @@ -1,251 +0,0 @@ -/* - * SonarLint for Visual Studio - * Copyright (C) 2016-2024 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Net.Http; -using SharpCompress.Compressors.Xz; - -namespace CFamilyJarPreProcessor -{ - internal static class Common - { - /// - /// Returns the full path to the local directory in which the plugin will be cached at build time - /// - /// Per-plugin unique folder name - /// By default the plugins will be stored under the user's %LocalAppData% folder e.g. C:\Users\JoeBloggs\AppData\Local. - /// An alternative root directory can be specified by setting the environment variable SONARLINT_INTERNAL_PLUGIN_CACHE_DIR. - /// This might be necessary if the user name is long so the full paths of the files being unpacked under the root folder - /// exceed the maximum path length. - public static string GetLocalBuildTimePluginCacheDir(string pluginFolderName) - { - var baseFolder = Environment.GetEnvironmentVariable("SONARLINT_INTERNAL_PLUGIN_CACHE_DIR"); - if (string.IsNullOrEmpty(baseFolder)) - { - baseFolder = Environment.GetEnvironmentVariable("LocalAppData"); - } - - var fullPath = Path.Combine(baseFolder, pluginFolderName); - return fullPath; - } - - public static void EnsureWorkingDirectoryExist(string localWorkingFolder, ILogger logger) - { - if (!Directory.Exists(localWorkingFolder)) - { - LogMessage($"Creating working folder: {localWorkingFolder}", logger); - Directory.CreateDirectory(localWorkingFolder); - } - } - - public static void DownloadJarFile(string url, string targetFilePath, ILogger logger) - { - LogMessage($"Download url: {url}", logger); - - if (File.Exists(targetFilePath)) - { - // Downloading the file is slow so skip if possible - LogMessage($"Jar file already exists at {targetFilePath}", logger); - return; - } - - LogMessage($"Downloading file from {url} to {targetFilePath}...", logger); - - var timer = Stopwatch.StartNew(); - - using (var httpClient = new HttpClient()) - using (var response = httpClient.GetAsync(url).Result) - { - if (response.IsSuccessStatusCode) - { - using (var fileStream = new FileStream(targetFilePath, FileMode.Create, FileAccess.Write)) - { - response.Content.CopyToAsync(fileStream).Wait(); - } - } - else - { - logger.LogError($"Failed to download the CFamily plugin: {response.Content}"); - } - } - timer.Stop(); - LogElapsedTime("Download completed. ", timer, logger); - } - - public static string ExtractPluginFileNameFromUrl(string url, ILogger logger) - { - if (!url.EndsWith(".jar", StringComparison.InvariantCultureIgnoreCase)) - { - throw new ArgumentException("Expecting the url to end with '.jar'"); - } - - var fileName = url.Split('/').Last(); - - LogMessage($"Plugin file name: {fileName}", logger); - return fileName; - } - - public static void UnzipJar(string jarFilePath, string destinationFolder, ILogger logger) - { - if (Directory.GetFiles(destinationFolder).Length > 1) - { - // Unzipping the jar is slow so skip if possible - LogMessage($"Skipping unzipping the jar because the destination folder already contains multiple files.", logger); - return; - } - - LogMessage($"Unzipping jar file...", logger); - var timer = Stopwatch.StartNew(); - - ZipFile.ExtractToDirectory(jarFilePath, destinationFolder); - - timer.Stop(); - LogElapsedTime("Unzipped jar file", timer, logger); - } - - public static void UncompressAndUnzipTgx(string tarFilePath, string destinationFolder, ILogger logger) - { - // The txz file is compressed using XZ compression and zipped using the tar format. - // There is no built-in framework support for these format so we are using two - // open source libraries, both licensed under the MIT license. - Common.EnsureWorkingDirectoryExist(destinationFolder, logger); - - var uncompresssedFile = Common.DecompressXZFile(tarFilePath, destinationFolder, logger); - Common.ExtractTarToDirectory(uncompresssedFile, destinationFolder, logger); - } - - public static string DecompressXZFile(string sourceFilePath, string destinationDirectory, ILogger logger) - { - var destFile = Path.Combine(destinationDirectory, Path.GetFileName(sourceFilePath)) + ".uncompressed"; - if (File.Exists(destFile)) - { - LogMessage($"Uncompressed tar file already exists: {destFile}", logger); - return destFile; - } - - using (Stream xz = new XZStream(File.OpenRead(sourceFilePath))) - using (Stream outputStream = new FileStream(destFile, FileMode.CreateNew)) - { - xz.CopyTo(outputStream); - } - return destFile; - } - - public static void UncompressAndUnzipTgz(string tarFilePath, string destinationFolder, ILogger logger) - { - // The txz file is compressed using XZ compression and zipped using the tar format. - // There is no built-in framework support for these format so we are using two - // open source libraries, both licensed under the MIT license. - EnsureWorkingDirectoryExist(destinationFolder, logger); - - var uncompresssedFile = DecompressGZipFile(tarFilePath, destinationFolder, logger); - ExtractTarToDirectory(uncompresssedFile, destinationFolder, logger); - } - - public static string DecompressGZipFile(string sourceFilePath, string destinationDirectory, ILogger logger) - { - var destFile = Path.Combine(destinationDirectory, Path.GetFileName(sourceFilePath)) + ".uncompressed"; - if (File.Exists(destFile)) - { - LogMessage($"Uncompressed tar file already exists: {destFile}", logger); - return destFile; - } - - using (Stream xz = new GZipStream(File.OpenRead(sourceFilePath), CompressionMode.Decompress)) - using (Stream outputStream = new FileStream(destFile, FileMode.CreateNew)) - { - xz.CopyTo(outputStream); - } - return destFile; - } - - public static void ExtractTarToDirectory(string sourceFilePath, string destinationDirectory, ILogger logger) - { - using (var outputStream = new FileStream(sourceFilePath, FileMode.Open)) - { - ICSharpCode.SharpZipLib.Tar.TarArchive tarArchive = ICSharpCode.SharpZipLib.Tar.TarArchive.CreateInputTarArchive(outputStream); - tarArchive.ExtractContents(destinationDirectory); - } - } - - public static List FindSingleFiles(string searchRoot, IEnumerable patterns, ILogger logger) - { - var files = new List(); - - foreach (var file in patterns) - { - files.Add(FindSingleFile(searchRoot, file, logger)); - } - - return files; - } - - public static List FindMultipleFiles(string searchRoot, IEnumerable patterns, ILogger logger) - { - var files = new List(); - - foreach (var pattern in patterns) - { - var matches = Directory.GetFiles(searchRoot, pattern, SearchOption.AllDirectories); - if (matches.Any()) - { - LogMessage($"Found {matches.Count()} files matching for '{pattern}'", logger); - files.AddRange(matches); - } - else - { - throw new InvalidOperationException($"Failed to find any files matching the pattern '{pattern}'"); - } - } - - return files; - } - - public static string FindSingleFile(string searchFolder, string pattern, ILogger logger) - { - var files = Directory.GetFiles(searchFolder, pattern, SearchOption.AllDirectories); - - if (files.Length != 1) - { - throw new InvalidOperationException($"Failed to locate one and only one file matching pattern {pattern} in {searchFolder}. Matching files: {files.Length}"); - } - - LogMessage($"Located file: {files[0]}", logger); - - return files[0]; - } - - private static void LogElapsedTime(string message, Stopwatch timer, ILogger logger) - { - LogMessage($"{message} {timer.Elapsed.ToString("g")}", logger); - } - - private static void LogMessage(string message, ILogger logger) - { - logger.LogMessage(message); - } - } -} diff --git a/build/tools/CFamilyJarPreProcessor/ILogger.cs b/build/tools/CFamilyJarPreProcessor/ILogger.cs deleted file mode 100644 index 602e4639ed..0000000000 --- a/build/tools/CFamilyJarPreProcessor/ILogger.cs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarLint for Visual Studio - * Copyright (C) 2016-2024 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -using System; - -namespace CFamilyJarPreProcessor -{ - internal interface ILogger - { - void LogMessage(string message); - void LogError(string message); - } - - internal class ConsoleLogger : ILogger - { - void ILogger.LogError(string message) => Console.Error.WriteLine(message); - - void ILogger.LogMessage(string message) => Console.WriteLine(message); - } -} diff --git a/build/tools/CFamilyJarPreProcessor/Preprocessor.cs b/build/tools/CFamilyJarPreProcessor/Preprocessor.cs deleted file mode 100644 index 80dbe4b23f..0000000000 --- a/build/tools/CFamilyJarPreProcessor/Preprocessor.cs +++ /dev/null @@ -1,126 +0,0 @@ -/* - * SonarLint for Visual Studio - * Copyright (C) 2016-2024 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -using System.Collections.Generic; -using System.IO; - -namespace CFamilyJarPreProcessor -{ - internal class Preprocessor - { - // The txz archive containing the subprocess.exe - private const string WindowsTxzFilePattern = "clang*-win.txz"; - - // Sub-folder into which the tar file should be unzipped - private const string TarUnzipSubFolder = "tar_xz"; - - // List of patterns to match single files in the uncompressed output - private readonly string[] SingleFilePatterns = new string[] - { - "Sonar_way_profile.json", - "RulesList.json", - "MisraRulesList.json", - TarUnzipSubFolder + @"\subprocess.exe", - TarUnzipSubFolder + @"\LICENSE_THIRD_PARTY.txt" - }; - - // List of patterns to match multiple files in the uncompressed output - private readonly string[] MultipleFilesPatterns = new string[] - { - @"org\sonar\l10n\cpp\rules\params\*_params.json", - @"org\sonar\l10n\cpp\rules\cpp\*.json", - @"org\sonar\l10n\cpp\rules\misra23\*.json", - }; - - private readonly ILogger logger; - public Preprocessor(ILogger logger) - { - this.logger = logger; - } - - /// - /// Downloads plugin, extracts files, and copies the requires file to the output folder - /// - /// The method is lazy i.e. won't download the plugin if it exists, won't copy a file - /// unless it is newer than the target file. - public void Execute(string downloadUrl, string destinationDir) - { - var pluginFileName = Common.ExtractPluginFileNameFromUrl(downloadUrl, logger); - - // Ensure working directories exists - var localWorkingFolder = Common.GetLocalBuildTimePluginCacheDir("SLVS_CFamily_Build"); - var perVersionPluginFolder = Path.Combine(localWorkingFolder, Path.GetFileNameWithoutExtension(pluginFileName)); - Common.EnsureWorkingDirectoryExist(perVersionPluginFolder, logger); - - // Download and unzip the jar - var jarFilePath = Path.Combine(perVersionPluginFolder, pluginFileName); - Common.DownloadJarFile(downloadUrl, jarFilePath, logger); - Common.UnzipJar(jarFilePath, perVersionPluginFolder, logger); - - // Uncompress and extract the windows tar archive to get the subprocess exe - var tarFilePath = Common.FindSingleFile(perVersionPluginFolder, WindowsTxzFilePattern, logger); - var tarSubFolder = Path.Combine(perVersionPluginFolder, TarUnzipSubFolder); - Common.UncompressAndUnzipTgx(tarFilePath, tarSubFolder, logger); - - // Locate the required files from the uncompressed jar and tar - var fileList = FindFiles(perVersionPluginFolder); - - // Copy the files to the output directory - CopyFilesToOutputDirectory(fileList, destinationDir); - } - - private List FindFiles(string searchRoot) - { - var files = new List(); - - files.AddRange(Common.FindSingleFiles(searchRoot, SingleFilePatterns, logger)); - files.AddRange(Common.FindMultipleFiles(searchRoot, MultipleFilesPatterns, logger)); - - return files; - } - - private void CopyFilesToOutputDirectory(IList files, string destinationDir) - { - Common.EnsureWorkingDirectoryExist(destinationDir, logger); - - foreach(var file in files) - { - CopyIfNewer(file, destinationDir); - } - } - - private void CopyIfNewer(string file, string destinationDir) - { - // Overwrite if newer - var sourceFileInfo = new FileInfo(file); - var destinationFileInfo = new FileInfo(Path.Combine(destinationDir, sourceFileInfo.Name)); - - if (!destinationFileInfo.Exists || sourceFileInfo.LastWriteTimeUtc > destinationFileInfo.LastWriteTimeUtc) - { - logger.LogMessage($" Copying file: {file}"); - File.Copy(sourceFileInfo.FullName, destinationFileInfo.FullName, true); - } - else - { - logger.LogMessage($" Skipping copying file - not newer: {file}"); - } - } - } -} diff --git a/build/tools/CFamilyJarPreProcessor/Program.cs b/build/tools/CFamilyJarPreProcessor/Program.cs deleted file mode 100644 index 3752b9e84e..0000000000 --- a/build/tools/CFamilyJarPreProcessor/Program.cs +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarLint for Visual Studio - * Copyright (C) 2016-2024 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -namespace CFamilyJarPreProcessor -{ - internal static class Program - { - static int Main(string[] args) - { - ILogger logger = new ConsoleLogger(); - - if (args.Length != 2) - { - logger.LogError("Expected parameters: [plugin download url] [full path to destination directory]"); - return -1; - } - - var downloadUrl = args[0]; - var destinationDir = args[1]; - - var preprocessor = new Preprocessor(logger); - - preprocessor.Execute(downloadUrl, destinationDir); - - return 0; - } - } -} diff --git a/build/tools/CFamilyJarPreProcessor/ReadMe.txt b/build/tools/CFamilyJarPreProcessor/ReadMe.txt deleted file mode 100644 index 1dcc8d9d16..0000000000 --- a/build/tools/CFamilyJarPreProcessor/ReadMe.txt +++ /dev/null @@ -1,21 +0,0 @@ -CFamily plugin pre-processor ----------------------------- - -Ultimately, we want to embed multiple artefacts in the SLVS VSIX: -1) the subprocess.exe, -2) the "LICENSE_THIRD_PARTY.txt" file, and -3) a file that contains all of rules metadata. - -Artefacts (1) and (2) exist somewhere in the jar. -However, artefact (3) does not. Instead, there are some well-known json files and hundreds of per-rule files. We need to find and load all of these files and generate artefact (3). - -Format of artefact (3) ----------------------- -TODO - - -Integration with the rest of the build --------------------------------------- -The application is a standalone exe that is called as part of the main solution build. - --> the solution needs to reference the build tools. diff --git a/build/tools/CFamilyJarPreProcessor/packages.lock.json b/build/tools/CFamilyJarPreProcessor/packages.lock.json deleted file mode 100644 index f0d7e6a2fb..0000000000 --- a/build/tools/CFamilyJarPreProcessor/packages.lock.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "version": 1, - "dependencies": { - ".NETFramework,Version=v4.7.2": { - "SharpCompress": { - "type": "Direct", - "requested": "[0.32.1, )", - "resolved": "0.32.1", - "contentHash": "9Cwj3lK/p7wkiBaQPCvaKINuHYuZ0ACDldA4M3o5ISSq7cjbbq3yqigTDBUoKjtyyXpqmQHUkw6fhLnjNF30ow==", - "dependencies": { - "System.Memory": "4.5.4", - "System.Text.Encoding.CodePages": "6.0.0" - } - }, - "SharpZipLib": { - "type": "Direct", - "requested": "[1.3.3, )", - "resolved": "1.3.3", - "contentHash": "N8+hwhsKZm25tDJfWpBSW7EGhH/R7EMuiX+KJ4C4u+fCWVc1lJ5zg1u3S1RPPVYgTqhx/C3hxrqUpi6RwK5+Tg==" - }, - "System.Buffers": { - "type": "Transitive", - "resolved": "4.5.1", - "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" - }, - "System.Memory": { - "type": "Transitive", - "resolved": "4.5.4", - "contentHash": "1MbJTHS1lZ4bS4FmsJjnuGJOu88ZzTT2rLvrhW7Ygic+pC0NWA+3hgAen0HRdsocuQXCkUTdFn9yHJJhsijDXw==", - "dependencies": { - "System.Buffers": "4.5.1", - "System.Numerics.Vectors": "4.5.0", - "System.Runtime.CompilerServices.Unsafe": "4.5.3" - } - }, - "System.Numerics.Vectors": { - "type": "Transitive", - "resolved": "4.5.0", - "contentHash": "QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==" - }, - "System.Runtime.CompilerServices.Unsafe": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==" - }, - "System.Text.Encoding.CodePages": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "ZFCILZuOvtKPauZ/j/swhvw68ZRi9ATCfvGbk1QfydmcXBkIWecWKn/250UH7rahZ5OoDBaiAudJtPvLwzw85A==", - "dependencies": { - "System.Memory": "4.5.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - } - }, - ".NETFramework,Version=v4.7.2/win7-x86": { - "System.Text.Encoding.CodePages": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "ZFCILZuOvtKPauZ/j/swhvw68ZRi9ATCfvGbk1QfydmcXBkIWecWKn/250UH7rahZ5OoDBaiAudJtPvLwzw85A==", - "dependencies": { - "System.Memory": "4.5.4", - "System.Runtime.CompilerServices.Unsafe": "6.0.0" - } - } - } - } -} \ No newline at end of file diff --git a/src/Integration.Vsix/Integration.Vsix.csproj b/src/Integration.Vsix/Integration.Vsix.csproj index 09a6fbb6da..87b3add947 100644 --- a/src/Integration.Vsix/Integration.Vsix.csproj +++ b/src/Integration.Vsix/Integration.Vsix.csproj @@ -326,60 +326,14 @@ - - - + - - https://binaries.sonarsource.com/CommercialDistribution/sonar-cfamily-plugin/sonar-cfamily-plugin-$(EmbeddedSonarCFamilyAnalyzerVersion).jar - - lib DownloadedJars EmbeddedDotnetAnalyzerDLLs Sloop - - - $(MSBuildThisFileDirectory)$(CFamilyFolderName) - - - $(PrepareForBuildDependsOn);GetCFamilyFiles - - - - - - - - - - - - - - - PreserveNewest - True - - - $(CFamilyFolderName) - false - - - - diff --git a/tools/CleanRebuild.cmd b/tools/CleanRebuild.cmd index 37fde4f9de..87b1755252 100644 --- a/tools/CleanRebuild.cmd +++ b/tools/CleanRebuild.cmd @@ -2,7 +2,7 @@ @REM %~dp0 gives the directory containing this batch file -(for %%a in ("%~dp0..\src\Integration.Vsix\lib" "%LOCALAPPDATA%\SLVS_Build_DownloadedJars" "%LOCALAPPDATA%\SLVS_CFamily_Build" "%LOCALAPPDATA%\SLVS_TypeScript_Build" "%LOCALAPPDATA%\SLVS_Build_SLOOP" "%LOCALAPPDATA%\SLVS_Build_Dotnet") do rd /s /q "%%~a") +(for %%a in ("%LOCALAPPDATA%\SLVS_Build_DownloadedJars" "%LOCALAPPDATA%\SLVS_Build_SLOOP" "%LOCALAPPDATA%\SLVS_Build_Dotnet") do rd /s /q "%%~a") call msbuild.exe %~dp0..\build\DownloadDependencies -t:Rebuild call msbuild.exe "%~dp0..\SonarLint.VisualStudio.Integration.sln" -t:Rebuild