Move OpenRA.Lint into a --check-yaml utility command.

This commit is contained in:
Paul Chote
2014-12-18 15:15:06 +13:00
committed by Matthias Mailänder
parent 91807cb53c
commit ecd4479807
6 changed files with 35 additions and 146 deletions

View File

@@ -67,7 +67,7 @@ INSTALL_PROGRAM = $(INSTALL) -m755
INSTALL_DATA = $(INSTALL) -m644 INSTALL_DATA = $(INSTALL) -m644
# program targets # program targets
CORE = rsdl2 rnull game utility ralint CORE = rsdl2 rnull game utility
TOOLS = editor tsbuild crashdialog TOOLS = editor tsbuild crashdialog
VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`) VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`)
@@ -112,7 +112,7 @@ mod_common: $(mod_common_TARGET)
##### Official Mods ##### ##### Official Mods #####
STD_MOD_LIBS = $(game_TARGET) STD_MOD_LIBS = $(game_TARGET)
STD_MOD_DEPS = $(STD_MOD_LIBS) $(ralint_TARGET) STD_MOD_DEPS = $(STD_MOD_LIBS)
# Red Alert # Red Alert
mod_ra_SRCS := $(shell find OpenRA.Mods.RA/ -iname '*.cs') mod_ra_SRCS := $(shell find OpenRA.Mods.RA/ -iname '*.cs')
@@ -168,24 +168,15 @@ OpenRA.Editor.Form1.resources:
resgen2 OpenRA.Editor/Form1.resx OpenRA.Editor.Form1.resources 1> /dev/null resgen2 OpenRA.Editor/Form1.resx OpenRA.Editor.Form1.resources 1> /dev/null
editor: OpenRA.Editor.MapSelect.resources OpenRA.Editor.Form1.resources $(editor_TARGET) editor: OpenRA.Editor.MapSelect.resources OpenRA.Editor.Form1.resources $(editor_TARGET)
# Analyses mod yaml for easy to detect errors
ralint_SRCS := $(shell find OpenRA.Lint/ -iname '*.cs')
ralint_TARGET = OpenRA.Lint.exe
ralint_KIND = exe
ralint_DEPS = $(game_TARGET)
ralint_LIBS = $(COMMON_LIBS) $(ralint_DEPS)
PROGRAMS += ralint
ralint: $(ralint_TARGET)
test: test:
@echo "OpenRA.Lint: checking Red Alert mod MiniYAML..." @echo "Testing Red Alert mod MiniYAML..."
@mono --debug OpenRA.Lint.exe --verbose ra @mono --debug OpenRA.Utility.exe ra --check-yaml
@echo "OpenRA.Lint: checking Tiberian Dawn mod MiniYAML..." @echo "Testing Tiberian Dawn mod MiniYAML..."
@mono --debug OpenRA.Lint.exe --verbose cnc @mono --debug OpenRA.Utility.exe cnc --check-yaml
@echo "OpenRA.Lint: checking Dune 2000 mod MiniYAML..." @echo "Testing Dune 2000 mod MiniYAML..."
@mono --debug OpenRA.Lint.exe --verbose d2k @mono --debug OpenRA.Utility.exe d2k --check-yaml
@echo "OpenRA.Lint: checking Tiberian Sun mod MiniYAML..." @echo "Testing Tiberian Sun mod MiniYAML..."
@mono --debug OpenRA.Lint.exe --verbose ts @mono --debug OpenRA.Utility.exe ts --check-yaml
# Builds and exports tilesets from a bitmap # Builds and exports tilesets from a bitmap
tsbuild_SRCS := $(shell find OpenRA.TilesetBuilder/ -iname '*.cs') tsbuild_SRCS := $(shell find OpenRA.TilesetBuilder/ -iname '*.cs')
@@ -254,7 +245,7 @@ $(foreach prog,$(PROGRAMS),$(eval $(call BUILD_ASSEMBLY,$(prog))))
# #
default: cli-dependencies core default: cli-dependencies core
core: game renderers mods utility ralint core: game renderers mods utility
tools: editor tsbuild gamemonitor tools: editor tsbuild gamemonitor

View File

@@ -1,87 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F9FA4D9F-2302-470A-8A07-6E37F488C124}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OpenRA</RootNamespace>
<AssemblyName>OpenRA.Lint</AssemblyName>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<OutputPath>..\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="YamlChecker.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
<Name>OpenRA.Game</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -243,6 +243,7 @@
<Compile Include="Widgets\TerrainTemplatePreviewWidget.cs" /> <Compile Include="Widgets\TerrainTemplatePreviewWidget.cs" />
<Compile Include="LoadScreens\LogoStripeLoadScreen.cs" /> <Compile Include="LoadScreens\LogoStripeLoadScreen.cs" />
<Compile Include="LoadScreens\BlankLoadScreen.cs" /> <Compile Include="LoadScreens\BlankLoadScreen.cs" />
<Compile Include="UtilityCommands\CheckYaml.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>

View File

@@ -14,52 +14,43 @@ using System.Linq;
using OpenRA.FileSystem; using OpenRA.FileSystem;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Lint namespace OpenRA.Mods.Common.UtilityCommands
{ {
static class YamlChecker class CheckYaml : IUtilityCommand
{ {
public string Name { get { return "--check-yaml"; } }
static int errors = 0; static int errors = 0;
// mimic Windows compiler error format // mimic Windows compiler error format
static void EmitError(string e) static void EmitError(string e)
{ {
Console.WriteLine("OpenRA.Lint(1,1): Error: {0}", e); Console.WriteLine("OpenRA.Utility(1,1): Error: {0}", e);
++errors; ++errors;
} }
static void EmitWarning(string e) static void EmitWarning(string e)
{ {
Console.WriteLine("OpenRA.Lint(1,1): Warning: {0}", e); Console.WriteLine("OpenRA.Utility(1,1): Warning: {0}", e);
} }
static int Main(string[] args) [Desc("[MAPFILE]", "Check a mod or map for certain yaml errors.")]
public void Run(ModData modData, string[] args)
{ {
if (args.Length == 0) // HACK: The engine code assumes that Game.modData is set.
{ Game.modData = modData;
Console.WriteLine("Usage: OpenRA.Lint.exe MOD [MAP] [--verbose]");
return 0;
}
try try
{ {
Log.AddChannel("debug", null); Log.AddChannel("debug", null);
Log.AddChannel("perf", null); Log.AddChannel("perf", null);
var options = args.Where(a => a.StartsWith("-"));
var mod = args.Where(a => !options.Contains(a)).First();
var map = args.Where(a => !options.Contains(a)).Skip(1).FirstOrDefault();
var verbose = options.Contains("-v") || options.Contains("--verbose");
// bind some nonfatal error handling into FieldLoader, so we don't just *explode*. // bind some nonfatal error handling into FieldLoader, so we don't just *explode*.
ObjectCreator.MissingTypeAction = s => EmitError("Missing Type: {0}".F(s)); ObjectCreator.MissingTypeAction = s => EmitError("Missing Type: {0}".F(s));
FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name)); FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name));
AppDomain.CurrentDomain.AssemblyResolve += GlobalFileSystem.ResolveAssembly;
Game.InitializeSettings(Arguments.Empty);
Game.modData = new ModData(mod);
IEnumerable<Map> maps; IEnumerable<Map> maps;
if (string.IsNullOrEmpty(map)) if (args.Length < 2)
{ {
Game.modData.MapCache.LoadMaps(); Game.modData.MapCache.LoadMaps();
maps = Game.modData.MapCache maps = Game.modData.MapCache
@@ -67,12 +58,11 @@ namespace OpenRA.Lint
.Select(m => m.Map); .Select(m => m.Map);
} }
else else
maps = new[] { new Map(map) }; maps = new[] { new Map(args[1]) };
foreach (var testMap in maps) foreach (var testMap in maps)
{ {
if (verbose) Console.WriteLine("Testing map: {0}".F(testMap.Title));
Console.WriteLine("Testing map: {0}".F(testMap.Title));
testMap.PreloadRules(); testMap.PreloadRules();
foreach (var customPassType in Game.modData.ObjectCreator foreach (var customPassType in Game.modData.ObjectCreator
@@ -95,15 +85,13 @@ namespace OpenRA.Lint
if (errors > 0) if (errors > 0)
{ {
Console.WriteLine("Errors: {0}", errors); Console.WriteLine("Errors: {0}", errors);
return 1; Environment.Exit(1);
} }
return 0;
} }
catch (Exception e) catch (Exception e)
{ {
EmitError("Failed with exception: {0}".F(e)); EmitError("Failed with exception: {0}".F(e));
return 1; Environment.Exit(1);
} }
} }
} }

View File

@@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Editor", "OpenRA.Edi
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.TilesetBuilder", "OpenRA.TilesetBuilder\OpenRA.TilesetBuilder.csproj", "{1A8E50CC-EE32-4E57-8842-0C39C8EA7541}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.TilesetBuilder", "OpenRA.TilesetBuilder\OpenRA.TilesetBuilder.csproj", "{1A8E50CC-EE32-4E57-8842-0C39C8EA7541}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Lint", "OpenRA.Lint\OpenRA.Lint.csproj", "{F9FA4D9F-2302-470A-8A07-6E37F488C124}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Utility", "OpenRA.Utility\OpenRA.Utility.csproj", "{F33337BE-CB69-4B24-850F-07D23E408DDF}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Utility", "OpenRA.Utility\OpenRA.Utility.csproj", "{F33337BE-CB69-4B24-850F-07D23E408DDF}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Renderer.Null", "OpenRA.Renderer.Null\OpenRA.Renderer.Null.csproj", "{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Renderer.Null", "OpenRA.Renderer.Null\OpenRA.Renderer.Null.csproj", "{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}"
@@ -80,8 +78,6 @@ Global
{00038B75-405B-44F5-8691-BD2546DBE224}.Debug|x86.Build.0 = Debug|x86 {00038B75-405B-44F5-8691-BD2546DBE224}.Debug|x86.Build.0 = Debug|x86
{1A8E50CC-EE32-4E57-8842-0C39C8EA7541}.Debug|x86.ActiveCfg = Debug|x86 {1A8E50CC-EE32-4E57-8842-0C39C8EA7541}.Debug|x86.ActiveCfg = Debug|x86
{1A8E50CC-EE32-4E57-8842-0C39C8EA7541}.Debug|x86.Build.0 = Debug|x86 {1A8E50CC-EE32-4E57-8842-0C39C8EA7541}.Debug|x86.Build.0 = Debug|x86
{F9FA4D9F-2302-470A-8A07-6E37F488C124}.Debug|x86.ActiveCfg = Debug|x86
{F9FA4D9F-2302-470A-8A07-6E37F488C124}.Debug|x86.Build.0 = Debug|x86
{F33337BE-CB69-4B24-850F-07D23E408DDF}.Debug|x86.ActiveCfg = Debug|x86 {F33337BE-CB69-4B24-850F-07D23E408DDF}.Debug|x86.ActiveCfg = Debug|x86
{F33337BE-CB69-4B24-850F-07D23E408DDF}.Debug|x86.Build.0 = Debug|x86 {F33337BE-CB69-4B24-850F-07D23E408DDF}.Debug|x86.Build.0 = Debug|x86
{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}.Debug|x86.ActiveCfg = Debug|x86 {0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}.Debug|x86.ActiveCfg = Debug|x86

View File

@@ -114,14 +114,14 @@ elseif ($command -eq "dependencies")
elseif ($command -eq "test") elseif ($command -eq "test")
{ {
echo "Testing mods..." echo "Testing mods..."
echo "OpenRA.Lint: checking Red Alert mod MiniYAML..." echo "Testing Red Alert mod MiniYAML..."
./OpenRA.Lint.exe --verbose ra ./OpenRA.Utility.exe ra --check-yaml
echo "OpenRA.Lint: checking Tiberian Dawn mod MiniYAML..." echo "Testing Tiberian Dawn mod MiniYAML..."
./OpenRA.Lint.exe --verbose cnc ./OpenRA.Utility.exe cnc --check-yaml
echo "OpenRA.Lint: checking Dune 2000 mod MiniYAML..." echo "Testing Dune 2000 mod MiniYAML..."
./OpenRA.Lint.exe --verbose d2k ./OpenRA.Utility.exe d2k --check-yaml
echo "OpenRA.Lint: checking Tiberian Sun mod MiniYAML..." echo "Testing Tiberian Sun mod MiniYAML..."
./OpenRA.Lint.exe --verbose ts ./OpenRA.Utility.exe ts --check-yaml
} }
else else
{ {