This commit is contained in:
Iain King-Speir
2024-08-04 08:19:13 +02:00
committed by GitHub
21 changed files with 805 additions and 79 deletions

View File

@@ -5,6 +5,28 @@ SET(EXECNAME "AerofoilX" CACHE STRING "Defines the exec name")
message(${CMAKE_BINARY_DIR})
# Use Release build type by default
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
message("Build type unspecified, using Release")
endif()
# Enable LTO by default if supported
if("${CMAKE_INTERPROCEDURAL_OPTIMIZATION}" STREQUAL "")
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
if(IPO_SUPPORTED)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION On)
message("Compiler supports LTO, enabling automatically")
endif()
endif()
# FIXME: Clang treats this as an error by default; fixing the source rather
# than downgrading the error to a warning would be a better solution.
add_compile_options(
$<$<COMPILE_LANG_AND_ID:CXX,AppleClang,Clang>:-Wno-error=c++11-narrowing>
)
find_package(SDL2 REQUIRED)
if(PLATFORM STREQUAL "MAC")
@@ -127,18 +149,18 @@ add_library(PortabilityLayer STATIC
)
target_include_directories(PortabilityLayer PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Common>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GpCommon>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/PortabilityLayer>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/zlib>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/MacRomanConversion>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/stb>
Common
GpCommon
PortabilityLayer
zlib
rapidjson/include
MacRomanConversion
stb
)
target_compile_options(PortabilityLayer PRIVATE -Wno-multichar)
target_link_libraries(PortabilityLayer zlib MacRomanConversion stb)
target_link_libraries(PortabilityLayer PRIVATE zlib MacRomanConversion stb)
add_library(GpShell STATIC
@@ -153,9 +175,9 @@ add_library(GpShell STATIC
)
target_include_directories(GpShell PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Common>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GpCommon>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/PortabilityLayer>
Common
GpCommon
PortabilityLayer
)
add_library(GpApp STATIC
@@ -233,16 +255,15 @@ add_library(GpApp STATIC
target_compile_options(GpApp PRIVATE -Wno-multichar)
target_include_directories(GpApp PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Common>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GpCommon>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/PortabilityLayer>
Common
GpCommon
PortabilityLayer
)
target_link_libraries(GpApp PortabilityLayer)
target_link_libraries(GpApp PRIVATE PortabilityLayer)
if(CMAKE_HOST_UNIX)
set(EXEC_SOURCES )
list(APPEND EXEC_SOURCES
set(EXEC_SOURCES
AerofoilPortable/GpSystemServices_POSIX.cpp
AerofoilPortable/GpThreadEvent_Cpp11.cpp
AerofoilPortable/GpAllocator_C.cpp
@@ -260,21 +281,20 @@ if(CMAKE_HOST_UNIX)
AerofoilX/GpFileSystem_X.cpp
)
set(EXEC_LIBS )
list(APPEND EXEC_LIBS
set(EXEC_LIBS
${SDL2_LIBRARIES}
GpApp
GpShell
PortabilityLayer
)
set(EXEC_INC_DIRS )
list(APPEND EXEC_INC_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Common>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GpCommon>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/GpShell>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/AerofoilSDL>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/AerofoilPortable>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/PortabilityLayer>
set(EXEC_INC_DIRS
Common
GpCommon
GpShell
AerofoilSDL
AerofoilPortable
PortabilityLayer
${SDL2_INCLUDE_DIRS}
)
if(PLATFORM STREQUAL "MAC")
@@ -283,7 +303,7 @@ if(CMAKE_HOST_UNIX)
AerofoilMac/AerofoilMac/MacInit.mm
)
list(APPEND EXEC_INC_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/AerofoilMac/AerofoilMac>
AerofoilMac/AerofoilMac
)
list(APPEND EXEC_LIBS
"-framework Cocoa"
@@ -296,4 +316,414 @@ if(CMAKE_HOST_UNIX)
endif()
install (TARGETS ${EXECNAME})
add_executable(flattenmov EXCLUDE_FROM_ALL flattenmov/flattenmov.cpp AerofoilPortable/GpAllocator_C.cpp)
target_include_directories(flattenmov PRIVATE
Common
GpCommon
PortabilityLayer
AerofoilPortable
)
target_link_libraries(flattenmov PortabilityLayer)
add_executable(bin2gp EXCLUDE_FROM_ALL bin2gp/bin2gp.cpp AerofoilPortable/GpAllocator_C.cpp)
target_include_directories(bin2gp PRIVATE
Common
GpCommon
PortabilityLayer
AerofoilPortable
)
target_link_libraries(bin2gp PortabilityLayer)
add_executable(hqx2bin EXCLUDE_FROM_ALL hqx2bin/hqx2bin.cpp AerofoilPortable/GpAllocator_C.cpp)
target_include_directories(hqx2bin PRIVATE
Common
GpCommon
PortabilityLayer
AerofoilPortable
)
target_link_libraries(hqx2bin PortabilityLayer)
add_executable(hqx2gp EXCLUDE_FROM_ALL hqx2gp/hqx2gp.cpp AerofoilPortable/GpAllocator_C.cpp)
target_include_directories(hqx2gp PRIVATE
Common
GpCommon
PortabilityLayer
AerofoilPortable
UnixCompat
)
target_link_libraries(hqx2gp PortabilityLayer)
add_executable(gpr2gpa EXCLUDE_FROM_ALL
gpr2gpa/gpr2gpa.cpp
gpr2gpa/macedec.cpp
AerofoilPortable/GpAllocator_C.cpp
UnixCompat/UnixCompat.cpp
)
target_include_directories(gpr2gpa PRIVATE
Common
GpCommon
PortabilityLayer
AerofoilPortable
MacRomanConversion
UnixCompat
rapidjson/include
zlib
)
target_link_libraries(gpr2gpa PortabilityLayer MacRomanConversion zlib)
add_executable(MakeTimestamp EXCLUDE_FROM_ALL MakeTimestamp/MakeTimestamp.cpp)
target_include_directories(MakeTimestamp PRIVATE PortabilityLayer UnixCompat)
target_link_libraries(MakeTimestamp PortabilityLayer)
add_executable(FTagData EXCLUDE_FROM_ALL FTagData/FTagData.cpp)
target_include_directories(FTagData PRIVATE
Common
GpCommon
PortabilityLayer
AerofoilPortable
UnixCompat
)
target_link_libraries(FTagData PortabilityLayer)
add_executable(MergeGPF EXCLUDE_FROM_ALL MergeGPF/MergeGPF.cpp AerofoilPortable/GpAllocator_C.cpp)
target_include_directories(MergeGPF PRIVATE
Common
GpCommon
PortabilityLayer
AerofoilPortable
UnixCompat
)
target_link_libraries(MergeGPF PortabilityLayer)
add_executable(MiniRez EXCLUDE_FROM_ALL MiniRez/MiniRez.cpp)
target_include_directories(MiniRez PRIVATE
Common
GpCommon
PortabilityLayer
UnixCompat
)
target_link_libraries(MiniRez PortabilityLayer)
add_executable(HouseTool EXCLUDE_FROM_ALL HouseTool/HouseTool.cpp)
target_include_directories(HouseTool PRIVATE
Common
GpCommon
PortabilityLayer
MacRomanConversion
UnixCompat
)
target_link_libraries(HouseTool PortabilityLayer MacRomanConversion)
add_executable(unpacktool EXCLUDE_FROM_ALL
unpacktool/ArchiveDescription.cpp
unpacktool/BWT.cpp
unpacktool/CompactProLZHDecompressor.cpp
unpacktool/CompactProLZHRLEDecompressor.cpp
unpacktool/CompactProParser.cpp
unpacktool/CompactProRLEDecompressor.cpp
unpacktool/CRC.cpp
unpacktool/CSInputBuffer.cpp
unpacktool/DecompressorProxyReader.cpp
unpacktool/LZSSDecompressor.cpp
unpacktool/LZW.cpp
unpacktool/LZWDecompressor.cpp
unpacktool/NullDecompressor.cpp
unpacktool/PrefixCode.cpp
unpacktool/RLE90Decompressor.cpp
unpacktool/StringCommon.cpp
unpacktool/StuffIt13Decompressor.cpp
unpacktool/StuffIt5Parser.cpp
unpacktool/StuffItArsenicDecompressor.cpp
unpacktool/StuffItCommon.cpp
unpacktool/StuffItHuffmanDecompressor.cpp
unpacktool/StuffItParser.cpp
unpacktool/unpacktool.cpp
)
target_include_directories(unpacktool PRIVATE
Common
GpCommon
PortabilityLayer
MacRomanConversion
UnixCompat
)
target_link_libraries(unpacktool PortabilityLayer MacRomanConversion)
find_package(Freetype)
if(FREETYPE_FOUND)
add_library(GpFontHandler_FreeType2 STATIC
GpFontHandler_FreeType2/GpFontHandler_FreeType2.cpp
)
target_include_directories(GpFontHandler_FreeType2 PRIVATE
Common
GpCommon
"${FREETYPE_INCLUDE_DIR_ft2build}"
)
target_link_libraries(GpFontHandler_FreeType2 PRIVATE Freetype::Freetype)
add_executable(GenerateFonts EXCLUDE_FROM_ALL GenerateFonts/GenerateFonts.cpp AerofoilPortable/GpAllocator_C.cpp)
target_include_directories(GenerateFonts PRIVATE
Common
GpCommon
PortabilityLayer
AerofoilPortable
UnixCompat
)
target_link_libraries(GenerateFonts PortabilityLayer GpFontHandler_FreeType2)
endif()
add_executable(ConvertColorCursors EXCLUDE_FROM_ALL
ConvertColorCursors/ConvertColorCursors.cpp
AerofoilPortable/GpAllocator_C.cpp
stb/stb_image_write.c
)
target_include_directories(ConvertColorCursors PRIVATE
Common
GpCommon
PortabilityLayer
AerofoilPortable
stb
UnixCompat
)
target_link_libraries(ConvertColorCursors PortabilityLayer)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Packaged/Houses")
set(DATA_FILES)
function(add_data_file NAME)
list(APPEND DATA_FILES "Packaged/${NAME}")
set(DATA_FILES "${DATA_FILES}" PARENT_SCOPE)
cmake_parse_arguments(PARSE_ARGV 1 ARG
""
""
"BYPRODUCTS;COMMANDS"
)
if(ARG_BYPRODUCTS)
set(RM_BYPRODUCTS_COMMAND COMMAND "${CMAKE_COMMAND}" -E rm)
set(RM_BYPRODUCTS_PATHS "${ARG_BYPRODUCTS}")
list(TRANSFORM RM_BYPRODUCTS_PATHS PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
endif()
add_custom_command(
OUTPUT "Packaged/${NAME}"
BYPRODUCTS ${ARG_BYPRODUCTS}
${ARG_COMMANDS}
${RM_BYPRODUCTS_COMMAND} ${RM_BYPRODUCTS_PATHS}
VERBATIM
)
endfunction()
add_data_file(ApplicationResources.gpf
BYPRODUCTS
Packaged/ApplicationResources.gpr
Packaged/ApplicationResources.gpa
COMMANDS
DEPENDS MiniRez gpr2gpa FTagData MergeGPF
COMMAND MiniRez
"GliderProData/Glider PRO.r"
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/ApplicationResources.gpr"
COMMAND gpr2gpa
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/ApplicationResources.gpr"
DefaultTimestamp.timestamp
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/ApplicationResources.gpa"
-patch ApplicationResourcePatches/manifest.json
COMMAND FTagData
DefaultTimestamp.timestamp
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/ApplicationResources.gpf"
data ozm5 0 0 locked
COMMAND MergeGPF
"${CMAKE_CURRENT_BINARY_DIR}/Packaged/ApplicationResources.gpf"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
add_data_file(Fonts.gpf
BYPRODUCTS
Packaged/Fonts.gpr
Packaged/Fonts.gpa
Packaged/FontCacheCatalog.bin
Packaged/FontCacheManifest.json
Packaged/CachedFont0.bin
Packaged/CachedFont1.bin
Packaged/CachedFont2.bin
Packaged/CachedFont3.bin
Packaged/CachedFont4.bin
Packaged/CachedFont5.bin
Packaged/CachedFont6.bin
Packaged/CachedFont7.bin
Packaged/CachedFont8.bin
Packaged/CachedFont9.bin
Packaged/CachedFont10.bin
Packaged/CachedFont11.bin
Packaged/CachedFont12.bin
Packaged/CachedFont13.bin
Packaged/CachedFont14.bin
COMMANDS
DEPENDS GenerateFonts MiniRez gpr2gpa FTagData MergeGPF
COMMAND GenerateFonts
"${CMAKE_SOURCE_DIR}/Resources"
Packaged
COMMAND MiniRez "${CMAKE_SOURCE_DIR}/Empty.r" Packaged/Fonts.gpr
COMMAND gpr2gpa
Packaged/Fonts.gpr
"${CMAKE_SOURCE_DIR}/DefaultTimestamp.timestamp"
Packaged/Fonts.gpa
-patch Packaged/FontCacheManifest.json
COMMAND FTagData
DefaultTimestamp.timestamp
Packaged/Fonts.gpf
data ozm5 0 0 locked
COMMAND MergeGPF Packaged/Fonts.gpf
)
# These files are committed to the repo and aren't currently useful on non-Windows systems anyway.
#file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Aerofoil/ConvertedResources)
#
#set(CONVERTED_ICONS
# Aerofoil/ConvertedResources/Large128.ico
# Aerofoil/ConvertedResources/Large129.ico
# Aerofoil/ConvertedResources/Large130.ico
# Aerofoil/ConvertedResources/Large131.ico
# Aerofoil/ConvertedResources/Large132.ico
# Aerofoil/ConvertedResources/Large133.ico
# Aerofoil/ConvertedResources/Small128.ico
# Aerofoil/ConvertedResources/Small129.ico
# Aerofoil/ConvertedResources/Small130.ico
# Aerofoil/ConvertedResources/Small133.ico
# )
#
#add_custom_command(
# OUTPUT ${CONVERTED_ICONS}
# COMMAND ConvertColorCursors
# )
set(HOUSE_FILES)
function(add_house NAME)
cmake_parse_arguments(PARSE_ARGV 0 ARG
""
PATCH
""
)
if(ARG_PATCH)
set(PATCH_ARGS -patch "${CMAKE_SOURCE_DIR}/HousePatches/${ARG_PATCH}")
endif()
set(BASE_PATH "Packaged/Houses/${NAME}")
list(APPEND HOUSE_FILES "${BASE_PATH}.gpf")
set(BYPRODUCTS "${BASE_PATH}.gpr" "${BASE_PATH}.gpa" "${BASE_PATH}.gpd")
add_custom_command(
OUTPUT
"${BASE_PATH}.gpf"
BYPRODUCTS
${BYPRODUCTS}
DEPENDS hqx2gp gpr2gpa MergeGPF
COMMAND hqx2gp
"${CMAKE_SOURCE_DIR}/GliderProData/Houses/${NAME}.binhex"
"${CMAKE_SOURCE_DIR}/DefaultTimestamp.timestamp"
"${BASE_PATH}"
COMMAND gpr2gpa
"${BASE_PATH}.gpr"
"${CMAKE_SOURCE_DIR}/DefaultTimestamp.timestamp"
"${BASE_PATH}.gpa"
${PATCH_ARGS}
${HOUSE_EXTRA_COMMANDS}
COMMAND MergeGPF
"${BASE_PATH}.gpf"
COMMAND "${CMAKE_COMMAND}" -E rm
${BYPRODUCTS}
VERBATIM
)
if(EXISTS "${CMAKE_SOURCE_DIR}/GliderProData/ConvertedMovies/${NAME}.mov.gpa")
list(APPEND HOUSE_FILES "${BASE_PATH}.mov.gpf")
add_custom_command(
OUTPUT
"${BASE_PATH}.mov.gpf"
BYPRODUCTS
"${BASE_PATH}.mov.gpa"
COMMAND FTagData
"${CMAKE_SOURCE_DIR}/DefaultTimestamp.timestamp"
"${BASE_PATH}.mov.gpf"
MooV ozm5 0 0 locked
COMMAND "${CMAKE_COMMAND}" -E copy
-t "Packaged/Houses"
"${CMAKE_SOURCE_DIR}/GliderProData/ConvertedMovies/${NAME}.mov.gpa"
COMMAND MergeGPF
"${BASE_PATH}.mov.gpf"
COMMAND "${CMAKE_COMMAND}" -E rm
"${BASE_PATH}.mov.gpa"
VERBATIM
)
endif()
set(HOUSE_FILES "${HOUSE_FILES}" PARENT_SCOPE)
endfunction()
add_house("Art Museum")
add_house("California or Bust!")
set(HOUSE_EXTRA_COMMANDS
DEPENDS HouseTool
COMMAND HouseTool
patch "Packaged/Houses/Castle o' the Air.gpd" .firstRoom 77
)
add_house("Castle o' the Air")
unset(HOUSE_EXTRA_COMMANDS)
add_house("CD Demo House")
add_house("Davis Station")
add_house("Demo House")
add_house("Fun House")
add_house("Grand Prix" PATCH "GrandPrix.json")
add_house("ImagineHouse PRO II" PATCH "ImagineHousePROII.json")
add_house("In The Mirror" PATCH "InTheMirror.json")
add_house("Land of Illusion")
add_house("Leviathan" PATCH "Leviathan.json")
add_house("Metropolis")
add_house("Nemo's Market")
add_house("Rainbow's End" PATCH "RainbowsEnd.json")
add_house("Slumberland")
add_house("SpacePods")
add_house("Teddy World")
add_house("The Asylum Pro")
add_house("Titanic")
add_custom_target(Executable DEPENDS "${EXECNAME}")
add_custom_target(Resources ALL
DEPENDS
${DATA_FILES}
${HOUSE_FILES}
)
set(TOOL_EXES
flattenmov
bin2gp
hqx2bin
hqx2gp
MakeTimestamp
FTagData
gpr2gpa
unpacktool
MergeGPF
)
add_custom_target(Tools ALL DEPENDS ${TOOL_EXES})
list(TRANSFORM DATA_FILES PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
list(TRANSFORM HOUSE_FILES PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(TARGETS "${EXECNAME}" COMPONENT Executable)
install(FILES ${DATA_FILES} DESTINATION lib/aerofoil/Packaged COMPONENT Resources)
install(FILES ${HOUSE_FILES} DESTINATION lib/aerofoil/Packaged/Houses COMPONENT Resources)
install(TARGETS ${TOOL_EXES} DESTINATION lib/aerofoil/tools COMPONENT Tools)

View File

@@ -10,6 +10,10 @@
#include "PLDrivers.h"
#include <assert.h>
#ifndef _WIN32
#include "UnixCompat.h"
#endif
#include <string>
#include <vector>
@@ -93,7 +97,7 @@ void ConvertIconFamily(PortabilityLayer::ResourceFile *resFile, int32_t iconBitm
}
char outPath[256];
sprintf_s(outPath, "Aerofoil\\ConvertedResources\\%s%i.ico", prefix, resID);
sprintf_s(outPath, "Aerofoil/ConvertedResources/%s%i.ico", prefix, resID);
FILE *outF = nullptr;
errno_t outErr = fopen_s(&outF, outPath, "wb");
@@ -137,7 +141,7 @@ void ConvertIconFamily(PortabilityLayer::ResourceFile *resFile, int32_t iconBitm
int main(int argc, const char **argv)
{
FILE *f = nullptr;
errno_t err = fopen_s(&f, "Packaged\\ApplicationResources.gpr", "rb");
errno_t err = fopen_s(&f, "Packaged/ApplicationResources.gpr", "rb");
if (err)
return err;

View File

@@ -8,7 +8,7 @@ x64\Release\gpr2gpa.exe "Packaged\ApplicationResources.gpr" "DefaultTimestamp.ti
x64\Release\FTagData.exe "DefaultTimestamp.timestamp" "Packaged\ApplicationResources.gpf" data ozm5 0 0 locked
x64\Release\MergeGPF.exe "Packaged\ApplicationResources.gpf"
x64\Release\GenerateFonts.exe
x64\Release\GenerateFonts.exe Resources Packaged
x64\Release\MiniRez.exe "Empty.r" Packaged\Fonts.gpr
x64\Release\gpr2gpa.exe "Packaged\Fonts.gpr" "DefaultTimestamp.timestamp" "Packaged\Fonts.gpa" -patch "Packaged\FontCacheManifest.json"

View File

@@ -1,11 +1,17 @@
#include <stdio.h>
#include <string>
#include <Windows.h>
#include "MacFileInfo.h"
#include "CFileStream.h"
#include "CombinedTimestamp.h"
#ifdef _WIN32
#include <Windows.h>
#include "WindowsUnicodeToolShim.h"
#else
#include "UnixCompat.h"
#endif
int toolMain(int argc, const char **argv)
{

View File

@@ -1,3 +1,7 @@
#include <algorithm>
#include <string>
#include <vector>
#include "FontFamily.h"
#include "FontManager.h"
#include "FontRenderer.h"
@@ -7,17 +11,25 @@
#include "GpAppInterface.h"
#include "GpDriverIndex.h"
#include "GpFontHandlerProperties.h"
#include "GpFileSystem_Win32.h"
#include "GpSystemServices_Win32.h"
#include "CFileStream.h"
#include "PLDrivers.h"
#include "RenderedFont.h"
#include "RenderedFontCatalog.h"
#ifdef _WIN32
#include "WindowsUnicodeToolShim.h"
#include "GpFileSystem_Win32.h"
#include "GpSystemServices_Win32.h"
#else
#include "UnixCompat.h"
#endif
extern "C" __declspec(dllimport) IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties);
extern "C"
#ifdef _MSC_VER
__declspec(dllimport)
#endif
IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties);
class MemBufferStream final : public GpIOStream
{
@@ -168,6 +180,16 @@ bool KnownFontSpec::operator!=(const KnownFontSpec &other) const
int toolMain(int argc, const char **argv)
{
if (argc < 3)
{
fputs("Usage: GenerateFonts <resources dir> <output dir>\n", stderr);
return -1;
}
std::string resourcesDir(argv[1]);
resourcesDir += '/';
std::string outputDir(argv[2]);
outputDir += '/';
IGpAllocator *alloc = GpAllocator_C::GetInstance();
GpFontHandlerProperties fhProperties;
@@ -187,12 +209,13 @@ int toolMain(int argc, const char **argv)
std::vector<PortabilityLayer::RenderedFontCatalogRFontEntry> catalog;
std::vector<KnownFontSpec> fontSpecs;
FILE *manifestF = fopen_utf8("Packaged/FontCacheManifest.json", "wb");
std::string tmpPath(outputDir + "FontCacheManifest.json");
FILE *manifestF = fopen_utf8(tmpPath.c_str(), "wb");
fprintf(manifestF, "{\n");
fprintf(manifestF, "\t\"add\" :\n");
fprintf(manifestF, "\t{\n");
fprintf(manifestF, "\t\t\"RFCT/1000.bin\" : \"Packaged/FontCacheCatalog.bin\"");
fprintf(manifestF, "\t\t\"RFCT/1000.bin\" : \"%sFontCacheCatalog.bin\"", outputDir.c_str());
int numFontsEmitted = 0;
for (int presetIndex = 0; presetIndex < PortabilityLayer::FontPresets::kCount; presetIndex++)
@@ -220,8 +243,9 @@ int toolMain(int argc, const char **argv)
fontSpecs.push_back(spec);
std::string resPath = std::string("Resources/") + path;
FILE *fontFile = fopen_utf8(resPath.c_str(), "rb");
tmpPath = resourcesDir;
tmpPath += path;
FILE *fontFile = fopen_utf8(tmpPath.c_str(), "rb");
if (fontFile)
{
@@ -236,7 +260,7 @@ int toolMain(int argc, const char **argv)
{
char fontPath[1024];
sprintf(fontPath, "Packaged/CachedFont%i.bin", numFontsEmitted);
sprintf(fontPath, "%sCachedFont%i.bin", outputDir.c_str(), numFontsEmitted);
FILE *cachedFontF = fopen_utf8(fontPath, "wb");
PortabilityLayer::CFileStream cacheStream(cachedFontF);
@@ -290,7 +314,9 @@ int toolMain(int argc, const char **argv)
PortabilityLayer::RenderedFontCatalogHeader catHeader;
FILE *catF = fopen_utf8("Packaged/FontCacheCatalog.bin", "wb");
tmpPath = outputDir;
tmpPath += "FontCacheCatalog.bin";
FILE *catF = fopen_utf8(tmpPath.c_str(), "wb");
catHeader.m_version = PortabilityLayer::RenderedFontCatalogHeader::kVersion;
catHeader.m_pathsOffset = static_cast<uint32_t>(sizeof(PortabilityLayer::RenderedFontCatalogHeader) + paths.size() * sizeof(PortabilityLayer::RenderedFontCatalogPathEntry) + numFontsEmitted * sizeof(PortabilityLayer::RenderedFontCatalogRFontEntry));

View File

@@ -1,5 +1,6 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
struct GpRenderedGlyphMetrics

View File

@@ -3,10 +3,15 @@
#include "PLBigEndian.h"
#include "MacRomanConversion.h"
#include "GpUnicode.h"
#include "WindowsUnicodeToolShim.h"
#include <vector>
#ifdef _WIN32
#include "WindowsUnicodeToolShim.h"
#else
#include "UnixCompat.h"
#endif
typedef uint8_t Boolean;
#define kMaxScores 10

View File

@@ -1,18 +1,49 @@
Linux support is IN ALPHA and may or may not work. Only Cygwin has been
tested so far.
Linux support is IN ALPHA and may or may not work.
You can attempt the following:
- Install CMake (https://cmake.org/download/)
- Install SDL 2.0.12 or higher, or build it from the included source
- Run "cmake ." in the Aerofoil source directory
- Run "make install" to build the AerofoilX program
- Unzip the the Windows build
- Copy the "Packaged" and "Resources" directories from the Windows build into
the "lib" folder above the "bin" folder that the AerofoilX program installed
to. For example, if it installed to /usr/local/bin/, then the data files
should go in /usr/local/lib/aerofoil/
- Run AerofoilX
Use these basic steps to build and install Aerofoil:
- Ensure dependencies are installed - all of these are likely available from
your distribution's package manager:
- CMake 3.10 or later (https://cmake.org/download/)
- SDL 2.0.12 or later (https://libsdl.org)
- FreeType 2.10.1 or later (https://freetype.org/download.html)
- Change directory to the Aerofoil source root (the directory containing this file)
- Run "cmake -B build" to create a CMake build tree under "build"
- Run "cmake --build build" to build the AerofoilX program and its resources
- Run "cmake --install build" to install everything under /usr/local
- You can now run Aerofoil with the command "AerofoilX"
You can also build just the AerofoilX executable and use the prebuilt resources
from the Windows release:
- Follow the steps above, ignoring the FreeType dependency and stopping after
running "cmake -B build"
- Run "cmake --build build --target Executable" to build only the executable
- Run "cmake --install build --component Executable" to install AerofoilX in
/usr/local/bin
- Download the Windows build from
https://github.com/elasota/Aerofoil/releases/latest and unzip it
- Create the directory /usr/local/lib/aerofoil and copy the "Packaged"
directory from the Windows build into it
To install under a prefix other than /usr/local add
"-DCMAKE_INSTALL_PREFIX=<prefix>" to "cmake -B build"
Tools for converting Glider PRO houses are installed under
/usr/local/lib/aerofoil/tools, see Documentation/userhouses.txt for
instructions on how to use them.
The main AerofoilX executable, its required resources and the conversion tools
can be built and installed individually via these build targets and install
components:
- Executable
- Resources
- Tools
For instance, you can use
cmake --build build --target Executable Resources
to build only Aerofoil and its resources, and
cmake --install build --component Executable
cmake --install build --component Resources
to install them.
Please report any issues that you experience with this to the issue tracker on
GitHub.

View File

@@ -1,6 +1,16 @@
#ifdef _WIN32
#include <Windows.h>
#include <stdio.h>
#include <stdint.h>
#else
#include <string.h>
#include <time.h>
#include "UnixCompat.h"
#endif
#include <stdio.h>
#include "CombinedTimestamp.h"
@@ -13,6 +23,7 @@ int main(int argc, const char **argv)
return -1;
}
#ifdef _WIN32
SYSTEMTIME epochStart;
epochStart.wYear = 1904;
epochStart.wMonth = 1;
@@ -34,13 +45,6 @@ int main(int argc, const char **argv)
int64_t currentTime64 = (static_cast<int64_t>(timestampFT.dwLowDateTime) & 0xffffffff) | (static_cast<int64_t>(timestampFT.dwHighDateTime) << 32);
int64_t timeDelta = (currentTime64 - epochStart64) / 10000000;
FILE *f = nullptr;
if (fopen_s(&f, argv[1], "wb"))
{
fprintf(stderr, "Error opening output file");
return -1;
}
TIME_ZONE_INFORMATION tz;
GetTimeZoneInformation(&tz);
@@ -60,9 +64,36 @@ int main(int argc, const char **argv)
ts.m_localHour = localST.wHour;
ts.m_localMinute = localST.wMinute;
ts.m_localSecond = localST.wSecond;
#else
time_t currentTimeUnix = time(nullptr);
tm *currentTimeStruct = localtime(&currentTimeUnix);
if (currentTimeStruct == nullptr) {
fprintf(stderr, "Error converting system time to calendar format");
return -1;
}
PortabilityLayer::CombinedTimestamp ts;
ts.SetMacEpochTime(currentTimeUnix + ts.kMacEpochToUTC);
ts.SetLocalYear(currentTimeStruct->tm_year + 1900);
ts.m_localMonth = currentTimeStruct->tm_mon;
ts.m_localDay = currentTimeStruct->tm_mday;
ts.m_localHour = currentTimeStruct->tm_hour;
ts.m_localMinute = currentTimeStruct->tm_min;
ts.m_localSecond = currentTimeStruct->tm_sec;
#endif
memset(ts.m_padding, 0, sizeof(ts.m_padding));
FILE *f;
if (fopen_s(&f, argv[1], "wb"))
{
fprintf(stderr, "Error opening output file");
return -1;
}
fwrite(&ts, sizeof(ts), 1, f);
fclose(f);

View File

@@ -1,4 +1,8 @@
#ifdef _WIN32
#include "WindowsUnicodeToolShim.h"
#else
#include "UnixCompat.h"
#endif
#include "CFileStream.h"
#include "CombinedTimestamp.h"

View File

@@ -1,3 +1,4 @@
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
@@ -9,7 +10,12 @@
#include "MacBinary2.h"
#include "MacFileMem.h"
#ifdef _WIN32
#include "WindowsUnicodeToolShim.h"
#else
#include "UnixCompat.h"
#endif
// Very simplified resource compiler

58
UnixCompat/UnixCompat.cpp Normal file
View File

@@ -0,0 +1,58 @@
#include <cstring>
#include <string>
#include <vector>
#include <dirent.h>
void ScanDirectoryForExtension
(
std::vector<std::string> &outPaths,
const char *path,
const char *ending,
bool recursive
) {
DIR *dir = opendir(path);
if (!dir)
{
return;
}
size_t endingLen = strlen(ending);
dirent *ent;
while ((ent = readdir(dir)))
{
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
continue;
else if (recursive && ent->d_type == DT_DIR)
{
std::string tmpPath(path);
tmpPath.append("/");
tmpPath.append(ent->d_name);
ScanDirectoryForExtension(
outPaths,
tmpPath.c_str(),
ending,
recursive
);
}
else
{
size_t nameLen = strlen(ent->d_name);
if (endingLen <= nameLen && memcmp
(
ent->d_name + nameLen - endingLen,
ending,
endingLen
) == 0
) {
std::string tmpPath(path);
tmpPath.append("/");
tmpPath.append(ent->d_name);
outPaths.push_back(std::move(tmpPath));
}
}
}
closedir(dir);
}

100
UnixCompat/UnixCompat.h Normal file
View File

@@ -0,0 +1,100 @@
#pragma once
// This header provides POSIX-compatible versions of some functions from
// WindowsUnicodeToolShim and the Windows API.
#include <cstdio>
#include <cstdarg>
#include <string>
#include <vector>
#include <sys/stat.h>
// Linux and macOS (and probably other non-Windows systems in general) do not
// have separate file system or command line APIs for different text encodings.
// On these systems UTF-8 is commonly the system encoding and, if so, argv will
// typically be UTF-8 encoded, though it is the calling process's responsibility
// to ensure this, as argv is passed verbatim as a sequence of byte strings.
//
// Filesystems on Unix-like systems are typically encoding-unaware, in which
// case the actual encoding used should match the system encoding, or else
// manual intervention is required.
//
// On macOS, HFS+ and APFS filenames are encoded as UTF-16 and UTF-8
// respectively, and the C filesystem API accepts UTF-8 strings. There are some
// gotchas relating to Unicode normalization, where HFS+ enforces a specific
// form of normalization at the filesystem layer but APFS does not, and using
// the C API to access the filesystem may avoid automatic normalization that
// higher-level macOS API functions may perform.
//
// In summary, text encoding is still a hairy problem on every computer system,
// though on the major non-Windows systems, assuming UTF-8 encoding is
// reasonable. For now, this header simply maps the WindowsUnicodeToolShim
// functions to their regular C API counterparts.
#define toolMain main
#define fopen_utf8 fopen
#define fputs_utf8 fputs
typedef int errno_t;
inline int mkdir_utf8(const char *path)
{
return mkdir(path, 0777);
}
// These use long as the offset type, which is 64 bits on 64-bit Linux and macOS
// systems, so explicitly 64-bit variants aren't necessary. 32-bit systems are
// likely to have a 32-bit long type, but we aren't likely to deal with
// multi-gigabyte files, are we?
#define _fseeki64 fseek
#define _ftelli64 ftell
// On Windows this is supposed to call an error handler if the buffer is too
// small. I don't think this is likely to happen in Aerofoil's case, but if it
// does, this function will crash the program as a precaution.
template <size_t size> int sprintf_s
(
char (&buffer)[size],
const char *format,
...
) {
va_list ap;
va_start(ap, format);
int count = vsnprintf(buffer, size, format, ap);
va_end(ap);
if (count >= size)
exit(1);
return count;
}
inline errno_t fopen_s(FILE **pFile, const char *name, const char *mode)
{
FILE *f = fopen(name, mode);
if (!f)
{
// Error codes might not match those from Windows, but all are
// non-zero, so *detecting* an error will work fine.
return errno;
}
*pFile = f;
return 0;
}
inline void TerminateDirectoryPath(std::string &path)
{
const size_t length = path.length();
if (length == 0 || path[length - 1] != '/')
path.push_back('/');
}
void ScanDirectoryForExtension
(
std::vector<std::string> &outPaths,
const char *path,
const char *ending,
bool recursive
);

View File

@@ -24,8 +24,6 @@
#include "rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "WindowsUnicodeToolShim.h"
#include "macedec.h"
#include <stdio.h>
@@ -33,7 +31,13 @@
#include <sstream>
#include <vector>
#include <algorithm>
#ifdef _WIN32
#include "WindowsUnicodeToolShim.h"
#include "GpWindows.h"
#else
#include "UnixCompat.h"
#endif
enum AudioCompressionCodecID
{
@@ -98,6 +102,11 @@ void AppendFmt(std::vector<uint8_t> &array, const char *fmt, ...)
if (resultSize <= 0)
return;
// vsnprintf invalidates the va_list, so we need to
// reinit args so the next call doesn't print garbage.
va_end(args);
va_start(args, fmt);
size_t appendSize = static_cast<size_t>(resultSize);
if (SIZE_MAX == appendSize)
@@ -1466,7 +1475,7 @@ bool DecompressSound(int compressionID, int channelCount, const void *sndData, s
}
}
}
else if (compressionID = AudioCompressionCodecID_SixToOne)
else if (compressionID == AudioCompressionCodecID_SixToOne)
{
if (channelCount != 1)
{

View File

@@ -31,7 +31,12 @@ SOFTWARE.
#include "MacBinary2.h"
#include "MacFileMem.h"
#include "ZipFile.h"
#ifdef _WIN32
#include "WindowsUnicodeToolShim.h"
#else
#include "UnixCompat.h"
#endif
#include <string>

View File

@@ -1,5 +1,7 @@
#pragma once
#include <stdint.h>
#include "IDecompressor.h"
class CompactProRLEDecompressor : public IDecompressor

View File

@@ -1,6 +1,6 @@
#pragma once
#include <stdint.h>
#include <stddef.h>
struct CSInputBuffer;

View File

@@ -1,5 +1,6 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
struct IFileReader

View File

@@ -1,3 +1,5 @@
#include <limits.h>
#include "PrefixCode.h"
struct XADCodeTreeNode

View File

@@ -1,5 +1,7 @@
#pragma once
#include <stdint.h>
#include "IDecompressor.h"
class RLE90Decompressor : public IDecompressor

View File

@@ -1,4 +1,17 @@
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#ifdef _WIN32
#include <Windows.h>
#include <shellapi.h>
#include "WindowsUnicodeToolShim.h"
#else
#include "UnixCompat.h"
#endif
#include "IArchiveParser.h"
#include "IFileReader.h"
@@ -22,18 +35,8 @@
#include "CompactProLZHRLEDecompressor.h"
#include "CSInputBuffer.h"
#include "WindowsUnicodeToolShim.h"
#include "CombinedTimestamp.h"
#include <string.h>
#include <Windows.h>
#include <shellapi.h>
#include <string>
#include <vector>
class CFileReader final : public IFileReader
{
public:
@@ -387,7 +390,7 @@ int ExtractItem(int depth, const ArchiveItem &item, const std::string &dirPath,
{
mkdir_utf8(path.c_str());
path.append("\\");
path.append("/");
int returnCode = RecursiveExtractFiles(depth + 1, item.m_children, path, pathParanoid, reader, ts);
if (returnCode)