-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[workspace] | ||
members = ["copper", "copper_derive", "copper_derive_test", "examples/config-gen", "examples/pluginload", "examples/simplelogger", "examples/v4lsrc"] | ||
members = ["copper", "copper_derive", "copper_derive_test", "copper_log", "examples/config-gen", "examples/pluginload", "examples/simplelogger", "examples/v4lsrc"] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
use copper_derive::copper_runtime; | ||
use copper_log::debug; | ||
|
||
#[copper_runtime(config = "copperconfig.ron")] | ||
struct MyApplication {} | ||
|
||
fn main() { | ||
debug!("Application created."); | ||
let application = MyApplication::new().expect("Failed to create runtime."); | ||
debug!("End of program."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "copper-log" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
|
||
[dependencies] | ||
proc-macro2 = { version = "1.0.83", features = ["span-locations"] } | ||
quote = "1.0.36" | ||
syn = { version = "2.0.65", features = ["full"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use std::env; | ||
|
||
fn main() { | ||
let out_dir = env::var("OUT_DIR").unwrap(); | ||
println!("cargo:rustc-env=OUT_DIR={}", out_dir); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
extern crate proc_macro; | ||
|
||
use proc_macro::TokenStream; | ||
use proc_macro2::Span; | ||
use quote::quote; | ||
use syn::{parse_macro_input, LitStr}; | ||
|
||
#[proc_macro] | ||
pub fn debug(input: TokenStream) -> TokenStream { | ||
let input = parse_macro_input!(input as LitStr); | ||
let message = input.value(); | ||
|
||
let expanded = quote! { | ||
{ | ||
let log_message = #message; | ||
println!("Log: {:?}", log_message); | ||
log_message | ||
} | ||
}; | ||
println!("Found logging string {}", message); | ||
|
||
// print the OUT env vairable | ||
println!("OUT: {}", std::env::var("OUT_DIR").unwrap()); | ||
|
||
TokenStream::from(expanded) | ||
} |