1
0
Fork 0

Port respack to lua

Simplifies the build system a little by cutting down on the number of
helpers that need to be built.
This commit is contained in:
Thomas Goyne 2014-05-08 08:22:03 -07:00
parent 9f8a10b014
commit d3a4bed994
14 changed files with 137 additions and 398 deletions

1
.gitignore vendored
View File

@ -71,7 +71,6 @@ svn-revision.h
svn_revision
tests/*.json
tests/run
tools/common-respack
tools/osx-bundle-restart-helper
tools/osx-bundle.sed
tools/repack-thes-dict

View File

@ -24,17 +24,10 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libresrc", "build\libresrc\libresrc.vcxproj", "{BD00D65F-24DA-4784-8860-3B972EA125FC}"
ProjectSection(ProjectDependencies) = postProject
{0518D6C0-7BF6-4FD1-91FB-191BD10DB2AC} = {0518D6C0-7BF6-4FD1-91FB-191BD10DB2AC}
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8} = {08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "luabins", "build\luabins\luabins.vcxproj", "{A7A30702-8162-4E1A-A010-EF51B590C121}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "respack", "build\respack\respack.vcxproj", "{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}"
ProjectSection(ProjectDependencies) = postProject
{FB8E8D19-A4D6-4181-943C-282075F49B41} = {FB8E8D19-A4D6-4181-943C-282075F49B41}
{F934AB7B-186B-4E96-B20C-A58C38C1B818} = {F934AB7B-186B-4E96-B20C-A58C38C1B818}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "universalchardet", "build\universalchardet\universalchardet.vcxproj", "{7B56955D-5162-4698-AA5B-47484EDC8783}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fftw", "build\fftw\fftw.vcxproj", "{EA3DCC95-2423-4EA0-A508-7A427B4C0594}"
@ -239,20 +232,6 @@ Global
{A7A30702-8162-4E1A-A010-EF51B590C121}.Release|x64.Build.0 = Release|x64
{A7A30702-8162-4E1A-A010-EF51B590C121}.Release-MinDep|Win32.ActiveCfg = Release|Win32
{A7A30702-8162-4E1A-A010-EF51B590C121}.Release-MinDep|x64.ActiveCfg = Release|x64
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Debug|Win32.ActiveCfg = Debug|Win32
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Debug|Win32.Build.0 = Debug|Win32
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Debug|x64.ActiveCfg = Debug|x64
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Debug|x64.Build.0 = Debug|x64
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Debug-MinDep|Win32.ActiveCfg = Debug|Win32
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Debug-MinDep|x64.ActiveCfg = Debug|Win32
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Debug-Tests|Win32.ActiveCfg = Debug|Win32
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Debug-Tests|x64.ActiveCfg = Debug|x64
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Release|Win32.ActiveCfg = Release|Win32
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Release|Win32.Build.0 = Release|Win32
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Release|x64.ActiveCfg = Release|x64
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Release|x64.Build.0 = Release|x64
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Release-MinDep|Win32.ActiveCfg = Release|Win32
{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}.Release-MinDep|x64.ActiveCfg = Release|x64
{7B56955D-5162-4698-AA5B-47484EDC8783}.Debug|Win32.ActiveCfg = Debug|Win32
{7B56955D-5162-4698-AA5B-47484EDC8783}.Debug|Win32.Build.0 = Debug|Win32
{7B56955D-5162-4698-AA5B-47484EDC8783}.Debug|x64.ActiveCfg = Debug|x64

View File

@ -8,7 +8,7 @@
<!-- Aegisub project configuration -->
<PropertyGroup Label="AegisubConfiguration">
<AegisubProjectType>lib</AegisubProjectType>
<SrcDir>..\..\src\libresrc\</SrcDir>
<SrcDir>$(MSBuildThisFileDirectory)..\..\src\libresrc\</SrcDir>
</PropertyGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(MSBuildThisFileDirectory)..\aegisub.props" />
@ -19,12 +19,9 @@
<ClCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ResPack>
<OutputDir>$(MSBuildThisFileDirectory)..\..\src\libresrc\</OutputDir>
</ResPack>
</ItemDefinitionGroup>
<ImportGroup Label="ExtensionTargets">
<Import Project="$(MSBuildThisFileDirectory)..\respack\Aegisub.ResPack.targets" />
<Import Project="$(MSBuildThisFileDirectory)..\respack.targets" />
</ImportGroup>
<Target Name="DefaultConfig" BeforeTargets="ResPackGenerate">
@ -37,20 +34,29 @@
<!-- Source files -->
<ItemGroup>
<ResPack Include="..\..\src\libresrc\manifest.respack">
<OutputName>default_config.cpp</OutputName>
<OutputHeader>default_config.h</OutputHeader>
<ResPack Include="$(SrcDir)manifest.respack">
<OutputName>default_config</OutputName>
<OutputDir>$(SrcDir)</OutputDir>
</ResPack>
<ResPack Include="..\..\src\bitmaps\manifest.respack">
<OutputName>bitmap.cpp</OutputName>
<OutputHeader>bitmap.h</OutputHeader>
<ResPack Include="$(SrcDir)..\bitmaps\manifest.respack">
<OutputName>bitmap</OutputName>
<OutputDir>$(SrcDir)</OutputDir>
</ResPack>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(SrcDir)libresrc.cpp" />
<ClCompile Include="$(SrcDir)bitmap.cpp" />
<ClCompile Include="$(SrcDir)default_config.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(SrcDir)libresrc.h" />
<ClInclude Include="$(SrcDir)bitmap.h" />
<ClInclude Include="$(SrcDir)default_config.h" />
</ItemGroup>
<ItemGroup>
<None Include="$(SrcDir)manifest.respack" />
<None Include="$(SrcDir)..\bitmaps\manifest.respack" />
<None Include="$(SrcDir)..\..\tools\respack.lua" />
</ItemGroup>
</Project>

View File

@ -14,22 +14,37 @@
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ResPack Include="..\..\src\libresrc\manifest.respack">
<Filter>Resource Files</Filter>
</ResPack>
<ResPack Include="..\..\src\bitmaps\manifest.respack">
<Filter>Resource Files</Filter>
</ResPack>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(SrcDir)libresrc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(SrcDir)bitmap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="$(SrcDir)default_config.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(SrcDir)libresrc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="$(SrcDir)bitmap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="$(SrcDir)default_config.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="$(SrcDir)..\..\tools\respack.lua">
<Filter>Resource Files</Filter>
</None>
<None Include="$(SrcDir)manifest.respack">
<Filter>Resource Files</Filter>
</None>
<None Include="$(SrcDir)..\bitmaps\manifest.respack">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>

27
build/respack.targets Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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>

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2011 Niels Martin Hansen
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Aegisub Group nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Aegisub Project http://www.aegisub.org/
$Id$
-->
<ProjectSchemaDefinitions
xmlns="http://schemas.microsoft.com/build/2009/properties">
<ContentType
Name="ResPackManifest"
DisplayName="ResPack manifest"
ItemType="ResPack">
</ContentType>
<ItemType Name="ResPack" DisplayName="Aegisub resource packer"/>
<FileExtension Name=".respack" ContentType="Text"/>
</ProjectSchemaDefinitions>

View File

@ -1,89 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2011 Niels Martin Hansen
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Aegisub Group nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Aegisub Project http://www.aegisub.org/
$Id$
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ResPackExe Condition="'$(ResPackExe)' == ''">$(AegisubBinaryDir)respack$(AegisubPlatformSuffix).exe</ResPackExe>
</PropertyGroup>
<Target
Name="ResPackGenerate"
BeforeTargets="ClCompile"
DependsOnTargets="PrepareForBuild"
Condition="'@(ResPack)' != ''"
Inputs="@(ResPack)"
Outputs="%(ResPack.OutputDir)%(ResPack.OutputName);%(ResPack.OutputDir)%(Respack.OutputHeader)"
>
<Error
Condition="!Exists('$(ResPackExe)')"
Text="The respack.exe program was not found, make sure it has been built and is at this location: $(ResPackExe)"
/>
<Exec
Command="$(ResPackExe) &quot;@(ResPack -> '%(FullPath)')&quot; &quot;%(ResPack.OutputDir)%(ResPack.OutputName)&quot; &quot;%(ResPack.OutputDir)%(ResPack.OutputHeader)&quot;"
Outputs="%(ResPack.OutputName);%(ResPack.OutputHeader)"
WorkingDirectory="@(ResPack -> '%(RootDir)%(Directory)')"
/>
</Target>
<Target
Name="ResPack"
BeforeTargets="ClCompile"
DependsOnTargets="ResPackGenerate"
Condition="'@(ResPack)' != ''"
Inputs="@(ResPack)"
Outputs="%(ResPack.OutputDir)%(ResPack.OutputName);%(ResPack.OutputDir)%(Respack.OutputHeader')"
>
<ItemGroup>
<ClCompile Include="%(ResPack.OutputDir)%(ResPack.OutputName)" />
</ItemGroup>
</Target>
<Target
Name="ResPackClean"
BeforeTargets="Clean"
DependsOnTargets="PrepareForBuild"
Condition="'@(ResPack)' != ''"
>
<Delete Files="%(ResPack.OutputDir)%(ResPack.OutputName);%(ResPack.OutputDir)%(ResPack.OutputHeader)" />
</Target>
<ItemGroup>
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Aegisub.ResPack.ProjectItems.xml" />
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)Aegisub.ResPack.xml" />
<ProjectTools Include="ResPack" />
<AvailableItemName Include="ResPack">
<Targets>ResPack</Targets>
</AvailableItemName>
</ItemGroup>
</Project>

View File

@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2011 Niels Martin Hansen
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Aegisub Group nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Aegisub Project http://www.aegisub.org/
$Id$
-->
<Rule Name="ResPack"
DisplayName="Aegisub resource packer"
Order="15"
PageTemplate="tool"
xmlns="http://schemas.microsoft.com/build/2009/properties">
<Rule.Categories>
<Category Name="General" DisplayName="General" Description="General" />
</Rule.Categories>
<Rule.DataSource>
<DataSource Persistence="ProjectFile" ItemType="ResPack" HasConfigurationCondition="false" />
</Rule.DataSource>
<StringProperty
Name="OutputDir"
Category="General"
DisplayName="Output directory"
Description="Directory the source and header files will be output to."
/>
<StringProperty
Name="OutputName"
Category="General"
DisplayName="Output source file"
Description="Name (without path) of source file produced from the resource manufest."
/>
<StringProperty
Name="OutputHeader"
Category="General"
DisplayName="Output header file"
Description="Name (without path) of header file produced from the resource manifest."
/>
</Rule>

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{08AF2BCC-FCDD-4F0E-8B41-59A6E634F2E8}</ProjectGuid>
<RootNamespace>respack</RootNamespace>
</PropertyGroup>
<!-- Aegisub project configuration -->
<PropertyGroup Label="AegisubConfiguration">
<AegisubProjectType>exe</AegisubProjectType>
</PropertyGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(MSBuildThisFileDirectory)..\aegisub.props" />
</ImportGroup>
<!-- Project specific configuration -->
<PropertyGroup>
<OutDir>$(ProjectDir)</OutDir>
<TargetName>respack$(AegisubPlatformSuffix)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(AegisubLibraryDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<!-- Source file -->
<ItemGroup>
<ClCompile Include="..\..\tools\common-respack.cpp" />
</ItemGroup>
</Project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="..\..\..\tools\common-respack.cpp" />
</ItemGroup>
</Project>

View File

@ -6,15 +6,15 @@ SRC += \
HEADER += \
libresrc/libresrc.h
libresrc/bitmap.cpp libresrc/bitmap.h: ../tools/common-respack bitmaps/button/*
../tools/common-respack bitmaps/manifest.respack libresrc/bitmap.cpp libresrc/bitmap.h
libresrc/bitmap.cpp libresrc/bitmap.h: ../tools/respack.lua bitmaps/button/*
../tools/respack.lua bitmaps/manifest.respack libresrc/bitmap.cpp libresrc/bitmap.h
ifeq (yes, $(BUILD_DARWIN))
libresrc/default_config.cpp libresrc/default_config.h: ../tools/common-respack libresrc/*.json libresrc/osx/*.json
../tools/common-respack libresrc/manifest_osx.respack libresrc/default_config.cpp libresrc/default_config.h
libresrc/default_config.cpp libresrc/default_config.h: ../tools/respack.lua libresrc/*.json libresrc/osx/*.json
../tools/respack.lua libresrc/manifest_osx.respack libresrc/default_config.cpp libresrc/default_config.h
else
libresrc/default_config.cpp libresrc/default_config.h: ../tools/common-respack libresrc/*.json
../tools/common-respack libresrc/manifest.respack libresrc/default_config.cpp libresrc/default_config.h
libresrc/default_config.cpp libresrc/default_config.h: ../tools/respack.lua libresrc/*.json
../tools/respack.lua libresrc/manifest.respack libresrc/default_config.cpp libresrc/default_config.h
endif
CLEANFILES += \

View File

@ -1,9 +1,5 @@
include ../Makefile.inc
PROGRAM = common-respack
SRC += common-respack.cpp
ifeq (yes, $(BUILD_DARWIN))
osx-bundle-restart-helper: osx-bundle-restart-helper.c
$(BIN_CC) -o osx-bundle-restart-helper osx-bundle-restart-helper.c

View File

@ -1,99 +0,0 @@
// Copyright (c) 2010, Amar Takhar <verm@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <iterator>
#include <fstream>
#include <iostream>
#include <string>
/// Clean a filename for use as an identity.
/// @param str[in] String containing filename.
void clean(std::string &str) {
// Chop extension
auto pos = str.rfind('.');
if (pos != std::string::npos)
str.erase(pos, str.size() - pos);
// Remove path
pos = str.rfind('/');
if (pos != std::string::npos)
str.erase(0, pos + 1);
}
int main(int argc, const char *argv[]) {
// Needs 3 arguments
if (argc != 4) {
std::cout << "Usage: <manifest>[in] <c++ file>[out] <header>[out]" << std::endl;
return 1;
}
std::cout << "Manifest: " << argv[1] << " CPP: " << argv[2] << " Header: " << argv[3] << std::endl;
std::ifstream file_manifest(argv[1]);
std::ofstream file_cpp(argv[2]);
std::ofstream file_h(argv[3]);
if (!file_manifest.good()) {
std::cout << "Failed to open manifest" << std::endl;
return 1;
}
if (!file_cpp.good()) {
std::cout << "Failed to open output CPP file" << std::endl;
return 1;
}
if (!file_h.good()) {
std::cout << "Failed to open output H file" << std::endl;
return 1;
}
// If the manifest has a path use that as the base for finding files.
std::string manifest(argv[1]);
std::string path_base;
std::string::size_type pos = manifest.rfind('/');
if (pos != std::string::npos) {
path_base = manifest.substr(0, pos+1);
}
file_cpp << "#include \"libresrc.h\"\n";
std::string file;
while (std::getline(file_manifest, file)) {
if (file.empty()) continue;
std::ifstream ifp((path_base + file).c_str(), std::ios_base::binary);
if (!ifp.is_open()) {
std::cout << "Error opening file: " << file << std::endl;
return 1;
}
clean(file);
file_cpp << "const unsigned char " << file << "[] = {";
size_t length = 0;
for (std::istreambuf_iterator<char> it(ifp), end; it != end; ++it) {
if (length > 0) file_cpp << ",";
file_cpp << (unsigned int)(unsigned char)*it;
++length;
}
file_cpp << "};\n";
file_h << "extern const unsigned char " << file << "[" << length << "];\n";
}
return 0;
}

64
tools/respack.lua Executable file
View File

@ -0,0 +1,64 @@
#!../vendor/luajit/src/host/minilua
-- Copyright (c) 2014, Thomas Goyne <plorkyeran@aegisub.org>
--
-- Permission to use, copy, modify, and distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--
-- Aegisub Project http://www.aegisub.org/
if not arg or #arg == 0 then arg = {...} end
if #arg ~= 3 then
io.stdout:write('Usage: <manifest>[in] <c++ file>[out] <header>[out]\n')
os.exit(1)
end
local function try_open(filename, mode)
local file, err = io.open(filename, mode)
if not file then
io.stdout:write(string.format('Failed to open "%s": %s\n', filename, err))
os.exit(1)
end
return file
end
io.stdout:write("Manifest: " .. arg[1] .. " CPP: " .. arg[2] .. " Header: " .. arg[3] .. '\n')
local manifest = try_open(arg[1], 'r')
local out_cpp = try_open(arg[2], 'w')
local out_h = try_open(arg[3], 'w')
local pos = arg[1]:find('/')
local path = pos and arg[1]:sub(1, pos) or ''
out_cpp:write('#include "libresrc.h"\n')
for line in manifest:lines() do
if line:find('.') then
local file = try_open(path..line, 'rb')
local id = line:gsub('^.*/', ''):gsub('\.[a-z]+$', '')
out_cpp:write("const unsigned char " .. id .. "[] = {")
local len = 0
while true do
local b = file:read(1)
if not b then break end
if len > 0 then out_cpp:write(',') end
out_cpp:write(string.format('%d', b:byte()))
len = len + 1
end
out_cpp:write('};\n')
out_h:write(string.format('extern const unsigned char %s[%d];\n', id, len))
file:close()
end
end