|
| 1 | +load("@rules_cc//cc/toolchains:cc_toolchain.bzl", "cc_toolchain") |
| 2 | +load("@rules_cc//cc/toolchains:cc_toolchain_suite.bzl", "cc_toolchain_suite") |
| 3 | +load(":platforms.bzl", "PROTOBUF_PLATFORMS") |
| 4 | +load(":cc_toolchain_config.bzl", "cc_toolchain_config") |
| 5 | + |
| 6 | +package(default_visibility = ["//visibility:public"]) |
| 7 | + |
| 8 | +filegroup(name = "empty") |
| 9 | + |
| 10 | +config_setting( |
| 11 | + name = "is_cross_compiling", |
| 12 | + flag_values = {":release": "True"}, |
| 13 | +) |
| 14 | + |
| 15 | +[ |
| 16 | + platform( |
| 17 | + name = name, |
| 18 | + constraint_values = config["compatible_with"], |
| 19 | + ) |
| 20 | + for name, config in PROTOBUF_PLATFORMS.items() |
| 21 | +] |
| 22 | + |
| 23 | +[ |
| 24 | + cc_toolchain( |
| 25 | + name = name + "-cc_toolchain", |
| 26 | + all_files = ":empty", |
| 27 | + compiler_files = ":empty", |
| 28 | + dwp_files = ":empty", |
| 29 | + dynamic_runtime_lib = ":empty", |
| 30 | + linker_files = ":empty", |
| 31 | + objcopy_files = ":empty", |
| 32 | + output_licenses = ["restricted"], |
| 33 | + static_runtime_lib = ":empty", |
| 34 | + strip_files = ":empty", |
| 35 | + toolchain_config = ":" + name + "-config", |
| 36 | + toolchain_identifier = name + "-cc_toolchain", |
| 37 | + ) |
| 38 | + for name in PROTOBUF_PLATFORMS.keys() |
| 39 | +] |
| 40 | + |
| 41 | +[ |
| 42 | + toolchain( |
| 43 | + name = name + "-toolchain", |
| 44 | + target_compatible_with = config["compatible_with"], |
| 45 | + toolchain = ":" + name + "-cc_toolchain", |
| 46 | + toolchain_type = "@rules_cc//cc:toolchain_type", |
| 47 | + ) |
| 48 | + for name, config in PROTOBUF_PLATFORMS.items() |
| 49 | +] |
| 50 | + |
| 51 | +cc_toolchain_config( |
| 52 | + name = "k8-config", |
| 53 | + linker_path = "/usr/bin/ld", |
| 54 | + sysroot = "/opt/manylinux/2014/x86_64", |
| 55 | + target_cpu = "x86_64", |
| 56 | + target_full_name = "x86_64-linux-gnu", |
| 57 | +) |
| 58 | + |
| 59 | +cc_toolchain_config( |
| 60 | + name = "linux-aarch_64-config", |
| 61 | + linker_path = "/usr/bin/ld", |
| 62 | + sysroot = "/opt/manylinux/2014/aarch64", |
| 63 | + target_cpu = "aarch64", |
| 64 | + target_full_name = "aarch64-linux-gnu", |
| 65 | +) |
| 66 | + |
| 67 | +cc_toolchain_config( |
| 68 | + name = "linux-ppcle_64-config", |
| 69 | + linker_path = "/usr/bin/ld", |
| 70 | + sysroot = "/opt/manylinux/2014/ppc64le", |
| 71 | + target_cpu = "ppc64", |
| 72 | + target_full_name = "powerpc64le-linux-gnu", |
| 73 | +) |
| 74 | + |
| 75 | +cc_toolchain_config( |
| 76 | + name = "linux-s390_64-config", |
| 77 | + linker_path = "/usr/bin/ld", |
| 78 | + sysroot = "/opt/manylinux/2014/s390x", |
| 79 | + target_cpu = "systemz", |
| 80 | + target_full_name = "s390x-linux-gnu", |
| 81 | +) |
| 82 | + |
| 83 | +cc_toolchain_config( |
| 84 | + name = "linux-x86_32-config", |
| 85 | + linker_path = "/usr/bin/ld", |
| 86 | + sysroot = "/opt/manylinux/2014/i686", |
| 87 | + target_cpu = "x86_32", |
| 88 | + target_full_name = "i386-linux-gnu", |
| 89 | +) |
| 90 | + |
| 91 | +cc_toolchain_config( |
| 92 | + name = "linux-x86_64-config", |
| 93 | + linker_path = "/usr/bin/ld", |
| 94 | + sysroot = "/opt/manylinux/2014/x86_64", |
| 95 | + target_cpu = "x86_64", |
| 96 | + target_full_name = "x86_64-linux-gnu", |
| 97 | +) |
| 98 | + |
| 99 | +cc_toolchain_config( |
| 100 | + name = "osx-aarch_64-config", |
| 101 | + extra_compiler_flags = [ |
| 102 | + "-I/usr/tools/xcode_14_0/macosx/usr/include/c++/v1", |
| 103 | + "-I/usr/tools/xcode_14_0/macosx/usr/include", |
| 104 | + "-F/usr/tools/xcode_14_0/macosx/System/Library/Frameworks", |
| 105 | + "-Wno-error=nullability-completeness", |
| 106 | + "-Wno-error=availability", |
| 107 | + "-Wno-error=elaborated-enum-base", |
| 108 | + ], |
| 109 | + extra_linker_flags = ["-framework CoreFoundation"], |
| 110 | + linker_path = "/usr/tools", |
| 111 | + sysroot = "/usr/tools/xcode_14_0/macosx", |
| 112 | + target_cpu = "aarch64", |
| 113 | + target_full_name = "aarch64-apple-macosx12.0", |
| 114 | +) |
| 115 | + |
| 116 | +cc_toolchain_config( |
| 117 | + name = "osx-x86_64-config", |
| 118 | + extra_compiler_flags = [ |
| 119 | + "-I/usr/tools/xcode_14_0/macosx/usr/include/c++/v1", |
| 120 | + "-I/usr/tools/xcode_14_0/macosx/usr/include", |
| 121 | + "-F/usr/tools/xcode_14_0/macosx/System/Library/Frameworks", |
| 122 | + "-Wno-error=nullability-completeness", |
| 123 | + "-Wno-error=availability", |
| 124 | + "-Wno-error=elaborated-enum-base", |
| 125 | + ], |
| 126 | + extra_linker_flags = ["-framework CoreFoundation"], |
| 127 | + linker_path = "/usr/tools", |
| 128 | + sysroot = "/usr/tools/xcode_14_0/macosx", |
| 129 | + target_cpu = "x86_64", |
| 130 | + target_full_name = "x86_64-apple-macosx12.0", |
| 131 | +) |
| 132 | + |
| 133 | +cc_toolchain_config( |
| 134 | + name = "win32-config", |
| 135 | + extra_compiler_flags = [ |
| 136 | + "-isystem/usr/lib/gcc/i686-w64-mingw32/10-posix/include/c++", |
| 137 | + "-isystem/usr/lib/gcc/i686-w64-mingw32/10-posix/include/c++/i686-w64-mingw32", |
| 138 | + ], |
| 139 | + extra_include = "/usr/lib/gcc/i686-w64-mingw32", |
| 140 | + extra_linker_flags = [ |
| 141 | + "-L/usr/lib/gcc/i686-w64-mingw32/10-posix", |
| 142 | + "-ldbghelp", |
| 143 | + "-pthread", |
| 144 | + ], |
| 145 | + linker_path = "/usr/bin/ld", |
| 146 | + sysroot = "/usr/i686-w64-mingw32", |
| 147 | + target_cpu = "x86_32", |
| 148 | + target_full_name = "i686-w64-mingw32", |
| 149 | +) |
| 150 | + |
| 151 | +cc_toolchain_config( |
| 152 | + name = "win64-config", |
| 153 | + extra_compiler_flags = [ |
| 154 | + "-isystem/usr/lib/gcc/x86_64-w64-mingw32/10-posix/include/c++/", |
| 155 | + "-isystem/usr/lib/gcc/x86_64-w64-mingw32/10-posix/include/c++/x86_64-w64-mingw32", |
| 156 | + ], |
| 157 | + extra_include = "/usr/lib/gcc/x86_64-w64-mingw32/10-posix/include", |
| 158 | + extra_linker_flags = [ |
| 159 | + "-L/usr/lib/gcc/x86_64-w64-mingw32/10-posix", |
| 160 | + "-ldbghelp", |
| 161 | + ], |
| 162 | + linker_path = "/usr/bin/ld", |
| 163 | + sysroot = "/usr/x86_64-w64-mingw32", |
| 164 | + target_cpu = "x86_64", |
| 165 | + target_full_name = "x86_64-w64-mingw32", |
| 166 | +) |
0 commit comments