Skip to content

Instantly share code, notes, and snippets.

@xslendix
Created May 14, 2020 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xslendix/fde51b9415fad060b185855e04ab7bf2 to your computer and use it in GitHub Desktop.
Save xslendix/fde51b9415fad060b185855e04ab7bf2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
for var in "$@"
do
printf "Generating project $var "
# Generate project
if [[ -d $var ]]
then
printf "[\e[0;49;91mFAILED\e[m]\n"
echo "E: $var exists on your filesystem."
continue
else
mkdir -p $var/src $var/include
echo -e "appname := $var
CXX := g++
CXXFLAGS := -Wall -g -Iinclude
srcfiles := \$(shell find src -maxdepth 1 -name "*.cpp")
objects := \$(patsubst %.cpp, %.o, \$(srcfiles))
all: \$(appname)
\$(appname): \$(objects)
\t\$(CXX) \$(CXXFLAGS) \$(LDFLAGS) -o \$(appname) \$(objects) \$(LDLIBS)
depend: .depend
.depend: \$(srcfiles)
\trm -f ./.depend
\t\$(CXX) \$(CXXFLAGS) -MM $^>>./.depend;
clean:
\trm -f \$(objects)
dist-clean: clean
\trm -f *~ .depend
include .depend" >> $var/Makefile;
echo -e "#include <iostream>
int main(int argc, char** argv) {
std::cout << \"Hello World!\\\\n\";
return 0;
}\n" >> $var/src/main.cpp;
fi
printf "[ \e[0;49;32mDONE\e[m ]\n"
done
#!/usr/bin/env bash
for var in "$@"
do
printf "Generating $var.hpp "
if [[ -f $var ]]
then
printf "[\e[0;49;91mFAILED\e[m]\n"
echo "E: $var exists on your filesystem."
continue
else
echo -e "#ifndef _${var^^}_HPP
#define _${var^^}_HPP
// Your code goes here
#endif // _${var^^}_HPP\n" >> $var.hpp
fi
printf "[ \e[0;49;32mDONE\e[m ]\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment