I use tracing for logging.
It prints file name on error, and it helps me a lot to debugging problems from users.
However, I am required to remove the path provided by file!() macro,
the Rust executable, due to various reasons.
Is there any way to obfuscate the file!() macro?
The path should not be in the string table of the Rust executable
The path should never appears in memory when the program is running
Neither absolute nor relative path are allowed.
Some formed of obfuscated path should be printed instead, and I can transform it back to the real path, by some other unreleased tools
I know I can create and use some other file! like macro,
but I want also make the obfuscation works for the 3rdparty crates without modifying their source code.
My possible solutions:
Possible to do this using proc macro? I don't know. Even this works, this not working for 3rdparty crates, but this can solve path problems in my own workspace.
Add many --remap-path-prefix options to rustc, for all possible path of .rs files that Rust may access. I think this works, but this is very complicated to setup.
Modify the string inside executable post compilation, but I am afraid that this may damage the file
Can you elaborate a bit on why you have this requirement? It would be very difficult to satisfy it as framed: option 2, manually remapping the name of every file in every crate in your program, is the most promising way to do what you have said as you've said it. I am hoping that a more complete understanding of why you're doing this may help us figure out a more practical alternative.
Put another way, what is it about the string "src/main.rs" that you object to?
To be clear, most OSS licenses require attribution anyway, so anyone using your software must have access to the names and other information required by each dependency’s license.