1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Merge pull request #16153 from IntelOrca/embed-duktape

Resolve #14259: Embed our own duktape library
This commit is contained in:
Michael Steenbeek
2022-01-23 13:45:42 +01:00
committed by GitHub
12 changed files with 106378 additions and 51 deletions

View File

@@ -1,36 +0,0 @@
# This file was obtained from:
# https://github.com/microsoft/vcpkg/blob/master/ports/duktape/duktapeConfig.cmake.in
# It is used under the terms of the MIT License.
# - Try to find duktape
# Once done this will define
#
# DUKTAPE_FOUND - system has Duktape
# DUKTAPE_INCLUDE_DIRS - the Duktape include directory
# DUKTAPE_LIBRARIES - Link these to use DUKTAPE
# DUKTAPE_DEFINITIONS - Compiler switches required for using Duktape
#
PKG_CHECK_MODULES(PC_DUK QUIET duktape libduktape)
find_path(DUKTAPE_INCLUDE_DIR duktape.h
HINTS ${PC_DUK_INCLUDEDIR} ${PC_DUK_INCLUDE_DIRS}
PATH_SUFFIXES duktape)
find_library(DUKTAPE_LIBRARY
NAMES duktape libduktape
HINTS ${PC_DUK_LIBDIR} ${PC_DUK_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(duktape
REQUIRED_VARS DUKTAPE_LIBRARY DUKTAPE_INCLUDE_DIR)
if (DUKTAPE_FOUND)
set (DUKTAPE_LIBRARIES ${DUKTAPE_LIBRARY})
set (DUKTAPE_INCLUDE_DIRS ${DUKTAPE_INCLUDE_DIR} )
endif ()
MARK_AS_ADVANCED(
DUKTAPE_INCLUDE_DIR
DUKTAPE_LIBRARY
)

2
debian/control vendored
View File

@@ -4,7 +4,7 @@ Section: misc
Priority: optional
Standards-Version: 3.9.2
Multi-Arch: same
Build-Depends: debhelper (>= 9), cmake (>= 3.8), duktape-dev, libsdl2-dev, g++ (>= 4:7), pkg-config, nlohmann-json3-dev (>= 3.6.0), libspeex-dev, libspeexdsp-dev, libcurl4-openssl-dev, libcrypto++-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev, libssl-dev, libzip-dev (>= 1.0.0), libicu-dev (>= 59.0)
Build-Depends: debhelper (>= 9), cmake (>= 3.8), libsdl2-dev, g++ (>= 4:7), pkg-config, nlohmann-json3-dev (>= 3.6.0), libspeex-dev, libspeexdsp-dev, libcurl4-openssl-dev, libcrypto++-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev, libssl-dev, libzip-dev (>= 1.0.0), libicu-dev (>= 59.0)
Package: openrct2
Architecture: any

View File

@@ -78,7 +78,7 @@
</ClCompile>
<Link>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<AdditionalDependencies>benchmarkd.lib;brotlicommon-static.lib;brotlidec-static.lib;brotlienc-static.lib;libbreakpadd.lib;libbreakpad_clientd.lib;bz2d.lib;discord-rpc.lib;duktape.lib;freetyped.lib;libpng16d.lib;libspeexdsp.lib;SDL2d.lib;zip.lib;zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>benchmarkd.lib;brotlicommon-static.lib;brotlidec-static.lib;brotlienc-static.lib;libbreakpadd.lib;libbreakpad_clientd.lib;bz2d.lib;discord-rpc.lib;freetyped.lib;libpng16d.lib;libspeexdsp.lib;SDL2d.lib;zip.lib;zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
@@ -97,7 +97,7 @@
<GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>benchmark.lib;brotlicommon-static.lib;brotlidec-static.lib;brotlienc-static.lib;libbreakpad.lib;libbreakpad_client.lib;bz2.lib;discord-rpc.lib;duktape.lib;freetype.lib;libpng16.lib;libspeexdsp.lib;SDL2.lib;zip.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>benchmark.lib;brotlicommon-static.lib;brotlidec-static.lib;brotlienc-static.lib;libbreakpad.lib;libbreakpad_client.lib;bz2.lib;discord-rpc.lib;freetype.lib;libpng16.lib;libspeexdsp.lib;SDL2.lib;zip.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>

View File

@@ -110,7 +110,6 @@ OpenRCT2 requires original files of RollerCoaster Tycoon 2 to play. It can be bo
- icu (>= 59.0)
- zlib
- gl (commonly provided by Mesa or GPU vendors; only for UI client, can be disabled)
- duktape (unless scripting is disabled)
- cmake
- innoextract (optional runtime dependency; used for GOG installer extraction during setup)

View File

@@ -18,7 +18,19 @@ if (APPLE)
set_source_files_properties(${OPENRCT2_CORE_MM_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c++ -fmodules")
endif ()
add_library(${PROJECT_NAME} ${OPENRCT2_CORE_SOURCES} ${OPENRCT2_CORE_MM_SOURCES})
if (ENABLE_SCRIPTING)
include_directories("${CMAKE_CURRENT_LIST_DIR}/../thirdparty/duktape")
# duktape is third party, ignore all warnings
set(OPENRCT2_DUKTAPE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/../thirdparty/duktape/duktape.cpp")
if (MSVC)
set_source_files_properties(${OPENRCT2_DUKTAPE_SOURCES} PROPERTIES COMPILE_FLAGS "/w")
else ()
set_source_files_properties(${OPENRCT2_DUKTAPE_SOURCES} PROPERTIES COMPILE_FLAGS "-w")
endif ()
endif ()
add_library(${PROJECT_NAME} ${OPENRCT2_CORE_SOURCES} ${OPENRCT2_CORE_MM_SOURCES} ${OPENRCT2_DUKTAPE_SOURCES})
if (APPLE)
target_link_platform_libraries(${PROJECT_NAME})
endif ()
@@ -104,16 +116,6 @@ if (NOT DISABLE_GOOGLE_BENCHMARK)
endif ()
endif ()
if (ENABLE_SCRIPTING)
find_package(duktape CONFIG REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${DUKTAPE_INCLUDE_DIRS})
if (STATIC)
target_link_libraries(${PROJECT_NAME} ${DUKTAPE_LIBRARY} ${DUKTAPE_STATIC_LIBRARY})
else ()
target_link_libraries(${PROJECT_NAME} ${DUKTAPE_LIBRARY})
endif ()
endif ()
# Third party libraries
if (MSVC)
find_package(png 1.6 REQUIRED)

View File

@@ -949,6 +949,9 @@
<ClCompile Include="world/TileElementBase.cpp" />
<ClCompile Include="world\TileInspector.cpp" />
<ClCompile Include="world\Wall.cpp" />
<ClCompile Include="..\thirdparty\duktape\duktape.cpp">
<WarningLevel>TurnOffAllWarnings</WarningLevel>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@@ -1443,4 +1443,9 @@ int32_t OpenRCT2::Scripting::GetTargetAPIVersion()
return plugin->GetTargetAPIVersion();
}
duk_bool_t duk_exec_timeout_check(void*)
{
return false;
}
#endif

20
src/thirdparty/duktape/README.md vendored Normal file
View File

@@ -0,0 +1,20 @@
## Duktape
[Duktape](https://duktape.org/) is geared around compile time switches to minimise code size and memory footprint. Because of this, we can not rely on shared libraries, as we have no control on what switches it may have been compiled with. It also can cause inconsistent behaviour of plugins across multiple platforms, depending on what version of Duktape is installed on the system.
[#14853](https://github.com/OpenRCT2/OpenRCT2/issues/14853) is the primary issue that was solved by embedding our own copy of duktape.
This directory contains a pre-configured copy of duktape v2.6.0 with the following switches enabled:
* `DUK_USE_CPP_EXCEPTIONS` for C++ exception handling.
* `DUK_USE_DATE_NOW_WINDOWS` for Windows Vista compatibility.
* `DUK_USE_INTERRUPT_COUNTER` for aborting long or non-terminating scripts.
duktape is configured with a command such as:
```
python2 duktape-2.6.0/tools/configure.py --output-directory src/thirdparty/duktape \
-DUK_USE_CPP_EXCEPTIONS
-DUK_USE_DATE_NOW_WINDOWS
-DUK_USE_INTERRUPT_COUNTER
```
See [Configuring Duktape for build](https://wiki.duktape.org/configuring) for more information.

3213
src/thirdparty/duktape/duk_config.h vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

99760
src/thirdparty/duktape/duktape.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

1450
src/thirdparty/duktape/duktape.h vendored Normal file

File diff suppressed because it is too large Load Diff