use std::fs::{copy, create_dir};
use std::path::Path;
fn main() -> std::io::Result<()> {
let manifest_path = Path::new(env!("CARGO_MANIFEST_DIR"));
let tmp_path = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/cli/tmp"));
if !tmp_path.exists() {
create_dir(tmp_path)?;
}
copy(
manifest_path.join("Cargo.toml"),
tmp_path.join("Freight.toml"),
)?;
let tmp_core_path = tmp_path.join("core");
if !tmp_core_path.exists() {
create_dir(tmp_core_path)?;
}
copy(
manifest_path.join("core/Cargo.toml"),
tmp_path.join("core/Freight.toml"),
)?;
let tmp_core_src_path = tmp_path.join("core/src");
if !tmp_core_src_path.exists() {
create_dir(tmp_core_src_path)?;
}
copy(
manifest_path.join("core/src/lib.rs"),
tmp_path.join("core/src/lib.rs"),
)?;
let tmp_core_src_models_path = tmp_path.join("core/src/models");
if !tmp_core_src_models_path.exists() {
create_dir(tmp_core_src_models_path)?;
}
copy(
manifest_path.join("core/src/models/example.rs"),
tmp_path.join("core/src/models/example.rs"),
)?;
let tmp_engines_path = tmp_path.join("engines");
if !tmp_engines_path.exists() {
create_dir(tmp_engines_path)?;
}
let tmp_engines_rocksdb_path = tmp_path.join("engines/rocksdb");
if !tmp_engines_rocksdb_path.exists() {
create_dir(tmp_engines_rocksdb_path)?;
}
copy(
manifest_path.join("engines/rocksdb/Cargo.toml"),
tmp_path.join("engines/rocksdb/Freight.toml"),
)?;
let tmp_engines_rocksdb_src_path = tmp_path.join("engines/rocksdb/src");
if !tmp_engines_rocksdb_src_path.exists() {
create_dir(tmp_engines_rocksdb_src_path)?;
}
copy(
manifest_path.join("engines/rocksdb/src/lib.rs"),
tmp_path.join("engines/rocksdb/src/lib.rs"),
)?;
let tmp_engines_sqlite_path = tmp_path.join("engines/sqlite");
if !tmp_engines_sqlite_path.exists() {
create_dir(tmp_engines_sqlite_path)?;
}
copy(
manifest_path.join("engines/sqlite/Cargo.toml"),
tmp_path.join("engines/sqlite/Freight.toml"),
)?;
let tmp_engines_sqlite_src_path = tmp_path.join("engines/sqlite/src");
if !tmp_engines_sqlite_src_path.exists() {
create_dir(tmp_engines_sqlite_src_path)?;
}
copy(
manifest_path.join("engines/sqlite/src/lib.rs"),
tmp_path.join("engines/sqlite/src/lib.rs"),
)?;
let tmp_proto_path = tmp_path.join("proto");
if !tmp_proto_path.exists() {
create_dir(tmp_proto_path)?;
}
copy(
manifest_path.join("proto/build.rs"),
tmp_path.join("proto/build.rs"),
)?;
copy(
manifest_path.join("proto/Cargo.toml"),
tmp_path.join("proto/Freight.toml"),
)?;
copy(
manifest_path.join("proto/bicycle.proto"),
tmp_path.join("proto/bicycle.proto"),
)?;
let tmp_proto_src_path = tmp_path.join("proto/src");
if !tmp_proto_src_path.exists() {
create_dir(tmp_proto_src_path)?;
}
copy(
manifest_path.join("proto/src/lib.rs"),
tmp_path.join("proto/src/lib.rs"),
)?;
let tmp_server_path = tmp_path.join("server");
if !tmp_server_path.exists() {
create_dir(tmp_server_path)?;
}
copy(
manifest_path.join("server/Cargo.toml"),
tmp_path.join("server/Freight.toml"),
)?;
let tmp_server_src_path = tmp_path.join("server/src");
if !tmp_server_src_path.exists() {
create_dir(tmp_server_src_path)?;
}
copy(
manifest_path.join("server/src/main.rs"),
tmp_path.join("server/src/main.rs"),
)?;
let tmp_shims_path = tmp_path.join("shims");
if !tmp_shims_path.exists() {
create_dir(tmp_shims_path)?;
}
copy(
manifest_path.join("shims/build.rs"),
tmp_path.join("shims/build.rs"),
)?;
copy(
manifest_path.join("shims/Cargo.toml"),
tmp_path.join("shims/Freight.toml"),
)?;
let tmp_shims_src_path = tmp_path.join("shims/src");
if !tmp_shims_src_path.exists() {
create_dir(tmp_shims_src_path)?;
}
copy(
manifest_path.join("shims/src/lib.rs"),
tmp_path.join("shims/src/lib.rs"),
)?;
let tmp_shims_src_models_path = tmp_path.join("shims/src/models");
if !tmp_shims_src_models_path.exists() {
create_dir(tmp_shims_src_models_path)?;
}
copy(
manifest_path.join("shims/src/models/example.rs"),
tmp_path.join("shims/src/models/example.rs"),
)?;
Ok(())
}