2020-07-25 03:43:01 +00:00
|
|
|
use std::{
|
|
|
|
env, fs,
|
|
|
|
ops::Deref,
|
|
|
|
path::{Path, PathBuf},
|
|
|
|
};
|
2015-05-09 10:07:24 +00:00
|
|
|
|
2020-07-25 03:43:01 +00:00
|
|
|
fn out_dir() -> PathBuf {
|
|
|
|
Path::new(&env::var("OUT_DIR").expect("env")).to_path_buf()
|
|
|
|
}
|
2016-11-21 02:48:17 +00:00
|
|
|
|
2020-07-25 03:43:01 +00:00
|
|
|
fn cleanup() {
|
2023-01-02 18:01:35 +00:00
|
|
|
let _ = fs::remove_dir_all(out_dir());
|
2020-07-25 03:43:01 +00:00
|
|
|
}
|
2016-11-21 02:48:17 +00:00
|
|
|
|
2020-07-25 03:43:01 +00:00
|
|
|
fn compile() {
|
|
|
|
let proto_dir = Path::new(&env::var("CARGO_MANIFEST_DIR").expect("env")).join("proto");
|
2016-11-21 02:48:17 +00:00
|
|
|
|
2020-07-25 03:43:01 +00:00
|
|
|
let files = &[
|
2021-11-26 22:21:27 +00:00
|
|
|
proto_dir.join("connect.proto"),
|
2022-01-22 22:17:10 +00:00
|
|
|
proto_dir.join("connectivity.proto"),
|
2021-11-26 22:21:27 +00:00
|
|
|
proto_dir.join("devices.proto"),
|
|
|
|
proto_dir.join("entity_extension_data.proto"),
|
|
|
|
proto_dir.join("extended_metadata.proto"),
|
|
|
|
proto_dir.join("extension_kind.proto"),
|
2021-06-19 20:29:48 +00:00
|
|
|
proto_dir.join("metadata.proto"),
|
2021-11-26 22:21:27 +00:00
|
|
|
proto_dir.join("player.proto"),
|
2021-11-27 10:59:22 +00:00
|
|
|
proto_dir.join("playlist_annotate3.proto"),
|
2021-12-10 19:33:43 +00:00
|
|
|
proto_dir.join("playlist_permission.proto"),
|
2021-11-27 10:59:22 +00:00
|
|
|
proto_dir.join("playlist4_external.proto"),
|
2022-01-22 22:17:10 +00:00
|
|
|
proto_dir.join("spotify/clienttoken/v0/clienttoken_http.proto"),
|
2024-10-19 18:27:26 +00:00
|
|
|
proto_dir.join("spotify/login5/v3/challenges/code.proto"),
|
|
|
|
proto_dir.join("spotify/login5/v3/challenges/hashcash.proto"),
|
|
|
|
proto_dir.join("spotify/login5/v3/client_info.proto"),
|
|
|
|
proto_dir.join("spotify/login5/v3/credentials/credentials.proto"),
|
|
|
|
proto_dir.join("spotify/login5/v3/identifiers/identifiers.proto"),
|
|
|
|
proto_dir.join("spotify/login5/v3/login5.proto"),
|
|
|
|
proto_dir.join("spotify/login5/v3/user_info.proto"),
|
2021-12-16 21:42:37 +00:00
|
|
|
proto_dir.join("storage-resolve.proto"),
|
2021-12-10 23:03:35 +00:00
|
|
|
proto_dir.join("user_attributes.proto"),
|
2021-06-19 20:29:48 +00:00
|
|
|
// TODO: remove these legacy protobufs when we are on the new API completely
|
2020-07-25 03:43:01 +00:00
|
|
|
proto_dir.join("authentication.proto"),
|
2021-11-26 22:21:27 +00:00
|
|
|
proto_dir.join("canvaz.proto"),
|
|
|
|
proto_dir.join("canvaz-meta.proto"),
|
2021-12-10 19:33:43 +00:00
|
|
|
proto_dir.join("explicit_content_pubsub.proto"),
|
2020-07-25 03:43:01 +00:00
|
|
|
proto_dir.join("keyexchange.proto"),
|
|
|
|
proto_dir.join("mercury.proto"),
|
|
|
|
proto_dir.join("pubsub.proto"),
|
|
|
|
proto_dir.join("spirc.proto"),
|
|
|
|
];
|
2019-12-16 11:47:52 +00:00
|
|
|
|
2020-07-25 03:43:01 +00:00
|
|
|
let slices = files.iter().map(Deref::deref).collect::<Vec<_>>();
|
2019-09-08 12:07:45 +00:00
|
|
|
|
2020-07-25 03:43:01 +00:00
|
|
|
let out_dir = out_dir();
|
|
|
|
fs::create_dir(&out_dir).expect("create_dir");
|
|
|
|
|
2023-01-17 20:46:14 +00:00
|
|
|
protobuf_codegen::Codegen::new()
|
|
|
|
.pure()
|
2020-07-25 03:43:01 +00:00
|
|
|
.out_dir(&out_dir)
|
|
|
|
.inputs(&slices)
|
|
|
|
.include(&proto_dir)
|
|
|
|
.run()
|
|
|
|
.expect("Codegen failed.");
|
|
|
|
}
|
2020-07-24 02:11:14 +00:00
|
|
|
|
2020-07-25 03:43:01 +00:00
|
|
|
fn main() {
|
|
|
|
cleanup();
|
|
|
|
compile();
|
2016-11-21 02:48:17 +00:00
|
|
|
}
|