Ocean is a project manager, similar to Rust's Cargo, for C and C++ written with Rust - that other systems programming language. The command syntax is very similar to that of Cargo's.
By default, Ocean will use gcc
to compile C and C++ source files, outputting
the executables to build/{mode}/{project_name}
.
rustc >= 1.46.0
- One of the supported compilers
Officially supported compilers:
- GNU C Compiler (GCC)
- Clang
- Make sure you have Cargo and Rust installed: https://rustup.rs/.
- From a command line, enter the following command:
cargo install --git https://github.com/STBoyden/ocean
. - Done!
Make sure to use ocean --help
if you're not sure how to use this application.
- The ability to build and run your project with a single command.
- Easy syntax - designed to be similar to Rust's Cargo.
- Easy setup - all the available options that can be changed in Ocean.toml can also be changed through the commands.
- Small project preparation time - can get your C/C++ project up and running in only a few seconds (with optional config arguments for multiple editors of your choice).
Usage: ocean [OPTION]
Create and manage C and C++ projects.
build Builds the current project
clean Cleans the current project's build artifacts
get Returns the values set in the Ocean.toml
set Sets the values inside Ocean.toml
help, --help Shows this help text
new Creates a new C/C++ project in a new directory
run Runs the current project, builds if no build is present
Usage: ocean build [OPTIONS]
By default, this builds projects in debug mode.
Options:
-d, --debug Builds the current project in debug mode (this is turned on by default)
-r, --release Builds the current project in release mode
-v, --verbose Makes the compiler output verbose.
-f, --flags Passes custom flags to the compiler.
Usage: ocean get [KEY]
This gets the current values inside the Ocean project file related to a datakey entered by the user.
Option:
build_dir Prints the build directory for the current project.
c++_compiler, cxx_compiler Prints the compiler being used for the C++ project.
c_compiler Prints the compiler being used for the C project.
compiler, current_compiler Prints the current compiler being used for the project.
flags Prints the flags of the current compiler.
lang, language Prints the current language of the project.
lib_dirs, library_directories Prints the library directories that would be searched by the linker.
libs, libraries Prints the libraries being compiled with the project.
name Prints the name of the project.
object_dir Prints the object output directory.
source_dir Prints the source code directory.
Usage: ocean set [KEY]
This set values inside the Ocean project file to a value specified by the user.
Option:
build_dir [DIRECTORY] Sets the build directory for the project.
c++_compiler [COMPILER], cxx_compiler [COMPILER] Set the compiler being used for the C++ project.
c_compiler [COMPILER] Sets the compiler being used for the C project.
compiler [COMPILER], current_compiler [COMPILER] Sets the current compiler being used for the project.
flags [FLAGS] Sets the flags of the current compiler, split by commas.
lang [LANG], language [LANG] Set the current language of the project.
lib_dirs [DIRS], library_directories [DIRS] Sets the library directories that would be searched by the linker, split by commas.
libs [LIBS], libraries [LIBS] Sets the libraries being compiled with the project, split by commas.
name [NAME] Sets the name of the project.
object_dir [DIRECTORY] Sets the object output directory.
source_dir [DIRECTORY] Sets the source code directory.
Usage: ocean new [NAME] [OPTIONS]
This creates a new project with a generated Ocean.toml in a new directory with a specified NAME.
Options:
-C Creates a new C project (default).
-CXX Creates a new C++ project.
-b, --build-dir Sets the build directory (default is "./build")
-s, --source-dir Sets the source directory (default is "./src")
-o, --obj-dir Sets the objects directory (default is "./obj")
-c, --compiler Sets the compiler for the current project (default is gcc for C and g++ for C++).
--ccls Outputs a .ccls file to be used with ccls. Allows a language server to be used with an editor like Vim, for example.
--vscode Outputs Visual Studio Code config files to make writing C/C++ easier.
Usage: ocean run [OPTIONS]
By default, this run projects in debug mode.
Options:
-d, --debug Runs the current project in debug mode (this is turned on by default)
-r, --release Runs the current project in release mode
-v, --verbose Makes the compiler output verbose.
-f, --flags Passes custom flags to the compiler.
A: Not yet. I am considering making a package manager but I have not decided fully. Either way, this will be decided at a later date.
A: Seeing as this is a personal side project, I will spend time on it when I please but probably quite often. I do have a job so that will take priority.
A: At least for me personally, using Ocean takes less time to get things set up over something like CMake and Premake. Especially for smaller projects where I just want to prototype something quickly and easily without having to mess around in a CMakeLists.txt. However, Ocean is not a replacement for either CMake or Premake and is not intended to.
- Use
cc
crate instead of manually calling the compiler commands.- Won't work for creating executables but might be able to used for creating libraries.
- Use
clap
orstructopt
to parse arguments. - Work on incremental builds:
- Look into Go's build cache.
- Provide examples of Ocean usage with varying degree of project size (in progress).