-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[issue1097] Modernize the CMake build system.
We update our build system and now require CMake 3.16. In order to add new files for compilation, they now have to be listed within a library in src/search/CMakeLists.txt. SoPlex installations should now set the environment variable soplex_DIR instead of DOWNWARD_SOPLEX_ROOT. The name of CMake options changed from, e.g., PLUGIN_FF_HEURISTIC_ENABLED to LIBRARY_FF_HEURISTIC_ENABLED.
- Loading branch information
1 parent
17ae77a
commit 6b192cd
Showing
22 changed files
with
1,466 additions
and
1,546 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is read by pytest before running the tests to set them up. | ||
# We use it to add the option '--suppress' to the tests that is used by | ||
# memory leak tests to ignore compiler-specific false positives. | ||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--suppress", action="append", default=[], | ||
help="Suppression files used in test-memory-leaks.py.") | ||
|
||
def pytest_generate_tests(metafunc): | ||
if "suppression_files" in metafunc.fixturenames: | ||
supression_files = list(metafunc.config.option.suppress) | ||
metafunc.parametrize("suppression_files", [supression_files], scope='session') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,86 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import re | ||
import shutil | ||
import subprocess | ||
import sys | ||
|
||
DIR = os.path.dirname(os.path.abspath(__file__)) | ||
REPO = os.path.dirname(os.path.dirname(DIR)) | ||
DOWNWARD_FILES = os.path.join(REPO, "src", "search", "DownwardFiles.cmake") | ||
TEST_BUILD_CONFIGS = os.path.join(REPO, "test_build_configs.py") | ||
BUILD = os.path.join(REPO, "build.py") | ||
BUILDS = os.path.join(REPO, "builds") | ||
paths_to_clean = [TEST_BUILD_CONFIGS] | ||
|
||
|
||
def clean_up(paths_to_clean): | ||
print("\nCleaning up") | ||
for path in paths_to_clean: | ||
print("Removing {path}".format(**locals())) | ||
if os.path.isfile(path): | ||
os.remove(path) | ||
if os.path.isdir(path): | ||
shutil.rmtree(path) | ||
print("Done cleaning") | ||
|
||
|
||
with open(DOWNWARD_FILES) as d: | ||
content = d.readlines() | ||
|
||
content = [line for line in content if '#' not in line] | ||
content = [line for line in content if 'NAME' in line or 'CORE_PLUGIN' in line or 'DEPENDENCY_ONLY' in line] | ||
|
||
plugins_to_be_tested = [] | ||
for line in content: | ||
if 'NAME' in line: | ||
plugins_to_be_tested.append(line.replace("NAME", "").strip()) | ||
if 'CORE_PLUGIN' in line or 'DEPENDENCY_ONLY' in line: | ||
plugins_to_be_tested.pop() | ||
|
||
with open(TEST_BUILD_CONFIGS, "w") as f: | ||
for plugin in plugins_to_be_tested: | ||
lowercase = plugin.lower() | ||
line = "{lowercase} = [\"-DCMAKE_BUILD_TYPE=Debug\", \"-DDISABLE_PLUGINS_BY_DEFAULT=YES\"," \ | ||
" \"-DPLUGIN_{plugin}_ENABLED=True\"]\n".format(**locals()) | ||
f.write(line) | ||
paths_to_clean.append(os.path.join(BUILDS, lowercase)) | ||
|
||
plugins_failed_test = [] | ||
for plugin in plugins_to_be_tested: | ||
LIBRARY_DEFINITION_FILE = os.path.join(REPO, "src", "search", "CMakeLists.txt") | ||
BUILDS = os.path.join(REPO, "builds/test-dependencies") | ||
|
||
|
||
# Find the closing bracket matching the opening bracket that occurred before start | ||
def find_corresponding_closing_bracket(content, start): | ||
nested_level = 1 | ||
for index, character in enumerate(content[start:]): | ||
if character == "(": | ||
nested_level += 1 | ||
if character == ")": | ||
nested_level -= 1 | ||
if nested_level == 0: | ||
return index+start | ||
|
||
# Extract all "create_fast_downward_library(...)" blocks and if the library is | ||
# not a core or depencency library, add its name to the return list. | ||
def get_library_definitions(content): | ||
libraries = [] | ||
library_definition_string = r"create_fast_downward_library\(" | ||
pattern = re.compile(library_definition_string) | ||
for library_match in pattern.finditer(content): | ||
start = library_match.start()+len(library_definition_string) | ||
end = find_corresponding_closing_bracket(content, start) | ||
library_definition = content[start:end] | ||
# we cannot manually en-/disable core and dependency only libraries | ||
if any(s in library_definition for s in ["CORE_LIBRARY", "DEPENDENCY_ONLY"]): | ||
continue | ||
name_match = re.search(r"NAME\s+(\S+)", library_definition) | ||
assert name_match | ||
name = name_match.group(1) | ||
libraries.append(name) | ||
return libraries | ||
|
||
|
||
# Try to get the number of CPUs | ||
try: | ||
# Number of usable CPUs (Unix only) | ||
NUM_CPUS = len(os.sched_getaffinity(0)) | ||
except AttributeError: | ||
# Number of available CPUs as a fall-back (may be None) | ||
NUM_CPUS = os.cpu_count() | ||
|
||
# Read in the file where libraries are defined and extract the library names. | ||
with open(LIBRARY_DEFINITION_FILE) as d: | ||
content = d.read() | ||
content = re.sub(r"#(.*)", "", content) # Remove all comments | ||
libraries = get_library_definitions(content) | ||
|
||
# Build each library and add it to libraries_failed_test if not successfull. | ||
libraries_failed_test = [] | ||
for library in libraries: | ||
build_path = os.path.join(BUILDS, library.lower()) | ||
config_cmd = [ | ||
"cmake", "-S", os.path.join(REPO, "src"), "-B", build_path, | ||
"-DCMAKE_BUILD_TYPE=Debug", "-DDISABLE_LIBRARIES_BY_DEFAULT=YES", | ||
f"-DLIBRARY_{library.upper()}_ENABLED=True" | ||
] | ||
build_cmd = ["cmake", "--build", build_path] | ||
if NUM_CPUS: | ||
build_cmd += ["-j", f"{NUM_CPUS}"] | ||
|
||
try: | ||
subprocess.check_call([BUILD, plugin.lower()]) | ||
subprocess.check_call(config_cmd) | ||
subprocess.check_call(build_cmd) | ||
except subprocess.CalledProcessError: | ||
plugins_failed_test.append(plugin) | ||
libraries_failed_test.append(library) | ||
|
||
if plugins_failed_test: | ||
# Report the result of the test. | ||
if libraries_failed_test: | ||
print("\nFailure:") | ||
for plugin in plugins_failed_test: | ||
print("{plugin} failed dependencies test".format(**locals())) | ||
for library in libraries_failed_test: | ||
print("{library} failed dependencies test".format(**locals())) | ||
sys.exit(1) | ||
else: | ||
print("\nAll plugins have passed dependencies test") | ||
clean_up(paths_to_clean) | ||
print("\nAll libraries have passed dependencies test") |
Oops, something went wrong.