diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 699cac6..fc4b32e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,12 +1,12 @@ name: Regression Build and Test -on: +on: push: - branches: [ "main" ] - + branches: ["main"] + pull_request: - branches: [ "main" ] - + branches: ["main"] + env: CARGO_TERM_COLOR: always @@ -15,15 +15,18 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - name: Install Protoc - uses: arduino/setup-protoc@v3 - with: - version: "27.3" - - - name: Build - run: cargo build --verbose - - - name: Run tests - run: cargo test --verbose + - uses: actions/checkout@v4 + + - name: Install Protoc + uses: arduino/setup-protoc@v3 + with: + version: "29.5" + + - name: Build + run: cargo build --verbose + + - name: Regenerate sources and check for uncommitted changes + run: cargo xtask generate check-dirty + + - name: Run tests + run: cargo test --verbose diff --git a/.protoc-version b/.protoc-version index 383283e..6fbdc91 100644 --- a/.protoc-version +++ b/.protoc-version @@ -1 +1 @@ -27.3 +29.5 diff --git a/Cargo.lock b/Cargo.lock index 977dd3b..f76cd0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,6 +26,56 @@ dependencies = [ "memchr", ] +[[package]] +name = "anstream" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +dependencies = [ + "windows-sys 0.60.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.60.2", +] + [[package]] name = "anyhow" version = "1.0.86" @@ -76,12 +126,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.7.1" @@ -103,6 +147,52 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clap" +version = "4.5.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + [[package]] name = "either" version = "1.13.0" @@ -169,17 +259,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" -[[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "gimli" version = "0.29.0" @@ -248,6 +327,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.13.0" @@ -317,6 +402,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + [[package]] name = "pbjson" version = "0.7.0" @@ -381,15 +472,6 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" -[[package]] -name = "ppv-lite86" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" -dependencies = [ - "zerocopy", -] - [[package]] name = "prettyplease" version = "0.2.22" @@ -470,36 +552,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - [[package]] name = "regex" version = "1.10.6" @@ -550,9 +602,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" @@ -576,9 +628,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" dependencies = [ "itoa", "memchr", @@ -601,6 +653,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "syn" version = "2.0.76" @@ -765,10 +823,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +name = "utf8parse" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" [[package]] name = "windows-sys" @@ -776,7 +840,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -785,7 +849,16 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.3", ] [[package]] @@ -794,14 +867,31 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] @@ -810,48 +900,96 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "winnow" version = "0.6.18" @@ -865,21 +1003,11 @@ dependencies = [ name = "xds-api" version = "0.2.0" dependencies = [ - "anyhow", "enum-map", - "glob", "pbjson", - "pbjson-build", "prost", - "prost-build", - "prost-types", - "rand", "serde", - "serde_json", - "toml", "tonic", - "tonic-build", - "xshell", ] [[package]] @@ -898,22 +1026,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547" [[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "byteorder", - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +name = "xtask" +version = "0.1.0" dependencies = [ - "proc-macro2", - "quote", - "syn", + "anyhow", + "clap", + "glob", + "pbjson-build", + "prost", + "prost-build", + "prost-types", + "serde", + "serde_json", + "toml", + "tonic", + "tonic-build", + "xshell", ] diff --git a/Cargo.toml b/Cargo.toml index 3d2cdf1..4f290a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,38 +11,36 @@ description = """ Protocol buffer types for working with Envoy's xDS APIs. """ keywords = ["grpc", "xds", "envoy"] - # we use std::sync::LazyLock rust-version = "1.81" +[workspace] +members = [".", "xtask"] + +[workspace.dependencies] +pbjson = "0.7" +pbjson-build = "0.7" +prost = "0.13" +prost-build = "0.13" +prost-types = "0.13" +serde = "1.0" +tonic = { version = "0.12", default-features = false } +tonic-build = { version = "0.12", default-features = false } + [lib] doctest = false + [dependencies] enum-map = "2.7" -prost = "0.13" -tonic = { version = "0.12", default-features = false, features = [ +prost.workspace = true +tonic = { workspace = true, default-features = false, features = [ "prost", "codegen", ] } -pbjson = { version = "0.7", optional = true } -serde = { version = "1.0", optional = true } +pbjson = { workspace = true, optional = true } +serde = { workspace = true, optional = true } [features] pbjson = ["dep:pbjson", "dep:serde"] descriptor = [] - -[dev-dependencies] -anyhow = "1" -glob = "0.3" -pbjson-build = "0.7" -prost-build = "0.13" -prost-types = "0.13" -rand = "0.8" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -toml = "0.8" -tonic-build = { version = "0.12", default-features = false, features = [ - "prost", -] } -xshell = "0.2" diff --git a/src/generated/google.protobuf.rs b/src/generated/google.protobuf.rs index 561d297..fbb6752 100644 --- a/src/generated/google.protobuf.rs +++ b/src/generated/google.protobuf.rs @@ -981,12 +981,13 @@ impl ::prost::Name for MessageOptions { } #[derive(Clone, PartialEq, ::prost::Message)] pub struct FieldOptions { + /// NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead. /// The ctype option instructs the C++ code generator to use a different /// representation of the field than it normally would. See the specific /// options below. This option is only implemented to support use of /// \[ctype=CORD\] and \[ctype=STRING\] (the default) on non-repeated fields of - /// type "bytes" in the open source release -- sorry, we'll try to include - /// other types in a future version! + /// type "bytes" in the open source release. + /// TODO: make ctype actually deprecated. #[prost( enumeration = "field_options::CType", optional, @@ -1224,8 +1225,6 @@ pub mod field_options { } } /// If set to RETENTION_SOURCE, the option will be omitted from the binary. - /// Note: as of January 2023, support for this is in progress and does not yet - /// have an effect (b/264593489). #[derive( Clone, Copy, @@ -1267,8 +1266,7 @@ pub mod field_options { } /// This indicates the types of entities that the field may apply to when used /// as an option. If it is unset, then the field may be freely used as an - /// option on any kind of entity. Note: as of January 2023, support for this is - /// in progress and does not yet have an effect (b/264593489). + /// option on any kind of entity. #[derive( Clone, Copy, @@ -2207,7 +2205,7 @@ pub enum Edition { Edition2023 = 1000, Edition2024 = 1001, /// Placeholder editions for testing feature resolution. These should not be - /// used or relyed on outside of tests. + /// used or relied on outside of tests. Edition1TestOnly = 1, Edition2TestOnly = 2, Edition99997TestOnly = 99997, diff --git a/src/xds-descriptors.bin b/src/xds-descriptors.bin index 90d8151..be62276 100644 Binary files a/src/xds-descriptors.bin and b/src/xds-descriptors.bin differ diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml new file mode 100644 index 0000000..35f8f86 --- /dev/null +++ b/xtask/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "xtask" +version = "0.1.0" +edition = "2024" + +[dependencies] +anyhow = "1" +clap = { version = "4.5", features = ["derive"] } +glob = "0.3" +pbjson-build.workspace = true +prost.workspace = true +prost-build.workspace = true +prost-types.workspace = true +serde = { workspace = true, features = ["derive"] } +serde_json = "1.0" +toml = "0.8" +tonic = { workspace = true, default-features = false, features = [ + "prost", + "codegen", +] } +tonic-build = { workspace = true, default-features = false, features = [ + "prost", +] } +xshell = "0.2" diff --git a/tests/generate_sources.rs b/xtask/src/main.rs similarity index 94% rename from tests/generate_sources.rs rename to xtask/src/main.rs index 60b7981..1d2b825 100644 --- a/tests/generate_sources.rs +++ b/xtask/src/main.rs @@ -6,11 +6,24 @@ use std::{ }; use anyhow::Context; +use clap::{Parser, ValueEnum}; use prost::Message; use prost_build::Module; use prost_types::FileDescriptorSet; use serde::Deserialize; -use xshell::{cmd, Shell}; +use xshell::{Shell, cmd}; + +#[derive(Debug, Parser)] +struct Args { + #[arg(value_enum)] + commands: Vec, +} + +#[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Eq)] +enum Commands { + Generate, + CheckDirty, +} /// Generate sources and check that the generated changes have been committed. /// @@ -20,14 +33,14 @@ use xshell::{cmd, Shell}; /// /// These flags are opt-out instead of opt-in so the checks run in CI and fail /// on pushes that get protos and generated sources out-of-sync. -#[test] -fn generate_sources() -> anyhow::Result<()> { +fn main() -> anyhow::Result<()> { + let args = Args::parse(); let sh = Shell::new().unwrap(); - if env::var("XDS_API_SKIP_GEN_SRC").is_err() { + + if args.commands.is_empty() || args.commands.contains(&Commands::Generate) { generate_xds_api(&sh)?; } - - if env::var("XDS_API_SKIP_GEN_SRC_DIRTY_CHECK").is_err() { + if args.commands.is_empty() || args.commands.contains(&Commands::CheckDirty) { check_dirty_repo(&sh)?; } @@ -36,6 +49,9 @@ fn generate_sources() -> anyhow::Result<()> { fn project_root() -> PathBuf { PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("..") + .canonicalize() + .unwrap() } /// Generate the xds-api definitions by downloading protobuf dependencies and running