[Build] Convert build system to raw cmake and remove premake layer
This commit is contained in:
Binary file not shown.
@@ -1,272 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright 2015 Ben Vanik. All Rights Reserved.
|
||||
|
||||
"""Premake trampoline script.
|
||||
"""
|
||||
|
||||
__author__ = "ben.vanik@gmail.com (Ben Vanik)"
|
||||
|
||||
|
||||
from json import loads as jsonloads
|
||||
import os
|
||||
from shutil import rmtree
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
self_path = os.path.dirname(os.path.abspath(__file__))
|
||||
root_path = os.path.join(self_path, "..", "..")
|
||||
premake_submodule_path = os.path.join(root_path, "third_party", "premake-core")
|
||||
premake_path = premake_submodule_path
|
||||
|
||||
|
||||
def setup_premake_path_override():
|
||||
global premake_path
|
||||
premake_path = premake_submodule_path
|
||||
if sys.platform == "linux":
|
||||
# On Android, the repository may be cloned to the external storage, which
|
||||
# doesn't support executables in it.
|
||||
# In this case, premake-core needs to be checked out in the internal
|
||||
# storage, which supports executables, with all the permissions as set in
|
||||
# its repository.
|
||||
# On Termux, the home directory is in the internal storage - use it for
|
||||
# executing.
|
||||
# If xenia-build.py doesn't have execute permissions, Xenia is in the external
|
||||
# storage now.
|
||||
try:
|
||||
popen = subprocess.Popen(
|
||||
["uname", "-o"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL,
|
||||
text=True)
|
||||
if popen.communicate()[0] == "Android\n":
|
||||
xb_file = os.path.join(root_path, "xenia-build.py")
|
||||
if (os.path.isfile(xb_file) and not os.access(xb_file, os.X_OK) and
|
||||
"HOME" in os.environ):
|
||||
premake_path = os.path.join(os.environ["HOME"], ".xenia-build", "premake-core")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
setup_premake_path_override()
|
||||
|
||||
|
||||
def main():
|
||||
# First try the freshly-built premake.
|
||||
premake5_bin = os.path.join(premake_path, "bin", "release", "premake5")
|
||||
if not has_bin(premake5_bin):
|
||||
# No fresh build, so fallback to checked in copy (which we may not have).
|
||||
premake5_bin = os.path.join(self_path, "bin", "premake5")
|
||||
if not has_bin(premake5_bin):
|
||||
# Still no valid binary, so build it.
|
||||
print("premake5 executable not found, attempting build...")
|
||||
build_premake()
|
||||
premake5_bin = os.path.join(premake_path, "bin", "release", "premake5")
|
||||
if not has_bin(premake5_bin):
|
||||
# Nope, boned.
|
||||
print("ERROR: cannot build premake5 executable.")
|
||||
sys.exit(1)
|
||||
|
||||
# Ensure the submodule has been checked out.
|
||||
if not os.path.exists(os.path.join(premake_path, "scripts", "package.lua")):
|
||||
print("third_party/premake-core was not present; run xb setup...")
|
||||
sys.exit(1)
|
||||
|
||||
if sys.platform == "win32":
|
||||
# Append the executable extension on windows.
|
||||
premake5_bin += ".exe"
|
||||
|
||||
return_code = shell_call([
|
||||
premake5_bin,
|
||||
f"--scripts={premake_path}",
|
||||
] + sys.argv[1:],
|
||||
throw_on_error=False)
|
||||
|
||||
sys.exit(return_code)
|
||||
|
||||
|
||||
def build_premake():
|
||||
"""Builds premake from source.
|
||||
"""
|
||||
# Ensure that on Android, premake-core is in the internal storage.
|
||||
clone_premake_to_internal_storage()
|
||||
cwd = os.getcwd()
|
||||
try:
|
||||
os.chdir(premake_path)
|
||||
if sys.platform == "darwin":
|
||||
subprocess.call([
|
||||
"make",
|
||||
"-f", "Bootstrap.mak",
|
||||
"osx",
|
||||
])
|
||||
elif sys.platform == "win32":
|
||||
# Grab Visual Studio version and execute shell to set up environment.
|
||||
vs_version = import_vs_environment()
|
||||
if not vs_version:
|
||||
print("ERROR: Visual Studio not found!")
|
||||
sys.exit(1)
|
||||
return
|
||||
|
||||
subprocess.call([
|
||||
"nmake",
|
||||
"-f", "Bootstrap.mak",
|
||||
"windows",
|
||||
])
|
||||
else:
|
||||
subprocess.call([
|
||||
"make",
|
||||
"-f", "Bootstrap.mak",
|
||||
"linux",
|
||||
])
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
pass
|
||||
|
||||
|
||||
def clone_premake_to_internal_storage():
|
||||
"""Clones premake to the Android internal storage so it can be executed.
|
||||
"""
|
||||
# premake_path is initialized to a value different than premake_submodule_path
|
||||
# if running from the Android external storage, and may not exist yet.
|
||||
if premake_path == premake_submodule_path:
|
||||
return
|
||||
|
||||
# Ensure the submodule has been checked out.
|
||||
if not os.path.exists(
|
||||
os.path.join(premake_submodule_path, "scripts", "package.lua")):
|
||||
print("third_party/premake-core was not present; run xb setup...")
|
||||
sys.exit(1)
|
||||
|
||||
# Create or refresh premake-core in the internal storage.
|
||||
print("Cloning premake5 to the internal storage...")
|
||||
rmtree(premake_path, ignore_errors=True)
|
||||
os.makedirs(premake_path)
|
||||
shell_call([
|
||||
"git",
|
||||
"clone",
|
||||
"--depth=1",
|
||||
premake_submodule_path,
|
||||
premake_path,
|
||||
])
|
||||
|
||||
|
||||
def has_bin(bin):
|
||||
"""Checks whether the given binary is present.
|
||||
"""
|
||||
for path in os.environ["PATH"].split(os.pathsep):
|
||||
if sys.platform == "win32":
|
||||
exe_file = os.path.join(path, f"{bin}.exe")
|
||||
if os.path.isfile(exe_file) and os.access(exe_file, os.X_OK):
|
||||
return True
|
||||
else:
|
||||
path = path.strip("\"")
|
||||
exe_file = os.path.join(path, bin)
|
||||
if os.path.isfile(exe_file) and os.access(exe_file, os.X_OK):
|
||||
return True
|
||||
return None
|
||||
|
||||
|
||||
def shell_call(command, throw_on_error=True, stdout_path=None, stderr_path=None, shell=False):
|
||||
"""Executes a shell command.
|
||||
|
||||
Args:
|
||||
command: Command to execute, as a list of parameters.
|
||||
throw_on_error: Whether to throw an error or return the status code.
|
||||
stdout_path: File path to write stdout output to.
|
||||
stderr_path: File path to write stderr output to.
|
||||
|
||||
Returns:
|
||||
If throw_on_error is False the status code of the call will be returned.
|
||||
"""
|
||||
stdout_file = None
|
||||
if stdout_path:
|
||||
stdout_file = open(stdout_path, "w")
|
||||
stderr_file = None
|
||||
if stderr_path:
|
||||
stderr_file = open(stderr_path, "w")
|
||||
result = 0
|
||||
try:
|
||||
if throw_on_error:
|
||||
result = 1
|
||||
subprocess.check_call(command, shell=shell, stdout=stdout_file, stderr=stderr_file)
|
||||
result = 0
|
||||
else:
|
||||
result = subprocess.call(command, shell=shell, stdout=stdout_file, stderr=stderr_file)
|
||||
finally:
|
||||
if stdout_file:
|
||||
stdout_file.close()
|
||||
if stderr_file:
|
||||
stderr_file.close()
|
||||
return result
|
||||
|
||||
|
||||
def import_vs_environment():
|
||||
"""Finds the installed Visual Studio version and imports
|
||||
interesting environment variables into os.environ.
|
||||
|
||||
Returns:
|
||||
A version such as 2022 or None if no installation is found.
|
||||
"""
|
||||
|
||||
if sys.platform != "win32":
|
||||
return None
|
||||
|
||||
version = None
|
||||
install_path = None
|
||||
env_tool_args = None
|
||||
|
||||
vswhere = subprocess.check_output(
|
||||
"tools/vswhere/vswhere.exe -version \"[17,)\" -latest -prerelease -format json -utf8 -products"
|
||||
" Microsoft.VisualStudio.Product.Enterprise"
|
||||
" Microsoft.VisualStudio.Product.Professional"
|
||||
" Microsoft.VisualStudio.Product.Community"
|
||||
" Microsoft.VisualStudio.Product.BuildTools",
|
||||
encoding="utf-8",
|
||||
)
|
||||
if vswhere:
|
||||
vswhere = jsonloads(vswhere)
|
||||
if vswhere and len(vswhere) > 0:
|
||||
version = int(vswhere[0].get("catalog", {}).get("productLineVersion", 2022))
|
||||
install_path = vswhere[0].get("installationPath", None)
|
||||
|
||||
vsdevcmd_path = os.path.join(install_path, "Common7", "Tools", "VsDevCmd.bat")
|
||||
if os.access(vsdevcmd_path, os.X_OK):
|
||||
env_tool_args = [vsdevcmd_path, "-arch=amd64", "-host_arch=amd64", "&&", "set"]
|
||||
else:
|
||||
vcvars_path = os.path.join(install_path, "VC", "Auxiliary", "Build", "vcvarsall.bat")
|
||||
env_tool_args = [vcvars_path, "x64", "&&", "set"]
|
||||
|
||||
if not version:
|
||||
return None
|
||||
|
||||
import_subprocess_environment(env_tool_args)
|
||||
os.environ["VSVERSION"] = f"{version}"
|
||||
return version
|
||||
|
||||
|
||||
def import_subprocess_environment(args):
|
||||
popen = subprocess.Popen(
|
||||
args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
||||
variables, _ = popen.communicate()
|
||||
envvars_to_save = (
|
||||
"devenvdir",
|
||||
"include",
|
||||
"lib",
|
||||
"libpath",
|
||||
"path",
|
||||
"pathext",
|
||||
"systemroot",
|
||||
"temp",
|
||||
"tmp",
|
||||
"vcinstalldir",
|
||||
"windowssdkdir",
|
||||
)
|
||||
for line in variables.splitlines():
|
||||
for envvar in envvars_to_save:
|
||||
if f"{envvar}=" in line.lower():
|
||||
var, setting = line.split("=", 1)
|
||||
if envvar == "path":
|
||||
setting = f"{os.path.dirname(sys.executable)}{os.pathsep}{setting}"
|
||||
os.environ[var.upper()] = setting
|
||||
break
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,9 +0,0 @@
|
||||
require("vstudio")
|
||||
|
||||
include("scripts/build_paths.lua")
|
||||
include("scripts/force_compile_as_c.lua")
|
||||
include("scripts/force_compile_as_cc.lua")
|
||||
include("scripts/pkg_config.lua")
|
||||
include("scripts/platform_files.lua")
|
||||
include("scripts/single_library.lua")
|
||||
include("scripts/test_suite.lua")
|
||||
@@ -1,16 +0,0 @@
|
||||
build_root = "build"
|
||||
build_bin = build_root .. "/bin/%{cfg.platform}/%{cfg.buildcfg}"
|
||||
build_gen = build_root .. "/gen/%{cfg.platform}/%{cfg.buildcfg}"
|
||||
build_obj = build_root .. "/obj/%{cfg.platform}/%{cfg.buildcfg}"
|
||||
|
||||
build_tools = "tools/build"
|
||||
build_scripts = build_tools .. "/scripts"
|
||||
build_tools_src = build_tools .. "/src"
|
||||
|
||||
if os.istarget("android") then
|
||||
platform_suffix = "android"
|
||||
elseif os.istarget("windows") then
|
||||
platform_suffix = "win"
|
||||
else
|
||||
platform_suffix = "posix"
|
||||
end
|
||||
@@ -1,32 +0,0 @@
|
||||
if premake.override then
|
||||
local forced_c_files = {}
|
||||
|
||||
-- Forces all of the given .c and .cc files to be compiled as if they were C.
|
||||
function force_compile_as_c(files)
|
||||
for _, val in ipairs(files) do
|
||||
for _, fname in ipairs(os.matchfiles(val)) do
|
||||
table.insert(forced_c_files, path.getabsolute(fname))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- for gmake
|
||||
premake.override(path, "iscfile", function(base, fname)
|
||||
if table.contains(forced_c_files, fname) then
|
||||
return true
|
||||
else
|
||||
return base(fname)
|
||||
end
|
||||
end)
|
||||
-- for msvc
|
||||
premake.override(premake.vstudio.vc2010, "additionalCompileOptions", function(base, cfg, condition)
|
||||
if cfg.abspath and table.contains(forced_c_files, cfg.abspath) then
|
||||
if condition == nil or condition == '' then
|
||||
_p(3,'<CompileAs>CompileAsC</CompileAs>')
|
||||
else
|
||||
_p(3,'<CompileAs Condition="\'$(Configuration)|$(Platform)\'==\'%s\'">CompileAsC</CompileAs>', condition)
|
||||
end
|
||||
end
|
||||
return base(cfg, condition)
|
||||
end)
|
||||
end
|
||||
@@ -1,32 +0,0 @@
|
||||
if premake.override then
|
||||
local forced_cc_files = {}
|
||||
|
||||
-- Forces all of the given .c files to be compiled as if they were C++.
|
||||
function force_compile_as_cc(files)
|
||||
for _, val in ipairs(files) do
|
||||
for _, fname in ipairs(os.matchfiles(val)) do
|
||||
table.insert(forced_cc_files, path.getabsolute(fname))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- for gmake
|
||||
premake.override(path, "iscfile", function(base, fname)
|
||||
if table.contains(forced_cc_files, fname) then
|
||||
return false
|
||||
else
|
||||
return base(fname)
|
||||
end
|
||||
end)
|
||||
-- for msvc
|
||||
premake.override(premake.vstudio.vc2010, "additionalCompileOptions", function(base, cfg, condition)
|
||||
if cfg.abspath and table.contains(forced_cc_files, cfg.abspath) then
|
||||
if condition == nil or condition == '' then
|
||||
_p(3,'<CompileAs>CompileAsCpp</CompileAs>')
|
||||
else
|
||||
_p(3,'<CompileAs Condition="\'$(Configuration)|$(Platform)\'==\'%s\'">CompileAsCpp</CompileAs>', condition)
|
||||
end
|
||||
end
|
||||
return base(cfg, condition)
|
||||
end)
|
||||
end
|
||||
@@ -1,45 +0,0 @@
|
||||
-- Helper methods to use the system pkg-config utility
|
||||
|
||||
pkg_config = {}
|
||||
|
||||
local function pkg_config_call(lib, what)
|
||||
local result, code = os.outputof("pkg-config --"..what.." "..lib)
|
||||
if result then
|
||||
return result
|
||||
else
|
||||
error("Failed to run 'pkg-config' for library '"..lib.."'. Are the development files installed?")
|
||||
end
|
||||
end
|
||||
|
||||
function pkg_config.cflags(lib)
|
||||
if not os.istarget("linux") then
|
||||
return
|
||||
end
|
||||
buildoptions({
|
||||
pkg_config_call(lib, "cflags"),
|
||||
})
|
||||
end
|
||||
|
||||
function pkg_config.lflags(lib)
|
||||
if not os.istarget("linux") then
|
||||
return
|
||||
end
|
||||
linkoptions({
|
||||
pkg_config_call(lib, "libs-only-L"),
|
||||
pkg_config_call(lib, "libs-only-other"),
|
||||
})
|
||||
-- We can't just drop the stdout of the `--libs` command in
|
||||
-- linkoptions because library order matters
|
||||
local output = pkg_config_call(lib, "libs-only-l")
|
||||
for k, flag in next, string.explode(output, " ") do
|
||||
-- remove "-l"
|
||||
if flag ~= "" then
|
||||
links(string.sub(flag, 3))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function pkg_config.all(lib)
|
||||
pkg_config.cflags(lib)
|
||||
pkg_config.lflags(lib)
|
||||
end
|
||||
@@ -1,71 +0,0 @@
|
||||
include("build_paths.lua")
|
||||
include("util.lua")
|
||||
|
||||
local function match_platform_files(base_path, base_match)
|
||||
files({
|
||||
base_path.."/"..base_match..".h",
|
||||
base_path.."/"..base_match..".c",
|
||||
base_path.."/"..base_match..".cc",
|
||||
base_path.."/"..base_match..".cpp",
|
||||
base_path.."/"..base_match..".inc",
|
||||
})
|
||||
removefiles({
|
||||
base_path.."/".."**_main.cc",
|
||||
base_path.."/".."**_test.cc",
|
||||
base_path.."/".."**_posix.h",
|
||||
base_path.."/".."**_posix.cc",
|
||||
base_path.."/".."**_linux.h",
|
||||
base_path.."/".."**_linux.cc",
|
||||
base_path.."/".."**_gnulinux.h",
|
||||
base_path.."/".."**_gnulinux.cc",
|
||||
base_path.."/".."**_x11.h",
|
||||
base_path.."/".."**_x11.cc",
|
||||
base_path.."/".."**_gtk.h",
|
||||
base_path.."/".."**_gtk.cc",
|
||||
base_path.."/".."**_android.h",
|
||||
base_path.."/".."**_android.cc",
|
||||
base_path.."/".."**_mac.h",
|
||||
base_path.."/".."**_mac.cc",
|
||||
base_path.."/".."**_win.h",
|
||||
base_path.."/".."**_win.cc",
|
||||
})
|
||||
filter("platforms:Windows")
|
||||
files({
|
||||
base_path.."/"..base_match.."_win.h",
|
||||
base_path.."/"..base_match.."_win.cc",
|
||||
})
|
||||
filter("platforms:Linux or Android-*")
|
||||
files({
|
||||
base_path.."/"..base_match.."_posix.h",
|
||||
base_path.."/"..base_match.."_posix.cc",
|
||||
base_path.."/"..base_match.."_linux.h",
|
||||
base_path.."/"..base_match.."_linux.cc",
|
||||
})
|
||||
filter("platforms:Linux")
|
||||
files({
|
||||
base_path.."/"..base_match.."_gnulinux.h",
|
||||
base_path.."/"..base_match.."_gnulinux.cc",
|
||||
base_path.."/"..base_match.."_x11.h",
|
||||
base_path.."/"..base_match.."_x11.cc",
|
||||
base_path.."/"..base_match.."_gtk.h",
|
||||
base_path.."/"..base_match.."_gtk.cc",
|
||||
})
|
||||
filter("platforms:Android-*")
|
||||
files({
|
||||
base_path.."/"..base_match.."_android.h",
|
||||
base_path.."/"..base_match.."_android.cc",
|
||||
})
|
||||
filter({})
|
||||
end
|
||||
|
||||
-- Adds all .h and .cc files in the current path that match the current platform
|
||||
-- suffix (_win, etc).
|
||||
function local_platform_files(base_path)
|
||||
match_platform_files(base_path or ".", "*")
|
||||
end
|
||||
|
||||
-- Adds all .h and .cc files in the current path and all subpaths that match
|
||||
-- the current platform suffix (_win, etc).
|
||||
function recursive_platform_files(base_path)
|
||||
match_platform_files(base_path or ".", "**")
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
SINGLE_LIBRARY_PLATFORM_PATTERNS = {
|
||||
"Android-*",
|
||||
};
|
||||
|
||||
SINGLE_LIBRARY_FILTER =
|
||||
"platforms:" .. table.concat(SINGLE_LIBRARY_PLATFORM_PATTERNS, " or ");
|
||||
NOT_SINGLE_LIBRARY_FILTER = table.translate(
|
||||
SINGLE_LIBRARY_PLATFORM_PATTERNS,
|
||||
function(pattern)
|
||||
return "platforms:not " .. pattern;
|
||||
end);
|
||||
|
||||
function single_library_windowed_app_kind()
|
||||
filter(SINGLE_LIBRARY_FILTER);
|
||||
kind("StaticLib");
|
||||
wholelib("On");
|
||||
filter(NOT_SINGLE_LIBRARY_FILTER);
|
||||
kind("WindowedApp");
|
||||
filter({});
|
||||
end
|
||||
@@ -1,99 +0,0 @@
|
||||
include("build_paths.lua")
|
||||
include("util.lua")
|
||||
|
||||
newoption({
|
||||
trigger = "test-suite-mode",
|
||||
description = "Whether to merge all tests in a test_suite into a single project",
|
||||
value = "MODE",
|
||||
allowed = {
|
||||
{ "individual", "One binary per test." },
|
||||
{ "combined", "One binary per test suite (default)." },
|
||||
},
|
||||
})
|
||||
|
||||
local function combined_test_suite(test_suite_name, project_root, base_path, config)
|
||||
group("tests")
|
||||
project(test_suite_name)
|
||||
kind("ConsoleApp")
|
||||
language("C++")
|
||||
includedirs(merge_arrays(config["includedirs"], {
|
||||
project_root.."/"..build_tools,
|
||||
project_root.."/"..build_tools_src,
|
||||
project_root.."/"..build_tools.."/third_party/catch/include",
|
||||
}))
|
||||
libdirs(merge_arrays(config["libdirs"], {
|
||||
project_root.."/"..build_bin,
|
||||
}))
|
||||
links(config["links"])
|
||||
if config.filtered_links ~= nil then
|
||||
for _, filtered_links in ipairs(config.filtered_links) do
|
||||
filter(filtered_links.filter)
|
||||
links(filtered_links.links)
|
||||
end
|
||||
filter({})
|
||||
end
|
||||
defines({
|
||||
"XE_TEST_SUITE_NAME=\""..test_suite_name.."\"",
|
||||
})
|
||||
files({
|
||||
project_root.."/"..build_tools_src.."/test_suite_main.cc",
|
||||
project_root.."/src/xenia/base/console_app_main_"..platform_suffix..".cc",
|
||||
base_path.."/**_test.cc",
|
||||
})
|
||||
filter("toolset:msc")
|
||||
-- Edit and Continue in MSVC can cause the __LINE__ macro to produce
|
||||
-- invalid values, which breaks the usability of Catch2 output on
|
||||
-- failed tests.
|
||||
editAndContinue("Off")
|
||||
end
|
||||
|
||||
local function split_test_suite(test_suite_name, project_root, base_path, config)
|
||||
local test_paths = os.matchfiles(base_path.."/**_test.cc")
|
||||
for _, file_path in pairs(test_paths) do
|
||||
local test_name = file_path:match("(.*).cc")
|
||||
group("tests/"..test_suite_name)
|
||||
project(test_suite_name.."-"..test_name)
|
||||
kind("ConsoleApp")
|
||||
language("C++")
|
||||
includedirs(merge_arrays(config["includedirs"], {
|
||||
project_root.."/"..build_tools,
|
||||
project_root.."/"..build_tools_src,
|
||||
project_root.."/"..build_tools.."/third_party/catch/include",
|
||||
}))
|
||||
libdirs(merge_arrays(config["libdirs"], {
|
||||
project_root.."/"..build_bin,
|
||||
}))
|
||||
links(config["links"])
|
||||
if config.filtered_links ~= nil then
|
||||
for _, filtered_links in ipairs(config.filtered_links) do
|
||||
filter(filtered_links.filter)
|
||||
links(filtered_links.links)
|
||||
end
|
||||
filter({})
|
||||
end
|
||||
files({
|
||||
project_root.."/"..build_tools_src.."/test_suite_main.cc",
|
||||
file_path,
|
||||
})
|
||||
filter("toolset:msc")
|
||||
-- Edit and Continue in MSVC can cause the __LINE__ macro to produce
|
||||
-- invalid values, which breaks the usability of Catch2 output on
|
||||
-- failed tests.
|
||||
editAndContinue("Off")
|
||||
end
|
||||
end
|
||||
|
||||
-- Defines a test suite binary.
|
||||
-- Can either be a single binary with all tests or one binary per test based on
|
||||
-- the --test-suite-mode= option.
|
||||
function test_suite(
|
||||
test_suite_name, -- Project or group name for the entire suite.
|
||||
project_root, -- Project root path (with build_tools/ under it).
|
||||
base_path, -- Base source path to search for _test.cc files.
|
||||
config) -- Include/lib directories and links for binaries.
|
||||
if _OPTIONS["test-suite-mode"] == "individual" then
|
||||
split_test_suite(test_suite_name, project_root, base_path, config)
|
||||
else
|
||||
combined_test_suite(test_suite_name, project_root, base_path, config)
|
||||
end
|
||||
end
|
||||
@@ -1,50 +0,0 @@
|
||||
-- Prints a table and all of its contents.
|
||||
function print_r(t)
|
||||
local print_r_cache={}
|
||||
local function sub_print_r(t, indent)
|
||||
if (print_r_cache[tostring(t)]) then
|
||||
print(indent.."*"..tostring(t))
|
||||
else
|
||||
print_r_cache[tostring(t)]=true
|
||||
if (type(t)=="table") then
|
||||
for pos,val in pairs(t) do
|
||||
if (type(val)=="table") then
|
||||
print(indent.."["..pos.."] => "..tostring(t).." {")
|
||||
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
|
||||
print(indent..string.rep(" ",string.len(pos)+6).."}")
|
||||
elseif (type(val)=="string") then
|
||||
print(indent.."["..pos..'] => "'..val..'"')
|
||||
else
|
||||
print(indent.."["..pos.."] => "..tostring(val))
|
||||
end
|
||||
end
|
||||
else
|
||||
print(indent..tostring(t))
|
||||
end
|
||||
end
|
||||
end
|
||||
if (type(t)=="table") then
|
||||
print(tostring(t).." {")
|
||||
sub_print_r(t," ")
|
||||
print("}")
|
||||
else
|
||||
sub_print_r(t," ")
|
||||
end
|
||||
print()
|
||||
end
|
||||
|
||||
-- Merges two tables and returns the resulting table.
|
||||
function merge_tables(t1, t2)
|
||||
local result = {}
|
||||
for k,v in pairs(t1 or {}) do result[k] = v end
|
||||
for k,v in pairs(t2 or {}) do result[k] = v end
|
||||
return result
|
||||
end
|
||||
|
||||
-- Merges to arrays and returns the resulting array.
|
||||
function merge_arrays(t1, t2)
|
||||
local result = {}
|
||||
for k,v in pairs(t1 or {}) do result[#result + 1] = v end
|
||||
for k,v in pairs(t2 or {}) do result[#result + 1] = v end
|
||||
return result
|
||||
end
|
||||
Reference in New Issue
Block a user