Created
April 14, 2025 13:02
-
-
Save lucasmeijer/4c639007fd9090b7a95d4e94055f7355 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Header files | |
filegroup( | |
name = "header_files", | |
srcs = glob(["**/*.h", "**/*.inl"]), | |
) | |
# Generate object files using glob patterns | |
[genrule( | |
name = file.replace("/", "_").replace(".cpp", "_o"), | |
srcs = [file, ":header_files"], | |
outs = [file.replace("/", "_").replace(".cpp", ".o")], | |
cmd = "clang++ -c $(location " + file + ") -o $@ -std=c++20 -I. -fvisibility=hidden", | |
) for file in glob( | |
["CoreLib/*.cpp", "EntityCore/*.cpp", "Safety/*.cpp", "Tests.cpp"], | |
exclude = [] | |
)] | |
# Create a filegroup for all object files | |
filegroup( | |
name = "all_object_files", | |
srcs = [":{}".format(file.replace("/", "_").replace(".cpp", "_o")) for file in glob( | |
["CoreLib/*.cpp", "EntityCore/*.cpp", "Safety/*.cpp", "Tests.cpp"], | |
exclude = [] | |
)], | |
) | |
# Directly link all object files into an executable | |
genrule( | |
name = "entity_tests", | |
srcs = [":all_object_files"], | |
outs = ["entity_tests_bin"], | |
cmd = "clang++ $(SRCS) -o $@ -lstdc++", | |
) | |
# Test running rule | |
genrule( | |
name = "run_tests", | |
srcs = [":entity_tests"], | |
outs = ["test_output.log"], | |
cmd = "$(location :entity_tests) > $(location test_output.log) 2>&1 || true", | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment