github.com/prysmaticlabs/prysm@v1.4.4/tools/cross-toolchain/cc_toolchain_config_windows.bzl.tpl (about) 1 load( 2 "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", 3 "action_config", 4 "feature", 5 "feature_set", 6 "flag_group", 7 "flag_set", 8 "make_variable", 9 "tool", 10 "tool_path", 11 "with_feature_set", 12 "artifact_name_pattern", 13 "env_set", 14 "env_entry", 15 ) 16 17 load( 18 "@bazel_tools//tools/cpp:cc_toolchain_config.bzl", 19 ALL_COMPILE_ACTIONS = "all_compile_actions", 20 ALL_CPP_COMPILE_ACTIONS = "all_cpp_compile_actions", 21 ALL_LINK_ACTIONS = "all_link_actions", 22 ) 23 24 load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") 25 26 def _impl(ctx): 27 toolchain_identifier = "msys_x64_mingw" 28 host_system_name = "local" 29 target_system_name = "local" 30 target_cpu = "x64_windows" 31 target_libc = "mingw" 32 compiler = "mingw-gcc" 33 abi_version = "local" 34 abi_libc_version = "local" 35 cc_target_os = None 36 builtin_sysroot = None 37 action_configs = [] 38 39 install = "/usr/x86_64-w64-mingw32/" 40 gcc_libpath = "/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/" 41 bin_prefix = "/usr/bin/x86_64-w64-mingw32-" 42 43 44 targets_windows_feature = feature( 45 name = "targets_windows", 46 implies = ["copy_dynamic_libraries_to_binary"], 47 enabled = True, 48 ) 49 50 copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary") 51 52 gcc_env_feature = feature( 53 name = "gcc_env", 54 enabled = True, 55 env_sets = [ 56 env_set( 57 actions = [ 58 ACTION_NAMES.c_compile, 59 ACTION_NAMES.cpp_compile, 60 ACTION_NAMES.cpp_module_compile, 61 ACTION_NAMES.cpp_module_codegen, 62 ACTION_NAMES.cpp_header_parsing, 63 ACTION_NAMES.assemble, 64 ACTION_NAMES.preprocess_assemble, 65 ACTION_NAMES.cpp_link_executable, 66 ACTION_NAMES.cpp_link_dynamic_library, 67 ACTION_NAMES.cpp_link_nodeps_dynamic_library, 68 ACTION_NAMES.cpp_link_static_library, 69 ], 70 env_entries = [ 71 env_entry(key = "PATH", value = "NOT_USED"), 72 ], 73 ), 74 ], 75 ) 76 77 msys_mingw_flags = [ 78 "-B " + install + "bin", 79 "-nostdinc", 80 "-U_FORTIFY_SOURCE", 81 "-fstack-protector", 82 "-fno-omit-frame-pointer", 83 "-fcolor-diagnostics", 84 "-Wall", 85 "-Wthread-safety", 86 "-Wself-assign", 87 "-x c++", 88 "-lstdc++", 89 "-lpthread" 90 ] 91 92 msys_mingw_link_flags = [ 93 "-l:libstdc++.a", 94 "-L" + install + "lib", 95 "-L/usr/lib/gcc/x86_64-w64-mingw32/8.3-w32", 96 "-v", 97 "-lm", 98 "-no-canonical-prefixes", 99 ] 100 101 default_compile_flags_feature = feature( 102 name = "default_compile_flags", 103 enabled = True, 104 flag_sets = [ 105 flag_set( 106 actions = [ 107 ACTION_NAMES.assemble, 108 ACTION_NAMES.preprocess_assemble, 109 ACTION_NAMES.linkstamp_compile, 110 ACTION_NAMES.c_compile, 111 ACTION_NAMES.cpp_compile, 112 ACTION_NAMES.cpp_header_parsing, 113 ACTION_NAMES.cpp_module_compile, 114 ACTION_NAMES.cpp_module_codegen, 115 ACTION_NAMES.lto_backend, 116 ACTION_NAMES.clif_match, 117 ], 118 ), 119 flag_set( 120 actions = [ 121 ACTION_NAMES.linkstamp_compile, 122 ACTION_NAMES.cpp_compile, 123 ACTION_NAMES.cpp_header_parsing, 124 ACTION_NAMES.cpp_module_compile, 125 ACTION_NAMES.cpp_module_codegen, 126 ACTION_NAMES.lto_backend, 127 ACTION_NAMES.clif_match, 128 ], 129 flag_groups = ([flag_group(flags = msys_mingw_flags)] if msys_mingw_flags else []), 130 ), 131 ], 132 ) 133 134 compiler_param_file_feature = feature( 135 name = "compiler_param_file", 136 ) 137 138 default_link_flags_feature = feature( 139 name = "default_link_flags", 140 enabled = True, 141 flag_sets = [ 142 flag_set( 143 actions = ALL_LINK_ACTIONS, 144 flag_groups = ([flag_group(flags = msys_mingw_link_flags)] if msys_mingw_link_flags else []), 145 ), 146 ], 147 ) 148 149 supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) 150 151 features = [ 152 targets_windows_feature, 153 copy_dynamic_libraries_to_binary_feature, 154 gcc_env_feature, 155 default_compile_flags_feature, 156 compiler_param_file_feature, 157 default_link_flags_feature, 158 supports_dynamic_linker_feature, 159 ] 160 161 cxx_builtin_include_directories = [ 162 install +"include", 163 gcc_libpath +"include", 164 gcc_libpath +"include-fixed", 165 "/usr/share/mingw-w64/include/" 166 ] 167 168 artifact_name_patterns = [ 169 artifact_name_pattern( 170 category_name = "executable", 171 prefix = "", 172 extension = ".exe", 173 ), 174 ] 175 176 make_variables = [] 177 tool_paths = [ 178 tool_path(name = "ld", path = bin_prefix + "ld"), 179 tool_path(name = "cpp", path = bin_prefix + "cpp"), 180 tool_path(name = "gcov", path = "/usr/bin/gcov"), 181 tool_path(name = "nm", path = bin_prefix + "nm"), 182 tool_path(name = "objcopy", path = bin_prefix + "objcopy"), 183 tool_path(name = "objdump", path = bin_prefix + "objdump"), 184 tool_path(name = "strip", path = bin_prefix + "strip"), 185 tool_path(name = "gcc", path = bin_prefix + "gcc"), 186 tool_path(name = "ar", path = bin_prefix + "ar"), 187 ] 188 189 return cc_common.create_cc_toolchain_config_info( 190 ctx = ctx, 191 features = features, 192 action_configs = action_configs, 193 artifact_name_patterns = artifact_name_patterns, 194 cxx_builtin_include_directories = cxx_builtin_include_directories, 195 toolchain_identifier = toolchain_identifier, 196 host_system_name = host_system_name, 197 target_system_name = target_system_name, 198 target_cpu = target_cpu, 199 target_libc = target_libc, 200 compiler = compiler, 201 abi_version = abi_version, 202 abi_libc_version = abi_libc_version, 203 tool_paths = tool_paths, 204 make_variables = make_variables, 205 builtin_sysroot = builtin_sysroot, 206 cc_target_os = cc_target_os, 207 ) 208 209 windows_cc_toolchain_config = rule( 210 implementation = _impl, 211 attrs = { 212 "target": attr.string(mandatory = True), 213 "stdlib": attr.string(), 214 }, 215 provides = [CcToolchainConfigInfo], 216 ) 217