Debian Codegraph @

lib/gen-protos/src/main.rs

raw
1 // Copyright 2022 The Jujutsu Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 use std::io::Result;
16 use std::path::Path;
17
18 fn main() -> Result<()> {
19 let input = [
20 "default_index.proto",
21 "git_store.proto",
22 "local_working_copy.proto",
23 "secure_config.proto",
24 "simple_op_store.proto",
25 "simple_store.proto",
26 "simple_workspace_store.proto",
27 ];
28
29 let root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap();
30 let protos_dir = root.join("src").join("protos");
31
32 prost_build::Config::new()
33 .out_dir(&protos_dir)
34 .include_file("mod.rs")
35 // For old protoc versions. 3.12.4 needs this, but 3.21.12 doesn't.
36 .protoc_arg("--experimental_allow_proto3_optional")
37 .compile_protos(
38 &input
39 .into_iter()
40 .map(|x| protos_dir.join(x))
41 .collect::<Vec<_>>(),
42 &[protos_dir],
43 )
44 }