Skip to content

Commit

Permalink
refactor: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
furesoft committed Dec 2, 2024
1 parent a7526f3 commit 329317a
Show file tree
Hide file tree
Showing 119 changed files with 6,110 additions and 0 deletions.
49 changes: 49 additions & 0 deletions NewSource/Backlang.Build.Tasks/Backlang.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsTool>true</IsTool>
<AssemblyName>Backlang.Build.Tasks</AssemblyName>
<RootNamespace>Backlang.Build.Tasks</RootNamespace>
<EnableDefaultBuildItems>true</EnableDefaultBuildItems>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<PropertyGroup Label="BuildInfo">
<IsPublishable>false</IsPublishable>
<IncludeBuildOutput>false</IncludeBuildOutput>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<BuildOutputTargetFolder>Tasks</BuildOutputTargetFolder>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
</PropertyGroup>

<PropertyGroup Label="PackageInfo">
<PackageId>Backlang.Sdk</PackageId>
<Version>0.1.5</Version>
<PackageType>MSBuildSdk</PackageType>
<PackageTags>msbuild sdk Backlang</PackageTags>
<Description>MSBuild SDK for Backlang</Description>
<DevelopmentDependency>true</DevelopmentDependency>
<RepositoryUrl>https://github.com/furesoft/compiler-test</RepositoryUrl>
</PropertyGroup>

<ItemGroup>
<!-- Project Rule Definitions -->
<Content Include="**\*.xaml" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)"/>
<None Include=".\core\**" Pack="true" PackagePath="core\"/>
<None Include=".\Tasks\**" Pack="true" PackagePath="Tasks\"/>
<None Include=".\Sdk\**" Pack="true" PackagePath="Sdk\"/>
<None Include="bin\$(Configuration)\*.dll" Pack="true" PackagePath="Tasks\bin\"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="DistIL.Core" Version="0.10.0-preview" />
<PackageReference Include="Microsoft.Build.Framework" Version="17.12.6"/>
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="17.12.6"/>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.12.6"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BacklangC\BacklangC.csproj" />
</ItemGroup>

</Project>
59 changes: 59 additions & 0 deletions NewSource/Backlang.Build.Tasks/BuildTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Backlang.Codeanalysis.Parsing;
using Microsoft.Build.Framework;
using BacklangC;
using Task = Microsoft.Build.Utilities.Task;

namespace Backlang.Build.Tasks;

public class BuildTask : Task
{
[System.ComponentModel.DataAnnotations.Required]
public ITaskItem[] SourceFiles { get; set; }

[System.ComponentModel.DataAnnotations.Required]
public string OutputPath { get; set; }

[System.ComponentModel.DataAnnotations.Required]
public ITaskItem[] ReferencePaths { get; set; }

public string OptimizeLevel { get; set; }
public bool DebugSymbols { get; set; }
public string Configuration { get; set; }
public string Version { get; set; }
public string RootNamespace { get; set; }

public override bool Execute()
{
var driver = Driver.Create(new DriverSettings
{
OutputPath = OutputPath,
RootNamespace = RootNamespace,
Sources = SourceFiles.Select(_ => _.ItemSpec).ToArray(),
OptimizeLevel = OptimizeLevel,
DebugSymbols = DebugSymbols,
IsDebug = Configuration == "Debug",
Version = Version
});

driver.Compile();

foreach (var message in driver.Messages)
{
switch (message.Severity)
{
case MessageSeverity.Error:
Log.LogError(null, null, null,
file: message.Document.FileName, message.Range.Start.Line, message.Range.Start.Column,
message.Range.End.Line, message.Range.End.Column, message.Text);
break;
case MessageSeverity.Warning:
Log.LogWarning(null, null, null,
file: message.Document.FileName, message.Range.Start.Line, message.Range.Start.Column,
message.Range.End.Line, message.Range.End.Column, message.Text);
break;
}
}

return true;
}
}
9 changes: 9 additions & 0 deletions NewSource/Backlang.Build.Tasks/Core/Backlang.Core.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>

<PropertyGroup>
<DefaultLanguageSourceExtension>.back</DefaultLanguageSourceExtension>
</PropertyGroup>

<Import Project="Backlang.ProjectSystem.props"/>

</Project>
19 changes: 19 additions & 0 deletions NewSource/Backlang.Build.Tasks/Core/Backlang.Core.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>

<Import Project="$(MSBuildToolsPath)\Microsoft.Managed.Before.targets" Condition="Exists('$(MSBuildToolsPath)\Microsoft.Managed.Before.targets')"/>

<ImportGroup Condition="'$(IsCrossTargetingBuild)' == 'true'">
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.CrossTargeting.targets"/>
<Import Project="Backlang.OuterBuild.targets"/>
</ImportGroup>

<Import Project="Backlang.ProjectSystem.targets"/>

<ImportGroup Condition="'$(IsCrossTargetingBuild)' != 'true'">
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets"/>
<Import Project="Backlang.CoreCompile.targets"/>
</ImportGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.Managed.After.targets" Condition="Exists('$(MSBuildToolsPath)\Microsoft.Managed.After.targets')"/>

</Project>
15 changes: 15 additions & 0 deletions NewSource/Backlang.Build.Tasks/Core/Backlang.CoreCompile.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>

<PropertyGroup>
<RootNamespace Condition="'$(RootNamespace)' == ''">$(MSBuildProjectName)</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration) == 'Release'">
<OptimizeLevel>O2</OptimizeLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

</Project>
55 changes: 55 additions & 0 deletions NewSource/Backlang.Build.Tasks/Core/Backlang.CoreCompile.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<Project>

<Import Project="..\Tasks\Backlang.tasks"/>

<Import Project="Backlang.CoreCompile.props"/>

<Target Name="CreateManifestResourceNames"/>

<Target Name="GetCoreCompileInputsOutputs">
<ItemGroup>
<!-- Inputs -->
<CoreCompileInput Include="@(Compile)"/>
<CoreCompileInput Include="@(_CoreCompileResourceInputs)"/>
<CoreCompileInput Include="$(ApplicationIcon)"/>
<CoreCompileInput Include="$(AssemblyOriginatorKeyFile)"/>
<CoreCompileInput Include="@(ReferencePathWithRefAssemblies)"/>
<CoreCompileInput Include="@(CompiledLicenseFile)"/>
<CoreCompileInput Include="@(LinkResource)"/>
<CoreCompileInput Include="@(EmbeddedDocumentation)"/>
<CoreCompileInput Include="$(Win32Resource)"/>
<CoreCompileInput Include="$(Win32Manifest)"/>
<CoreCompileInput Include="@(CustomAdditionalCompileInputs)"/>
<CoreCompileInput Include="$(ResolvedCodeAnalysisRuleSet)"/>
<CoreCompileInput Include="@(AdditionalFiles)"/>
<CoreCompileInput Include="@(EmbeddedFiles)"/>
<CoreCompileInput Include="@(EditorConfigFiles)"/>
<!-- Outputs -->
<CoreCompileOutput Include="@(DocFileItem)"/>
<CoreCompileOutput Include="@(IntermediateAssembly)"/>
<CoreCompileOutput Include="@(IntermediateRefAssembly)"/>
<CoreCompileOutput Include="@(_DebugSymbolsIntermediatePath)"/>
<CoreCompileOutput Include="$(NonExistentFile)"/>
<CoreCompileOutput Include="@(CustomAdditionalCompileOutputs)"/>
</ItemGroup>
</Target>

<Target Name="CoreCompile" Inputs="@(CoreCompileInput)" Outputs="@(CoreCompileOutput)" DependsOnTargets="GetCoreCompileInputsOutputs;$(CoreCompileDependsOn)">
<BuildTask SourceFiles="@(Compile)" OutputPath="@(IntermediateAssembly)" ReferencePaths="@(ReferencePathWithRefAssemblies)" Configuration="$(Configuration)" RootNamespace="$(RootNamespace)" DebugSymbols="$(DebugSymbols)" Version="$(Version)" Optimize="$(Optimize)" />

<ItemGroup>
<OutputFiles Include="$(OutputPath)\**\*.dll"/>
</ItemGroup>

<Copy SourceFiles="@(OutputFiles)" DestinationFolder="$(IntermediateOutputPath)\refint\%(RecursiveDir)" OverwriteReadOnlyFiles="true" />

<Copy SourceFiles="@(OutputFiles)" DestinationFolder="$(IntermediateOutputPath)\$(RuntimeIdentifier)\refint\%(RecursiveDir)" OverwriteReadOnlyFiles="true" />

<ItemGroup>
<_CoreCompileResourceInputs Remove="@(_CoreCompileResourceInputs)"/>
</ItemGroup>

<CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''"/>
</Target>

</Project>
29 changes: 29 additions & 0 deletions NewSource/Backlang.Build.Tasks/Core/Backlang.OuterBuild.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project>

<!--
============================================================
Publish
Multi-targeting version of Publish.
[IN]
$(TargetFrameworks) - Semicolon delimited list of target frameworks.
$(InnerTargets) - The targets to publish for each target framework.
Defaults to 'Publish' if unset, but allows override to support
`msbuild /p:InnerTargets=X;Y;Z` which will build X, Y & Z
targets for each target framework.
[OUT]
@(InnerOutput) - The combined output items of the inner targets across all builds.
============================================================
-->
<Target Name="Publish" DependsOnTargets="_SetPublishInnerTarget;DispatchToInnerBuilds"/>

<Target Name="_SetPublishInnerTarget" Returns="@(InnerOutput)">
<PropertyGroup Condition="'$(InnerTargets)' == ''">
<InnerTargets>Publish</InnerTargets>
</PropertyGroup>
</Target>

</Project>
43 changes: 43 additions & 0 deletions NewSource/Backlang.Build.Tasks/Core/Backlang.ProjectSystem.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project>

<!-- Properties -->
<PropertyGroup>
<AppDesignerFolder Condition="'$(AppDesignerFolder)' == ''">Properties</AppDesignerFolder>
<AppDesignerFolderContentsVisibleOnlyInShowAllFiles Condition="'$(AppDesignerFolderContentsVisibleOnlyInShowAllFiles)' == ''">false</AppDesignerFolderContentsVisibleOnlyInShowAllFiles>
<TemplateLanguage Condition="'$(TemplateLanguage)' == ''">Backlang</TemplateLanguage>
<LanguageServiceName Condition="'$(LanguageServiceName)' == ''">Backlang</LanguageServiceName>
<DesignerVariableNaming Condition="'$(DesignerVariableNaming)' == ''">Camel</DesignerVariableNaming>
<DesignerFunctionVisibility Condition="'$(DesignerFunctionVisibility)' == ''">Private</DesignerFunctionVisibility>
<DesignerHiddenCodeGeneration Condition="'$(DesignerHiddenCodeGeneration)' == ''">Declarations</DesignerHiddenCodeGeneration>
</PropertyGroup>

<!--
CL CPS: {13B669BE-BB05-4DDF-9536-439F39A36129}
C# CPS: {9A19103F-16F7-4668-BE54-9A1E7A4F7556}
VB CPS: {778DAE3C-4631-46EA-AA77-85C1314464D9}
F# CPS: {6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}
-->
<PropertyGroup>
<DefaultProjectTypeGuid>{13B669BE-BB05-4DDF-9536-439F39A36129}</DefaultProjectTypeGuid>
</PropertyGroup>

<!-- TODO: Replace with Backlang ProjectSystem GUIDs when developed -->
<PropertyGroup>
<LanguageServiceId Condition="'$(LanguageServiceId)'==''">$(DefaultProjectTypeGuid)</LanguageServiceId>
<AddItemTemplatesGuid Condition="'$(AddItemTemplatesGuid)' == ''">$(DefaultProjectTypeGuid)</AddItemTemplatesGuid>
<GeneratorsTypeGuid Condition="'$(GeneratorsTypeGuid)' == ''">$(DefaultProjectTypeGuid)</GeneratorsTypeGuid>
<CmdUIContextGuid Condition="'$(CmdUIContextGuid)' == ''">$(DefaultProjectTypeGuid)</CmdUIContextGuid>
</PropertyGroup>

<!-- TODO: Remove CSharp when Backlang support is added in VS -->
<PropertyGroup Condition="'$(DisableCSharpProjectSystem)' != 'true'">
<TemplateLanguage>CSharp</TemplateLanguage>
<LanguageServiceName>C#</LanguageServiceName>
<DefaultProjectTypeGuid>{9A19103F-16F7-4668-BE54-9A1E7A4F7556}</DefaultProjectTypeGuid>
<LanguageServiceId>{694DD9B6-B865-4C5B-AD85-86356E9C88DC}</LanguageServiceId>
<AddItemTemplatesGuid>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</AddItemTemplatesGuid>
<GeneratorsTypeGuid>{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}</GeneratorsTypeGuid>
<CmdUIContextGuid>{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}</CmdUIContextGuid>
</PropertyGroup>

</Project>
41 changes: 41 additions & 0 deletions NewSource/Backlang.Build.Tasks/Core/Backlang.ProjectSystem.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project>

<!-- Import design time targets for the Roslyn Project System. These are only available if Visual Studio is installed. -->
<PropertyGroup>
<DesignTimeExtensionsPath Condition="'$(DesignTimeExtensionsPath)'==''">$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed</DesignTimeExtensionsPath>
<DesignTimeLanguageTargets Condition="'$(DesignTimeLanguageTargets)'==''">$(DesignTimeExtensionsPath)\Microsoft.Managed.DesignTime.targets</DesignTimeLanguageTargets>
</PropertyGroup>

<Import Project="$(DesignTimeLanguageTargets)" Condition="'$(DesignTimeLanguageTargets)' != '' AND Exists('$(DesignTimeLanguageTargets)')"/>

<ItemGroup>
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Rules\Backlang.ProjectItemsSchema.xaml"/>
<!-- TODO: Remove CSharp when Backlang support is added in VS -->
<ProjectCapability Include="CSharp"/>
<ProjectCapability Include="Backlang;Managed;ClassDesigner"/>
</ItemGroup>

<ItemGroup Condition="'$(DefineCommonManagedItemSchemas)' == 'true'">

<PropertyPageSchema Include="$(ManagedXamlNeutralResourcesDirectory)EditorConfigFiles.xaml">
<Context>File</Context>
</PropertyPageSchema>

<PropertyPageSchema Include="$(ManagedXamlResourcesDirectory)EditorConfigFiles.BrowseObject.xaml">
<Context>BrowseObject</Context>
</PropertyPageSchema>

</ItemGroup>

<!-- Targets -->

<!-- Returns Msc command-line arguments for the language service -->
<Target Name="CompileDesignTime" Returns="@(_CompilerCommandLineArgs)" DependsOnTargets="_CheckCompileDesignTimePrerequisite;Compile" Condition="'$(IsCrossTargetingBuild)' != 'true'">

<ItemGroup>
<_CompilerCommandLineArgs Include="@(MscCommandLineArgs)"/>
</ItemGroup>

</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<ProjectSchemaDefinitions xmlns="http://schemas.microsoft.com/build/2009/properties">

<ContentType Name="BacklangFile" DisplayName="Backlang file" ItemType="Compile">
</ContentType>

<ItemType Name="Compile" DisplayName="Backlang compiler" />
<ItemType Name="AdditionalFiles" DisplayName="Backlang analyzer additional file" />
<ItemType Name="EditorConfigFiles" DisplayName=".editorconfig file" />

<FileExtension Name=".back" ContentType="BacklangFile" />

</ProjectSchemaDefinitions>
12 changes: 12 additions & 0 deletions NewSource/Backlang.Build.Tasks/Sdk/Sdk.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>

<!-- Indicate whether `Backlang.Sdk` is being used. -->
<PropertyGroup>
<UsingBacklangSdk>true</UsingBacklangSdk>
</PropertyGroup>

<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props"/>

<Import Project="..\Core\Backlang.Runtime.props" Condition="'$(MSBuildProjectExtension)' == '.backproj'"/>

</Project>
9 changes: 9 additions & 0 deletions NewSource/Backlang.Build.Tasks/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>

<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.backproj'">
<LanguageTargets>$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..\Core\Backlang.Runtime.targets'))</LanguageTargets>
</PropertyGroup>

<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets"/>

</Project>
18 changes: 18 additions & 0 deletions NewSource/Backlang.Build.Tasks/Tasks/Backlang.tasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project>

<!-- This file lists all the tasks that ship with Backlang.Sdk -->

<!--
NOTE: Listing a <UsingTask> tag in a *.tasks file like this one rather than in a project or targets file
can give a significant performance advantage in a large build, because every time a <UsingTask> tag
is encountered, it will cause the task to be rediscovered next time the task is used.
-->

<!-- NOTE: Using the fully qualified class name in a <UsingTask> tag is faster than using a partially qualified name. -->

<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)bin\Backlang.Build.Tasks.dll" TaskName="Backlang.Build.Tasks.BuildTask"/>

<PropertyGroup>

</PropertyGroup>
</Project>
Binary file added NewSource/Backlang.Build.Tasks/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 329317a

Please sign in to comment.