|
| 1 | +const std = @import("std"); |
| 2 | + |
| 3 | +const version = .{ .major = 3, .minor = 7, .patch = 1 }; |
| 4 | + |
| 5 | +pub fn build(b: *std.Build) !void { |
| 6 | + const target = b.standardTargetOptions(.{}); |
| 7 | + const optimize = b.standardOptimizeOption(.{}); |
| 8 | + |
| 9 | + const upstream = b.dependency("upstream", .{ .target = target, .optimize = optimize }); |
| 10 | + |
| 11 | + const add_prefix = b.option(bool, "add-prefix", "Prefix all macros with CATCH_") orelse false; |
| 12 | + const console_width = b.option(u32, "console-width", "Number of columns in the output: affects line wraps. (Defaults to 80)") orelse 80; |
| 13 | + const fast_compile = b.option(bool, "fast-compile", "Sacrifices some (rather minor) features for compilation speed") orelse false; |
| 14 | + const disable = b.option(bool, "disable", "Disables assertions and test case registration") orelse false; |
| 15 | + |
| 16 | + const config = b.addConfigHeader( |
| 17 | + .{ |
| 18 | + .style = .{ .cmake = upstream.path("src/catch2/catch_user_config.hpp.in") }, |
| 19 | + .include_path = "catch2/catch_user_config.hpp", |
| 20 | + }, |
| 21 | + .{ |
| 22 | + .CATCH_CONFIG_PREFIX_ALL = add_prefix, |
| 23 | + .CATCH_CONFIG_CONSOLE_WIDTH = console_width, |
| 24 | + .CATCH_CONFIG_FAST_COMPILE = fast_compile, |
| 25 | + .CATCH_CONFIG_DISABLE = disable, |
| 26 | + .CATCH_CONFIG_DEFAULT_REPORTER = null, |
| 27 | + .CATCH_CONFIG_FALLBACK_STRINGIFIER = null, |
| 28 | + }, |
| 29 | + ); |
| 30 | + |
| 31 | + const catch2 = b.addStaticLibrary(.{ .name = "catch2", .target = target, .optimize = optimize }); |
| 32 | + catch2.addCSourceFiles(.{ |
| 33 | + .root = upstream.path("src/catch2"), |
| 34 | + .files = &source_files, |
| 35 | + .flags = &CXXFLAGS, |
| 36 | + }); |
| 37 | + catch2.installConfigHeader(config); |
| 38 | + |
| 39 | + const with_main = b.addStaticLibrary(.{ .name = "Catch2WithMain", .target = target, .optimize = optimize }); |
| 40 | + with_main.addCSourceFiles(.{ |
| 41 | + .root = upstream.path("src/catch2/internal"), |
| 42 | + .files = &.{"catch_main.cpp"}, |
| 43 | + .flags = &CXXFLAGS, |
| 44 | + }); |
| 45 | + |
| 46 | + const libs = [_]*std.Build.Step.Compile{ catch2, with_main }; |
| 47 | + for (libs) |lib| { |
| 48 | + lib.linkLibCpp(); |
| 49 | + lib.addIncludePath(upstream.path("src")); |
| 50 | + lib.addConfigHeader(config); |
| 51 | + b.installArtifact(lib); |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +const CXXFLAGS = .{ |
| 56 | + "--std=c++20", |
| 57 | + "-Wall", |
| 58 | + "-Wextra", |
| 59 | + "-Werror", |
| 60 | +}; |
| 61 | + |
| 62 | +const source_files = .{ |
| 63 | + "benchmark/catch_chronometer.cpp", |
| 64 | + "benchmark/detail/catch_analyse.cpp", |
| 65 | + "benchmark/detail/catch_benchmark_function.cpp", |
| 66 | + "benchmark/detail/catch_run_for_at_least.cpp", |
| 67 | + "benchmark/detail/catch_stats.cpp", |
| 68 | + |
| 69 | + "catch_approx.cpp", |
| 70 | + "catch_assertion_result.cpp", |
| 71 | + "catch_config.cpp", |
| 72 | + "catch_get_random_seed.cpp", |
| 73 | + "catch_message.cpp", |
| 74 | + "catch_registry_hub.cpp", |
| 75 | + "catch_session.cpp", |
| 76 | + "catch_tag_alias_autoregistrar.cpp", |
| 77 | + "catch_test_case_info.cpp", |
| 78 | + "catch_test_spec.cpp", |
| 79 | + "catch_timer.cpp", |
| 80 | + "catch_tostring.cpp", |
| 81 | + "catch_totals.cpp", |
| 82 | + "catch_translate_exception.cpp", |
| 83 | + "catch_version.cpp", |
| 84 | + "internal/catch_assertion_handler.cpp", |
| 85 | + "internal/catch_case_insensitive_comparisons.cpp", |
| 86 | + "internal/catch_clara.cpp", |
| 87 | + "internal/catch_commandline.cpp", |
| 88 | + "internal/catch_console_colour.cpp", |
| 89 | + "internal/catch_context.cpp", |
| 90 | + "internal/catch_debug_console.cpp", |
| 91 | + "internal/catch_debugger.cpp", |
| 92 | + "internal/catch_decomposer.cpp", |
| 93 | + "internal/catch_enforce.cpp", |
| 94 | + "internal/catch_enum_values_registry.cpp", |
| 95 | + "internal/catch_errno_guard.cpp", |
| 96 | + "internal/catch_exception_translator_registry.cpp", |
| 97 | + "internal/catch_fatal_condition_handler.cpp", |
| 98 | + "internal/catch_floating_point_helpers.cpp", |
| 99 | + "internal/catch_getenv.cpp", |
| 100 | + "internal/catch_istream.cpp", |
| 101 | + "internal/catch_jsonwriter.cpp", |
| 102 | + "internal/catch_lazy_expr.cpp", |
| 103 | + "internal/catch_leak_detector.cpp", |
| 104 | + "internal/catch_list.cpp", |
| 105 | + "internal/catch_message_info.cpp", |
| 106 | + "internal/catch_output_redirect.cpp", |
| 107 | + "internal/catch_parse_numbers.cpp", |
| 108 | + "internal/catch_polyfills.cpp", |
| 109 | + "internal/catch_random_number_generator.cpp", |
| 110 | + "internal/catch_random_seed_generation.cpp", |
| 111 | + "internal/catch_reporter_registry.cpp", |
| 112 | + "internal/catch_reporter_spec_parser.cpp", |
| 113 | + "internal/catch_reusable_string_stream.cpp", |
| 114 | + "internal/catch_run_context.cpp", |
| 115 | + "internal/catch_section.cpp", |
| 116 | + "internal/catch_singletons.cpp", |
| 117 | + "internal/catch_source_line_info.cpp", |
| 118 | + "internal/catch_startup_exception_registry.cpp", |
| 119 | + "internal/catch_stdstreams.cpp", |
| 120 | + "internal/catch_string_manip.cpp", |
| 121 | + "internal/catch_stringref.cpp", |
| 122 | + "internal/catch_tag_alias_registry.cpp", |
| 123 | + "internal/catch_test_case_info_hasher.cpp", |
| 124 | + "internal/catch_test_case_registry_impl.cpp", |
| 125 | + "internal/catch_test_case_tracker.cpp", |
| 126 | + "internal/catch_test_failure_exception.cpp", |
| 127 | + "internal/catch_test_registry.cpp", |
| 128 | + "internal/catch_test_spec_parser.cpp", |
| 129 | + "internal/catch_textflow.cpp", |
| 130 | + "internal/catch_uncaught_exceptions.cpp", |
| 131 | + "internal/catch_wildcard_pattern.cpp", |
| 132 | + "internal/catch_xmlwriter.cpp", |
| 133 | + |
| 134 | + "interfaces/catch_interfaces_capture.cpp", |
| 135 | + "interfaces/catch_interfaces_config.cpp", |
| 136 | + "interfaces/catch_interfaces_exception.cpp", |
| 137 | + "interfaces/catch_interfaces_generatortracker.cpp", |
| 138 | + "interfaces/catch_interfaces_registry_hub.cpp", |
| 139 | + "interfaces/catch_interfaces_reporter.cpp", |
| 140 | + "interfaces/catch_interfaces_reporter_factory.cpp", |
| 141 | + "interfaces/catch_interfaces_testcase.cpp", |
| 142 | + |
| 143 | + "generators/catch_generator_exception.cpp", |
| 144 | + "generators/catch_generators.cpp", |
| 145 | + "generators/catch_generators_random.cpp", |
| 146 | + |
| 147 | + "matchers/catch_matchers.cpp", |
| 148 | + "matchers/catch_matchers_container_properties.cpp", |
| 149 | + "matchers/catch_matchers_exception.cpp", |
| 150 | + "matchers/catch_matchers_floating_point.cpp", |
| 151 | + "matchers/catch_matchers_predicate.cpp", |
| 152 | + "matchers/catch_matchers_quantifiers.cpp", |
| 153 | + "matchers/catch_matchers_string.cpp", |
| 154 | + "matchers/catch_matchers_templated.cpp", |
| 155 | + "matchers/internal/catch_matchers_impl.cpp", |
| 156 | + |
| 157 | + "reporters/catch_reporter_automake.cpp", |
| 158 | + "reporters/catch_reporter_common_base.cpp", |
| 159 | + "reporters/catch_reporter_compact.cpp", |
| 160 | + "reporters/catch_reporter_console.cpp", |
| 161 | + "reporters/catch_reporter_cumulative_base.cpp", |
| 162 | + "reporters/catch_reporter_event_listener.cpp", |
| 163 | + "reporters/catch_reporter_helpers.cpp", |
| 164 | + "reporters/catch_reporter_json.cpp", |
| 165 | + "reporters/catch_reporter_junit.cpp", |
| 166 | + "reporters/catch_reporter_multi.cpp", |
| 167 | + "reporters/catch_reporter_registrars.cpp", |
| 168 | + "reporters/catch_reporter_sonarqube.cpp", |
| 169 | + "reporters/catch_reporter_streaming_base.cpp", |
| 170 | + "reporters/catch_reporter_tap.cpp", |
| 171 | + "reporters/catch_reporter_teamcity.cpp", |
| 172 | + "reporters/catch_reporter_xml.cpp", |
| 173 | +}; |
0 commit comments