diff --git a/SConstruct b/SConstruct index 8f5d335..e0077cd 100644 --- a/SConstruct +++ b/SConstruct @@ -631,3 +631,81 @@ 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 = [ + "register_types.cpp", + + "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/SCsub b/platform/SCsub index 469a57e..53c2e9a 100644 --- a/platform/SCsub +++ b/platform/SCsub @@ -10,3 +10,10 @@ env.add_source_files(env.platform_sources, "sfwl.cpp") lib = env.add_library("platform", env.platform_sources) env.Prepend(LIBS=[lib]) + +# TODO Move this to somewhere else, so it can be easily overridden +env.main_sources = [] + +env.add_source_files(env.main_sources, "main.cpp") +lib = env.add_library("main", env.main_sources) +env.Prepend(LIBS=[lib]) diff --git a/platform/main.cpp b/platform/main.cpp new file mode 100644 index 0000000..79f309d --- /dev/null +++ b/platform/main.cpp @@ -0,0 +1,5 @@ + +int main() { + + return 0; +} diff --git a/platform/osx/SCsub b/platform/osx/SCsub new file mode 100644 index 0000000..df2030b --- /dev/null +++ b/platform/osx/SCsub @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +Import("env") + +from platform_methods import run_in_subprocess +import platform_osx_builders + +files = [ +] + +prog = env.add_program("#bin/pandemonium", 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/osx/platform_osx_builders.py b/platform/osx/platform_osx_builders.py new file mode 100644 index 0000000..953ed47 --- /dev/null +++ b/platform/osx/platform_osx_builders.py @@ -0,0 +1,21 @@ +"""Functions used to generate source files during build time + +All such functions are invoked in a subprocess on Windows to prevent build flakiness. + +""" +import os +from platform_methods import subprocess_main + + +def make_debug_osx(target, source, env): + if env["macports_clang"] != "no": + mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") + mpclangver = env["macports_clang"] + os.system(mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-dsymutil {0} -o {0}.dSYM".format(target[0])) + else: + os.system("dsymutil {0} -o {0}.dSYM".format(target[0])) + os.system("strip -u -r {0}".format(target[0])) + + +if __name__ == "__main__": + subprocess_main(globals()) diff --git a/platform/windows/SCsub b/platform/windows/SCsub new file mode 100644 index 0000000..46d8c88 --- /dev/null +++ b/platform/windows/SCsub @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +Import("env") + +import os +from platform_methods import run_in_subprocess +import platform_windows_builders + +common_win = [ +] + +prog = env.add_program("#bin/pandemonium", common_win + res_obj, PROGSUFFIX=env["PROGSUFFIX"]) + +# Microsoft Visual Studio Project Generation +if env["vsproj"]: + for x in common_win: + env.vs_srcs += ["platform/windows/" + str(x)] + +if not os.getenv("VCINSTALLDIR"): + if env["debug_symbols"] and env["separate_debug_symbols"]: + env.AddPostAction(prog, run_in_subprocess(platform_windows_builders.make_debug_mingw)) diff --git a/platform/windows/platform_windows_builders.py b/platform/windows/platform_windows_builders.py new file mode 100644 index 0000000..22e33b5 --- /dev/null +++ b/platform/windows/platform_windows_builders.py @@ -0,0 +1,22 @@ +"""Functions used to generate source files during build time + +All such functions are invoked in a subprocess on Windows to prevent build flakiness. + +""" +import os +from platform_methods import subprocess_main + + +def make_debug_mingw(target, source, env): + mingw_prefix = "" + if env["bits"] == "32": + mingw_prefix = env["mingw_prefix_32"] + else: + mingw_prefix = env["mingw_prefix_64"] + os.system(mingw_prefix + "objcopy --only-keep-debug {0} {0}.debugsymbols".format(target[0])) + os.system(mingw_prefix + "strip --strip-debug --strip-unneeded {0}".format(target[0])) + os.system(mingw_prefix + "objcopy --add-gnu-debuglink={0}.debugsymbols {0}".format(target[0])) + + +if __name__ == "__main__": + subprocess_main(globals()) diff --git a/platform/x11/SCsub b/platform/x11/SCsub new file mode 100644 index 0000000..a62a1a5 --- /dev/null +++ b/platform/x11/SCsub @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +Import("env") + +from platform_methods import run_in_subprocess +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) + +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/platform_x11_builders.py b/platform/x11/platform_x11_builders.py new file mode 100644 index 0000000..5884f8e --- /dev/null +++ b/platform/x11/platform_x11_builders.py @@ -0,0 +1,17 @@ +"""Functions used to generate source files during build time + +All such functions are invoked in a subprocess on Windows to prevent build flakiness. + +""" +import os +from platform_methods import subprocess_main + + +def make_debug_x11(target, source, env): + os.system("objcopy --only-keep-debug {0} {0}.debugsymbols".format(target[0])) + os.system("strip --strip-debug --strip-unneeded {0}".format(target[0])) + os.system("objcopy --add-gnu-debuglink={0}.debugsymbols {0}".format(target[0])) + + +if __name__ == "__main__": + subprocess_main(globals())