diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f1d51d61e..354139be80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ project(${PROJECT}) add_definitions(-DORCT2_RESOURCE_DIR="${ORCT2_RESOURCE_DIR}") add_definitions(-DHAVE_CONFIG_H) add_definitions(-DCURL_STATICLIB) +add_definitions(-DUSE_LIBPNG) INCLUDE(FindPkgConfig) @@ -48,16 +49,9 @@ option(STATIC "Create a static build.") # Not required yet PKG_CHECK_MODULES(PNG libpng>=1.6) if (NOT PNG_FOUND) - PKG_CHECK_MODULES(PNG libpng16) + PKG_CHECK_MODULES(PNG REQUIRED libpng16) endif (NOT PNG_FOUND) -if (PNG_FOUND) - set (USE_LODEPNG FALSE) -else (PNG_FOUND) - set (USE_LODEPNG TRUE) - message("Falling back to deprecated Lodepng for PNG support. Please upgrade your system to libpng 1.6") -endif (PNG_FOUND) - # Handle creating the rct2 text and data files on OS X and Linux # See details in src/openrct2.c:openrct2_setup_rct2_segment for how the values # were derived. @@ -109,16 +103,10 @@ set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG=${DEBUG_LEVEL}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}") -if (USE_LODEPNG) - set (LODEPNG_SOURCES "lib/lodepng/*.c") -else (USE_LODEPNG) - add_definitions(-DUSE_LIBPNG) -endif (USE_LODEPNG) - # include lib include_directories("lib/") # add source files -file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "lib/argparse/*.c" "lib/cutest/*.c" ${LODEPNG_SOURCES}) +file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp") if (APPLE) file(GLOB_RECURSE ORCT2_MM_SOURCES "src/*.m") set_source_files_properties(${ORCT2_MM_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c -fmodules") @@ -225,7 +213,7 @@ endif (UNIX AND NOT APPLE) # libopenrct2.dll -> openrct2.dll set_target_properties(${PROJECT} PROPERTIES PREFIX "") -TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2LIBS} ${ORCTLIBS_LIB} ${HTTPLIBS} ${NETWORKLIBS} ${SPEEX_LIBRARIES} ${DLLIB} ${PNGLIBS}) +TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2LIBS} ${HTTPLIBS} ${NETWORKLIBS} ${SPEEX_LIBRARIES} ${DLLIB} ${PNGLIBS}) if (APPLE OR STATIC) FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c) diff --git a/distribution/windows/install.nsi b/distribution/windows/install.nsi index c0455e61a9..8b8917aef3 100644 --- a/distribution/windows/install.nsi +++ b/distribution/windows/install.nsi @@ -141,7 +141,6 @@ Section "!OpenRCT2" Section1 ; Copy executable File /oname=openrct2.exe ${BINARY_DIR}\openrct2.exe File /oname=openrct2.dll ${BINARY_DIR}\openrct2.dll - File /oname=SDL2.dll ${BINARY_DIR}\SDL2.dll ; Create the Registry Entries WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenRCT2" "Comments" "Visit ${APPURLLINK}" @@ -207,7 +206,6 @@ Section "Uninstall" Delete "$INSTDIR\contributors.md" Delete "$INSTDIR\openrct2.exe" Delete "$INSTDIR\openrct2.dll" - Delete "$INSTDIR\SDL2.dll" Delete "$INSTDIR\licence.txt" Delete "$INSTDIR\INSTALL.LOG" Delete "$INSTDIR\crash.log" diff --git a/libs.vcxproj b/libs.vcxproj deleted file mode 100644 index 0148b48b6e..0000000000 --- a/libs.vcxproj +++ /dev/null @@ -1,219 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Release XP - Win32 - - - Release with Tests - Win32 - - - - {074DC930-05C6-4B7F-B5DD-DD237E6E44DB} - libs - - - - StaticLibrary - true - v140 - MultiByte - - - StaticLibrary - false - v140 - true - MultiByte - - - StaticLibrary - false - v140_xp - true - MultiByte - - - StaticLibrary - false - v140 - true - MultiByte - - - - - - - - - - - - - - - - - - - $(SolutionDir)bin\ - $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ - lib\libcurl\include;lib\jansson;lib\cutest\CuTest.h;lib\SDL2_ttf\include;$(IncludePath) - lib\libcurl\lib;lib\SDL2_ttf\lib\x86;$(LibraryPath) - - - $(SolutionDir)bin\ - $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ - lib\libcurl\include;lib\jansson;lib\cutest\CuTest.h;lib\SDL2_ttf\include;$(IncludePath) - lib\libcurl\lib;lib\SDL2_ttf\lib\x86;$(LibraryPath) - - - $(SolutionDir)bin\ - $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ - lib\libcurl\include;lib\jansson;lib\cutest\CuTest.h;lib\SDL2_ttf\include;$(IncludePath) - lib\libcurl\lib;lib\SDL2_ttf\lib\x86;$(LibraryPath) - - - $(SolutionDir)bin\ - $(SolutionDir)obj\$(ProjectName)\Release\ - lib\libcurl\include;lib\jansson;lib\cutest\CuTest.h;lib\SDL2_ttf\include;$(IncludePath) - lib\libcurl\lib;lib\SDL2_ttf\lib\x86;$(LibraryPath) - - - - Level3 - Disabled - true - MultiThreaded - 1Byte - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;NS_ENABLE_THREADS;NS_ENABLE_SSL;DISABLE_MD5;%(PreprocessorDefinitions) - - - true - - - libcurl.lib;Ws2_32.lib;SDL2_ttf.lib;%(AdditionalDependencies) - true - - - - - Level3 - MaxSpeed - true - true - true - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;NS_ENABLE_THREADS;NS_ENABLE_SSL;DISABLE_MD5;%(PreprocessorDefinitions) - MultiThreaded - 1Byte - - - - - true - true - true - - - libcurl.lib;Ws2_32.lib;SDL2_ttf.lib;%(AdditionalDependencies) - - - - - Level3 - MaxSpeed - true - true - true - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;NS_ENABLE_THREADS;NS_ENABLE_SSL;DISABLE_MD5;%(PreprocessorDefinitions) - MultiThreaded - 1Byte - - - - - true - true - true - - - libcurl.lib;Ws2_32.lib;SDL2_ttf.lib;%(AdditionalDependencies) - - - - - Level3 - MaxSpeed - true - true - true - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;NS_ENABLE_THREADS;NS_ENABLE_SSL;DISABLE_MD5;%(PreprocessorDefinitions) - MultiThreaded - 1Byte - - - - - true - true - true - - - libcurl.lib;Ws2_32.lib;SDL2_ttf.lib;%(AdditionalDependencies) - - - - - TurnOffAllWarnings - - - - - - - - - - - - - - - TurnOffAllWarnings - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/libs.vcxproj.filters b/libs.vcxproj.filters deleted file mode 100644 index cfa41aa854..0000000000 --- a/libs.vcxproj.filters +++ /dev/null @@ -1,124 +0,0 @@ - - - - - {f28d7721-061f-44b8-bbd5-42dc9483b387} - - - {69f22202-b887-4e7c-bf7c-eb581571398d} - - - {45966214-8043-431c-8eb3-920c00bf749d} - - - {7f953e55-d294-4158-b309-67f41fa82760} - - - {7b46a2d6-1095-4e7a-b98b-006b832ef7a1} - - - {16ee6cb9-307a-4e8a-8261-a69d91b17739} - - - {92e56bd7-37be-465c-9212-3b6cfb8cf7c9} - - - - - argparse - - - libspeex - - - lodepng - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - cutest - - - - - argparse - - - libspeex - - - libspeex - - - libspeex - - - libspeex - - - libspeex\speex - - - libspeex\speex - - - lodepng - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - jansson - - - - \ No newline at end of file diff --git a/libs.vcxproj.user b/libs.vcxproj.user deleted file mode 100644 index a11cd7f915..0000000000 --- a/libs.vcxproj.user +++ /dev/null @@ -1,6 +0,0 @@ - - - - true - - \ No newline at end of file diff --git a/openrct2.sln b/openrct2.sln index b3adc8b5f0..e92027ef3a 100644 --- a/openrct2.sln +++ b/openrct2.sln @@ -5,32 +5,16 @@ VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2", "openrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libs", "libs.vcxproj", "{074DC930-05C6-4B7F-B5DD-DD237E6E44DB}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 - Release with Tests|Win32 = Release with Tests|Win32 - Release XP|Win32 = Release XP|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.ActiveCfg = Debug|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Debug|Win32.Build.0 = Debug|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.Release with Tests|Win32.ActiveCfg = Release with Tests|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.Release with Tests|Win32.Build.0 = Release with Tests|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.Release XP|Win32.ActiveCfg = Release XP|Win32 - {D24D94F6-2A74-480C-B512-629C306CE92F}.Release XP|Win32.Build.0 = Release XP|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.ActiveCfg = Release|Win32 {D24D94F6-2A74-480C-B512-629C306CE92F}.Release|Win32.Build.0 = Release|Win32 - {074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Debug|Win32.ActiveCfg = Debug|Win32 - {074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Debug|Win32.Build.0 = Debug|Win32 - {074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Release with Tests|Win32.ActiveCfg = Release with Tests|Win32 - {074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Release with Tests|Win32.Build.0 = Release with Tests|Win32 - {074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Release XP|Win32.ActiveCfg = Release XP|Win32 - {074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Release XP|Win32.Build.0 = Release XP|Win32 - {074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Release|Win32.ActiveCfg = Release|Win32 - {074DC930-05C6-4B7F-B5DD-DD237E6E44DB}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/openrct2.vcxproj b/openrct2.vcxproj index 0427c85709..df7f253bfc 100644 --- a/openrct2.vcxproj +++ b/openrct2.vcxproj @@ -3,7 +3,6 @@ - @@ -14,20 +13,13 @@ Release Win32 - - Release XP - Win32 - - - Release with Tests - Win32 - + @@ -116,9 +108,6 @@ - - - @@ -196,6 +185,7 @@ + @@ -292,16 +282,10 @@ - - - {074dc930-05c6-4b7f-b5dd-dd237e6e44db} - - {D24D94F6-2A74-480C-B512-629C306CE92F} openrct2 openrct2 - 10.0.10240.0 @@ -317,67 +301,35 @@ true MultiByte - - DynamicLibrary - false - v140_xp - true - MultiByte - - - DynamicLibrary - false - v140 - true - MultiByte - - - + - - - - - - - $(SolutionDir)lib;$(SolutionDir)lib\libspeex;$(SolutionDir)lib\sdl\include;$(SolutionDir)lib\libcurl\include;$(SolutionDir)lib\jansson;$(SolutionDir)lib\cutest;$(SolutionDir)lib\SDL2_ttf\include;$(IncludePath) - $(SolutionDir)lib\sdl\lib\x86;$(SolutionDir)lib\libcurl\lib;$(LibraryPath) + $(SolutionDir)lib\include;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(IncludePath) + $(SolutionDir)lib;$(LibraryPath) $(SolutionDir)bin\ $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ + - $(SolutionDir)lib;$(SolutionDir)lib\libspeex;$(SolutionDir)lib\sdl\include;$(SolutionDir)lib\libcurl\include;$(SolutionDir)lib\jansson;$(SolutionDir)lib\cutest;$(SolutionDir)lib\SDL2_ttf\include;$(IncludePath) - $(SolutionDir)lib\sdl\lib\x86;$(SolutionDir)lib\libcurl\lib;$(LibraryPath) + $(SolutionDir)lib\include;$(SolutionDir)lib\include\libspeex;$(SolutionDir)lib\include\sdl;$(SolutionDir)lib\include\jansson;$(SolutionDir)lib\include\sdl_ttf;$(SolutionDir)lib\include\libpng;$(IncludePath) + $(SolutionDir)lib;$(LibraryPath) $(SolutionDir)bin\ $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ - - $(SolutionDir)lib;$(SolutionDir)lib\libspeex;$(SolutionDir)lib\sdl\include;$(SolutionDir)lib\libcurl\include;$(SolutionDir)lib\jansson;$(SolutionDir)lib\cutest;$(SolutionDir)lib\SDL2_ttf\include;$(IncludePath) - $(SolutionDir)lib\sdl\lib\x86;$(SolutionDir)lib\libcurl\lib;$(LibraryPath) - $(SolutionDir)bin\ - $(SolutionDir)obj\$(ProjectName)\$(Configuration)\ - - - $(SolutionDir)lib;$(SolutionDir)lib\libspeex;$(SolutionDir)lib\sdl\include;$(SolutionDir)lib\libcurl\include;$(SolutionDir)lib\jansson;$(SolutionDir)lib\cutest;$(SolutionDir)lib\SDL2_ttf\include;$(IncludePath) - $(SolutionDir)lib\sdl\lib\x86;$(SolutionDir)lib\libcurl\lib;$(LibraryPath) - $(SolutionDir)bin\ - $(SolutionDir)obj\$(ProjectName)\Release\ - Level3 Disabled true 1Byte - $(OpenRCT2_DEFINES);DEBUG;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + $(OpenRCT2_DEFINES);DEBUG;USE_LIBPNG;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreaded true $(IntDir)\%(RelativeDir) @@ -386,7 +338,9 @@ true - winmm.lib;sdl2.lib;%(AdditionalDependencies) + openrct2-libs-vs2015.lib;imm32.lib;version.lib;winmm.lib;%(AdditionalDependencies) + UseFastLinkTimeCodeGeneration + /OPT:NOLBR /ignore:4099 %(AdditionalOptions) @@ -395,16 +349,14 @@ Full true true - - + MultiThreaded 1Byte 4013 - - + false - $(OpenRCT2_DEFINES);_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;%(PreprocessorDefinitions) - $(IntDir)fake\%(RelativeDir) + $(OpenRCT2_DEFINES);USE_LIBPNG;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;%(PreprocessorDefinitions) + $(IntDir)\%(RelativeDir) true Speed @@ -412,65 +364,10 @@ true true true - winmm.lib;sdl2.lib;%(AdditionalDependencies) - /ignore:4099 %(AdditionalOptions) - - - - - Level3 - Full - true - true - - - MultiThreaded - 1Byte - 4013 - - - false - $(OpenRCT2_DEFINES);DISABLE_NETWORK;DISABLE_HTTP;DISABLE_TWITCH;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;%(PreprocessorDefinitions) - $(IntDir)fake\%(RelativeDir) - true - Speed - - - true - true - true - winmm.lib;sdl2.lib;%(AdditionalDependencies) - /ignore:4099 %(AdditionalOptions) - Windows - - - - - Level3 - Disabled - true - true - - - MultiThreaded - 1Byte - 4013 - - - false - $(OpenRCT2_DEFINES);_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;ENABLE_TESTS;%(PreprocessorDefinitions) - $(IntDir)fake\%(RelativeDir) - true - - - true - true - true - winmm.lib;sdl2.lib;%(AdditionalDependencies) + openrct2-libs-vs2015.lib;imm32.lib;version.lib;winmm.lib;%(AdditionalDependencies) /ignore:4099 %(AdditionalOptions) - - + \ No newline at end of file diff --git a/openrct2.vcxproj.filters b/openrct2.vcxproj.filters index 9c8b9cd76b..95890bc7c5 100644 --- a/openrct2.vcxproj.filters +++ b/openrct2.vcxproj.filters @@ -56,6 +56,9 @@ {28a808eb-9017-44cc-939b-f828fd1e2e7d} + + {b1a4d0cf-f4a1-4a38-934c-369d4c129a85} + @@ -459,15 +462,6 @@ Source\Windows - - Test - - - Test\Management - - - Test\Ride - Source\Windows @@ -564,6 +558,9 @@ Source\Core + + Source\argparse + @@ -851,5 +848,8 @@ Source\Core + + Source\argparse + \ No newline at end of file diff --git a/scripts/linux/build.sh b/scripts/linux/build.sh index 049059f2fa..49d199fb99 100755 --- a/scripts/linux/build.sh +++ b/scripts/linux/build.sh @@ -7,52 +7,56 @@ mkdir -p $cachedir # Sets default target to "linux", if none specified TARGET=${TARGET-linux} +SYSTEM=$(uname -s) if [[ ! -d build ]]; then mkdir -p build fi -# keep in sync with version in install.sh -if [[ $(uname -s) == "Darwin" ]]; then - # keep in sync with version in Xcode project - sha256sum=6562ce9e1f37f125e3345bfd8b961777800436bf607b30dc7c964e0e6991ad2c -else - sha256sum=31c5e19d9f794bd5f0e75f20c2b4c3c4664d736b0a4d50c8cde14a9a9007b62d -fi -libVFile="./libversion" -libdir="./lib" -currentversion=0 -needsdownload="true" - -if [ -f $libVFile ]; then - while read line; do - currentversion=$line - continue - done < $libVFile -fi - -if [ "z$currentversion" == "z$sha256sum" ]; then - needsdownload="false" -fi - -if [ ! -d $libdir ]; then - needsdownload="true" -fi - -if [[ "$needsdownload" = "true" ]]; then - echo "Found library had sha256sum $currentversion, expected $sha256sum" - echo "New libraries need to be downloaded. Clearing cache and calling ./install.sh" - rm -rf ./lib - if [[ -f $cachedir/orctlibs.zip ]]; then - rm -rf $cachedir/orctlibs.zip +if [[ $TARGET != "linux" && $TARGET != "docker32" && $SYSTEM != "Darwin" ]]; then + # keep in sync with version in install.sh + if [[ $SYSTEM == "Darwin" ]]; then + # keep in sync with version in Xcode project + sha256sum=6562ce9e1f37f125e3345bfd8b961777800436bf607b30dc7c964e0e6991ad2c + else + sha256sum=31c5e19d9f794bd5f0e75f20c2b4c3c4664d736b0a4d50c8cde14a9a9007b62d fi - if [[ -d /usr/local/cross-tools/orctlibs ]]; then - sudo rm -rf /usr/local/cross-tools/orctlibs + libVFile="./libversion" + libdir="./lib" + currentversion=0 + needsdownload="true" + + if [ -f $libVFile ]; then + while read line; do + currentversion=$line + continue + done < $libVFile fi - if [[ -d $cachedir/orctlibs ]]; then - rm -rf $cachedir/orctlibs + + if [ "z$currentversion" == "z$sha256sum" ]; then + needsdownload="false" fi - scripts/linux/install.sh + + if [ ! -d $libdir ]; then + needsdownload="true" + fi + + if [[ "$needsdownload" = "true" ]]; then + echo "Found library had sha256sum $currentversion, expected $sha256sum" + echo "New libraries need to be downloaded. Clearing cache and calling ./install.sh" + rm -rf ./lib + if [[ -f $cachedir/orctlibs.zip ]]; then + rm -rf $cachedir/orctlibs.zip + fi + if [[ -d /usr/local/cross-tools/orctlibs ]]; then + sudo rm -rf /usr/local/cross-tools/orctlibs + fi + if [[ -d $cachedir/orctlibs ]]; then + rm -rf $cachedir/orctlibs + fi + scripts/linux/install.sh + fi +# if [[ $TARGET != "linux" && $TARGET != "docker32" && $SYSTEM != "Darwin" ]]; then fi pushd build diff --git a/scripts/linux/install.sh b/scripts/linux/install.sh index c0bde470cd..55806bbbdc 100755 --- a/scripts/linux/install.sh +++ b/scripts/linux/install.sh @@ -193,11 +193,14 @@ elif [[ $(uname) == "Linux" ]]; then fi fi -download_libs -calculate_sha256 "$cachedir/orctlibs.zip" > "$libVFile" -echo "Downloaded library with sha256sum: $(cat "$libVFile")" -# Local libs are required for all targets -install_local_libs +if [[ $TARGET == "windows" || $(uname -s) == "Darwin" ]]; then + download_libs + calculate_sha256 "$cachedir/orctlibs.zip" > "$libVFile" + echo "Downloaded library with sha256sum: $(cat "$libVFile")" + # Local libs are required for all targets + install_local_libs +# $TARGET == "windows" || $(uname -s) == "Darwin" +fi if [[ $TARGET == "windows" ]]; then download_sdl diff --git a/scripts/ps/install.ps1 b/scripts/ps/install.ps1 index e578c731bf..8ca77d1acf 100644 --- a/scripts/ps/install.ps1 +++ b/scripts/ps/install.ps1 @@ -13,13 +13,13 @@ $scriptsPath = Split-Path $Script:MyInvocation.MyCommand.Path Import-Module "$scriptsPath\common.psm1" -DisableNameChecking # Constants -$libsUrl = "https://openrct2.website/files/orctlibs-vs.zip" -$libsVersion = 4 +$libsUrl = "https://openrct2.website/files/openrct2-libs-vs2015.zip" +$libsVersion = 5 # Get paths $rootPath = Get-RootPath $libsPath = Join-Path $rootPath "lib" -$zipPath = Join-Path $libsPath "orctlibs.zip" +$zipPath = Join-Path $libsPath "openrct2-libs-vs2015.zip" $libsVersionPath = Join-Path $libsPath "libversion" # Check if we need to update the dependencies diff --git a/scripts/ps/publish.ps1 b/scripts/ps/publish.ps1 index 07b5f2580a..4e83208408 100644 --- a/scripts/ps/publish.ps1 +++ b/scripts/ps/publish.ps1 @@ -80,7 +80,6 @@ function Do-Package() Copy-Item -Force "$releaseDir\openrct2.exe" $tempDir -ErrorAction Stop Copy-Item -Force "$releaseDir\openrct2.dll" $tempDir -ErrorAction Stop Copy-Item -Force "$releaseDir\curl-ca-bundle.crt" $tempDir -ErrorAction Stop - Copy-Item -Force "$releaseDir\SDL2.dll" $tempDir -ErrorAction Stop Copy-Item -Force "$distDir\changelog.txt" $tempDir -ErrorAction Stop Copy-Item -Force "$distDir\known_issues.txt" $tempDir -ErrorAction Stop Copy-Item -Force "$distDir\readme.txt" $tempDir -ErrorAction Stop diff --git a/src/argparse/argparse.c b/src/argparse/argparse.c new file mode 100644 index 0000000000..e2e14d068f --- /dev/null +++ b/src/argparse/argparse.c @@ -0,0 +1,324 @@ +#include "argparse.h" + +#define OPT_UNSET 1 + +static const char * +prefix_skip(const char *str, const char *prefix) +{ + size_t len = strlen(prefix); + return strncmp(str, prefix, len) ? NULL : str + len; +} + +int +prefix_cmp(const char *str, const char *prefix) +{ + for (;; str++, prefix++) + if (!*prefix) + return 0; + else if (*str != *prefix) + return (unsigned char)*prefix - (unsigned char)*str; +} + +static void +argparse_error(struct argparse *this, const struct argparse_option *opt, + const char *reason) +{ + if (!strncmp(this->argv[0], "--", 2)) { + fprintf(stderr, "error: option `%s` %s\n", opt->long_name, reason); + exit(1); + } else { + fprintf(stderr, "error: option `%c` %s\n", opt->short_name, reason); + exit(1); + } +} + +static int +argparse_getvalue(struct argparse *this, const struct argparse_option *opt, + int flags) +{ + const char *s = NULL; + if (!opt->value) + goto skipped; + switch (opt->type) { + case ARGPARSE_OPT_BOOLEAN: + if (flags & OPT_UNSET) { + *(int *)opt->value = *(int *)opt->value - 1; + } else { + *(int *)opt->value = *(int *)opt->value + 1; + } + if (*(int *)opt->value < 0) { + *(int *)opt->value = 0; + } + break; + case ARGPARSE_OPT_BIT: + if (flags & OPT_UNSET) { + *(int *)opt->value &= ~opt->data; + } else { + *(int *)opt->value |= opt->data; + } + break; + case ARGPARSE_OPT_STRING: + if (this->optvalue) { + *(const char **)opt->value = this->optvalue; + this->optvalue = NULL; + } else if (this->argc > 1) { + this->argc--; + *(const char **)opt->value = *++this->argv; + } else { + argparse_error(this, opt, "requires a value"); + } + break; + case ARGPARSE_OPT_INTEGER: + if (this->optvalue) { + *(int *)opt->value = strtol(this->optvalue, (char **)&s, 0); + this->optvalue = NULL; + } else if (this->argc > 1) { + this->argc--; + *(int *)opt->value = strtol(*++this->argv, (char **)&s, 0); + } else { + argparse_error(this, opt, "requires a value"); + } + if (s[0] != '\0') + argparse_error(this, opt, "expects a numerical value"); + break; + default: + assert(0); + } + +skipped: + if (opt->callback) { + return opt->callback(this, opt); + } + + return 0; +} + +static void +argparse_options_check(const struct argparse_option *options) +{ + for (; options->type != ARGPARSE_OPT_END; options++) { + switch (options->type) { + case ARGPARSE_OPT_END: + case ARGPARSE_OPT_BOOLEAN: + case ARGPARSE_OPT_BIT: + case ARGPARSE_OPT_INTEGER: + case ARGPARSE_OPT_STRING: + case ARGPARSE_OPT_GROUP: + continue; + default: + fprintf(stderr, "wrong option type: %d", options->type); + break; + } + } +} + +static int +argparse_short_opt(struct argparse *this, const struct argparse_option *options) +{ + for (; options->type != ARGPARSE_OPT_END; options++) { + if (options->short_name == *this->optvalue) { + this->optvalue = this->optvalue[1] ? this->optvalue + 1 : NULL; + return argparse_getvalue(this, options, 0); + } + } + return -2; +} + +static int +argparse_long_opt(struct argparse *this, const struct argparse_option *options) +{ + for (; options->type != ARGPARSE_OPT_END; options++) { + const char *rest; + int opt_flags = 0; + if (!options->long_name) + continue; + + rest = prefix_skip(this->argv[0] + 2, options->long_name); + if (!rest) { + // Negation allowed? + if (options->flags & OPT_NONEG) { + continue; + } + // Only boolean/bit allow negation. + if (options->type != ARGPARSE_OPT_BOOLEAN && options->type != ARGPARSE_OPT_BIT) { + continue; + } + + if (!prefix_cmp(this->argv[0] + 2, "no-")) { + rest = prefix_skip(this->argv[0] + 2 + 3, options->long_name); + if (!rest) + continue; + opt_flags |= OPT_UNSET; + } else { + continue; + } + } + if (*rest) { + if (*rest != '=') + continue; + this->optvalue = rest + 1; + } + return argparse_getvalue(this, options, opt_flags); + } + return -2; +} + +int +argparse_init(struct argparse *this, struct argparse_option *options, + const char *const *usage, int flags) +{ + memset(this, 0, sizeof(*this)); + this->options = options; + this->usage = usage; + this->flags = flags; + return 0; +} + +int +argparse_parse(struct argparse *this, int argc, const char **argv) +{ + this->argc = argc - 1; + this->argv = argv + 1; + this->out = argv; + + argparse_options_check(this->options); + + for (; this->argc; this->argc--, this->argv++) { + const char *arg = this->argv[0]; + if (arg[0] != '-' || !arg[1]) { + if (this->flags & ARGPARSE_STOP_AT_NON_OPTION) { + goto end; + } + // if it's not option or is a single char '-', copy verbatimly + this->out[this->cpidx++] = this->argv[0]; + continue; + } + // short option + if (arg[1] != '-') { + this->optvalue = arg + 1; + switch (argparse_short_opt(this, this->options)) { + case -1: + break; + case -2: + goto unknown; + } + while (this->optvalue) { + switch (argparse_short_opt(this, this->options)) { + case -1: + break; + case -2: + goto unknown; + } + } + continue; + } + // if '--' presents + if (!arg[2]) { + this->argc--; + this->argv++; + break; + } + // long option + switch (argparse_long_opt(this, this->options)) { + case -1: + break; + case -2: + goto unknown; + } + continue; + +unknown: + fprintf(stderr, "error: unknown option `%s`\n", this->argv[0]); + argparse_usage(this); + exit(1); + } + +end: + memmove((void*)(this->out + this->cpidx), + this->argv, + this->argc * sizeof(*this->out)); + this->out[this->cpidx + this->argc] = NULL; + + return this->cpidx + this->argc; +} + +void +argparse_usage(struct argparse *this) +{ + fprintf(stdout, "Usage: %s\n", *this->usage++); + while (*this->usage && **this->usage) + fprintf(stdout, " or: %s\n", *this->usage++); + fputc('\n', stdout); + + const struct argparse_option *options; + + // figure out best width + size_t usage_opts_width = 0; + size_t len; + options = this->options; + for (; options->type != ARGPARSE_OPT_END; options++) { + len = 0; + if ((options)->short_name) { + len += 2; + } + if ((options)->short_name && (options)->long_name) { + len += 2; // separator ", " + } + if ((options)->long_name) { + len += strlen((options)->long_name) + 2; + } + if (options->type == ARGPARSE_OPT_INTEGER) { + len += strlen("="); + } else if (options->type == ARGPARSE_OPT_STRING) { + len += strlen("="); + } + len = ((len + 3) / 4) * 4; + if (usage_opts_width < len) { + usage_opts_width = len; + } + } + usage_opts_width += 4; // 4 spaces prefix + + options = this->options; + for (; options->type != ARGPARSE_OPT_END; options++) { + size_t pos = 0; + int pad = 0; + if (options->type == ARGPARSE_OPT_GROUP) { + fputc('\n', stdout); + pos += fprintf(stdout, "%s", options->help); + fputc('\n', stdout); + continue; + } + pos = fprintf(stdout, " "); + if (options->short_name) { + pos += fprintf(stdout, "-%c", options->short_name); + } + if (options->long_name && options->short_name) { + pos += fprintf(stdout, ", "); + } + if (options->long_name) { + pos += fprintf(stdout, "--%s", options->long_name); + } + if (options->type == ARGPARSE_OPT_INTEGER) { + pos += fprintf(stdout, "="); + } else if (options->type == ARGPARSE_OPT_STRING) { + pos += fprintf(stdout, "="); + } + if (pos <= usage_opts_width) { + pad = usage_opts_width - pos; + } else { + fputc('\n', stdout); + pad = usage_opts_width; + } + fprintf(stdout, "%*s%s\n", pad + 2, "", options->help); + } +} + +int +argparse_help_cb(struct argparse *this, const struct argparse_option *option) +{ + (void)option; + argparse_usage(this); + exit(0); + return 0; +} diff --git a/src/argparse/argparse.h b/src/argparse/argparse.h new file mode 100644 index 0000000000..350ee58df4 --- /dev/null +++ b/src/argparse/argparse.h @@ -0,0 +1,132 @@ +#ifndef ARGPARSE_H +#define ARGPARSE_H +/** + * Command-line arguments parsing library. + * + * This module is inspired by parse-options.c (git) and python's argparse + * module. + * + * Arguments parsing is common task in cli program, but traditional `getopt` + * libraries are not easy to use. This library provides high-level arguments + * parsing solutions. + * + * The program defines what arguments it requires, and `argparse` will figure + * out how to parse those out of `argc` and `argv`, it also automatically + * generates help and usage messages and issues errors when users give the + * program invalid arguments. + * + * Reserved namespaces: + * argparse + * OPT + * Author: Yecheng Fu + */ + +#include +#include +#include +#include +#include +#include + +struct argparse; +struct argparse_option; + +typedef int argparse_callback(struct argparse *this, + const struct argparse_option *option); + +enum argparse_flag { + ARGPARSE_STOP_AT_NON_OPTION = 1, +}; + +enum argparse_option_type { + /* special */ + ARGPARSE_OPT_END, + ARGPARSE_OPT_GROUP, + /* options with no arguments */ + ARGPARSE_OPT_BOOLEAN, + ARGPARSE_OPT_BIT, + /* options with arguments (optional or required) */ + ARGPARSE_OPT_INTEGER, + ARGPARSE_OPT_STRING, +}; + +enum argparse_option_flags { + OPT_NONEG = 1, /* Negation disabled. */ +}; + +/* + * Argparse option struct. + * + * `type`: + * holds the type of the option, you must have an ARGPARSE_OPT_END last in your + * array. + * + * `short_name`: + * the character to use as a short option name, '\0' if none. + * + * `long_name`: + * the long option name, without the leading dash, NULL if none. + * + * `value`: + * stores pointer to the value to be filled. + * + * `help`: + * the short help message associated to what the option does. + * Must never be NULL (except for ARGPARSE_OPT_END). + * + * `callback`: + * function is called when corresponding argument is parsed. + * + * `data`: + * associated data. Callbacks can use it like they want. + * + * `flags`: + * option flags. + * + */ +struct argparse_option { + enum argparse_option_type type; + const char short_name; + const char *long_name; + void *value; + const char *help; + argparse_callback *callback; + intptr_t data; + int flags; +}; + +/* + * argpparse + */ +struct argparse { + // user supplied + const struct argparse_option *options; + const char *const *usage; + int flags; + // internal context + int argc; + const char **argv; + const char **out; + int cpidx; + const char *optvalue; // current option value +}; + +// builtin callbacks +int argparse_help_cb(struct argparse *this, + const struct argparse_option *option); + +// builtin option macros +#define OPT_END() { ARGPARSE_OPT_END } +#define OPT_BOOLEAN(...) { ARGPARSE_OPT_BOOLEAN, __VA_ARGS__ } +#define OPT_BIT(...) { ARGPARSE_OPT_BIT, __VA_ARGS__ } +#define OPT_INTEGER(...) { ARGPARSE_OPT_INTEGER, __VA_ARGS__ } +#define OPT_STRING(...) { ARGPARSE_OPT_STRING, __VA_ARGS__ } +#define OPT_GROUP(h) { ARGPARSE_OPT_GROUP, 0, NULL, NULL, h, NULL } +#define OPT_HELP() OPT_BOOLEAN('h', "help", NULL, "show this help message and exit", argparse_help_cb) + +int argparse_init(struct argparse *this, struct argparse_option *options, + const char *const *usage, int flags); +int argparse_parse(struct argparse *this, int argc, const char **argv); +void argparse_usage(struct argparse *this); + +#endif diff --git a/src/cmdline.c b/src/cmdline.c index 003f6faba4..c4fb495947 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -19,7 +19,7 @@ *****************************************************************************/ #include -#include +#include "argparse/argparse.h" #include "addresses.h" #include "cmdline.h" #include "interface/screenshot.h" diff --git a/test/management/finance_test.c b/test/management/finance_test.c deleted file mode 100644 index 0772dfb0ff..0000000000 --- a/test/management/finance_test.c +++ /dev/null @@ -1,60 +0,0 @@ -/***************************************************************************** -* Copyright (c) 2015 Marco Costa -* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. -* -* This file is part of OpenRCT2. -* -* OpenRCT2 is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include "../../src/addresses.h" -#include "../../src/management/finance.h" -#include "../../src/openrct2.h" -#include "../../src/scenario.h" - -#include "finance_test.h" - -void test_finance_setup(CuTest* tc) { - test_load_scenario(tc, "Build your own Six Flags Park.SC6"); -} - -void test_finance_loan_increase(CuTest* tc) { - money32 initialCash = finance_get_current_cash(); - money32 initialLoan = finance_get_current_loan(); - - money32 newLoan = finance_get_maximum_loan(); - finance_set_loan(newLoan); - - money32 actual = finance_get_current_loan(); - CuAssertIntEquals(tc, newLoan, actual); - - money32 actualCash = finance_get_current_cash(); - CuAssertIntEquals(tc, initialCash + newLoan - initialLoan, actualCash); -} - -void test_finance_loan_pay_back(CuTest* tc) { - money32 initialCash = finance_get_current_cash(); - money32 initialLoan = finance_get_current_loan(); - - money32 newLoan = MONEY(0, 00); - finance_set_loan(newLoan); - - money32 actual = finance_get_current_loan(); - CuAssertIntEquals(tc, newLoan, actual); - - money32 actualCash = finance_get_current_cash(); - CuAssertIntEquals(tc, MONEY(0, 00), actualCash); -} - - diff --git a/test/management/finance_test.h b/test/management/finance_test.h deleted file mode 100644 index 482d31d390..0000000000 --- a/test/management/finance_test.h +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************************** -* Copyright (c) 2015 Marco Costa -* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. -* -* This file is part of OpenRCT2. -* -* OpenRCT2 is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef _FINANCE_TEST_H_ -#define _FINANCE_TEST_H_ - -#include "../tests.h" - -void test_finance_setup(CuTest* tc); -void test_finance_loan_increase(CuTest* tc); -void test_finance_loan_pay_back(CuTest* tc); - -#endif diff --git a/test/ride/ride_ratings_test.c b/test/ride/ride_ratings_test.c deleted file mode 100644 index 9282d6be07..0000000000 --- a/test/ride/ride_ratings_test.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "../../src/ride/ride_ratings.h" -#include "../../src/localisation/localisation.h" - -#include "ride_ratings_test.h" - -void test_ride_ratings_setup(CuTest* tc) { - test_load_scenario(tc, "Six Flags Magic Mountain.SC6"); -} - -void test_ride_ratings(CuTest* tc) { - int i; - rct_ride *ride; - rating_tuple *rideRatings = malloc(256 * sizeof(rating_tuple)); - char rideName[256]; - char buffer[256]; - - // Store original ride ratings - FOR_ALL_RIDES(i, ride) - rideRatings[i] = ride->ratings; - - // Update all the ride ratings - // TODO use a better function that can just be called once for each ride - for (int i = 0; i < MAX_RIDES * 10; i++) - ride_ratings_update_all(); - - FOR_ALL_RIDES(i, ride) { - format_string(rideName, ride->name, &ride->name_arguments); - - sprintf(buffer, "[%s.excitement]", rideName); - CuAssertIntEquals_Msg(tc, buffer, rideRatings[i].excitement, ride->excitement); - sprintf(buffer, "[%s.intensity]", rideName); - CuAssertIntEquals_Msg(tc, buffer, rideRatings[i].intensity, ride->intensity); - sprintf(buffer, "[%s.nausea]", rideName); - CuAssertIntEquals_Msg(tc, buffer, rideRatings[i].nausea, ride->nausea); - } - - free(rideRatings); -} diff --git a/test/ride/ride_ratings_test.h b/test/ride/ride_ratings_test.h deleted file mode 100644 index ed19312ce8..0000000000 --- a/test/ride/ride_ratings_test.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _RIDE_RATINGS_TEST_H_ -#define _RIDE_RATINGS_TEST_H_ - -#include "../tests.h" - -void test_ride_ratings_setup(CuTest* tc); -void test_ride_ratings(CuTest* tc); - -#endif diff --git a/test/tests.c b/test/tests.c deleted file mode 100644 index 6963f14517..0000000000 --- a/test/tests.c +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** -* Copyright (c) 2015 Marco Costa -* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. -* -* This file is part of OpenRCT2. -* -* OpenRCT2 is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include "../src/openrct2.h" -#include "management/finance_test.h" -#include "ride/ride_ratings_test.h" - -int cmdline_for_test(const char **argv, int argc) -{ - // NOTE Currently all tests are running in a OpenRCT2 setup frame. Tests for the initialisation and disposing should be - // separate and independent. - - int numFailedTests; - - gOpenRCT2Headless = true; - if (openrct2_initialise()) { - numFailedTests = run_all_tests(); - - openrct2_dispose(); - } - return numFailedTests > 0 ? -1 : 1; -} - -CuSuite* new_suite(void) -{ - CuSuite* suite = CuSuiteNew(); - - // Test Finance - SUITE_ADD_TEST(suite, test_finance_setup); - SUITE_ADD_TEST(suite, test_finance_loan_increase); - SUITE_ADD_TEST(suite, test_finance_loan_pay_back); - - // Test Ride - SUITE_ADD_TEST(suite, test_ride_ratings_setup); - SUITE_ADD_TEST(suite, test_ride_ratings); - - // Future Tests: - // Test X - // SUITE_ADD_TEST(suite, test_X_setup); - // SUITE_ADD_TEST(suite, test_X_Y); - // SUITE_ADD_TEST(suite, test_X_Z); - - return suite; -} - -int run_all_tests(void) -{ - CuString *output = CuStringNew(); - CuSuite* suite = CuSuiteNew(); - - CuSuiteAddSuite(suite, new_suite()); - - CuSuiteRun(suite); - CuSuiteSummary(suite, output); - CuSuiteDetails(suite, output); - printf("Test results:\n%s\n", output->buffer); - - return suite->failCount; -} diff --git a/test/tests.h b/test/tests.h deleted file mode 100644 index 06619ec167..0000000000 --- a/test/tests.h +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************** -* Copyright (c) 2015 Marco Costa -* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. -* -* This file is part of OpenRCT2. -* -* OpenRCT2 is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef _TESTS_H_ -#define _TESTS_H_ - -#include -#include -#include "../src/common.h" - -int cmdline_for_test(const char **argv, int argc); -int run_all_tests(); - -// Test utilities - -#include "../src/scenario.h" - -static void test_load_scenario(CuTest* tc, const char* file_name) { - const scenario_index_entry* scenario = scenario_list_find_by_path(file_name); - if (scenario == NULL) { - CuFail(tc, "Could not load scenario"); - } - scenario_load_and_play_from_path(scenario->name); -} - -#endif