added tools, Makefile, and setup

This commit is contained in:
Derek Tan
2024-06-26 03:36:43 -04:00
parent cb0557932a
commit 3e1fb62242
8 changed files with 119 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.~undo-tree~ *.~undo-tree~
*.dSYM~

19
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}

33
Makefile Normal file
View File

@ -0,0 +1,33 @@
# Universal makefile for single C++ program
#
# Use gcc flag -MMD (user) or -MD (user/system) to generate dependencies among source files.
# Use make default rules for commonly used file-name suffixes and make variables names.
#
# % make [ a.out ]
########## Variables ##########
CXX = g++ # compiler
CXXFLAGS = -std=c++20 -g -Wall -MMD # compiler flags
MAKEFILE_NAME = ${firstword ${MAKEFILE_LIST}} # makefile name
SOURCES = $(wildcard *.cc) # source files (*.cc)
OBJECTS = ${SOURCES:.cc=.o} # object files forming executable
DEPENDS = ${OBJECTS:.o=.d} # substitute ".o" with ".d"
EXEC = a.out # executable name
########## Targets ##########
.PHONY : clean # not file names
${EXEC} : ${OBJECTS} # link step
${CXX} ${CXXFLAGS} $^ -o $@ # additional object files before $^
${OBJECTS} : ${MAKEFILE_NAME} # OPTIONAL : changes to this file => recompile
# make implicitly generates rules to compile C++ files that generate .o files
-include ${DEPENDS} # include *.d files containing program dependences
clean : # remove files that can be regenerated
rm -f ${DEPENDS} ${OBJECTS} ${EXEC}

8
test.cc Normal file
View File

@ -0,0 +1,8 @@
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!" << endl;
}

33
tools/Makefile Normal file
View File

@ -0,0 +1,33 @@
# Universal makefile for single C++ program
#
# Use gcc flag -MMD (user) or -MD (user/system) to generate dependencies among source files.
# Use make default rules for commonly used file-name suffixes and make variables names.
#
# % make [ a.out ]
########## Variables ##########
CXX = g++-11 # compiler
CXXFLAGS = -std=c++20 -g -Wall -MMD # compiler flags
MAKEFILE_NAME = ${firstword ${MAKEFILE_LIST}} # makefile name
SOURCES = $(wildcard *.cc) # source files (*.cc)
OBJECTS = ${SOURCES:.cc=.o} # object files forming executable
DEPENDS = ${OBJECTS:.o=.d} # substitute ".o" with ".d"
EXEC = a.out # executable name
########## Targets ##########
.PHONY : clean # not file names
${EXEC} : ${OBJECTS} # link step
${CXX} ${CXXFLAGS} $^ -o $@ # additional object files before $^
${OBJECTS} : ${MAKEFILE_NAME} # OPTIONAL : changes to this file => recompile
# make implicitly generates rules to compile C++ files that generate .o files
-include ${DEPENDS} # include *.d files containing program dependences
clean : # remove files that can be regenerated
rm -f ${DEPENDS} ${OBJECTS} ${EXEC}

25
tools/compile Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# Use this script to compile your .cc files in dependency order
# Arguments:
# $1 = name of file containing list of .cc files
# $2 = name of the output file
cxx="g++-11"
cxxflags="-std=c++20 -fmodules-ts -Wall -g"
if [ $# -lt 1 ]; then
echo "Usage: $0 list-filename [output-name]" 1>&2
exit 1
fi
if [ $# -eq 2 ]; then
name="-o $2"
fi
for x in $(cat $1); do
$cxx $cxxflags -c $x
done
$cxx *.o $name

BIN
tools/produceOutputs Executable file

Binary file not shown.

BIN
tools/runSuite Executable file

Binary file not shown.