Skip to content

AbdoViper23/Smart-Compile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Smart Compile

A smart script to automate C++ compilation β€” only recompiles when the source code changes.


πŸš€ Features

  • Saves time and resources by reducing unnecessary compilations.
  • Only recompiles when the source file changes.
  • Displays clear success or error messages.

πŸ› οΈ Installation

  1. Clone the repository:
    git clone https://github.com/AbdoViper23/Smart-Compile.git
  2. Navigate to the script folder:
    cd Smart-Compile
  3. Make the script executable:
    chmod +x smart-compile.sh
  4. Ensure g++ is installed:
    sudo apt install g++

πŸš€ Usage

To compile a C++ file:

./smart-compile.sh <filename.cpp>

Example:

./smart-compile.sh main.cpp

πŸ’» Use with VS Code (Code Runner Extension)

  1. Install the Code Runner extension from the VS Code marketplace.
  2. Open VS Code and open Settings (Ctrl + ,) or go to File > Preferences > Settings.
  3. Search for code-runner.executorMap and click on Edit in settings.json.
  4. Make sure to move the script file (smart-compile.sh) to the same directory as your C++ file OR place it in the ~/bin directory, then add its path to the PATH using the command:

If it's in the same folder, you don't need to add it to ~/bin and PATH.

echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
  1. change the "CPP" configuration to use the script with C++ files:
    "code-runner.executorMap": {  
        "cpp": "bash ./smart-compile.sh $fileName"  
    }  
  2. Enable Code Runner to run in the terminal:
    • Open Settings (Ctrl + ,)
    • Search for code-runner.runInTerminal
    • Check the option βœ… "Code-runner: Run in Terminal"
  3. Save the file.
  4. To run a C++ file using Code Runner, open the file and press Ctrl + Alt + N or click the Run button.

🎯 Output Example

Successful compilation:

####################
# Compilation Done #
####################

Compilation error:

#####################
# Compilation Error #
#####################

🀝 Contributing

  1. Fork the repo.
  2. Create a new branch:
    git checkout -b feature/new-feature
  3. Make your changes and commit:
    git commit -m "Add new feature"
  4. Push to your branch:
    git push origin feature/new-feature
  5. Create a Pull Request.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages