-
Notifications
You must be signed in to change notification settings - Fork 16
Compile and develop effectively
Here you can find some notes on how to develop effectively. Especially the correct way to compile the project can save time.
The project contains one main crate, the uosql-server
. This crate is designed as an executable -- the cargo build
command will create this executable in target/debug/uosql-server
. However, the crate can be used and compiled as library, too. This makes it possible to write other executables that use functions and types of the main crate.
To build the server, simply execute:
cargo build
To build the server, build and run all tests, build all examples and test pretty much everything else, execute:
cargo test
To generate the documentation, execute:
cargo doc # generates html files in /target/doc/
cargo doc --open # this will also open the index.html in your browser
To clean your project and delete all temporary objects, execute:
cargo clean
To update dependencies, execute:
cargo update
There are two possibilities:
- You are working on the "front-end" of the server, something that happens directly after starting the server (like configuration files, network, ...)
- You are working on the "back-end", like the parser, storage engines, ...
You can build the whole server executable and test with it. This is done with:
$ cargo build --bin uosql-server && ./target/debug/uosql-server
Currently, one bad thing about this is, that the crate is actually build twice: Once as a library and once as an executable. When compile times starting to become too long to wait and you just want to test if your code compiles, you can compile the library via:
$ cargo build --lib
Remember, however, that this won't build the executable!
If your work is slowly drifting from the front- to the backend and testing your code with the server executable becomes impractical, you may consider using a own test executable (see Backend).
If you're working on something deep in the server, you don't want to test your code with the server itself. In this case you should create your own testing executable in the src/bin/
directory.
For example: If you're working on the parser, you don't want to test your parsing methods by starting the server, sending queries via network (...) and then see the results. You want to call your parsing methods directly with test data. To do that, you create the file src/bin/parser.rs
and write something like this:
extern crate uosql;
fn main() {
uosql::parse::parse_query("SELECT test");
}
Here you have access to all functions and types of the main crate via uosql
. Remember to copy the logger initialization from main.rs
to get logging output! The logger needs to be initialized before doing anything else.
To compile your executable (and the main crate, if necessary), execute this (replace "parser" with your executable name):
$ cargo build --bin parser && ./target/debug/parser
If some files in the main crate were updated, the main crate is compiled as library. After that your executable is compiled into target/debug/parser
.