All files can be found on the Releases page.
This is a command line tool to help initiate my custom Linux C++ (g++) project system by creating the directory tree, Makefile, main source file, possible prebuild script, possible class files, and all the basic boilerplate code I almost always start with.
I have my own style of programming and, of course, my style is not for everyone, but if you would like to use my system then by all means... More information on my style is provided below.
I have been meaning to write this for a long time and, of course, time is hard to find, but I finally got around to writing this. For years I have usually written scripts and/or copied old project files to a new project to help start my projects, but with this I can quickly initiate my projects within a minute and usually less. Especially times when I'm on a roll and start many projects all at once I can script the project creation with config file.
This is an open-source (FOSS) command line utility for use in Linux shells (terminals/ttys/etc.). This can be built from source (as per the LICENSE file provided), used portably (single executable put wherever you like), or installed via the provided Debian (.deb) package.
The recommended method of use is via the Debian package installation for the Debian (apt, deb) packager manager, but there are other methods provided here or if you would care to provide an installer for a different package manager then please fork this project, build the appropriate workflow and source files, and make a pull-request.
The .deb installer provides a Bash Completion file, a Man Page, changelog, icons, and (of course) a way to uninstall.
Man Page:
CPPPROJ(1) CPPPROJ(1)
NAME
cppproj - A Linux command line tool to initiate Ian Pride’s personal and custom C++ project.
SYNOPSIS
cppproj [-h | –help] | [-d | –directory] <DIRECTORY PATH> [-m | –main] <MAIN FILE NAME> [-c | –class] <CLASS FILE NAME> [-p | –prebuild]
DESCRIPTION
A Linux command line tool to initiate my personal and custom C++ project directory structure, files, and basic boilerplate code.
OPTIONS
-h, --help
This HELP message.
-d, --directory
Project path location.
-m, --main
Main source file name.
-c, --class
Class file name.
-p, --prebuild
Create a prebuild file to build precompiled header, object file, and library archive file.
EXAMPLES
$ cppproj --help
$ cppproj --directory ~/cppl/projectname --class ClassName -p
EXIT CODES
0 No errors.
1 No argument provide for –main switch.
2 Invalid argument provided for –main switch.
3 No argument provide for –class switch.
4 Invalid argument provided for –class switch.
5 No argument provide for –directory switch.
6 Invalid argument provided for –directory switch.
7 Filesystem error when checking if a directory exists.
8 Filesystem error when trying to create a directory.
9 Filesystem error when checking if a file exists.
10 Filesystem error when trying to create a file.
CONTACT
Ian Pride
This Project
GitHub
AUTHORS
Ian Pride.
cppproj - 1.0.0 Fri Jul 14 06:35:07 PM UTC 2023 CPPPROJ(1)
This tool can can be used like any other command line tool directly from the command line, a script, or another program.
This system only involves GCC/make (I do not use CMAKE) and can be imported into some IDEs (VS Code and especially Code::Blocks (you can use a custom Makefile in the build options and set prebulds there) which I use).
A basic example creates a project directory tree and files in the following format (pch.cpp is not usually necessary, but created just in case. It's the precompiled header source companion and rarely used and created just like any other class file):
ᗛ⦗flux⦘@⦗⇛⦘ᗘ cppproj -d ~/cpp_project
...
ᗛ⦗flux⦘@⦗⇛⦘ᗘ tree cpp_project/
cpp_project/
├── Makefile
└── src
├── include
│ ├── pch.cpp
│ └── pch.h
├── lib
└── main.cpp
3 directories, 4 files
ᗛ⦗flux⦘@⦗⇛⦘ᗘ
All headers (class, pch, and all else) and their corresponding source files are located in the src/include
directory and all object files (*.o
) and library archives (*.a
, archive of all extra objects) are compiled to src/lib
. The Makefile provides many commands to do everything with this structure in mind. If the prebuild script is created with the -p
or --prebuild
switch it will compile all of the objects from sources in src/include
and create the archive and compile precompiled headers included in pch.h (pcp.h->pch.gch).
As stated above the Makefile has many options (but not everything under the sun, of course) and many of which you may never use, but are there if needed and, of course, can be altered or added to to fit any needs.
The Makefile defaults to C++20. To learn more about my system just study the Makefile and it should be fairly clear.
Help message:
ᗛ⦗flux⦘@⦗⇛⦘ᗘ cppproj --help
CPP Project - Create a custom Linux C++ tree and
files project from the command line.
Customn project style developed by
Ian Pride using a normal (but custom
) Makefile system (no CMAKE) with a
possible prebuild file to help build
the precompiled header, objects, and
library archive.
USAGE:
cppproj [-h | --help] |
[-d | --directory] <DIRECTORY PATH>
[-m | --main] <MAIN FILE NAME>
[-c | --class] <CLASS FILE NAME>
[-p | --prebuild]
PARAMETERS:
DIRECTORY PATH: Parent path to the project.
MAIN FILE NAME: Name of the main source file
without the extension.
CLASS FILE NAME: Create class files by name.
Each different file name must
be preceeded by the switch:
e.g: -c ClassOne -c ClassTwo.
SWITCHES:
-h, --help This help screen.
-d, --directory Project path location.
-m, --main Main source file name.
-c, --class Class file name.
-p, --prebuild Create a prebuild file to build
precompiled header, object files
, and library archive file.
ᗛ⦗flux⦘@⦗⇛⦘ᗘ
Create a basic project in the current directory (./
):
ᗛ⦗flux⦘@⦗cpp_project⦘ᗘ cppproj
Checking if ./src/include exists...
./src/include does not exist; attempting to create directory...
./src/include was created successfully...
Checking if ./src/lib exists...
./src/lib does not exist; attempting to create directory...
./src/lib was created successfully...
Checking if ./src/main.cpp exists...
./src/main.cpp does not exist; attempting to create file...
./src/main.cpp created successfully.
Checking if ./Makefile exists...
./Makefile does not exist; attempting to create file...
./Makefile created successfully.
Checking if ./src/include/pch.cpp exists...
./src/include/pch.cpp does not exist; attempting to create file...
./src/include/pch.cpp created successfully.
Checking if ./src/include/pch.h exists...
./src/include/pch.h does not exist; attempting to create file...
./src/include/pch.h created successfully.
ᗛ⦗flux⦘@⦗cpp_project⦘ᗘ tree
.
├── Makefile
└── src
├── include
│ ├── pch.cpp
│ └── pch.h
├── lib
└── main.cpp
3 directories, 4 files
ᗛ⦗flux⦘@⦗cpp_project⦘ᗘ
Create a project with a provided directory, provide a prebuild script, and change the name of the main source file:
ᗛ⦗flux⦘@⦗⇛⦘ᗘ projName="cpp_project"
ᗛ⦗flux⦘@⦗⇛⦘ᗘ cppproj -d $projName -m $projName -p
Checking if cpp_project/src/include exists...
cpp_project/src/include does not exist; attempting to create directory...
cpp_project/src/include was created successfully...
Checking if cpp_project/src/lib exists...
cpp_project/src/lib does not exist; attempting to create directory...
cpp_project/src/lib was created successfully...
Checking if cpp_project/src/cpp_project.cpp exists...
cpp_project/src/cpp_project.cpp does not exist; attempting to create file...
cpp_project/src/cpp_project.cpp created successfully.
Checking if cpp_project/Makefile exists...
cpp_project/Makefile does not exist; attempting to create file...
cpp_project/Makefile created successfully.
Checking if cpp_project/src/include/pch.cpp exists...
cpp_project/src/include/pch.cpp does not exist; attempting to create file...
cpp_project/src/include/pch.cpp created successfully.
Checking if cpp_project/src/include/pch.h exists...
cpp_project/src/include/pch.h does not exist; attempting to create file...
cpp_project/src/include/pch.h created successfully.
Checking if cpp_project/prebuild exists...
cpp_project/prebuild does not exist; attempting to create file...
cpp_project/prebuild created successfully.
ᗛ⦗flux⦘@⦗⇛⦘ᗘ tree $projName
cpp_project
├── Makefile
├── prebuild
└── src
├── cpp_project.cpp
├── include
│ ├── pch.cpp
│ └── pch.h
└── lib
3 directories, 5 files
ᗛ⦗flux⦘@⦗⇛⦘ᗘ
Add class files to an existing project (same goes with a new project):
ᗛ⦗flux⦘@⦗⇛⦘ᗘ projName="cpp_project"
ᗛ⦗flux⦘@⦗⇛⦘ᗘ cppproj -d $projName -m $projName -c ClassNameA -c ClassNameB
Checking if cpp_project/src/include exists...
cpp_project/src/include already exists and does not need to be created...
Checking if cpp_project/src/lib exists...
cpp_project/src/lib already exists and does not need to be created...
Checking if cpp_project/src/include/ClassNameA.cpp exists...
cpp_project/src/include/ClassNameA.cpp does not exist; attempting to create file...
cpp_project/src/include/ClassNameA.cpp created successfully.
Checking if cpp_project/src/include/ClassNameA.h exists...
cpp_project/src/include/ClassNameA.h does not exist; attempting to create file...
cpp_project/src/include/ClassNameA.h created successfully.
Checking if cpp_project/src/include/ClassNameB.cpp exists...
cpp_project/src/include/ClassNameB.cpp does not exist; attempting to create file...
cpp_project/src/include/ClassNameB.cpp created successfully.
Checking if cpp_project/src/include/ClassNameB.h exists...
cpp_project/src/include/ClassNameB.h does not exist; attempting to create file...
cpp_project/src/include/ClassNameB.h created successfully.
Checking if cpp_project/src/cpp_project.cpp exists...
cpp_project/src/cpp_project.cpp already exists and does not need to be created...
Checking if cpp_project/Makefile exists...
cpp_project/Makefile already exists and does not need to be created...
Checking if cpp_project/src/include/pch.cpp exists...
cpp_project/src/include/pch.cpp already exists and does not need to be created...
Checking if cpp_project/src/include/pch.h exists...
cpp_project/src/include/pch.h already exists and does not need to be created...
ᗛ⦗flux⦘@⦗⇛⦘ᗘ tree $projName
cpp_project
├── Makefile
├── prebuild
└── src
├── cpp_project.cpp
├── include
│ ├── ClassNameA.cpp
│ ├── ClassNameA.h
│ ├── ClassNameB.cpp
│ ├── ClassNameB.h
│ ├── pch.cpp
│ └── pch.h
└── lib
3 directories, 9 files
ᗛ⦗flux⦘@⦗⇛⦘ᗘ
This project is written in C++
.
This is graded by CodeFactor and is subjective, but helps me to refactor my work.
Name | Status |
---|---|
codefactor.io |
All hashes are retrieved at compile/build time.
Description | Status |
---|---|
Project Release Date | |
Total downloads for this project | |
Complete repository size | |
Commits in last month | |
Commits in last year |
Logo
Help message
If you like any of the projects below and care to donate to my PayPal:
Or Buy Me A Coffee if your prefer:
License Excerpt
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.