diff --git a/SConstruct b/SConstruct index 7e6e1f2..63fcea9 100644 --- a/SConstruct +++ b/SConstruct @@ -766,9 +766,22 @@ def _compile_java_plugins_in_folder(env, folder): ) +_LANGUAGE_SOURCE_BY_OPTION = { + "without-python": "Py.cxx", + "without-perl": "Perl.cxx", + "without-r": "R.cxx", +} + + def build_language_objects(env): - """Build language support objects and return the language file list.""" - languages = Glob("src/languages/*.cxx") + """Build language support objects, skipping any disabled languages.""" + disabled = { + src for opt, src in _LANGUAGE_SOURCE_BY_OPTION.items() if GetOption(opt) + } + languages = [ + node for node in Glob("src/languages/*.cxx") + if os.path.basename(node.get_path()) not in disabled + ] for language in languages: output = language.get_path().replace("src", "obj").replace(".cxx", ".os") @@ -776,8 +789,6 @@ def build_language_objects(env): return languages - env.Program("PluGen/plugen", Glob("src/PluGen/*.cxx"), CPPPATH=[Dir("src")]) - def _build_language_object(env, language, output): """Build a single language object file.""" is_perl = "Perl" in output @@ -787,11 +798,14 @@ def _build_language_object(env, language, output): def build_main_executable(env, languages): - """Build the main PluMA executable.""" - program_libs = [ - "pthread", "m", "dl", "crypt", "c", - f"python{python_version}", "util", "perl", "R", "RInside", - ] + """Build the main PluMA executable, linking only enabled language runtimes.""" + program_libs = ["pthread", "m", "dl", "crypt", "c"] + if not GetOption("without-python"): + program_libs.extend([f"python{python_version}", "util"]) + if not GetOption("without-perl"): + program_libs.append("perl") + if not GetOption("without-r"): + program_libs.extend(["R", "RInside"]) env.Append(LIBPATH=[LibPath("")]) env.Program( diff --git a/src/PluginManager.h b/src/PluginManager.h index 886f115..230424d 100755 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -46,10 +46,18 @@ #include #include "languages/Compiled.h" +#ifdef HAVE_PYTHON #include "languages/Py.h" +#endif +#ifdef HAVE_R #include "languages/R.h" +#endif +#ifdef HAVE_PERL #include "languages/Perl.h" +#endif +#ifdef HAVE_JAVA #include "languages/Java.h" +#endif #ifdef HAVE_RUST #include "languages/Rust.h" #endif @@ -122,9 +130,15 @@ class PluginManager { #else supported.push_back(new Compiled("C", "so", pluginpath, "lib")); #endif +#ifdef HAVE_PYTHON supported.push_back(new Py("Python", "py", pluginpath)); +#endif +#ifdef HAVE_R supported.push_back(new MiAMi::R("R", "R", pluginpath, argc, argv)); +#endif +#ifdef HAVE_PERL supported.push_back(new Perl("Perl", "pl", pluginpath)); +#endif #ifdef HAVE_JAVA supported.push_back(new Java("Java", "class", pluginpath)); #endif