Skip to content

Commit

Permalink
Remove CompilerMode; instead, set Language based on project file name…
Browse files Browse the repository at this point in the history
… extension.

Closes #108.
  • Loading branch information
alexrp committed Jan 15, 2024
1 parent bb040a4 commit e9af86f
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
2 changes: 0 additions & 2 deletions doc/configuration/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ historical reasons.

## Project Setup

* `CompilerMode` (`C`, `Cxx`, `Zig`): The language to compile the project as.
This is inferred from the project file extension by default.
* `AssemblyName`: Name of the project. By default, this is set to the file name
of the project file. Used to compute the final binary name (e.g. `foo` becomes
`libfoo.so`).
Expand Down
1 change: 1 addition & 0 deletions src/sdk/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
last.
-->

<Import Project="../build/Vezel.Zig.Sdk.Language.targets" />
<Import Project="../build/Vezel.Zig.Sdk.Overrides.targets" />
<Import Project="../build/Vezel.Zig.Sdk.Cross.targets" />
<Import Project="../build/Vezel.Zig.Sdk.Symbols.targets" />
Expand Down
8 changes: 4 additions & 4 deletions src/sdk/build/Vezel.Zig.Sdk.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<ItemGroup Condition="'$(DefaultSources)' == 'true'">
<Compile Include="**/*.c"
Excludes="$(DefaultItemExcludes); $(DefaultExcludesInProjectFolder)"
Condition="'$(CompilerMode)' == 'C'" />
Condition="'$(Language)' == 'C'" />
<Compile Include="**/*.cxx"
Excludes="$(DefaultItemExcludes); $(DefaultExcludesInProjectFolder)"
Condition="'$(CompilerMode)' == 'Cxx'" />
Condition="'$(Language)' == 'Cxx'" />
<Compile Include="$(AssemblyName).zig"
Condition="'$(CompilerMode)' == 'Zig' and '$(OutputType)' == 'Library'" />
Condition="'$(Language)' == 'Zig' and '$(OutputType)' == 'Library'" />
<Compile Include="main.zig"
Condition="'$(CompilerMode)' == 'Zig' and '$(OutputType)' != 'Library'" />
Condition="'$(Language)' == 'Zig' and '$(OutputType)' != 'Library'" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/sdk/build/Vezel.Zig.Sdk.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
AsyncExceptions="$(AsyncExceptions)"
BlockExtensions="$(BlockExtensions)"
CommandFragmentsDirectory="$(_CommandFragmentsPath)"
CompilerMode="$(CompilerMode)"
CompilerMode="$(Language)"
ConsumptionAnalysis="$(ConsumptionAnalysis)"
Configuration="$(Configuration)"
CxxExceptions="$(CxxExceptions)"
Expand Down
12 changes: 3 additions & 9 deletions src/sdk/build/Vezel.Zig.Sdk.Defaults.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
allow users to alter if they wish.
-->

<PropertyGroup Condition="'$(CompilerMode)' == ''">
<CompilerMode Condition="'$(MSBuildProjectExtension)' == '.cproj'">C</CompilerMode>
<CompilerMode Condition="'$(MSBuildProjectExtension)' == '.cxxproj'">Cxx</CompilerMode>
<CompilerMode Condition="'$(MSBuildProjectExtension)' == '.zigproj'">Zig</CompilerMode>
</PropertyGroup>

<PropertyGroup>
<CachePath Condition="'$(CachePath)' == ''">$(IntermediateOutputPath)zig-cache</CachePath>
<CommandsPath Condition="'$(CommandsPath)' == ''">$(IntermediateOutputPath)compile_commands.json</CommandsPath>
Expand All @@ -27,9 +21,9 @@
</PropertyGroup>

<PropertyGroup Condition="'$(LanguageStandard)' == ''">
<LanguageStandard Condition="'$(CompilerMode)' == 'C'">gnu2x</LanguageStandard>
<LanguageStandard Condition="'$(CompilerMode)' == 'Cxx'">gnu++2b</LanguageStandard>
<LanguageStandard Condition="'$(CompilerMode)' == 'Zig'">zig</LanguageStandard>
<LanguageStandard Condition="'$(Language)' == 'C'">gnu2x</LanguageStandard>
<LanguageStandard Condition="'$(Language)' == 'Cxx'">gnu++2b</LanguageStandard>
<LanguageStandard Condition="'$(Language)' == 'Zig'">zig</LanguageStandard>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/build/Vezel.Zig.Sdk.Editor.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Target Name="_CheckCompileCommands"
Inputs="$(MSBuildAllProjects); $(IntermediateOutputPath)$(MSBuildProjectFile).CoreCompileInputs.cache"
Outputs="$(CommandsPath)"
Condition="'$(CompilerMode)' != 'Zig' and '$(EditorSupport)' == 'true'">
Condition="'$(Language)' != 'Zig' and '$(EditorSupport)' == 'true'">
<CreateProperty Value="true">
<Output TaskParameter="ValueSetByTask"
PropertyName="_RefreshCompileCommands" />
Expand Down
4 changes: 2 additions & 2 deletions src/sdk/build/Vezel.Zig.Sdk.Format.targets
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project>
<Target Name="_CheckFormat"
Condition="'$(CompilerMode)' == 'Zig' and @(ZigSource->Count()) != 0">
Condition="'$(Language)' == 'Zig' and @(ZigSource->Count()) != 0">
<ZigFormat FormatterMode="Check"
Sources="@(ZigSource)"
StandardOutputImportance="high"
ToolExe="$(ZigExePath)" />
</Target>

<Target Name="Format"
Condition="'$(CompilerMode)' == 'Zig' and @(ZigSource->Count()) != 0">
Condition="'$(Language)' == 'Zig' and @(ZigSource->Count()) != 0">
<ZigFormat FormatterMode="Execute"
Sources="@(ZigSource)"
ToolExe="$(ZigExePath)" />
Expand Down
7 changes: 7 additions & 0 deletions src/sdk/build/Vezel.Zig.Sdk.Language.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<Language Condition="'$(MSBuildProjectExtension)' == '.cproj'">C</Language>
<Language Condition="'$(MSBuildProjectExtension)' == '.cxxproj'">Cxx</Language>
<Language Condition="'$(MSBuildProjectExtension)' == '.zigproj'">Zig</Language>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/sdk/build/Vezel.Zig.Sdk.Pack.targets
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
Exclude="$(DefaultItemExcludes)"
Pack="true"
PackagePath="zig"
Condition="'$(CompilerMode)' == 'Zig'" />
Condition="'$(Language)' == 'Zig'" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/build/Vezel.Zig.Sdk.Test.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-->
<Target Name="VSTest"
DependsOnTargets="$(VSTestDependsOn)"
Condition="'$(CompilerMode)' == 'Zig' and '$(IsTestable)' == 'true'">
Condition="'$(Language)' == 'Zig' and '$(IsTestable)' == 'true'">
<!--
We might be run before an actual build, in which case the intermediate
output path will not exist.
Expand Down

0 comments on commit e9af86f

Please sign in to comment.