ubisoft / Sharpmake

Sharpmake is an open-source C#-based solution for generating project definition files, such as Visual Studio projects and solutions, GNU makefiles, Xcode projects, etc.
Apache License 2.0
927 stars 171 forks source link

Unable to parse clang version #288

Closed xoorath closed 1 year ago

xoorath commented 1 year ago

This code linked below will throw an exception (in my build environment, at least):

https://github.com/ubisoft/Sharpmake/blob/d20ebacbce2f3aff42ae1b478861ac4966e1ce04/Sharpmake.Platforms/Sharpmake.CommonPlatforms/Windows/ClangForWindowsSettings.cs#L52C40-L52C40

[ERROR]
Error:
Version string portion was too short or too long. (Parameter 'input')
        While running C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\tmp\bin\Debug\net6.0\SharpMake.Application.exe
        @08/17/2023 20:34:22: Exception message (level 0):
        Error encountered while generating Lateralus.LunaSVGProject
        Inner exception message (level 1):
        Version string portion was too short or too long. (Parameter 'input')

        Stack trace:
        Inner exception stack trace (level 1):
   at System.Version.ParseVersion(ReadOnlySpan`1 input, Boolean throwOnFailure)
   at System.Version.Parse(String input)
   at Sharpmake.ClangForWindows.GetWindowsClangLibraryPath(String llvmInstallDir, String clangVersion, String libFolderName) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Platforms\Sharpmake.CommonPlatforms\Windows\ClangForWindowsSettings.cs:line 60
   at Sharpmake.ClangForWindows.GetWindowsClangLibraryPath(String libFolderName) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Platforms\Sharpmake.CommonPlatforms\Windows\ClangForWindowsSettings.cs:line 47
   at Sharpmake.Windows.BaseWindowsPlatform.SetupSdkOptions(IGenerationContext context) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Platforms\Sharpmake.CommonPlatforms\Windows\BaseWindowsPlatform.cs:line 109
   at Sharpmake.Generators.VisualStudio.ProjectOptionsGenerator.GenerateCompilerOptions(IGenerationContext context, ProjectOptionsGenerationContext optionsContext) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Generators\VisualStudio\ProjectOptionsGenerator.cs:line 492
   at Sharpmake.Generators.VisualStudio.ProjectOptionsGenerator.GenerateOptions(IGenerationContext context, ProjectOptionGenerationLevel level) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Generators\VisualStudio\ProjectOptionsGenerator.cs:line 96
   at Sharpmake.Generators.VisualStudio.Vcxproj.GenerateConfOptions(GenerationContext context) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Generators\VisualStudio\Vcxproj.cs:line 347
   at Sharpmake.Generators.VisualStudio.Vcxproj.GenerateImpl(GenerationContext context, IList`1 generatedFiles, IList`1 skipFiles) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Generators\VisualStudio\Vcxproj.cs:line 360
   at Sharpmake.Generators.VisualStudio.Vcxproj.Generate(Builder builder, Project project, List`1 configurations, String projectFile, List`1 generatedFiles, List`1 skipFiles) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Generators\VisualStudio\Vcxproj.cs:line 154
   at Sharpmake.Generators.GeneratorManager.Generate(Builder builder, Project project, List`1 configurations, String projectFile, List`1 generatedFiles, List`1 skipFiles) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Generators\GeneratorManager.cs:line 107
   at Sharpmake.Builder.GenerateProjectFile(Object arg) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake\Builder.cs:line 1311
        Root stack trace (level 0):
   at Sharpmake.Application.Program.CreateBuilderAndGenerate(BaseBuildContext buildContext, Argument parameters, Boolean generateDebugSolution) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Application\Program.cs:line 463
   at Sharpmake.Application.Program.GenerateAll(BaseBuildContext buildContext, Argument parameters) in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Application\Program.cs:line 492
   at Sharpmake.Application.Program.Main() in C:\Users\Jared\Documents\Git\lateralus\ThirdParty\Sharpmake\Sharpmake.Application\Program.cs:line 325

To reproduce this I am building sharpmake with .NET 6.0 and I have LLVM 16.0.6 installed using the ClangPowerTools extension in visual studio.

The version 16 in this case will be parsed from a path like: C:\Users\Jared\AppData\Roaming\ClangPowerTools\LLVM\LLVM16.0.6\lib\clang\16.

jspelletier commented 1 year ago

Hello, We will check this soon.

jspelletier commented 1 year ago

It looks from the callstack that you are using an old sharpmake version. The System.Version.Parse call was removed in commit f6d15d. Could you retry without your changes using latest sharpmake version? The change was released in version 27.0

xoorath commented 1 year ago

Hey,

Sorry for the confusion - I'm not sure how I ended up missing the fix when looking at the source. If I had noticed that fix in the repository I would have just updated. Whoops!