diff --git a/bincrafters/autodetect.py b/bincrafters/autodetect.py index 909ff33..31c9c68 100644 --- a/bincrafters/autodetect.py +++ b/bincrafters/autodetect.py @@ -1,8 +1,6 @@ import os from bincrafters.build_shared import get_recipe_path, inspect_value_from_recipe -_recipe_path = os.path.dirname(get_recipe_path()) - def _file_contains(file, word): """ Read file and search for word @@ -40,13 +38,21 @@ def recipe_has_setting(setting_name): def is_custom_build_py_existing() -> (bool, str): - custom_build_path = os.path.join(_recipe_path, "build.py") + custom_build_path = os.path.join(os.path.dirname(get_recipe_path()), "build.py") if os.path.isfile(custom_build_path): return True, custom_build_path return False, None +def has_test_package(): + test_package_path = os.path.join(os.path.dirname(get_recipe_path()), "test_package") + if os.path.isdir(test_package_path): + return True + + return False + + def is_pure_c(): if recipe_contains("del self.settings.compiler.libcxx") and recipe_contains("del self.settings.compiler.cppstd"): return True @@ -65,6 +71,13 @@ def is_unconditional_header_only(): return False +def is_testable_header_only(): + if is_unconditional_header_only() and has_test_package(): + return True + + return False + + def is_installer(): if not is_unconditional_header_only() and not is_conditional_header_only(): if (recipe_contains("self.env_info.PATH.append") or recipe_contains("self.env_info.PATH.extend")) \ @@ -78,7 +91,9 @@ def autodetect() -> str: if is_installer(): return "installer" else: - if is_unconditional_header_only(): + if is_testable_header_only(): + return "testable_header_only" + elif is_unconditional_header_only(): return "unconditional_header_only" else: if is_conditional_header_only(): diff --git a/bincrafters/build_autodetect.py b/bincrafters/build_autodetect.py index 90fb00c..dce2276 100644 --- a/bincrafters/build_autodetect.py +++ b/bincrafters/build_autodetect.py @@ -65,6 +65,9 @@ def run_autodetect(): ### # Output collected recipe information in the builds logs ### + recipe_conanfile = get_recipe_path() + printer.print_message("Recipe path: {}".format(str(recipe_conanfile))) + recipe_is_installer = is_installer() printer.print_message("Is the package an installer for executable(s)? {}" .format(str(recipe_is_installer))) @@ -74,6 +77,10 @@ def run_autodetect(): printer.print_message("Is the package header only? {}" .format(str(recipe_is_unconditional_header_only))) + recipe_is_testable_header_only = is_testable_header_only() + printer.print_message("Is the package testable header only? {}" + .format(str(recipe_is_testable_header_only))) + if not recipe_is_unconditional_header_only: recipe_is_conditional_header_only = is_conditional_header_only() printer.print_message("Is the package conditionally header only ('header_only' option)? {}" @@ -98,6 +105,9 @@ def run_autodetect(): builder = build_template_installer.get_builder(**kwargs) builder.add({"os": get_os(), "arch_build": arch, "arch": arch}, {}, {}, {}) builder.run() + elif is_testable_header_only(): + builder = build_template_header_only.get_builder(**kwargs) + builder.run() elif recipe_is_unconditional_header_only: builder = build_template_header_only.get_builder(**kwargs) builder.run()