Automate creation of C/C++ projects with Visual Studio Code
This automation tool is mainly targeted at Linux and macOS users.
Clone this project into your $HOME directory (or any directory really).
- Simple to setup and use
- No need to install (but possible)
- No hidden configuration files
- No modification of your system
- Inspired by Create React App
- Tested and maintained for Linux and macOS
Bash is really the only true requirement to run the script.
The list below is additional software to get the most out of VSCODE INIT.
- Bash or Zsh
- Visual Studio Code
- C/C++ for Visual Studio Code (VSCode plugin)
- gcc, gdb, clang, lldb, Make, Meson
- clang-format (optional)
- git (optional)
- Valgrind (optional)
- AddressSanitizer (optional)
Install the C/C++ for Visual Studio Code plugin https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools
After this repo has been cloned to your $HOME directory, the following commands
can be used to create C/C++ projects.
To create a C project in the directory /tmp/test1 run:
~/vscode_init/bin/create-c-app /tmp/test1To create a C++ project in the directory /tmp/test1 run:
~/vscode_init/bin/create-cpp-app /tmp/test1To install the scripts run (as root):
make installdefault location is /usr/local/
to uninstall the scripts run (as root):
make uninstallUse PREFIX to specify your own installation directory:
make install PREFIX=/usr/localIf you don't want to install the scripts, they can be run directly.
Add to ~/.zshrc (or your shell config of choice).
These aliases can be added automatically by running append_alias.sh
alias copy-vsctasks="$HOME/vscode_init/utils/copy_tasks.sh"alias create-c-app="$HOME/vscode_init/bin/create-c-app"alias create-cpp-app="$HOME/vscode_init/bin/create-cpp-app"alias create-shared-lib-c-app="$HOME/vscode_init/bin/create-shared-lib-c-app"alias create-c-meson-app="$HOME/vscode_init/bin/create-c-meson-app"In a directory of choice then run:
create-c-app <name-of-my-app>to setup a C project with VScode tasks.
Or run:
copy-vsctasksin an existing project to copy VScode tasks to that directory.
To build your newly created C project run:
makein the root directory of the project.
To build a production suitable binary run:
FINAL=y makeEdit settings.json to add custom project workspace settings.
Example: source a script for zsh at terminal startup.
{
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "zsh",
"args": [
"-c",
"source ${workspaceFolder}/my_script.sh; zsh"
]
}
}
}