Skip to content

Commit

Permalink
Extend menu.yml to accept configurations (argument to --config)
Browse files Browse the repository at this point in the history
This is needed for Visual Studio, which can generate debug and release
builds at once. The behavior can only be controlled passing --config
to CMake when building it would seem.
  • Loading branch information
robertodr committed May 17, 2018
1 parent 068ac09 commit 144b3e4
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 25 deletions.
4 changes: 4 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[style]
COLUMN_LIMIT = 80
INDENT_WIDTH = 4
USE_TABS = False
4 changes: 4 additions & 0 deletions chapter-01/recipe-10/cxx-example/menu.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
appveyor:
configurations:
- 'Release'

drone:
definitions:
- CMAKE_CXX_COMPILER: 'pgc++'
1 change: 0 additions & 1 deletion chapter-03/recipe-02/c-example/menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ appveyor:
definitions:
- CMAKE_BUILD_TYPE: 'Release'
- CMAKE_CONFIGURATION_TYPES: 'Release'
- MS_WIN64: 'ON'
6 changes: 6 additions & 0 deletions chapter-03/recipe-03/cxx-example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ else()
Py3-pure-embedding.cpp
)
endif()
if(WIN32)
target_compile_definitions(pure-embedding
PUBLIC
"hypot=_hypot"
)
endif()
target_include_directories(pure-embedding
PRIVATE
${PYTHON_INCLUDE_DIRS}
Expand Down
1 change: 0 additions & 1 deletion chapter-03/recipe-03/cxx-example/menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ appveyor:
definitions:
- CMAKE_BUILD_TYPE: 'Release'
- CMAKE_CONFIGURATION_TYPES: 'Release'
- MS_WIN64: 'ON'
2 changes: 0 additions & 2 deletions chapter-03/recipe-09/cxx-example-3.5/menu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
appveyor:
failing_generators:
- 'MSYS Makefiles'
- 'Ninja'
- 'Visual Studio 14 2015'
- 'Visual Studio 15 2017'
2 changes: 0 additions & 2 deletions chapter-03/recipe-09/cxx-example/menu.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
appveyor:
failing_generators:
- 'MSYS Makefiles'
- 'Ninja'
- 'Visual Studio 14 2015'
- 'Visual Studio 15 2017'
50 changes: 34 additions & 16 deletions testing/collect_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def run_command(step, command, expect_failure):
child_return_code = child.returncode

return_code = 0
sys.stdout.write(colorama.Fore.BLUE + colorama.Style.BRIGHT +
' {0} ... '.format(step))
sys.stdout.write(
colorama.Fore.BLUE + colorama.Style.BRIGHT + ' {0} ... '.format(step))
if child_return_code == 0:
sys.stdout.write(colorama.Fore.GREEN + colorama.Style.BRIGHT + 'OK\n')
if verbose_output():
Expand All @@ -60,8 +60,8 @@ def run_command(step, command, expect_failure):
sys.stdout.write(colorama.Fore.YELLOW + colorama.Style.BRIGHT +
'EXPECTED TO FAIL\n')
else:
sys.stdout.write(colorama.Fore.RED + colorama.Style.BRIGHT +
'FAILED\n')
sys.stdout.write(
colorama.Fore.RED + colorama.Style.BRIGHT + 'FAILED\n')
sys.stderr.write(stdout + stderr + '\n')
return_code = child_return_code
sys.stdout.flush()
Expand All @@ -70,19 +70,18 @@ def run_command(step, command, expect_failure):
return return_code


def run_example(topdir, generator, ci_environment, buildflags, recipe,
example):
def run_example(topdir, generator, ci_environment, buildflags, recipe, example):

# extract global menu
menu_file = os.path.join(topdir, 'testing', 'menu.yml')
expect_failure_global, env_global, definitions_global, targets_global = extract_menu_file(
expect_failure_global, env_global, definitions_global, targets_global, configurations_global = extract_menu_file(
menu_file, generator, ci_environment)

sys.stdout.write('\n {}\n'.format(example))

# extract local menu
menu_file = os.path.join(recipe, example, 'menu.yml')
expect_failure_local, env_local, definitions_local, targets_local = extract_menu_file(
expect_failure_local, env_local, definitions_local, targets_local, configurations_local = extract_menu_file(
menu_file, generator, ci_environment)

expect_failure = expect_failure_global or expect_failure_local
Expand All @@ -100,10 +99,15 @@ def run_example(topdir, generator, ci_environment, buildflags, recipe,
# local targets extend global targets
targets = targets_global + targets_local

# local configurations override global ones
configurations = configurations_global.copy()
for entry in configurations_local:
configurations[entry] = configurations_local[entry]

for entry in env:
os.environ[entry] = env[entry]
definitions_string = ' '.join('-D{0}={1}'.format(entry, definitions[entry])
for entry in definitions)
definitions_string = ' '.join(
'-D{0}={1}'.format(entry, definitions[entry]) for entry in definitions)

# we append a time stamp to the build directory
# to avoid it being re-used when running tests multiple times
Expand Down Expand Up @@ -143,18 +147,32 @@ def run_example(topdir, generator, ci_environment, buildflags, recipe,
return_code += run_command(
step=step, command=command, expect_failure=expect_failure)

base_command = 'cmake --build {0}'.format(build_directory)

# build step
step = 'building'
command = 'cmake --build {0} -- {1}'.format(build_directory,
buildflags)
return_code += run_command(
step=step, command=command, expect_failure=expect_failure)
if configurations:
for c in configurations:
step += ' configuration {}'.format(c)
config = '--config {}'.format(c)
# append configuration to base command
base_command += ' {0}'.format(config)
# form build command by appending tool-native buildflags
command = base_command + ' -- {0}'.format(buildflags)
# ready to roll
return_code += run_command(
step=step, command=command, expect_failure=expect_failure)
else:
# form build command by appending tool-native buildflags
command = base_command + ' -- {0}'.format(buildflags)
# ready to roll
return_code += run_command(
step=step, command=command, expect_failure=expect_failure)

# extra targets
for target in targets:
step = target
command = 'cmake --build {0} --target {1}'.format(
build_directory, target)
command = base_command + ' --target {1}'.format(target)
return_code += run_command(
step=step, command=command, expect_failure=expect_failure)

Expand Down
3 changes: 2 additions & 1 deletion testing/dependencies/appveyor/install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ rem more packages
bash -lc "pacman -S --noconfirm mingw64/mingw-w64-x86_64-boost"
bash -lc "pacman -S --noconfirm mingw64/mingw-w64-x86_64-ninja"
bash -lc "pacman -S --noconfirm mingw64/mingw-w64-x86_64-openblas"
bash -lc "pacman -S --noconfirm mingw64/mingw-w64-x86_64-eigen3"
bash -lc "pacman -S --noconfirm mingw64/mingw-w64-x86_64-eigen3"
bash -lc "pacman -S --noconfirm mingw64/mingw-w64-x86_64-pkg-config"
11 changes: 9 additions & 2 deletions testing/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def extract_menu_file(file_name, generator, ci_environment):
env: dictionary of environment variables passed to CMake
definitions: dictionary of CMake configure-step definitions
targets: list of targets to build
configurations: list of CMake configurations to build (Debug, Release, ...)
'''
config = parse_yaml(file_name)

Expand All @@ -35,8 +36,14 @@ def extract_menu_file(file_name, generator, ci_environment):
for entry in config['targets']:
targets.append(entry)

# assemble configurations
configurations = []
if 'configurations' in config:
for entry in config['configurations']:
configurations.append(entry)

if ci_environment not in config:
return False, {}, {}, targets
return False, {}, {}, targets, configurations

failing_generators = []
if 'failing_generators' in config[ci_environment]:
Expand All @@ -59,4 +66,4 @@ def extract_menu_file(file_name, generator, ci_environment):
v = entry[k]
definitions[k] = v

return expect_failure, env, definitions, targets
return expect_failure, env, definitions, targets, configurations

0 comments on commit 144b3e4

Please sign in to comment.