Brian Silverman | 0aa1373 | 2022-05-19 23:14:08 -0700 | [diff] [blame] | 1 | # A fake Cargo.toml for cargo-raze. This will not work well if you try actually |
| 2 | # running cargo. |
| 3 | # |
| 4 | # cargo-raze generates BUILD files etc for all dependencies listed here and in the workspace |
| 5 | # members. Hand-written BUILD files can then depend on the corresponding targets that they need. |
| 6 | # |
| 7 | # To generate BUILD files from this: |
| 8 | # ```console |
| 9 | # $ bazel run @cargo_raze//:raze -- --manifest-path=$(realpath Cargo.toml) --generate-lockfile |
| 10 | # ``` |
| 11 | # To remove unnecessary redundant BUILD files afterwards: |
| 12 | # ```console |
| 13 | # $ bazel run //tools/rust:tweak_cargo_raze_output -- $(readlink -f .) |
| 14 | # ``` |
| 15 | # |
| 16 | # # Generated targets |
| 17 | # //third_party/cargo has forwarding targets for the individual crates. Don't |
| 18 | # reference the repositories by name, because those change when they're |
| 19 | # upgraded. If you need to access another target, set `extra_aliased_targets` |
| 20 | # for the crate. |
| 21 | # |
| 22 | # See here for what you can set in the package.metadata.raze sections: |
| 23 | # https://github.com/google/cargo-raze/blob/main/impl/src/settings.rs |
| 24 | [package] |
| 25 | name = "compile_with_bazel" |
| 26 | version = "0.0.0" |
| 27 | |
| 28 | # Mandatory (or Cargo tooling is unhappy) |
| 29 | [lib] |
| 30 | path = "fake_lib.rs" |
| 31 | |
| 32 | [workspace] |
| 33 | members = [ |
| 34 | "third_party/autocxx", |
| 35 | "third_party/autocxx/engine", |
| 36 | "third_party/autocxx/parser", |
| 37 | "third_party/autocxx/gen/cmd", |
| 38 | "third_party/autocxx/macro", |
| 39 | "third_party/autocxx/integration-tests", |
| 40 | "third_party/flatbuffers/rust/flatbuffers", |
| 41 | ] |
| 42 | |
| 43 | [dependencies] |
| 44 | cxx = "1.0" |
| 45 | cxxbridge-macro = "1.0" |
| 46 | cxxbridge-cmd = "1.0" |
| 47 | uuid = "1.0" |
| 48 | toml = "0.5" |
| 49 | anyhow = "1.0" |
| 50 | |
| 51 | # For bindgen. |
| 52 | bindgen = "0.58.1" |
| 53 | libloading = "=0.6.3" |
| 54 | |
| 55 | # Bazel toolchains take care of linking the C++ standard library, so don't add |
| 56 | # an extra flag via Rust by enabling the `nothing` feature. I'm not even sure |
| 57 | # it would end up on the link command line, but this crate's build.rs attempts |
| 58 | # to find a C++ compiler itself otherwise which definitely doesn't work. |
| 59 | link-cplusplus = { version = "1.0", features = ["nothing"] } |
| 60 | |
| 61 | [package.metadata.raze.binary_deps] |
| 62 | # Needed if we want to generate BUILD files for autocxx-gen. |
| 63 | #autocxx-gen = "0.16.0" |
| 64 | |
| 65 | [workspace.metadata.raze] |
| 66 | # `cargo raze` will generate Bazel-compatible BUILD files into this path. |
| 67 | workspace_path = "//third_party/cargo" |
| 68 | |
| 69 | # Put the aliases in the same package as the BUILD files. |
| 70 | package_aliases_dir = "third_party/cargo" |
| 71 | |
| 72 | # The set of targets to generate BUILD rules for. |
| 73 | targets = [ |
| 74 | "x86_64-unknown-linux-gnu", |
| 75 | "arm-unknown-linux-gnueabi", |
| 76 | "armv7-unknown-linux-gnueabihf", |
| 77 | "aarch64-unknown-linux-gnueabi", |
| 78 | ] |
| 79 | |
| 80 | # Reference crates by URL, instead of vendoring them all. |
| 81 | genmode = "Remote" |
| 82 | |
| 83 | # TODO(Brian): This isn't great for being hermetic or repeatable, but it is the |
| 84 | # default. A lot of the problematic crates probably have pre-written versions |
| 85 | # which avoid build.rs in cargo-raze itself or elsewhere. rules_rust is another |
| 86 | # place to look. |
| 87 | # https://github.com/bazelbuild/rules_rust/blob/main/bindgen/raze/Cargo.toml |
Brian Silverman | 4e27808 | 2022-05-19 22:47:41 -0700 | [diff] [blame] | 88 | # https://github.com/google/cargo-raze/blob/main/impl/Cargo.toml |
Brian Silverman | 0aa1373 | 2022-05-19 23:14:08 -0700 | [diff] [blame] | 89 | default_gen_buildrs = true |
| 90 | |
| 91 | [package.metadata.raze.crates.cxx.'*'] |
| 92 | gen_buildrs = false |
| 93 | additional_build_file = "third_party/cargo/cxx/include.BUILD.bazel" |
| 94 | extra_aliased_targets = ["cxx_cc"] |
| 95 | |
| 96 | [package.metadata.raze.crates.cxxbridge-cmd.'*'] |
| 97 | compile_data_attr = "[\"src/gen/include/cxx.h\"]" |
| 98 | extra_aliased_targets = ["cargo_bin_cxxbridge"] |
| 99 | |
| 100 | [package.metadata.raze.crates.cxx-gen.'*'] |
| 101 | compile_data_attr = "[\"src/gen/include/cxx.h\"]" |
| 102 | |
| 103 | [package.metadata.raze.crates.supports-hyperlinks.'*'] |
| 104 | compile_data_attr = "[\"README.md\"]" |
| 105 | |
| 106 | [package.metadata.raze.crates.supports-unicode.'*'] |
| 107 | compile_data_attr = "[\"README.md\"]" |
| 108 | |
| 109 | [package.metadata.raze.crates.autocxx.'*'] |
| 110 | compile_data_attr = "[\"README.md\"]" |
| 111 | |
| 112 | [package.metadata.raze.crates.autocxx-gen.'*'] |
| 113 | extra_aliased_targets = ["cargo_bin_autocxx_gen"] |
| 114 | |
| 115 | [package.metadata.raze.crates.bindgen.'*'] |
| 116 | extra_aliased_targets = ["cargo_bin_bindgen"] |
| 117 | |
| 118 | [package.metadata.raze.crates.log.'*'] |
| 119 | additional_flags = [ |
| 120 | "--cfg=atomic_cas", |
| 121 | ] |