Skip to content

Commit

Permalink
code updates complete, now only documentation is left.
Browse files Browse the repository at this point in the history
  • Loading branch information
jyothiraditya-n committed Aug 17, 2023
1 parent b8bdbec commit 0d9d992
Show file tree
Hide file tree
Showing 19 changed files with 597 additions and 667 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/c-cpp.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: C/C++ CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v3

- name: Install Dependencies
run: |
apt-get update
apt-get install -y valgrind
- name: Autoconfigure Build
run: make autoconfig

- name: Test
run: make test release
69 changes: 37 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,39 @@
ifeq ($(shell [ -d ".config/" ] && echo "config"),)
ifeq ($(filter config,$(MAKECMDGOALS)),)
ifeq ($(filter autoconfig,$(MAKECMDGOALS)),)
$(info *** Configuration missing; running `make autoconfig'.)

$(info *** Configuration missing; running 'make autoconfig'.)
$(shell make autoconfig)

endif
endif
endif

# Compilation Flags for Make
# We want to build with debugging symbols as a default.
.DEFAULT_GOAL = debug

# Compilation Flags for C
# Getting Config Values.
CC = $(shell cat .config/cc.conf)

ifneq ($(filter release,$(MAKECMDGOALS)),)
CFLAGS = $(shell cat .config/cflags_release.conf)
else
CFLAGS = $(shell cat .config/cflags_debug.conf)
endif

# Compilation Flags for C++
CPP = $(shell cat .config/cpp.conf)

ifneq ($(filter release,$(MAKECMDGOALS)),)
CCFLAGS = $(shell cat .config/ccflags_release.conf)
else
CCFLAGS = $(shell cat .config/ccflags_debug.conf)
endif

# Compilation Flags for Linking
LD = $(shell cat .config/ld.conf)
AR = $(shell cat .config/ar.conf)

LD_LIBS = $(shell cat .config/ld_libs.conf)

# Command to make the LaTeX docs.
ifneq ($(filter release,$(MAKECMDGOALS)),)

CFLAGS = $(shell cat .config/cflags_release.conf)
CCFLAGS = $(shell cat .config/ccflags_release.conf)
LATEX = $(shell cat .config/latex_release.conf)
TEST_FLAGS = -valgrind

else

CFLAGS = $(shell cat .config/cflags_debug.conf)
CCFLAGS = $(shell cat .config/ccflags_debug.conf)
LATEX = $(shell cat .config/latex_debug.conf)
TEST_FLAGS = -nogrind

endif

# Files that need to be created.
Expand All @@ -65,21 +60,26 @@ build_scripts = $(wildcard *.sh)
test_scripts = $(wildcard tests/*.sh)
scripts = $(build_scripts) $(test_scripts)

c_srcs = $(shell find * -type f -name "*.c")
cpp_srcs += $(shell find * -type f -name "*.cpp")

c_headers = $(shell find inc/ -type f -name "*.h")
cpp_headers += $(shell find inc/ -type f -name "*.hpp")
headers = $(c_headers) $(cpp_headers)

c_texs = $(patsubst demos/%.c,build/docs/%.c.tex,$(wildcard demos/*.c))
cpp_texs = $(patsubst demos/%.cpp,build/docs/%.cpp.tex,$(wildcard demos/*.cpp))
texs = $(c_texs) $(cpp_texs)

docs = $(texs) $(wildcard docs/*)
headers = $(wildcard inc/*.h) $(wildcard inc/libClame/*.h)
headers = $(wildcard inc/*.hpp) $(wildcard inc/libClame/*.hpp)

c_objs = $(patsubst src/%.c,build/src/%.o,$(wildcard src/*.c))
cpp_objs = $(patsubst src/%.cpp,build/src/%_cpp.o,$(wildcard src/*.cpp))
objs = $(c_objs) $(cpp_objs)

c_demos = $(patsubst demos/%.c,build/%_demo,$(wildcard demos/*.c))
cpp_demos += $(patsubst demos/%.cpp,build/%_cpp_demo,$(wildcard demos/*.cpp))
demos = $(c_demos) $(cpp_demos)
demos = $(c_demos) $(cpp_de_mos)

c_tests = $(patsubst tests/%.c,build/%_test,$(wildcard tests/*.c))
cpp_tests += $(patsubst tests/%.cpp,build/%_cpp_test,$(wildcard tests/*.cpp))
Expand Down Expand Up @@ -136,13 +136,8 @@ build/libClame.pdf : $(docs)
mv build/docs/main.pdf build/libClame.pdf

# Commands
.PHONY : config autoconfig release debug demos docs test clean deep-clean

config : $(build_scripts)
./configure.sh

autoconfig : $(build_scripts)
./configure.sh -auto
.PHONY : release debug demos docs clean deep-clean
.PHONY : config autoconfig tidy format

release : build/libClame.a

Expand All @@ -157,12 +152,22 @@ clean :

deep-clean : clean
-rm -r .config/
config : $(build_scripts)

./configure.sh

autoconfig : $(build_scripts)
./configure.sh -auto

tidy :
clang-tidy $(c_srcs) $(headers) -- $(CFLAGS)
cland-tidy $(cpp_srcs) $(headers) -- $(CCFLAGS)

# Testing requires a little bit of hacky coding.
runnable_tests = $(patsubst %,run-%,$(test_scripts))

.PHONY : $(runnable_tests)
.PHONY : $(runnable_tests) test
$(runnable_tests) : run-% : % $(tests)
$<
$< $(TEST_FLAGS)

test : $(runnable_tests)
47 changes: 0 additions & 47 deletions clang_tidy.sh

This file was deleted.

24 changes: 8 additions & 16 deletions demos/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ std::list<double> coords;
* without preceding flags. */
std::vector<std::string> files;

/* These helper functions are specified as part of the arguments structure. */
void about_func();
void help_func();

/* We want a vector of the arguments. */
std::vector<LC_flag_t> flags;

Expand All @@ -99,10 +95,16 @@ void print_arr(const std::string header, const C<T>& arr) {

int main(int argc, char **argv) {
/* --about, -a: prints the about dialogue. */
flags.push_back(libClame::make_call("about", 'a', about_func));
flags.push_back(libClame::make_call("about", 'a', [](){
std::cout << LICENCE_TEXT;
std::exit(0);
}));

/* --help, -h: prints the help dialogue. */
flags.push_back(libClame::make_call("help", 'h', help_func));
flags.push_back(libClame::make_call("help", 'h', [](){
std::cout << HELP_TEXT(libClame::prog_name);
std::exit(0);
}));

/* --flag, -f: sets the flag to true. */
flags.push_back(libClame::make_bool("flag", 'f', flag, true));
Expand Down Expand Up @@ -166,13 +168,3 @@ int main(int argc, char **argv) {
std::cout << "\n\n"; // Two extra newlines for padding.
std::exit(0);
}

void about_func() {
std::cout << LICENCE_TEXT;
std::exit(0);
}

void help_func() {
std::cout << HELP_TEXT(libClame::prog_name);
std::exit(0);
}
Loading

0 comments on commit 0d9d992

Please sign in to comment.