Merge pull request 'First build system' (#1) from first-build into main
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -52,3 +52,5 @@ Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
# Ignore /bin directory
|
||||
/bin
|
||||
|
||||
29
build-all.sh
Executable file
29
build-all.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Build script to build everything
|
||||
|
||||
set echo on
|
||||
|
||||
mkdir -p bin/
|
||||
|
||||
echo "Building all.."
|
||||
|
||||
pushd quantum
|
||||
source build.sh
|
||||
popd
|
||||
|
||||
ERRORLEVEL=$?
|
||||
if [ $ERRORLEVEL -ne 0 ]; then
|
||||
echo "Error:"$ERRORLEVEL && exit
|
||||
fi
|
||||
|
||||
pushd test_stuff
|
||||
source build.sh
|
||||
popd
|
||||
|
||||
ERRORLEVEL=$?
|
||||
if [ $ERRORLEVEL -ne 0 ]; then
|
||||
echo "Error:"$ERRORLEVEL && exit
|
||||
fi
|
||||
|
||||
echo "All assemblies built successfully!!!!"
|
||||
23
quantum/build.sh
Executable file
23
quantum/build.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Build script for quantum
|
||||
|
||||
set echo on
|
||||
|
||||
mkdir -p build/
|
||||
|
||||
# Get a list of all the .c files.
|
||||
cFilenames=$(find . -type f -name "*.c")
|
||||
|
||||
assembly="quantum"
|
||||
objLocation="build/libquantum.o"
|
||||
compilerFlags="-g -c -fpic"
|
||||
includeFlags="-Isrc"
|
||||
|
||||
echo "Building $assembly..."
|
||||
|
||||
# First we need to compile down to .o files
|
||||
gcc $cFilenames $compilerFlags -o $objLocation $includeFlags
|
||||
|
||||
compilerFlags="-g -shared"
|
||||
gcc $objLocation $compilerFlags -o ../bin/libquantum.so $includeFlags
|
||||
5
quantum/src/test.c
Normal file
5
quantum/src/test.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "test.h"
|
||||
|
||||
void hello_quantum() { printf("Hello from Quantum!\n"); }
|
||||
1
quantum/src/test.h
Normal file
1
quantum/src/test.h
Normal file
@@ -0,0 +1 @@
|
||||
void hello_quantum();
|
||||
15
test_stuff/build.sh
Executable file
15
test_stuff/build.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
#Build script for test_stuff
|
||||
|
||||
set echo on
|
||||
|
||||
# Get a list of all the .c files.
|
||||
cFilenames=$(find . -type f -name "*.c")
|
||||
|
||||
assembly="test_stuff"
|
||||
compilerFlags="-g -fpic"
|
||||
includeFlags="-Isrc -I../quantum/src/"
|
||||
linkerFlags="-L../bin/ -lquantum -Wl,-rpath,."
|
||||
|
||||
echo "Building $assembly..."
|
||||
gcc $cFilenames $compilerFlags -o ../bin/$assembly $includeFlags $linkerFlags
|
||||
7
test_stuff/src/main.c
Normal file
7
test_stuff/src/main.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <test.h>
|
||||
|
||||
int main() {
|
||||
hello_quantum();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user