Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modify src while building #21

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = [
"fav_core",
"fav_utils_old",
"fav_utils",
"fav_derive"
"fav_derive",
]
resolver = "2"

Expand All @@ -21,9 +21,9 @@ repository = "https://github.com/kingwingfly/fav"
documentation = ""

[workspace.dependencies]
fav_core = { path = "fav_core" }
fav_core = { path = "fav_core", version = ">=0.0.1" }
fav_derive = { path = "fav_derive", version = ">=0.0.1" }
fav_utils = { path = "fav_utils" }
fav_utils = { path = "fav_utils", version = ">=0.0.1" }
fav_cli = { path = "fav_cli" }
fav_utils_old = { path = "fav_utils_old" }

Expand Down
3 changes: 1 addition & 2 deletions fav_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[package]
name = "fav_cli"
version.workspace= true
version.workspace = true
authors.workspace = true
description = "Fav's CLI, helping persist the remote source. Repo: https://github.com/kingwingfly/fav"
license.workspace = true
edition.workspace = true
repository.workspace = true
documentation = "https://docs.rs/fav_cli"
publish = false

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion fav_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fav_core"
version = "0.0.1"
version = "0.0.2"
authors.workspace = true
description = "Fav's core crate; A collection of traits."
license.workspace = true
Expand Down
9 changes: 7 additions & 2 deletions fav_core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.pure()
.includes(["proto"])
.inputs(["proto/data.proto"])
.out_dir("src/test_utils/proto")
.cargo_out_dir("proto")
.run()
.ok(); // Just omit the err since crates.io build on a readonly system
.unwrap();
let path = std::path::PathBuf::from(std::env::var("OUT_DIR")?).join("proto/data.rs");
let gen = std::fs::read_to_string(&path)?;
let processed = gen.replace("#!", "//").replace("//!", "//");
std::fs::write(path, processed)?;
println!("cargo:return-if-changed=proto");
println!("cargo:return-if-changed=build.rs");
Ok(())
}
18 changes: 18 additions & 0 deletions fav_core/src/test_utils/data.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![allow(unknown_lints)]
#![allow(clippy::all)]

#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]

#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_results)]
#![allow(unused_mut)]

//! Generated file from `data.proto`
include!(concat!(env!("OUT_DIR"), "/proto/data.rs"));
11 changes: 5 additions & 6 deletions fav_core/src/test_utils/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::{api::DefaultApiKind, prelude::*};
#[cfg(not(test))]
use fav_core::{api::DefaultApiKind, prelude::*};

use super::data::{App, Conf, TestRes, TestSet, TestSets};
use std::future::Future;
use super::data::{App, TestRes, TestSet, TestSets};

impl HttpConfig for App {
fn headers(&self) -> reqwest::header::HeaderMap {
Expand All @@ -23,7 +22,7 @@ impl HttpConfig for App {
impl ApiProvider for App {
type ApiKind = DefaultApiKind;

fn api(&self, api_kind: Self::ApiKind) -> &dyn Api {
fn api(&self, _: Self::ApiKind) -> &dyn Api {
todo!()
}
}
Expand All @@ -41,19 +40,19 @@ impl AuthOps for App {
impl ResOps for App {
type Res = TestRes;

async fn fetch_res(&self, resource: &mut Self::Res) -> FavCoreResult<()> {
async fn fetch_res(&self, _: &mut Self::Res) -> FavCoreResult<()> {
todo!()
}

async fn pull_res(&self, resource: &mut Self::Res) -> FavCoreResult<()> {
async fn pull_res(&self, _: &mut Self::Res) -> FavCoreResult<()> {
todo!()
}
}

impl SetOps for App {
type Set = TestSet;

async fn fetch_set(&self, set: &mut Self::Set) -> FavCoreResult<()> {
async fn fetch_set(&self, _: &mut Self::Set) -> FavCoreResult<()> {
todo!()
}
}
Expand Down
7 changes: 1 addition & 6 deletions fav_core/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
#![allow(unused)]

pub mod data;
mod impls;
mod proto;

pub use impls::*;
pub use proto::*;
Loading
Loading