<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <MiniLuaCommand>$(AegisubBinaryDir)luajit-minilua$(AegisubPlatformSuffix)</MiniLuaCommand>
    <ResPackCommand>$(AegisubSourceBase)tools\respack.lua</ResPackCommand>
  </PropertyGroup>

  <Target
    Name="ResPackGenerate"
    BeforeTargets="ClCompile"
    Inputs="@(ResPack)"
    Outputs="%(ResPack.OutputDir)%(ResPack.OutputName).cpp;%(ResPack.OutputDir)%(ResPack.OutputName).h"
    >
    <Exec
      Command="$(MiniLuaCommand) $(ResPackCommand) &quot;@(ResPack -> '%(FullPath)')&quot; &quot;%(ResPack.OutputDir)%(ResPack.OutputName).cpp&quot; &quot;%(ResPack.OutputDir)%(ResPack.OutputName).h&quot;"
      WorkingDirectory="@(ResPack -> '%(RootDir)%(Directory)')"
      />
  </Target>

  <Target
    Name="ResPackClean"
    BeforeTargets="Clean"
    DependsOnTargets="PrepareForBuild"
    >
    <Delete Files="%(ResPack.OutputDir)%(ResPack.OutputName).cpp;%(ResPack.OutputDir)%(ResPack.OutputName).h" />
  </Target>
</Project>