Skip to content

Commit

Permalink
Add x86 support (required by compiled lua scripts)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyuu17 committed Jul 10, 2024
1 parent ffd6e8f commit a7ab438
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 102 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ add_library( ${PROJECT_NAME} SHARED )

# LIB_ARCH is the architecture being built. It is set to the build system's architecture.
# For macOS, we build a universal library (both arm64 and x86_64).
set( LIB_ARCH ${CMAKE_SYSTEM_PROCESSOR} )
# set( LIB_ARCH ${CMAKE_SYSTEM_PROCESSOR} )
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(LIB_ARCH "x86_64")
else()
set(LIB_ARCH "x86")
endif()
if ( APPLE )
set( LIB_ARCH "universal" )
endif()
Expand Down
226 changes: 129 additions & 97 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,100 +1,132 @@
{
"version": 5,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "default",
"description": "Default preset that are inherited by all",
"generator": "Ninja",
"hidden": true,
"environment": {
"PROJECT_NAME": "swbf2"
}
"version": 5,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
{
"name": "windows-debug",
"displayName": "64bit Windows Debug",
"inherits": "default",
"binaryDir": "${sourceDir}/build/Windows-AMD64",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "windows-release",
"displayName": "64bit Windows Release",
"inherits": "windows-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux-debug",
"displayName": "64bit Linux Debug",
"inherits": "default",
"binaryDir": "${sourceDir}/build/Linux-x86_64",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "linux-release",
"displayName": "64bit Linux Release",
"inherits": "linux-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "macOS-debug",
"displayName": "64bit macOS Debug",
"inherits": "default",
"binaryDir": "${sourceDir}/build/Darwin-Universal",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_C_COMPILER": "clang",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "macOS-release",
"displayName": "64bit macOS Release",
"inherits": "macOS-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
]
"configurePresets": [
{
"name": "default",
"displayName": "default",
"description": "Default preset that are inherited by all",
"generator": "Ninja",
"hidden": true,
"environment": {
"PROJECT_NAME": "swbf2"
}
},
{
"name": "windows-x86-debug",
"displayName": "32bit Windows Debug",
"inherits": "default",
"binaryDir": "${sourceDir}/build/Windows-x86",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"toolset": {
"value": "host=x86",
"strategy": "external"
},
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "windows-x86-release",
"displayName": "32bit Windows Release",
"inherits": "windows-x86-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "windows-x64-debug",
"displayName": "64bit Windows Debug",
"inherits": "default",
"binaryDir": "${sourceDir}/build/Windows-x86_64",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
},
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "windows-x64-release",
"displayName": "64bit Windows Release",
"inherits": "windows-x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux-debug",
"displayName": "64bit Linux Debug",
"inherits": "default",
"binaryDir": "${sourceDir}/build/Linux-x86_64",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "linux-release",
"displayName": "64bit Linux Release",
"inherits": "linux-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "macOS-debug",
"displayName": "64bit macOS Debug",
"inherits": "default",
"binaryDir": "${sourceDir}/build/Darwin-Universal",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_C_COMPILER": "clang",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "macOS-release",
"displayName": "64bit macOS Release",
"inherits": "macOS-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
]
}
5 changes: 5 additions & 0 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ set_target_properties(godot-cpp

# lua
add_subdirectory(lua)

target_compile_definitions(lua
PUBLIC
LUA_NUMBER=float
)
2 changes: 1 addition & 1 deletion src/SWBF2/Native/Chunks/UcfbChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace SWBF2::Native
return false;
}

auto size = is.tellg();
std::size_t size = (std::size_t)is.tellg();
std::vector<std::byte> bytes;
bytes.resize(size);

Expand Down
6 changes: 4 additions & 2 deletions templates/template.debug.gdextension.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ compatibility_minimum = 4.1
Example = "icons/Example.svg"

[libraries]
linux.debug.x86_64 = "lib/Linux-x86_64/lib${PROJECT_NAME}-d.so"
linux.debug.x86 = "lib/Linux-x86/lib${PROJECT_NAME}-d.so"
linux.debug.x86_64 = "lib/Linux-x86_x64/lib${PROJECT_NAME}-d.so"
macos.debug = "lib/Darwin-Universal/lib${PROJECT_NAME}-d.dylib"
windows.debug.x86_64 = "lib/Windows-AMD64/${LIB_PREFIX}${PROJECT_NAME}-d.dll"
windows.debug.x86 = "lib/Windows-x86/${LIB_PREFIX}${PROJECT_NAME}-d.dll"
windows.debug.x86_64 = "lib/Windows-x86_64/${LIB_PREFIX}${PROJECT_NAME}-d.dll"
4 changes: 3 additions & 1 deletion templates/template.release.gdextension.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ compatibility_minimum = 4.1
Example = "icons/Example.svg"

[libraries]
linux.release.x86 = "lib/Linux-x86/lib${PROJECT_NAME}.so"
linux.release.x86_64 = "lib/Linux-x86_64/lib${PROJECT_NAME}.so"
macos.release = "lib/Darwin-universal/lib${PROJECT_NAME}.dylib"
windows.release.x86_64 = "lib/Windows-AMD64/${LIB_PREFIX}${PROJECT_NAME}.dll"
windows.release.x86 = "lib/Windows-x86/${LIB_PREFIX}${PROJECT_NAME}.dll"
windows.release.x86_64 = "lib/Windows-x86_64/${LIB_PREFIX}${PROJECT_NAME}.dll"

0 comments on commit a7ab438

Please sign in to comment.