mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Added mold linker support.
This commit is contained in:
38
premake4.lua
38
premake4.lua
@@ -160,6 +160,7 @@ newoption { trigger = "with-gles1", description = "Compile with GLES1 support" }
|
||||
newoption { trigger = "with-mojoal", description = "Compile with mojoAL as OpenAL implementation instead of using openal-soft (requires SDL2 backend)" }
|
||||
newoption { trigger = "use-frameworks", description = "In macOS it will try to link the external libraries from its frameworks. For example, instead of linking against SDL2 it will link agains SDL2.framework." }
|
||||
newoption { trigger = "with-emscripten-pthreads", description = "Enables emscripten build to use posix threads" }
|
||||
newoption { trigger = "with-mold-linker", description = "Tries to use the mold linker instead of the default linker of the toolchain" }
|
||||
newoption {
|
||||
trigger = "with-backend",
|
||||
description = "Select the backend to use for window and input handling.\n\t\t\tIf no backend is selected or if the selected is not installed the script will search for a backend present in the system, and will use it.",
|
||||
@@ -387,6 +388,29 @@ function fix_shared_lib_linking_path( package_name, libname )
|
||||
end
|
||||
end
|
||||
|
||||
function version_to_number( version )
|
||||
versionpart = 0
|
||||
versionnum = 0
|
||||
versionmod = 1000
|
||||
for str in string.gmatch(version, "[^%.]+") do
|
||||
versionnum = versionnum + tonumber(str) * versionmod
|
||||
versionpart = versionpart + 1
|
||||
if versionpart == 1 then
|
||||
versionmod = 100
|
||||
elseif versionpart == 2 then
|
||||
versionmod = 10
|
||||
end
|
||||
end
|
||||
return versionnum
|
||||
end
|
||||
|
||||
function popen( executable_path )
|
||||
local handle = io.popen(executable_path)
|
||||
local result = handle:read("*a")
|
||||
handle:close()
|
||||
return result
|
||||
end
|
||||
|
||||
function build_link_configuration( package_name, use_ee_icon )
|
||||
includedirs { "include" }
|
||||
|
||||
@@ -444,6 +468,20 @@ function build_link_configuration( package_name, use_ee_icon )
|
||||
end
|
||||
end
|
||||
|
||||
if _OPTIONS["with-mold-linker"] then
|
||||
if _OPTIONS.platform == "clang" or _OPTIONS.platform == "clang-analyzer" then
|
||||
linkoptions { "-fuse-ld=mold" }
|
||||
else
|
||||
gccversion = popen( "gcc -dumpfullversion" )
|
||||
gccversionnumber = version_to_number( gccversion )
|
||||
if gccversionnumber >= 12110 then
|
||||
linkoptions { "-fuse-ld=mold" }
|
||||
else
|
||||
linkoptions { "-B/usr/bin/mold" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG", "EE_DEBUG", "EE_MEMORY_MANAGER" }
|
||||
flags { "Symbols" }
|
||||
|
||||
33
premake5.lua
33
premake5.lua
@@ -8,6 +8,7 @@ newoption { trigger = "with-mojoal", description = "Compile with mojoAL as OpenA
|
||||
newoption { trigger = "use-frameworks", description = "In macOS it will try to link the external libraries from its frameworks. For example, instead of linking against SDL2 it will link against SDL2.framework." }
|
||||
newoption { trigger = "windows-vc-build", description = "This is used to build the framework in Visual Studio downloading its external dependencies and making them available to the VS project without having to install them manually." }
|
||||
newoption { trigger = "with-emscripten-pthreads", description = "Enables emscripten build to use posix threads" }
|
||||
newoption { trigger = "with-mold-linker", description = "Tries to use the mold linker instead of the default linker of the toolchain" }
|
||||
newoption {
|
||||
trigger = "with-backend",
|
||||
description = "Select the backend to use for window and input handling.\n\t\t\tIf no backend is selected or if the selected is not installed the script will search for a backend present in the system, and will use it.",
|
||||
@@ -102,7 +103,7 @@ function download_and_extract_sdl(sdl_url)
|
||||
print("Downloading: " .. sdl_url)
|
||||
local dest_dir = "src/thirdparty/"
|
||||
local local_file = dest_dir .. remote_sdl2_version .. ".zip"
|
||||
local result_str, response_code = http.download(sdl_url, local_file)
|
||||
local _, response_code = http.download(sdl_url, local_file)
|
||||
if response_code == 200 then
|
||||
print("Downloaded successfully to: " .. local_file)
|
||||
zip.extract(local_file, dest_dir)
|
||||
@@ -113,6 +114,22 @@ function download_and_extract_sdl(sdl_url)
|
||||
end
|
||||
end
|
||||
|
||||
function version_to_number( version )
|
||||
versionpart = 0
|
||||
versionnum = 0
|
||||
versionmod = 1000
|
||||
for str in string.gmatch(version, "[^%.]+") do
|
||||
versionnum = versionnum + tonumber(str) * versionmod
|
||||
versionpart = versionpart + 1
|
||||
if versionpart == 1 then
|
||||
versionmod = 100
|
||||
elseif versionpart == 2 then
|
||||
versionmod = 10
|
||||
end
|
||||
end
|
||||
return versionnum
|
||||
end
|
||||
|
||||
function download_and_extract_dependencies()
|
||||
if not os.isdir("src/thirdparty/" .. remote_sdl2_version) then
|
||||
if _OPTIONS["windows-vc-build"] then
|
||||
@@ -210,6 +227,20 @@ function build_link_configuration( package_name, use_ee_icon )
|
||||
end
|
||||
end
|
||||
|
||||
if _OPTIONS["with-mold-linker"] then
|
||||
if _OPTIONS.platform == "clang" or _OPTIONS.platform == "clang-analyzer" then
|
||||
linkoptions { "-fuse-ld=mold" }
|
||||
else
|
||||
gccversion = os.outputof( "gcc -dumpfullversion" )
|
||||
gccversionnumber = version_to_number( gccversion )
|
||||
if gccversionnumber >= 12110 then
|
||||
linkoptions { "-fuse-ld=mold" }
|
||||
else
|
||||
linkoptions { "-B/usr/bin/mold" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_ios_config()
|
||||
set_xcode_config()
|
||||
build_arch_configuration()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 7.0.0, 2022-04-01T00:37:29. -->
|
||||
<!-- Written by QtCreator 7.0.1, 2022-06-04T01:27:29. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
@@ -186,7 +186,7 @@
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProcessStep.Arguments">--with-mojoal gmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProcessStep.Arguments">--with-mojoal --with-mold-linker gmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProcessStep.Command">premake4</value>
|
||||
<value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">%{buildDir}../../../</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.ProcessStep</value>
|
||||
@@ -227,7 +227,7 @@
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProcessStep.Arguments">--with-mojoal gmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProcessStep.Arguments">--with-mold-linker --with-mojoal gmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProcessStep.Command">premake4</value>
|
||||
<value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">%{buildDir}../../../</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.ProcessStep</value>
|
||||
|
||||
Reference in New Issue
Block a user