Skip to content

Commit

Permalink
Makes it possible for header only libs to be buidl tested.
Browse files Browse the repository at this point in the history
This adds the concept of "testable header only" recipes. Those are
recipes for header only libraries that also include a "test_package"
that should be built across configurations to check for correct
functioning of header libs that have platform and/or system
requirements. This resolves issue
bincrafters/community#1391
  • Loading branch information
grafikrobot committed Jul 14, 2021
1 parent dcbcab9 commit 0c22e0b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
23 changes: 19 additions & 4 deletions bincrafters/autodetect.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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")) \
Expand All @@ -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():
Expand Down
10 changes: 10 additions & 0 deletions bincrafters/build_autodetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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)? {}"
Expand All @@ -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()
Expand Down

0 comments on commit 0c22e0b

Please sign in to comment.