Skip to content

Commit

Permalink
Compile tauri app before frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovenoboyo committed Dec 22, 2024
1 parent 1a3a3fd commit af14530
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ jobs:
- name: Run cargo check
run: |
cd src-tauri
cargo check ${{ matrix.args }}
cargo build --release ${{ matrix.args }}
ls ../target/
- uses: tauri-apps/tauri-action@v0
env:
Expand Down
37 changes: 29 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
use std::{env, path::Path};
use std::{
env, fs,
path::{Path, PathBuf},
};

fn find_function_details_json(target_dir: &Path) -> Option<PathBuf> {
for entry in fs::read_dir(target_dir).ok()? {
let entry = entry.ok()?;
let path = entry.path();

if path.is_dir() {
if let Some(found) = find_function_details_json(&path) {
return Some(found);
}
} else if path.ends_with("function_details.json") {
return Some(path);
}
}

None
}

fn main() {
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is not set");
let manifest_dir = Path::new(&manifest_dir);
let profile = env::var("PROFILE").expect("PROFILE environment variable is not set");

let file_path = manifest_dir.join("target").join(profile).join("build");

println!(
"cargo:rustc-env=TAURI_INVOKE_PROC_DIR={}",
file_path.to_string_lossy()
);
if let Some(file_path) = find_function_details_json(manifest_dir.join("target").as_path()) {
println!(
"cargo:rustc-env=TAURI_INVOKE_PROC_DIR={}",
file_path.to_string_lossy()
);
} else {
println!("cargo:warning=Could not find function_details.json");
}
}
1 change: 1 addition & 0 deletions src-tauri/tauri-invoke-proc/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,6 @@ fn write_function_details_to_file() {
let json_output =
serde_json::to_string_pretty(&existing_data).expect("Failed to serialize JSON data");

eprintln!("Writing output to {:?}", file_path);
std::fs::write(file_path, json_output).expect("Failed to write JSON data to file");
}
2 changes: 1 addition & 1 deletion src-tauri/tauri-invoke-proc/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn generate_tauri_invoke_wrapper(input: TokenStream) -> TokenStream {
let out_dir = env::var("TAURI_INVOKE_PROC_DIR")
.expect("TAURI_INVOKE_PROC_DIR environment variable is not set");

let file_path = Path::new(&out_dir).join("function_details.json");
let file_path = Path::new(&out_dir);

let json_content = fs::read_to_string(file_path).expect("Failed to read function_details.json");
let json: HashMap<String, Vec<FnDetails>> = serde_json::from_str(&json_content)
Expand Down

0 comments on commit af14530

Please sign in to comment.