diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 000000000..4aa73996b --- /dev/null +++ b/.style.yapf @@ -0,0 +1,4 @@ +[style] +COLUMN_LIMIT = 80 +INDENT_WIDTH = 4 +USE_TABS = False diff --git a/chapter-01/recipe-10/cxx-example/menu.yml b/chapter-01/recipe-10/cxx-example/menu.yml index 3cda3d89f..747ff69d0 100644 --- a/chapter-01/recipe-10/cxx-example/menu.yml +++ b/chapter-01/recipe-10/cxx-example/menu.yml @@ -1,3 +1,7 @@ +appveyor: + configurations: + - 'Release' + drone: definitions: - CMAKE_CXX_COMPILER: 'pgc++' diff --git a/chapter-03/recipe-02/c-example/menu.yml b/chapter-03/recipe-02/c-example/menu.yml index d18ea8575..6cf6a6d59 100644 --- a/chapter-03/recipe-02/c-example/menu.yml +++ b/chapter-03/recipe-02/c-example/menu.yml @@ -4,4 +4,3 @@ appveyor: definitions: - CMAKE_BUILD_TYPE: 'Release' - CMAKE_CONFIGURATION_TYPES: 'Release' - - MS_WIN64: 'ON' diff --git a/chapter-03/recipe-03/cxx-example/CMakeLists.txt b/chapter-03/recipe-03/cxx-example/CMakeLists.txt index 48b3fd7e8..9b60b9155 100644 --- a/chapter-03/recipe-03/cxx-example/CMakeLists.txt +++ b/chapter-03/recipe-03/cxx-example/CMakeLists.txt @@ -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} diff --git a/chapter-03/recipe-03/cxx-example/menu.yml b/chapter-03/recipe-03/cxx-example/menu.yml index d18ea8575..6cf6a6d59 100644 --- a/chapter-03/recipe-03/cxx-example/menu.yml +++ b/chapter-03/recipe-03/cxx-example/menu.yml @@ -4,4 +4,3 @@ appveyor: definitions: - CMAKE_BUILD_TYPE: 'Release' - CMAKE_CONFIGURATION_TYPES: 'Release' - - MS_WIN64: 'ON' diff --git a/chapter-03/recipe-09/cxx-example-3.5/menu.yml b/chapter-03/recipe-09/cxx-example-3.5/menu.yml index 915995ec3..ccd59a996 100644 --- a/chapter-03/recipe-09/cxx-example-3.5/menu.yml +++ b/chapter-03/recipe-09/cxx-example-3.5/menu.yml @@ -1,6 +1,4 @@ appveyor: failing_generators: - - 'MSYS Makefiles' - - 'Ninja' - 'Visual Studio 14 2015' - 'Visual Studio 15 2017' diff --git a/chapter-03/recipe-09/cxx-example/menu.yml b/chapter-03/recipe-09/cxx-example/menu.yml index 915995ec3..ccd59a996 100644 --- a/chapter-03/recipe-09/cxx-example/menu.yml +++ b/chapter-03/recipe-09/cxx-example/menu.yml @@ -1,6 +1,4 @@ appveyor: failing_generators: - - 'MSYS Makefiles' - - 'Ninja' - 'Visual Studio 14 2015' - 'Visual Studio 15 2017' diff --git a/testing/collect_tests.py b/testing/collect_tests.py index 54a911ecc..4d357d186 100644 --- a/testing/collect_tests.py +++ b/testing/collect_tests.py @@ -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(): @@ -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() @@ -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 @@ -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 @@ -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) diff --git a/testing/dependencies/appveyor/install.bat b/testing/dependencies/appveyor/install.bat index acd108ab9..d1678b53e 100644 --- a/testing/dependencies/appveyor/install.bat +++ b/testing/dependencies/appveyor/install.bat @@ -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" \ No newline at end of file +bash -lc "pacman -S --noconfirm mingw64/mingw-w64-x86_64-eigen3" +bash -lc "pacman -S --noconfirm mingw64/mingw-w64-x86_64-pkg-config" \ No newline at end of file diff --git a/testing/parse.py b/testing/parse.py index b61307405..6148a58df 100644 --- a/testing/parse.py +++ b/testing/parse.py @@ -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) @@ -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]: @@ -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