Support the 'buildGrammar' option
This commit is contained in:
Родитель
7c8643d6de
Коммит
fbacc2b992
|
@ -134,6 +134,12 @@ module.exports = Generator.extend({
|
|||
this.destinationPath(path.join(this.props.name, learningNamespace, 'packages.config')),
|
||||
this.props
|
||||
);
|
||||
if (this.props.buildGrammar) {
|
||||
this.fs.copy(
|
||||
this.templatePath('solution/app/BuildGrammar.targets'),
|
||||
this.destinationPath(path.join(this.props.name, this.props.name, 'BuildGrammar.targets'))
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
install: function () {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{EFBD1A76-0A93-4CE8-8579-A0E6C078E341}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace><%= name %></RootNamespace>
|
||||
|
@ -10,7 +10,7 @@
|
|||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
|
@ -21,7 +21,7 @@
|
|||
<ExternalConsole>true</ExternalConsole>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
|
@ -207,9 +207,10 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="<%= name %>.grammar">
|
||||
<Content Include="<%= name %>.grammar">
|
||||
<Label>GrammarDefinition</Label>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\<%= name %>.<%= semantics %>\<%= name %>.<%= semantics %>.csproj">
|
||||
|
@ -222,4 +223,24 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<% if (buildGrammar) { %>
|
||||
<ItemGroup>
|
||||
<DslAssemblyReference Include="$(SolutionDir)<%= name %>.<%= semantics %>/$(OutputPath)/<%= name %>.<%= semantics %>.dll" >
|
||||
<InProject>false</InProject>
|
||||
</DslAssemblyReference>
|
||||
<DslAssemblyReference Include="$(SolutionDir)<%= name %>.<%= learning %>/$(OutputPath)/<%= name %>.<%= learning %>.dll" >
|
||||
<InProject>false</InProject>
|
||||
</DslAssemblyReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="<%= name %>.Language">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(OutputPath)\<%= name %>.Language.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="BuildGrammar.targets" />
|
||||
</ItemGroup>
|
||||
<Import Project="BuildGrammar.targets" />
|
||||
<% } %>
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="SetProperties">
|
||||
<ItemGroup>
|
||||
<GrammarDefinition Include="@(Content)" Condition="'%(Content.Label)' == 'GrammarDefinition'"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<DslCompiler Include="$(SolutionDir)packages/Microsoft.ProgramSynthesis*/tools/dslc.exe"/>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<InputGrammar>@(GrammarDefinition -> '%(FullPath)')</InputGrammar>
|
||||
<DslName>@(GrammarDefinition -> '%(Filename)')</DslName>
|
||||
<DslCompiler Condition="'$(OS)' == 'Windows_NT'">"@(DslCompiler -> '%(FullPath)')"</DslCompiler>
|
||||
<DslCompiler Condition="'$(OS)' != 'Windows_NT'">mono "@(DslCompiler -> '%(FullPath)')"</DslCompiler>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<AssemblyPaths Include="@(DslAssemblyReference -> '%(RootDir)%(Directory)')"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- Fix the double-backslash-in-quoted-strings problem on Windows.
|
||||
See http://weblogs.asp.net/jongalloway/_5B002E00_NET-Gotcha_5D00_-Commandline-args-ending-in-_5C002200_-are-subject-to-CommandLineToArgvW-whackiness -->
|
||||
<AssemblyPathsFixedSlash Include="@(AssemblyPaths -> Replace('\', '/'))"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<OutputGrammar Include="@(GrammarDefinition -> '$(TargetDir)%(Filename).Language.dll')"/>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
<Target Name="RecompileGrammar" DependsOnTargets="SetProperties">
|
||||
<Message Importance="High" Text="Recompiling $(InputGrammar) using $(DSLCompiler)..."/>
|
||||
<PropertyGroup>
|
||||
<DslcCommand>$(DslCompiler) -p "@(AssemblyPathsFixedSlash)" -o "@(OutputGrammar)" -v verbose -- "$(InputGrammar)"</DslcCommand>
|
||||
</PropertyGroup>
|
||||
<Message Importance="High" Text="$(DslcCommand)"/>
|
||||
<Exec Command="$(DslcCommand)"/>
|
||||
</Target>
|
||||
<Target Name="AfterResolveReferences" DependsOnTargets="SetProperties"
|
||||
Inputs="$(InputGrammar);@(DslAssemblyReference -> '%(FullPath)');" Outputs="@(OutputGrammar)">
|
||||
<CallTarget Targets="RecompileGrammar" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -10,5 +10,6 @@ language <%= name %>;
|
|||
|
||||
@complete feature double <%= scoreFeature %> = <%= scoreHolder %>;
|
||||
|
||||
// Your grammar rules here
|
||||
|
||||
// Your grammar rules here. For example:
|
||||
@start string P := x;
|
||||
@input string x;
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Semantics.cs" />
|
||||
<Compile Include="<%= semantics %>.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
Загрузка…
Ссылка в новой задаче