This repository has been archived by the owner on Jun 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
73 lines (63 loc) · 2.08 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#[cfg(any(feature = "fbs", feature = "proto"))]
fn main() -> Result<(), Box<dyn std::error::Error>> {
const ARROW_TAG: &str = "apache-arrow-5.0.0";
const ARROW_GIT: &str = "https://github.com/apache/arrow";
use flate2::read::GzDecoder;
use std::{env, path::PathBuf};
use tar::Archive;
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
Archive::new(GzDecoder::new(
reqwest::blocking::get(format!("{}/archive/{}.tar.gz", ARROW_GIT, ARROW_TAG))
.expect("arrow download failed"),
))
.unpack(&out_dir)
.expect("arrow tarball extract failed");
let arrow_dir = out_dir.join(format!("arrow-{}", ARROW_TAG));
let arrow_dir = arrow_dir.display();
#[cfg(feature = "fbs")]
let fbs_files = [
#[cfg(feature = "file")]
"format/File.fbs",
#[cfg(feature = "message")]
"format/Message.fbs",
#[cfg(feature = "schema")]
"format/Schema.fbs",
#[cfg(feature = "sparse_tensor")]
"format/SparseTensor.fbs",
#[cfg(feature = "tensor")]
"format/Tensor.fbs",
#[cfg(feature = "plasma_common")]
"cpp/src/plasma/common.fbs",
#[cfg(feature = "plasma")]
"cpp/src/plasma/plasma.fbs",
#[cfg(feature = "feather")]
"cpp/src/arrow/ipc/feather.fbs",
]
.iter()
.map(|file| format!("{}/{}", arrow_dir, file))
.collect::<Vec<_>>();
#[cfg(feature = "fbs")]
assert!(std::process::Command::new(flatc::flatc())
.arg("--rust")
// .arg("--gen-all")
.arg("--filename-suffix")
.arg("")
.arg("-o")
.arg(out_dir)
.args(fbs_files)
.status()?
.success());
#[cfg(feature = "proto")]
let proto_files = [
#[cfg(feature = "flight")]
"format/Flight.proto",
]
.iter()
.map(|file: &&str| format!("{}/{}", arrow_dir, file))
.collect::<Vec<_>>();
#[cfg(feature = "proto")]
prost_build::compile_protos(&proto_files, &[format!("{}/format", arrow_dir)])?;
Ok(())
}
#[cfg(not(any(feature = "fbs", feature = "proto")))]
fn main() {}