Skip to content
hosealyuPublic

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

Cinit

Cinit is a Bash project generator for a minimal C Hello World application. It detects an installed build system or C compiler, creates the project without overwriting existing files, and can optionally initialize a Git repository.

Quick start

./cinit

You can provide all choices on the command line:

./cinit --build-tool cmake --target ./my-project
./cinit --compiler clang --target ./my-project --no-git

If options are omitted, Cinit lists the detected build systems and compilers, then asks you to choose one and enter a project directory.

Command options

--build-tool ID   Select an installed build system
--compiler ID     Compile directly with an installed compiler
--target PATH     Set the project directory
--no-git          Skip Git repository initialization
-h, --help        Show command help

--build-tool and --compiler are mutually exclusive. Supported IDs are:

  • Build systems: make, cmake, bazel, meson
  • Compilers: cc, gcc, clang

The requested tool must be installed and recognized from build-systems.conf or compilers.conf.

Project destination

--target accepts an absolute or relative path. Relative paths are resolved from the current directory, missing parent directories are created, and . selects the current directory. If --target is omitted, Cinit prompts for the path.

The destination must be empty or missing; Cinit refuses to overwrite existing files and refuses symbolic-link destinations. Git initialization is enabled by default. Use --no-git to skip it, or omit Git from the environment and Cinit will continue after reporting that it could not initialize a repository.

The executable name is derived from the destination directory name: letters are lowercased, unsupported characters become hyphens, and long or leading-numeric names are normalized. --target . uses hello-world.

Generated project

Every selection creates the common C source and test layout:

src/main.c
src/hello.c
include/hello.h
tests/test_hello.c
.gitignore
README.md

The starter test uses the standard C assert macro. The selected template adds its build configuration and project-specific instructions.

Selection Additional files Build and run Test
Make Makefile make && ./<executable-name> make test
CMake CMakeLists.txt cmake -S . -B build && cmake --build build && ./build/<executable-name> ctest --test-dir build --output-on-failure
Bazel MODULE.bazel, BUILD.bazel bazel run //:<executable-name> bazel test //:hello_test
Meson meson.build meson setup build && meson compile -C build && ./build/<executable-name> meson test -C build
Compiler None <compiler> -std=c11 -Wall -Wextra -Iinclude src/main.c src/hello.c -o <executable-name> Compile and run tests/test_hello.c with src/hello.c

For build-system selections, the C compiler must be available separately. For compiler selections, Cinit uses templates/manual/README.md to generate direct compile and test commands.

Requirements

At least one supported build system or C compiler must be installed. Cinit exits with installation guidance if none is detected.

Smoke test

Run the project smoke test with:

bash tests/smoke.sh

It verifies build-system and compiler selection, generated files, executable output, and starter tests. Environment-dependent Make and C compiler checks are skipped when the corresponding tools are unavailable.

Contributing

To add a build system or compiler, see CONTRIBUTING.md.

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages