More sfw build fixes.

This commit is contained in:
Relintai 2024-01-25 16:33:10 +01:00
parent 5a7dca5818
commit ff114c379f
8 changed files with 109 additions and 102 deletions

2
.gitignore vendored
View File

@ -17,3 +17,5 @@ config.log
.sconsign.dblite .sconsign.dblite
gdnative_cpp/ gdnative_cpp/
bin/

View File

@ -28,6 +28,82 @@ platform_apis = []
time_at_start = time.time() time_at_start = time.time()
def add_mlpp(env):
env.modules_sources = []
module_env = env.Clone()
module_env.pmlpp_build_tests = True
if ARGUMENTS.get('pmlpp_build_tests', 'yes') == 'no':
module_env.pmlpp_build_tests = False
sources = [
"lin_alg/mlpp_vector.cpp",
"lin_alg/mlpp_matrix.cpp",
"lin_alg/mlpp_tensor3.cpp",
"activation/activation.cpp",
"ann/ann.cpp",
"auto_encoder/auto_encoder.cpp",
"bernoulli_nb/bernoulli_nb.cpp",
"c_log_log_reg/c_log_log_reg.cpp",
"convolutions/convolutions.cpp",
"cost/cost.cpp",
"data/data.cpp",
"dual_svc/dual_svc.cpp",
"exp_reg/exp_reg.cpp",
"gan/gan.cpp",
"gaussian_nb/gaussian_nb.cpp",
"gauss_markov_checker/gauss_markov_checker.cpp",
"hidden_layer/hidden_layer.cpp",
"hypothesis_testing/hypothesis_testing.cpp",
"kmeans/kmeans.cpp",
"knn/knn.cpp",
"lin_alg/lin_alg.cpp",
"lin_reg/lin_reg.cpp",
"log_reg/log_reg.cpp",
"mann/mann.cpp",
"mlp/mlp.cpp",
"multinomial_nb/multinomial_nb.cpp",
"multi_output_layer/multi_output_layer.cpp",
"numerical_analysis/numerical_analysis.cpp",
"outlier_finder/outlier_finder.cpp",
"output_layer/output_layer.cpp",
"pca/pca.cpp",
"probit_reg/probit_reg.cpp",
"regularization/reg.cpp",
"softmax_net/softmax_net.cpp",
"softmax_reg/softmax_reg.cpp",
"stat/stat.cpp",
"svc/svc.cpp",
"tanh_reg/tanh_reg.cpp",
"transforms/transforms.cpp",
"uni_lin_reg/uni_lin_reg.cpp",
"utilities/utilities.cpp",
"wgan/wgan.cpp",
]
if module_env.pmlpp_build_tests:
module_env.Prepend(CPPDEFINES=["TESTS_ENABLED"])
sources += [
"test/mlpp_tests.cpp",
"test/mlpp_matrix_tests.cpp",
]
if ARGUMENTS.get('pmlpp_shared', 'no') == 'yes':
# Shared lib compilation
module_env.Append(CCFLAGS=['-fPIC'])
module_env['LIBS'] = []
shared_lib = module_env.SharedLibrary(target='#bin/pmlpp', source=sources)
shared_lib_shim = shared_lib[0].name.rsplit('.', 1)[0]
env.Append(LIBS=[shared_lib_shim])
env.Append(LIBPATH=['#bin'])
else:
# Static compilation
module_env.add_source_files(env.modules_sources, sources)
for x in sorted(glob.glob("platform/*")): for x in sorted(glob.glob("platform/*")):
if not os.path.isdir(x) or not os.path.exists(x + "/detect.py"): if not os.path.isdir(x) or not os.path.exists(x + "/detect.py"):
continue continue
@ -322,6 +398,8 @@ if env_base["rids"] == "tracked_handles":
env_base.Append(CPPDEFINES=["RID_HANDLE_ALLOCATION_TRACKING_ENABLED"]) env_base.Append(CPPDEFINES=["RID_HANDLE_ALLOCATION_TRACKING_ENABLED"])
print("WARNING: Building with RIDs as tracked handles.") print("WARNING: Building with RIDs as tracked handles.")
#env_base.Append(LIBS=["stdc++"])
if selected_platform in platform_list: if selected_platform in platform_list:
tmppath = "./platform/" + selected_platform tmppath = "./platform/" + selected_platform
sys.path.insert(0, tmppath) sys.path.insert(0, tmppath)
@ -582,9 +660,12 @@ if selected_platform in platform_list:
Export("env") Export("env")
# build subdirs, the build order is dependent on link order. # build subdirs, the build order is dependent on link order.
add_mlpp(env)
SConscript("platform/SCsub") SConscript("platform/SCsub")
SConscript("platform/" + selected_platform + "/SCsub") # build selected platform
# Microsoft Visual Studio Project Generation # Microsoft Visual Studio Project Generation
if env["vsproj"]: if env["vsproj"]:
if os.name != "nt": if os.name != "nt":
@ -636,78 +717,3 @@ def print_elapsed_time():
atexit.register(print_elapsed_time) atexit.register(print_elapsed_time)
env.modules_sources = []
module_env = env.Clone()
module_env.pmlpp_build_tests = True
if ARGUMENTS.get('pmlpp_build_tests', 'yes') == 'no':
module_env.pmlpp_build_tests = False
sources = [
"lin_alg/mlpp_vector.cpp",
"lin_alg/mlpp_matrix.cpp",
"lin_alg/mlpp_tensor3.cpp",
"activation/activation.cpp",
"ann/ann.cpp",
"auto_encoder/auto_encoder.cpp",
"bernoulli_nb/bernoulli_nb.cpp",
"c_log_log_reg/c_log_log_reg.cpp",
"convolutions/convolutions.cpp",
"cost/cost.cpp",
"data/data.cpp",
"dual_svc/dual_svc.cpp",
"exp_reg/exp_reg.cpp",
"gan/gan.cpp",
"gaussian_nb/gaussian_nb.cpp",
"gauss_markov_checker/gauss_markov_checker.cpp",
"hidden_layer/hidden_layer.cpp",
"hypothesis_testing/hypothesis_testing.cpp",
"kmeans/kmeans.cpp",
"knn/knn.cpp",
"lin_alg/lin_alg.cpp",
"lin_reg/lin_reg.cpp",
"log_reg/log_reg.cpp",
"mann/mann.cpp",
"mlp/mlp.cpp",
"multinomial_nb/multinomial_nb.cpp",
"multi_output_layer/multi_output_layer.cpp",
"numerical_analysis/numerical_analysis.cpp",
"outlier_finder/outlier_finder.cpp",
"output_layer/output_layer.cpp",
"pca/pca.cpp",
"probit_reg/probit_reg.cpp",
"regularization/reg.cpp",
"softmax_net/softmax_net.cpp",
"softmax_reg/softmax_reg.cpp",
"stat/stat.cpp",
"svc/svc.cpp",
"tanh_reg/tanh_reg.cpp",
"transforms/transforms.cpp",
"uni_lin_reg/uni_lin_reg.cpp",
"utilities/utilities.cpp",
"wgan/wgan.cpp",
]
if module_env.pmlpp_build_tests:
module_env.Prepend(CPPDEFINES=["TESTS_ENABLED"])
sources += [
"test/mlpp_tests.cpp",
"test/mlpp_matrix_tests.cpp",
]
if ARGUMENTS.get('pmlpp_shared', 'no') == 'yes':
# Shared lib compilation
module_env.Append(CCFLAGS=['-fPIC'])
module_env['LIBS'] = []
shared_lib = module_env.SharedLibrary(target='#bin/pmlpp', source=sources)
shared_lib_shim = shared_lib[0].name.rsplit('.', 1)[0]
env.Append(LIBS=[shared_lib_shim])
env.Append(LIBPATH=['#bin'])
else:
# Static compilation
module_env.add_source_files(env.modules_sources, sources)

View File

@ -1,5 +1,20 @@
#include "sfw.h"
//#include "test/mlpp_tests.h"
//#include "test/mlpp_matrix_tests.h"
int main() { int main() {
SFWCore::setup();
//Ref<MLPPTests> tests;
//tests.instance();
//tests->test_statistics();
//tests->test_multivariate_linear_regression_gradient_descent(true);
SFWCore::cleanup();
return 0; return 0;
} }

View File

@ -8,7 +8,7 @@ import platform_osx_builders
files = [ files = [
] ]
prog = env.add_program("#bin/pandemonium", files) prog = env.add_program("#bin/pmlpp", files)
if env["debug_symbols"] and env["separate_debug_symbols"]: if env["debug_symbols"] and env["separate_debug_symbols"]:
env.AddPostAction(prog, run_in_subprocess(platform_osx_builders.make_debug_osx)) env.AddPostAction(prog, run_in_subprocess(platform_osx_builders.make_debug_osx))

View File

@ -8438,7 +8438,7 @@ String *RLogger::get_string_ptr(const char *p_prefix, const char *p_function, co
return s; return s;
} }
void RLogger::return_string_ptr(String *str) { void RLogger::return_string_ptr(String *str) {
delete str; memdelete(str);
} }
String *RLogger::get_trace_string_ptr(const int p_default_size) { String *RLogger::get_trace_string_ptr(const int p_default_size) {
@ -19586,7 +19586,7 @@ Array::~Array() {
#line 1 "sfw/object/psignal.cpp" #line 1 "sfw/object/psignal.cpp"
void Signal::connect_static(void (*func)(Signal *)) { void Signal::connect_static(void (*func)(Signal *)) {
StaticSignalEntry *se = new StaticSignalEntry(); StaticSignalEntry *se = memnew(StaticSignalEntry());
se->func = func; se->func = func;
entries.push_back(se); entries.push_back(se);

View File

@ -9,7 +9,7 @@ import platform_windows_builders
common_win = [ common_win = [
] ]
prog = env.add_program("#bin/pandemonium", common_win + res_obj, PROGSUFFIX=env["PROGSUFFIX"]) prog = env.add_program("#bin/pmlpp", common_win + res_obj, PROGSUFFIX=env["PROGSUFFIX"])
# Microsoft Visual Studio Project Generation # Microsoft Visual Studio Project Generation
if env["vsproj"]: if env["vsproj"]:

View File

@ -8,10 +8,7 @@ import platform_x11_builders
common_x11 = [ common_x11 = [
] ]
if "udev" in env and env["udev"]: prog = env.add_program("#bin/pmlpp", common_x11)
common_x11.append("libudev-so_wrap.c")
prog = env.add_program("#bin/pandemonium", common_x11)
if env["debug_symbols"] and env["separate_debug_symbols"]: if env["debug_symbols"] and env["separate_debug_symbols"]:
env.AddPostAction(prog, run_in_subprocess(platform_x11_builders.make_debug_x11)) env.AddPostAction(prog, run_in_subprocess(platform_x11_builders.make_debug_x11))

View File

@ -372,6 +372,8 @@ def configure(env):
env.Append(LIBS=["pthread"]) env.Append(LIBS=["pthread"])
env.Append(LIBS=["m"])
if platform.system() == "Linux": if platform.system() == "Linux":
env.Append(LIBS=["dl"]) env.Append(LIBS=["dl"])
@ -384,24 +386,6 @@ def configure(env):
if env["execinfo"]: if env["execinfo"]:
env.Append(LIBS=["execinfo"]) env.Append(LIBS=["execinfo"])
if True:#not env["tools"]:
import subprocess
import re
linker_version_str = subprocess.check_output(
[env.subst(env["LINK"]), "-Wl,--version"] + env.subst(env["LINKFLAGS"])
).decode("utf-8")
gnu_ld_version = re.search("^GNU ld [^$]*(\d+\.\d+)$", linker_version_str, re.MULTILINE)
if not gnu_ld_version:
print(
"Warning: Creating export template binaries enabled for PCK embedding is currently only supported with GNU ld, not gold, LLD or mold."
)
else:
if float(gnu_ld_version.group(1)) >= 2.30:
env.Append(LINKFLAGS=["-T", "platform/x11/pck_embed.ld"])
else:
env.Append(LINKFLAGS=["-T", "platform/x11/pck_embed.legacy.ld"])
## Cross-compilation ## Cross-compilation
if is64 and env["bits"] == "32": if is64 and env["bits"] == "32":
@ -421,3 +405,6 @@ def configure(env):
else: else:
if env["use_llvm"] and platform.system() != "FreeBSD": if env["use_llvm"] and platform.system() != "FreeBSD":
env.Append(LIBS=["atomic"]) env.Append(LIBS=["atomic"])
env.Append(LIBS=["stdc++"])