From ff114c379ff842e252a59e9b98f63a8e2a58b231 Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 25 Jan 2024 16:33:10 +0100 Subject: [PATCH] More sfw build fixes. --- .gitignore | 2 + SConstruct | 156 +++++++++++++++++++++-------------------- platform/main.cpp | 17 ++++- platform/osx/SCsub | 2 +- platform/sfw.cpp | 4 +- platform/windows/SCsub | 2 +- platform/x11/SCsub | 5 +- platform/x11/detect.py | 23 ++---- 8 files changed, 109 insertions(+), 102 deletions(-) diff --git a/.gitignore b/.gitignore index 45b0cdb..414c37f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ config.log .sconsign.dblite gdnative_cpp/ + +bin/ diff --git a/SConstruct b/SConstruct index f4c8d90..71ea193 100644 --- a/SConstruct +++ b/SConstruct @@ -28,6 +28,82 @@ platform_apis = [] 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/*")): if not os.path.isdir(x) or not os.path.exists(x + "/detect.py"): continue @@ -322,6 +398,8 @@ if env_base["rids"] == "tracked_handles": env_base.Append(CPPDEFINES=["RID_HANDLE_ALLOCATION_TRACKING_ENABLED"]) print("WARNING: Building with RIDs as tracked handles.") +#env_base.Append(LIBS=["stdc++"]) + if selected_platform in platform_list: tmppath = "./platform/" + selected_platform sys.path.insert(0, tmppath) @@ -582,9 +660,12 @@ if selected_platform in platform_list: Export("env") # build subdirs, the build order is dependent on link order. + add_mlpp(env) SConscript("platform/SCsub") + SConscript("platform/" + selected_platform + "/SCsub") # build selected platform + # Microsoft Visual Studio Project Generation if env["vsproj"]: if os.name != "nt": @@ -636,78 +717,3 @@ def 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) - diff --git a/platform/main.cpp b/platform/main.cpp index 79f309d..2a6233e 100644 --- a/platform/main.cpp +++ b/platform/main.cpp @@ -1,5 +1,20 @@ +#include "sfw.h" + +//#include "test/mlpp_tests.h" +//#include "test/mlpp_matrix_tests.h" + int main() { + SFWCore::setup(); - return 0; + //Ref tests; + //tests.instance(); + + //tests->test_statistics(); + + //tests->test_multivariate_linear_regression_gradient_descent(true); + + SFWCore::cleanup(); + + return 0; } diff --git a/platform/osx/SCsub b/platform/osx/SCsub index df2030b..2f4a219 100644 --- a/platform/osx/SCsub +++ b/platform/osx/SCsub @@ -8,7 +8,7 @@ import platform_osx_builders files = [ ] -prog = env.add_program("#bin/pandemonium", files) +prog = env.add_program("#bin/pmlpp", files) if env["debug_symbols"] and env["separate_debug_symbols"]: env.AddPostAction(prog, run_in_subprocess(platform_osx_builders.make_debug_osx)) diff --git a/platform/sfw.cpp b/platform/sfw.cpp index 1b4a7cc..177dcd7 100644 --- a/platform/sfw.cpp +++ b/platform/sfw.cpp @@ -8438,7 +8438,7 @@ String *RLogger::get_string_ptr(const char *p_prefix, const char *p_function, co return s; } void RLogger::return_string_ptr(String *str) { - delete str; + memdelete(str); } String *RLogger::get_trace_string_ptr(const int p_default_size) { @@ -19586,7 +19586,7 @@ Array::~Array() { #line 1 "sfw/object/psignal.cpp" void Signal::connect_static(void (*func)(Signal *)) { - StaticSignalEntry *se = new StaticSignalEntry(); + StaticSignalEntry *se = memnew(StaticSignalEntry()); se->func = func; entries.push_back(se); diff --git a/platform/windows/SCsub b/platform/windows/SCsub index 46d8c88..9f42d04 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -9,7 +9,7 @@ import platform_windows_builders 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 if env["vsproj"]: diff --git a/platform/x11/SCsub b/platform/x11/SCsub index a62a1a5..6c4ef2f 100644 --- a/platform/x11/SCsub +++ b/platform/x11/SCsub @@ -8,10 +8,7 @@ import platform_x11_builders common_x11 = [ ] -if "udev" in env and env["udev"]: - common_x11.append("libudev-so_wrap.c") - -prog = env.add_program("#bin/pandemonium", common_x11) +prog = env.add_program("#bin/pmlpp", common_x11) if env["debug_symbols"] and env["separate_debug_symbols"]: env.AddPostAction(prog, run_in_subprocess(platform_x11_builders.make_debug_x11)) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index ee2ea5b..293ec0e 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -372,6 +372,8 @@ def configure(env): env.Append(LIBS=["pthread"]) + env.Append(LIBS=["m"]) + if platform.system() == "Linux": env.Append(LIBS=["dl"]) @@ -384,24 +386,6 @@ def configure(env): if env["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 if is64 and env["bits"] == "32": @@ -421,3 +405,6 @@ def configure(env): else: if env["use_llvm"] and platform.system() != "FreeBSD": env.Append(LIBS=["atomic"]) + + + env.Append(LIBS=["stdc++"])