Skip to content

Commit

Permalink
ARROW-7794: [Rust] [Flight] Remove hard-coded relative path to Flight…
Browse files Browse the repository at this point in the history
….proto

This is my second attempt at this and I made it more robust this time. I manually tested the following:

- `cargo publish --dry-run --allow-dirty`
- `cargo test` from `arrow/rust`
- `cargo test` from `arrow/rust/arrow-flight`
- Building another project that had a dependency on this branch

Closes #6873 from andygrove/ARROW-7794b

Authored-by: Andy Grove <andygrove73@gmail.com>
Signed-off-by: Andy Grove <andygrove73@gmail.com>
  • Loading branch information
andygrove committed Apr 10, 2020
1 parent c6e4f55 commit e04e9cc
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions rust/arrow-flight/build.rs
Expand Up @@ -15,7 +15,28 @@
// specific language governing permissions and limitations
// under the License.

fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::compile_protos("../../format/Flight.proto")?;
Ok(())
use std::env;

fn main() -> Result<(), String> {
// The current working directory can vary depending on how the project is being
// built or released so we build an absolute path to the proto file
let mut path = env::current_dir().map_err(|e| format!("{:?}", e))?;
loop {
// build path to format/Flight.proto
let mut flight_proto = path.clone();
flight_proto.push("format");
flight_proto.push("Flight.proto");

if flight_proto.exists() {
tonic_build::compile_protos(flight_proto).map_err(|e| format!("{:?}", e))?;
return Ok(());
}

if !path.pop() {
// reached root of file system
break;
}
}

Err("Failed to locate format/Flight.proto in any parent directory".to_string())
}

0 comments on commit e04e9cc

Please sign in to comment.