Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use modern CMake #164

Merged
merged 79 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
ae43bec
Use modern CMake
FlorianPommerening Jul 26, 2023
04c92e1
Update Apple compiler ID string.
remochristen Jul 26, 2023
0ecab3e
Allow non-Apple clang again.
remochristen Jul 26, 2023
aa2b316
Remove profile build, simplify build.py
FlorianPommerening Jul 26, 2023
2b69623
Fix counting of CPUs
FlorianPommerening Jul 26, 2023
dadb7f1
Fix CMake generators
FlorianPommerening Jul 26, 2023
5534719
More modern way of setting compiler requirements
FlorianPommerening Jul 26, 2023
edc8796
Use versions in Cplex find script
FlorianPommerening Jul 26, 2023
4f149c4
Replace 'set(CMAKE_*' calls.
salome-eriksson Jul 27, 2023
7cbd214
AdBugfix: add PRIVATE keyword to target_link_libraries call
salome-eriksson Jul 27, 2023
e1e098a
define plugins as interface libraries
FlorianPommerening Jul 27, 2023
90bace8
add debug output
FlorianPommerening Jul 28, 2023
f16bd72
restructure warnings and compiler-dependent code
FlorianPommerening Jul 28, 2023
251af36
Add debug output.
salome-eriksson Jul 28, 2023
71c28fd
Remove debug output, specify COMPILER_ID var differently.
salome-eriksson Jul 28, 2023
e3af72a
Yet another way to specify COMPILER_ID (needed if cmake version less …
salome-eriksson Jul 28, 2023
c99c979
Fix typo.
salome-eriksson Jul 28, 2023
e4ccc42
use generator expressions again
FlorianPommerening Jul 28, 2023
1a7041f
Remove some TODOs, revert how to set output dir, revert commenting ou…
salome-eriksson Jul 28, 2023
b838b68
Trying out dirty hack for fixing windows cplex builds.
salome-eriksson Jul 28, 2023
3c1a5dc
Rename plugin to library.
salome-eriksson Jul 28, 2023
1de2904
Fix some code that still referenced plugin instead of library.
salome-eriksson Jul 28, 2023
8a8a3b0
Rename interface and warning library and build it as soon as FastDown…
salome-eriksson Jul 28, 2023
0192d7c
update documentation
FlorianPommerening Jul 28, 2023
d0fad92
Add project description, homepage, and languages.
remochristen Jul 28, 2023
f0aa52d
check only compiler
FlorianPommerening Jul 28, 2023
8039697
Fix build types and add some TODOs
FlorianPommerening Jul 28, 2023
31e22b8
reduce code affected by #ifdefs
FlorianPommerening Jul 28, 2023
1490f5c
Link soplex from cmake config package
FlorianPommerening Jul 29, 2023
451ab08
fix workflow for soplex
FlorianPommerening Jul 30, 2023
818cb32
fix workflow for soplex
FlorianPommerening Jul 30, 2023
defdd51
fix tox setup
FlorianPommerening Jul 30, 2023
df21a27
fix case of soplex_DIR
FlorianPommerening Jul 30, 2023
cc499bd
remove comment (no need for two cmake calls)
Jul 31, 2023
12186f9
Fix dependency test.
salome-eriksson Aug 2, 2023
1a949c2
Fix style.
salome-eriksson Aug 2, 2023
e87cc97
remove hack to explicitly look for cc variables and use gcc as fallback
Aug 2, 2023
f906705
Fix rebase error.
salome-eriksson Aug 2, 2023
bc99df4
Suppress warning when soplex was not found.
salome-eriksson Aug 2, 2023
262da58
Updated test-memory-leaks to take command line parameters for suppres…
salome-eriksson Aug 2, 2023
3f5a29e
rt and psapi are now a dependency of the UTILS library.
salome-eriksson Aug 3, 2023
bb5d339
The cmake subdirectory search is now self-contained.
salome-eriksson Aug 3, 2023
8017851
New find script for CPLEX
FlorianPommerening Aug 6, 2023
c7fcbcc
Fix problems in find script for CPLEX
FlorianPommerening Aug 6, 2023
c511b8c
Fix problems in find script for CPLEX
FlorianPommerening Aug 6, 2023
6e1605c
OS-specific find script for CPLEX
FlorianPommerening Aug 6, 2023
02237af
Remove debug output
FlorianPommerening Aug 6, 2023
1a70937
restructure cmake files
FlorianPommerening Sep 12, 2023
add0f7f
Remove displayname, lower case downward libraries
FlorianPommerening Sep 12, 2023
c1bb73c
renaming and cleanup
FlorianPommerening Sep 12, 2023
7d6da78
forgot to add renamed files
FlorianPommerening Sep 12, 2023
bb56ab7
Fix cmake copy command and comment out artifact deletion.
remochristen Sep 12, 2023
b5d6129
Use uppercase library name, remove redundant DownwardFiles.cmake, and…
remochristen Sep 12, 2023
7330af3
Move includes from macros to CMakeLists.
remochristen Sep 12, 2023
35c915c
Fix dependency test.
remochristen Sep 13, 2023
2a7408b
Fix typos and add include guard.
remochristen Sep 13, 2023
cd132b7
Reformat dependencies.
remochristen Sep 13, 2023
c40b386
Remove downward_ prefix from Fast Downward interface library names.
remochristen Sep 13, 2023
bf407c6
Remove commented-out code.
remochristen Sep 13, 2023
92dc5df
Add debug functions.
remochristen Sep 13, 2023
ba3a805
Debug print cplex::cplex.
remochristen Sep 13, 2023
8651926
Print location variable.
remochristen Sep 13, 2023
accf431
New and improved debug printing.
remochristen Sep 13, 2023
b6bf7f8
Copy DLL in a stupid way.
remochristen Sep 13, 2023
93daeb5
Add debug prints to windows workflow.
remochristen Sep 13, 2023
e371a7e
Add CMake echos.
remochristen Sep 13, 2023
38b722d
Fix CPLEX find script.
remochristen Sep 13, 2023
6504d79
check if CPLEX is a target after adding it
FlorianPommerening Sep 13, 2023
403b5e5
add more debug output
FlorianPommerening Sep 13, 2023
9a7defd
add more debug output
FlorianPommerening Sep 13, 2023
bc0afd0
try with generator expressions
FlorianPommerening Sep 13, 2023
40fb8d4
try with more generator expressions
FlorianPommerening Sep 13, 2023
0b007a7
remove debug code
FlorianPommerening Sep 13, 2023
9ad0103
fix copy command for cases on windows without cplex
FlorianPommerening Sep 14, 2023
87a61c5
evaluate the option USE_GLIBCXX_DEBUG
FlorianPommerening Sep 14, 2023
a9697e3
Minor cleanups.
remochristen Sep 15, 2023
9d7bf2f
rename some variables in test
FlorianPommerening Sep 15, 2023
c08f6be
(C)Make last remaining single-line DEPENDS into multi-line.
remochristen Sep 15, 2023
69f2e32
simplify and document --suppress option in memory leak tests
FlorianPommerening Sep 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
CPLEX_URL: ${{ secrets.CPLEX2211_LINUX_URL }}
DOWNWARD_CPLEX_ROOT: /home/runner/lib/ibm/ILOG/CPLEX_Studio2211/cplex
CPLEX_LIB: /home/runner/lib/ibm/ILOG/CPLEX_Studio2211/cplex/bin/x86-64_linux/libcplex2211.so
DOWNWARD_SOPLEX_ROOT: /home/runner/lib/soplex-6.0.3x
soplex_DIR: /home/runner/lib/soplex-6.0.3x
SOPLEX_LIB: /home/runner/lib/soplex-6.0.3x/lib/
SOPLEX_INCLUDE: /home/runner/lib/soplex-6.0.3x/include/
steps:
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
cd ..
cmake -S soplex -B build
cmake --build build
cmake --install build --prefix "${DOWNWARD_SOPLEX_ROOT}"
cmake --install build --prefix "${soplex_DIR}"
rm -rf soplex build

- name: Compile planner
Expand Down
84 changes: 37 additions & 47 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3

import errno
import multiprocessing
import os
import subprocess
import sys
Expand All @@ -12,25 +11,18 @@
if not config.startswith("_")}
DEFAULT_CONFIG_NAME = CONFIGS.pop("DEFAULT")
DEBUG_CONFIG_NAME = CONFIGS.pop("DEBUG")

CMAKE = "cmake"
DEFAULT_MAKE_PARAMETERS = []
CMAKE_GENERATOR = None
if os.name == "posix":
MAKE = "make"
try:
num_cpus = multiprocessing.cpu_count()
except NotImplementedError:
pass
else:
DEFAULT_MAKE_PARAMETERS.append('-j{}'.format(num_cpus))
CMAKE_GENERATOR = "Unix Makefiles"
elif os.name == "nt":
MAKE = "nmake"
CMAKE_GENERATOR = "NMake Makefiles"
else:
print("Unsupported OS: " + os.name)
sys.exit(1)

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()

def print_usage():
script_name = os.path.basename(__file__)
Expand All @@ -43,18 +35,16 @@ def print_usage():
configs.append(name + "\n " + " ".join(args))
configs_string = "\n ".join(configs)
cmake_name = os.path.basename(CMAKE)
make_name = os.path.basename(MAKE)
generator_name = CMAKE_GENERATOR.lower()
default_config_name = DEFAULT_CONFIG_NAME
debug_config_name = DEBUG_CONFIG_NAME
print("""Usage: {script_name} [BUILD [BUILD ...]] [--all] [--debug] [MAKE_OPTIONS]
print(f"""Usage: {script_name} [BUILD [BUILD ...]] [--all] [--debug] [MAKE_OPTIONS]

Build one or more predefined build configurations of Fast Downward. Each build
uses {cmake_name} to generate {generator_name} and then uses {make_name} to compile the
code. Build configurations differ in the parameters they pass to {cmake_name}.
By default, the build uses N threads on a machine with N cores if the number of
cores can be determined. Use the "-j" option for {cmake_name} to override this default
behaviour.
uses {cmake_name} to compile the code using {generator_name} . Build configurations
differ in the parameters they pass to {cmake_name}. By default, the build uses all
available cores if this number can be determined. Use the "-j" option for
{cmake_name} to override this default behaviour.

Build configurations
{configs_string}
Expand All @@ -64,7 +54,7 @@ def print_usage():
--help Print this message and exit.

Make options
All other parameters are forwarded to {make_name}.
All other parameters are forwarded to the build step.

Example usage:
./{script_name} # build {default_config_name} in #cores threads
Expand All @@ -73,7 +63,7 @@ def print_usage():
./{script_name} --debug # build {debug_config_name}
./{script_name} release debug # build release and debug configs
./{script_name} --all VERBOSE=true # build all build configs with detailed logs
""".format(**locals()))
""")


def get_project_root_path():
Expand All @@ -92,41 +82,41 @@ def get_src_path():
def get_build_path(config_name):
return os.path.join(get_builds_path(), config_name)

def try_run(cmd, cwd):
print('Executing command "{}" in directory "{}".'.format(" ".join(cmd), cwd))
def try_run(cmd):
print(f'Executing command "{" ".join(cmd)}"')
try:
subprocess.check_call(cmd, cwd=cwd)
subprocess.check_call(cmd)
except OSError as exc:
if exc.errno == errno.ENOENT:
print("Could not find '%s' on your PATH. For installation instructions, "
"see https://www.fast-downward.org/ObtainingAndRunningFastDownward." %
cmd[0])
print(f"Could not find '{cmd[0]}' on your PATH. For installation instructions, "
"see https://www.fast-downward.org/ObtainingAndRunningFastDownward.")
sys.exit(1)
else:
raise

def build(config_name, cmake_parameters, make_parameters):
print("Building configuration {config_name}.".format(**locals()))
def build(config_name, configure_parameters, build_parameters):
print(f"Building configuration {config_name}.")

build_path = get_build_path(config_name)
rel_src_path = os.path.relpath(get_src_path(), build_path)
try:
os.makedirs(build_path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(build_path):
pass
else:
raise
generator_cmd = [CMAKE, "-S", get_src_path(), "-B", build_path]
if CMAKE_GENERATOR:
generator_cmd += ["-G", CMAKE_GENERATOR]
generator_cmd += configure_parameters
try_run(generator_cmd)

try_run([CMAKE, "-G", CMAKE_GENERATOR] + cmake_parameters + [rel_src_path],
cwd=build_path)
try_run([MAKE] + make_parameters, cwd=build_path)
build_cmd = [CMAKE, "--build", build_path]
if NUM_CPUS:
build_cmd += ["-j", f"{NUM_CPUS}"]
if build_parameters:
build_cmd += ["--"] + build_parameters
try_run(build_cmd)

print("Built configuration {config_name} successfully.".format(**locals()))
print(f"Built configuration {config_name} successfully.")


def main():
config_names = []
make_parameters = DEFAULT_MAKE_PARAMETERS
build_parameters = []
for arg in sys.argv[1:]:
if arg == "--help" or arg == "-h":
print_usage()
Expand All @@ -138,11 +128,11 @@ def main():
elif arg in CONFIGS:
config_names.append(arg)
else:
make_parameters.append(arg)
build_parameters.append(arg)
if not config_names:
config_names.append(DEFAULT_CONFIG_NAME)
for config_name in config_names:
build(config_name, CONFIGS[config_name], make_parameters)
build(config_name, CONFIGS[config_name], build_parameters)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion build_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
release_no_lp = ["-DCMAKE_BUILD_TYPE=Release", "-DUSE_LP=NO"]
# USE_GLIBCXX_DEBUG is not compatible with USE_LP (see issue983).
glibcxx_debug = ["-DCMAKE_BUILD_TYPE=Debug", "-DUSE_LP=NO", "-DUSE_GLIBCXX_DEBUG=YES"]
minimal = ["-DCMAKE_BUILD_TYPE=Release", "-DDISABLE_PLUGINS_BY_DEFAULT=YES"]
minimal = ["-DCMAKE_BUILD_TYPE=Release", "-DDISABLE_LIBRARIES_BY_DEFAULT=YES"]

DEFAULT = "release"
DEBUG = "debug"
12 changes: 12 additions & 0 deletions misc/tests/conftest.py
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):
FlorianPommerening marked this conversation as resolved.
Show resolved Hide resolved
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')
119 changes: 71 additions & 48 deletions misc/tests/test-dependencies.py
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")
Loading