Created
April 20, 2016 21:55
-
-
Save arbalest/01c45e4a8c5d4780adc220c0667f9663 to your computer and use it in GitHub Desktop.
Quick python script for compiling all .cpp files in a folder and subfolders with G++ (A simple, lazy makefile in Python)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Recursively finds all .cpp files within the current directory, | |
# and compiles them, printing any messages generated by g++ and writing the | |
# output to the bin folder. | |
from pathlib import Path | |
import os | |
import subprocess | |
bin_path = 'bin/output' | |
file_list = [] # The list of .cpp files to be compiled | |
for a_file in Path('.').glob('**/*.cpp'): | |
file_list.append(str(a_file)) | |
cpp_file_sep = ' ' | |
command = 'g++ -I./ ' + cpp_file_sep.join(file_list) + ' -o ' + bin_path | |
print(subprocess.getoutput(command)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment