aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-12-07 04:01:14 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-12-07 04:01:14 +0200
commit290a499b3ac03cd241255880e3176d2656741ca1 (patch)
tree8618021d01fbab8106c429cd1be838161fbb76c2 /src
parentfbf8c1d3cf60bf620b1535a0af523ff23ae3a200 (diff)
downloadarching-kaos-tools-290a499b3ac03cd241255880e3176d2656741ca1.tar.gz
arching-kaos-tools-290a499b3ac03cd241255880e3176d2656741ca1.tar.bz2
arching-kaos-tools-290a499b3ac03cd241255880e3176d2656741ca1.zip
Updating build system
Diffstat (limited to 'src')
-rwxr-xr-xsrc/build.sh25
-rwxr-xr-xsrc/build_tree/ak_fs_build.sh15
-rwxr-xr-xsrc/build_tree/ak_log_build.sh9
-rwxr-xr-xsrc/build_tree/ak_settings_build.sh2
-rwxr-xr-xsrc/new_lib.sh83
5 files changed, 113 insertions, 21 deletions
diff --git a/src/build.sh b/src/build.sh
index 3ad716e..b09c0de 100755
--- a/src/build.sh
+++ b/src/build.sh
@@ -4,24 +4,7 @@ then
mkdir $PWD/lib
fi
-echo "Building lib/akfs.so" && \
-gcc -c -shared -Wextra -Wall -Werror -pedantic -ggdb -fPIC -I./include akfs.c -o lib/akfs.so && \
-echo "Building tests/test_akfs" && \
-gcc -Wextra -Wall -Werror -pedantic -ggdb -Wl,-rpath=lib -I./include tests/test_akfs.c lib/akfs.so -o tests/test_akfs && \
-echo "Running test_akfs" && \
-time ./tests/test_akfs
-rm ./tests/test_akfs
-
-echo "Building tests/test_akfs_mkdir.c" && \
-gcc -Wextra -Wall -Werror -pedantic -ggdb -Wl,-rpath=lib -I./include tests/test_akfs_mkdir.c lib/akfs.so -o tests/test_akfs_mkdir && \
-echo "Running test_akfs_mkdir" && \
-time ./tests/test_akfs_mkdir
-rm ./tests/test_akfs_mkdir
-
-echo "Building lib/aklog.so" && \
-gcc -c -shared -Wextra -Wall -Werror -pedantic -ggdb -fPIC -I./include aklog.c -o lib/aklog.so && \
-echo "Building tests/test_aklog" && \
-gcc -Wextra -Wall -Werror -pedantic -ggdb -Wl,-rpath=lib -I./include tests/test_aklog.c lib/aklog.so -o tests/test_aklog && \
-echo "Running test_aklog" && \
-time ./tests/test_aklog
-rm ./tests/test_aklog
+find build_tree -type f | while read build_script
+do
+ bash ${build_script}
+done
diff --git a/src/build_tree/ak_fs_build.sh b/src/build_tree/ak_fs_build.sh
new file mode 100755
index 0000000..91ad759
--- /dev/null
+++ b/src/build_tree/ak_fs_build.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+echo "Building lib/akfs.so" && \
+gcc -c -shared -Wextra -Wall -Werror -pedantic -ggdb -fPIC -I./include akfs.c -o lib/akfs.so && \
+echo "Building tests/test_akfs" && \
+gcc -Wextra -Wall -Werror -pedantic -ggdb -Wl,-rpath=lib -I./include tests/test_akfs.c lib/akfs.so -o tests/test_akfs && \
+echo "Running test_akfs" && \
+time ./tests/test_akfs
+rm ./tests/test_akfs
+
+echo "Building tests/test_akfs_mkdir.c" && \
+gcc -Wextra -Wall -Werror -pedantic -ggdb -Wl,-rpath=lib -I./include tests/test_akfs_mkdir.c lib/akfs.so -o tests/test_akfs_mkdir && \
+echo "Running test_akfs_mkdir" && \
+time ./tests/test_akfs_mkdir
+rm ./tests/test_akfs_mkdir
diff --git a/src/build_tree/ak_log_build.sh b/src/build_tree/ak_log_build.sh
new file mode 100755
index 0000000..bbc8db6
--- /dev/null
+++ b/src/build_tree/ak_log_build.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+echo "Building lib/aklog.so" && \
+gcc -c -shared -Wextra -Wall -Werror -pedantic -ggdb -fPIC -I./include aklog.c -o lib/aklog.so && \
+echo "Building tests/test_aklog" && \
+gcc -Wextra -Wall -Werror -pedantic -ggdb -Wl,-rpath=lib -I./include tests/test_aklog.c lib/aklog.so -o tests/test_aklog && \
+echo "Running test_aklog" && \
+time ./tests/test_aklog
+rm ./tests/test_aklog
diff --git a/src/build_tree/ak_settings_build.sh b/src/build_tree/ak_settings_build.sh
new file mode 100755
index 0000000..5edcd19
--- /dev/null
+++ b/src/build_tree/ak_settings_build.sh
@@ -0,0 +1,2 @@
+echo "Building lib/aksettings.so" && gcc -c -shared -Wextra -Wall -Werror -pedantic -ggdb -fPIC -I./include aksettings.c -o lib/aksettings.so && echo "Building tests/test_aksettings" && gcc -Wextra -Wall -Werror -pedantic -ggdb -Wl,-rpath=lib -I./include tests/test_aksettings.c lib/aksettings.so -o tests/test_aksettings && echo "Running test_aksettings" && time ./tests/test_aksettings
+rm ./tests/test_aksettings
diff --git a/src/new_lib.sh b/src/new_lib.sh
new file mode 100755
index 0000000..94dd695
--- /dev/null
+++ b/src/new_lib.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+library="${1}"
+library_capitals="$(echo ${library} | tr '[:lower:]' '[:upper:]')"
+include_file="include/ak${library}.h"
+test_file="tests/test_ak${library}.c"
+implementation_file="ak${library}.c"
+build_file="build_tree/ak_${library}_build.sh"
+
+include_template(){
+ cat > ${include_file} << EOF
+#ifndef AK_${library_capitals}_H
+#define AK_${library_capitals}_H
+
+int ak_${library}();
+
+#endif // AK_${library_capitals}_H
+EOF
+
+}
+
+implementation_template(){
+ cat > ${implementation_file} << EOF
+#include <ak${library}.h>
+#include <stdio.h>
+
+int ak_${library}()
+{
+ printf("Testing: %s\n", __func__);
+ return 0;
+}
+EOF
+}
+
+test_template(){
+ cat > ${test_file} << EOF
+#include <ak${library}.h>
+
+int main()
+{
+ ak_${library}();
+ return 0;
+}
+EOF
+}
+
+build_template(){
+ cat > ${build_file} << EOF
+echo "Building lib/ak${library}.so" && \
+gcc -c -shared -Wextra -Wall -Werror -pedantic -ggdb -fPIC -I./include ak${library}.c -o lib/ak${library}.so && \
+echo "Building tests/test_ak${library}" && \
+gcc -Wextra -Wall -Werror -pedantic -ggdb -Wl,-rpath=lib -I./include tests/test_ak${library}.c lib/ak${library}.so -o tests/test_ak${library} && \
+echo "Running test_ak${library}" && \
+time ./tests/test_ak${library}
+rm ./tests/test_ak${library}
+EOF
+ chmod +x ${build_file}
+}
+
+if [ ! -f ${include_file} ]
+then
+ include_template
+else
+ echo "ERROR: ${include_file} exists"
+fi
+if [ ! -f ${test_file} ]
+then
+ test_template
+else
+ echo "ERROR: ${test_file} exists"
+fi
+if [ ! -f ${implementation_file} ]
+then
+implementation_template
+else
+ echo "ERROR: ${implementation_file} exists"
+fi
+if [ ! -f ${build_file} ]
+then
+build_template
+else
+ echo "ERROR: ${build_file} exists"
+fi