mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2025-01-13 02:43:54 +08:00
use path.getabsolute instead of os.realpath since the later returns nil if the path doesn't exist
This commit is contained in:
parent
b1c5b69349
commit
a45ab0987b
@ -1,5 +1,13 @@
|
|||||||
require("premake", ">=5.0.0-beta2")
|
require("premake", ">=5.0.0-beta2")
|
||||||
|
|
||||||
|
-- don't forget to set env var CMAKE_GENERATOR to one of these values:
|
||||||
|
-- https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#manual:cmake-generators(7)
|
||||||
|
-- common ones
|
||||||
|
-- ============
|
||||||
|
-- Unix Makefiles
|
||||||
|
-- Visual Studio 17 2022
|
||||||
|
-- MSYS Makefiles
|
||||||
|
|
||||||
local os_iden = '' -- identifier
|
local os_iden = '' -- identifier
|
||||||
if os.target() == "windows" then
|
if os.target() == "windows" then
|
||||||
os_iden = 'win'
|
os_iden = 'win'
|
||||||
@ -12,11 +20,17 @@ end
|
|||||||
|
|
||||||
-- options
|
-- options
|
||||||
---------
|
---------
|
||||||
-- verbose
|
-- general
|
||||||
newoption {
|
newoption {
|
||||||
|
category = "general",
|
||||||
trigger = "verbose",
|
trigger = "verbose",
|
||||||
description = "Verbose output",
|
description = "Verbose output",
|
||||||
}
|
}
|
||||||
|
newoption {
|
||||||
|
category = "general",
|
||||||
|
trigger = "clean",
|
||||||
|
description = "Cleanup before any action",
|
||||||
|
}
|
||||||
|
|
||||||
-- local tools
|
-- local tools
|
||||||
newoption {
|
newoption {
|
||||||
@ -33,11 +47,6 @@ newoption {
|
|||||||
trigger = "all-ext",
|
trigger = "all-ext",
|
||||||
description = "Extract all deps",
|
description = "Extract all deps",
|
||||||
}
|
}
|
||||||
newoption {
|
|
||||||
category = "extract",
|
|
||||||
trigger = "clean-ext",
|
|
||||||
description = "Clean folder before extraction",
|
|
||||||
}
|
|
||||||
|
|
||||||
newoption {
|
newoption {
|
||||||
category = "extract",
|
category = "extract",
|
||||||
@ -76,11 +85,6 @@ newoption {
|
|||||||
trigger = "all-build",
|
trigger = "all-build",
|
||||||
description = "Build all deps",
|
description = "Build all deps",
|
||||||
}
|
}
|
||||||
newoption {
|
|
||||||
category = "build",
|
|
||||||
trigger = "clean-build",
|
|
||||||
description = "Clean folder before building",
|
|
||||||
}
|
|
||||||
newoption {
|
newoption {
|
||||||
category = "build",
|
category = "build",
|
||||||
trigger = "32-build",
|
trigger = "32-build",
|
||||||
@ -142,11 +146,10 @@ end
|
|||||||
|
|
||||||
-- common defs
|
-- common defs
|
||||||
---------
|
---------
|
||||||
|
local deps_dir = path.getabsolute(path.join('build', 'deps', os_iden), _MAIN_SCRIPT_DIR)
|
||||||
local deps_dir = os.realpath(path.join('build', 'deps', os_iden))
|
local third_party_dir = path.getabsolute('third-party')
|
||||||
local third_party_dir = os.realpath('third-party')
|
local third_party_deps_dir = path.join(third_party_dir, 'deps', os_iden)
|
||||||
local third_party_deps_dir = os.realpath(path.join(third_party_dir, 'deps', os_iden))
|
local third_party_common_dir = path.join(third_party_dir, 'deps', 'common')
|
||||||
local third_party_common_dir = os.realpath(path.join(third_party_dir, 'deps', 'common'))
|
|
||||||
local extractor = os.realpath(path.join(third_party_deps_dir, '7za', '7za'))
|
local extractor = os.realpath(path.join(third_party_deps_dir, '7za', '7za'))
|
||||||
local mycmake = os.realpath(path.join(third_party_deps_dir, 'cmake', 'bin', 'cmake'))
|
local mycmake = os.realpath(path.join(third_party_deps_dir, 'cmake', 'bin', 'cmake'))
|
||||||
|
|
||||||
@ -169,8 +172,9 @@ if os.target() == 'windows' then
|
|||||||
table.insert(cmake_common_defs, 'CMAKE_CXX_FLAGS_RELEASE="-MT -D_MT"')
|
table.insert(cmake_common_defs, 'CMAKE_CXX_FLAGS_RELEASE="-MT -D_MT"')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function cmake_build(dep_folder, is_32, extra_defs)
|
local function cmake_build(dep_folder, is_32, extra_defs)
|
||||||
dep_base = os.realpath(path.join(deps_dir, dep_folder))
|
local dep_base = path.getabsolute(path.join(deps_dir, dep_folder))
|
||||||
local arch_iden = ''
|
local arch_iden = ''
|
||||||
if is_32 then
|
if is_32 then
|
||||||
arch_iden = '32'
|
arch_iden = '32'
|
||||||
@ -178,10 +182,10 @@ local function cmake_build(dep_folder, is_32, extra_defs)
|
|||||||
arch_iden = '64'
|
arch_iden = '64'
|
||||||
end
|
end
|
||||||
|
|
||||||
local build_dir = os.realpath(path.join(dep_base, 'build' .. arch_iden))
|
local build_dir = path.getabsolute(path.join(dep_base, 'build' .. arch_iden))
|
||||||
|
|
||||||
-- clean if required
|
-- clean if required
|
||||||
if _OPTIONS["clean-build"] then
|
if _OPTIONS["clean"] then
|
||||||
print('cleaning dir: ' .. build_dir)
|
print('cleaning dir: ' .. build_dir)
|
||||||
os.rmdir(build_dir)
|
os.rmdir(build_dir)
|
||||||
end
|
end
|
||||||
@ -191,20 +195,20 @@ local function cmake_build(dep_folder, is_32, extra_defs)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local install_dir = os.realpath(path.join(dep_base, 'install' .. arch_iden))
|
local install_dir = path.join(dep_base, 'install' .. arch_iden)
|
||||||
local cmake_common_defs_str = '-D' .. table.concat(cmake_common_defs, ' -D') .. ' -DCMAKE_INSTALL_PREFIX="' .. install_dir .. '"'
|
local cmake_common_defs_str = '-D' .. table.concat(cmake_common_defs, ' -D') .. ' -DCMAKE_INSTALL_PREFIX="' .. install_dir .. '"'
|
||||||
local cmd_gen = mycmake .. ' -S "' .. dep_base .. '" -B "' .. build_dir .. '" ' .. cmake_common_defs_str
|
local cmd_gen = mycmake .. ' -S "' .. dep_base .. '" -B "' .. build_dir .. '" ' .. cmake_common_defs_str
|
||||||
|
|
||||||
-- arch
|
-- arch
|
||||||
if string.match(_ACTION, 'gmake.*') then
|
if string.match(_ACTION, 'gmake.*') then
|
||||||
if is_32 then
|
if is_32 then
|
||||||
local toolchain_file = os.realpath(path.join(deps_dir, 'toolchain_32.cmake'))
|
local toolchain_file = path.join(deps_dir, 'toolchain_32.cmake')
|
||||||
if not os.isfile(toolchain_file) then
|
if not os.isfile(toolchain_file) then
|
||||||
if not io.writefile(toolchain_file, [[
|
if not io.writefile(toolchain_file, [[
|
||||||
set(CMAKE_C_FLAGS_INIT "-m32")
|
set(CMAKE_C_FLAGS_INIT "-m32")
|
||||||
set(CMAKE_CXX_FLAGS_INIT "-m32")
|
set(CMAKE_CXX_FLAGS_INIT "-m32")
|
||||||
]]) then
|
]]) then
|
||||||
error("failed to create 32-bit cmake toolchain")
|
error("failed to create 32-bit cmake toolchain (gmake)")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -263,7 +267,7 @@ local function cmake_build(dep_folder, is_32, extra_defs)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- clean if required
|
-- clean if required
|
||||||
if _OPTIONS["clean-build"] then
|
if _OPTIONS["clean"] then
|
||||||
print('cleaning dir: ' .. install_dir)
|
print('cleaning dir: ' .. install_dir)
|
||||||
os.rmdir(install_dir)
|
os.rmdir(install_dir)
|
||||||
end
|
end
|
||||||
@ -322,18 +326,18 @@ if _OPTIONS["ext-ingame_overlay"] or _OPTIONS["all-ext"] then
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
for _, v in pairs(deps_to_extract) do
|
for _, dep in pairs(deps_to_extract) do
|
||||||
-- check archive
|
-- check archive
|
||||||
local archive_file = os.realpath(third_party_common_dir .. '/' .. v[1])
|
local archive_file = path.join(third_party_common_dir, dep[1])
|
||||||
if not os.isfile(archive_file) then
|
if not os.isfile(archive_file) then
|
||||||
error("archive not found: " .. archive_file)
|
error("archive not found: " .. archive_file)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local out_folder = os.realpath(deps_dir .. '/' .. v[2])
|
local out_folder = path.join(deps_dir, dep[2])
|
||||||
|
|
||||||
-- clean if required
|
-- clean if required
|
||||||
if _OPTIONS["clean-ext"] then
|
if _OPTIONS["clean"] then
|
||||||
print('cleaning dir: ' .. out_folder)
|
print('cleaning dir: ' .. out_folder)
|
||||||
os.rmdir(out_folder)
|
os.rmdir(out_folder)
|
||||||
end
|
end
|
||||||
@ -422,25 +426,25 @@ if os.target() == 'windows' then
|
|||||||
else
|
else
|
||||||
zlib_name = 'libz'
|
zlib_name = 'libz'
|
||||||
end
|
end
|
||||||
-- ext
|
-- extension
|
||||||
if string.match(_ACTION, 'vs.+') then
|
if string.match(_ACTION, 'vs.+') then
|
||||||
zlib_name = zlib_name .. '.lib'
|
zlib_name = zlib_name .. '.lib'
|
||||||
else
|
else
|
||||||
zlib_name = zlib_name .. '.a'
|
zlib_name = zlib_name .. '.a'
|
||||||
end
|
end
|
||||||
|
|
||||||
local wild_zlib_path_32 = os.realpath(path.join(deps_dir, 'zlib', 'install32', 'lib', zlib_name))
|
local wild_zlib_path_32 = path.join(deps_dir, 'zlib', 'install32', 'lib', zlib_name)
|
||||||
local wild_zlib_32 = {
|
local wild_zlib_32 = {
|
||||||
'ZLIB_USE_STATIC_LIBS=ON',
|
'ZLIB_USE_STATIC_LIBS=ON',
|
||||||
'ZLIB_ROOT="' .. os.realpath(path.join(deps_dir, 'zlib', 'install32')) .. '"',
|
'ZLIB_ROOT="' .. path.join(deps_dir, 'zlib', 'install32') .. '"',
|
||||||
'ZLIB_INCLUDE_DIR="' .. os.realpath(path.join(deps_dir, 'zlib', 'install32', 'include')) .. '"',
|
'ZLIB_INCLUDE_DIR="' .. path.join(deps_dir, 'zlib', 'install32', 'include') .. '"',
|
||||||
'ZLIB_LIBRARY="' .. wild_zlib_path_32 .. '"',
|
'ZLIB_LIBRARY="' .. wild_zlib_path_32 .. '"',
|
||||||
}
|
}
|
||||||
local wild_zlib_path_64 = os.realpath(path.join(deps_dir, 'zlib', 'install64', 'lib', zlib_name))
|
local wild_zlib_path_64 = path.join(deps_dir, 'zlib', 'install64', 'lib', zlib_name)
|
||||||
local wild_zlib_64 = {
|
local wild_zlib_64 = {
|
||||||
'ZLIB_USE_STATIC_LIBS=ON',
|
'ZLIB_USE_STATIC_LIBS=ON',
|
||||||
'ZLIB_ROOT="' .. os.realpath(path.join(deps_dir, 'zlib', 'install64')) .. '"',
|
'ZLIB_ROOT="' .. path.join(deps_dir, 'zlib', 'install64') .. '"',
|
||||||
'ZLIB_INCLUDE_DIR="' .. os.realpath(path.join(deps_dir, 'zlib', 'install64', 'include')) .. '"',
|
'ZLIB_INCLUDE_DIR="' .. path.join(deps_dir, 'zlib', 'install64', 'include') .. '"',
|
||||||
'ZLIB_LIBRARY="' .. wild_zlib_path_64 .. '"',
|
'ZLIB_LIBRARY="' .. wild_zlib_path_64 .. '"',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,7 +525,7 @@ end
|
|||||||
|
|
||||||
if _OPTIONS["build-ingame_overlay"] or _OPTIONS["all-build"] then
|
if _OPTIONS["build-ingame_overlay"] or _OPTIONS["all-build"] then
|
||||||
-- fixes 32-bit compilation of DX12
|
-- fixes 32-bit compilation of DX12
|
||||||
local overaly_imgui_cfg_file = os.realpath(path.join(deps_dir, 'ingame_overlay', 'imconfig.imcfg'))
|
local overaly_imgui_cfg_file = path.join(deps_dir, 'ingame_overlay', 'imconfig.imcfg')
|
||||||
if not os.isfile(overaly_imgui_cfg_file) then
|
if not os.isfile(overaly_imgui_cfg_file) then
|
||||||
if not io.writefile(overaly_imgui_cfg_file, [[
|
if not io.writefile(overaly_imgui_cfg_file, [[
|
||||||
#pragma once
|
#pragma once
|
||||||
|
Loading…
x
Reference in New Issue
Block a user