This question already has an answer here:
What is the recommended directory structure for a Rust project?
(1 answer)
Closed 4 years ago.
Where in the project structure do benchmark tests for a library go? I tried putting them in a file in the tests folder of the library and they fail to run when running cargo bench.
The documentation for Cargo's project layout says:
Benchmarks go in the benches directory.
That's the convention, but in your Cargo.toml you can configure targets, and one of those is the [[bench]] target. Doing that will let you place them wherever you'd like.
Related
This question already has answers here:
How do I pin indirect dependencies of a crate?
(2 answers)
Can I force the use of my dependencies' Cargo.lock when resolving package versions?
(1 answer)
Closed 3 years ago.
I have a specific problem, but understanding the solution I think is going to be useful in a broader context.
I have a project that indirectly depends on pnet; I don't directly reference it anywhere.
It was building fine for a few weeks with pnet version 0.22. On Monday, something changed and the version of pnet incremented to 0.23 and our CI server started failing to build.
It seems that moving forward, especially once we start deploying builds, being able to definitively reproduce exact outputs is going to be pretty critical for us, so this isn't specific to this library. This could really happen at any time with any library.
Is there a way in Cargo to somehow "force" the dependency tree to use the older version short of us pulling the source of the older pnet (and maybe whatever is using it)?
I'd love to just be able to put an entry into Cargo.toml that pins the old version.
I tried adding the following, but it didn't help:
pnet = "=0.22.0"
This question already has answers here:
How do I change a function's qualifiers via conditional compilation?
(1 answer)
How to write documentation tests for an internal API?
(1 answer)
Can I make an object public for integration tests and/or benchmarks only?
(2 answers)
Closed 3 years ago.
I use doc tests whenever reasonable for a number of reasons (locality, serves as an example, etc). I would like to use doc tests for functions and methods that are not marked pub. I figure this would probably involve using #[cfg(test)] in appropriate places, but I'm not sure.
How would you mark functions and methods so that they can be used in doc tests?
This question already has answers here:
How can I build multiple binaries with Cargo?
(3 answers)
Package with both a library and a binary?
(4 answers)
Closed 3 years ago.
I'd like to create a rust package with two binary crates and a library which contains the shared code. I know how do do this for a simple program by putting the source files for the binaries in a src/bin/ subdirectory (e.g. src/bin/firstbin.rs and src/bin/secondbin.rs) and the library code either in src/ or in src/lib/.
However, if the binaries have a substantial amount of non-shared code which does not belong in the library, and I want to split their source into multiple files, I'm not sure of how to lay out the source files. I'm thinking something along the lines of having src/bin/firstbin/ for the files which belong only to the first binary, and src/bin/secondbin/ for the second binary. However, I'm not sure how to reference these files from firstbin.rs and secondbin.rs.
So is this the right approach and if so how do I reference the files? If not, what's the best layout?
You can put your fn main() into src/bin/firstbin/main.rs and add more files for submodules in the same directory. This is documented in this section of the Cargo manual (in the text, the gray box is wrong).
This question already has answers here:
How to obfuscate a shell script?
(4 answers)
Closed 6 years ago.
I wrote a nice program in linux and I don't want people to steal my work, is there a way for me to hide the contents of my sh file from other people seeing it when I publish it? And it still has to be functional when I publish it to the public. I won't be posting any of the code because of this.
You could consider adding an open source license to your program to protect it:
https://dzone.com/articles/selecting-an-open-source-license-for-your-project
One possibility is to compile the shell script to C and ship a binary executable. Compilers for the shell language exist, such as CCsh from Comeau Computing, which is a proprietary product, like yours.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Common GNU makefile directory path
After reading Recursive Make Considered Harmful I decided to use "include makefile" to my next project. I got a main Makefile that include two sub-makefiles that are in diffrent dirs. the problem is that the paths that inside the sub-makefile is relative to his dir so when I include it from the main Makefile he can't find the files. is there a way to solve this problem without changing the paths?
Although the article is right about recursive make and DAG tree, I read the article about half a year ago and tried to use the approach described in it and found the "classic" approach to recursive make much more convenient. Consider this:
big_project
|--Makefile
|
|--sub_project_1
| |--...
| |--Makefile
|
|--sub_project_2
|--...
|--Makefile
It's wonderful when you're running make from big_project project directory, but well, if you do things as it's recommended in the article, there would be no Makefiles in sub_project_x directories, thus you won't be able to treat each sub-project separately.