aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-24 21:56:59 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-24 21:56:59 +0200
commit937a3a736aaf2c468c8c8e8dbc7963a87eae890f (patch)
treedb8d9a717727b907c77c24aff98ed90c82ccb22a
parentede8a89706209fa26e151a34a28e64affbffd23d (diff)
move some code to a shared folder
-rw-r--r--client/makefile1
-rw-r--r--robot/errcatch.c1
-rw-r--r--robot/errcatch.h2
-rw-r--r--robot/makefile1
-rw-r--r--robot/sercomm.c2
-rw-r--r--robot/sercomm.h4
-rw-r--r--robot/setup.c4
-rw-r--r--robot/sim.c2
-rw-r--r--shared/bin.c (renamed from robot/bin.c)0
-rw-r--r--shared/bin.h (renamed from robot/bin.h)0
-rw-r--r--shared/consts.h (renamed from robot/consts.h)0
-rw-r--r--shared/makefile2
-rw-r--r--shared/readme.md8
13 files changed, 19 insertions, 8 deletions
diff --git a/client/makefile b/client/makefile
index 23d5ce6..2209c95 100644
--- a/client/makefile
+++ b/client/makefile
@@ -6,6 +6,7 @@ EXECNAME = main
SOURCES := $(wildcard *.c)
HEADERS := $(wildcard *.h)
+include ../shared/makefile
OBJECTS := $(patsubst %.c,%.o, $(SOURCES))
all: main
diff --git a/robot/errcatch.c b/robot/errcatch.c
index 2a59d3d..4bdbaef 100644
--- a/robot/errcatch.c
+++ b/robot/errcatch.c
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <string.h>
-#include "consts.h"
#include "errcatch.h"
#include "halt.h"
#include "modes.h"
diff --git a/robot/errcatch.h b/robot/errcatch.h
index f0e25d9..1e273bd 100644
--- a/robot/errcatch.h
+++ b/robot/errcatch.h
@@ -2,7 +2,7 @@
#include <stdint.h>
-#include "consts.h"
+#include "../shared/consts.h"
#define W2_E_TYPE_MASK (0b11 << 6)
diff --git a/robot/makefile b/robot/makefile
index 53010dd..cd5c032 100644
--- a/robot/makefile
+++ b/robot/makefile
@@ -12,6 +12,7 @@ LDFLAGS=-Wl,-gc-sections -Wl,-relax
SOURCES := $(filter-out sim.c, $(wildcard *.c))
HEADERS := $(filter-out sim.h, $(wildcard *.h))
+include ../shared/makefile
# simulation
SIM = true
diff --git a/robot/sercomm.c b/robot/sercomm.c
index d1bb3b3..7072f9e 100644
--- a/robot/sercomm.c
+++ b/robot/sercomm.c
@@ -1,7 +1,7 @@
#include <stdlib.h>
#include <string.h>
-#include "bin.h"
+#include "../shared/bin.h"
#include "orangutan_shim.h"
#include "sercomm.h"
diff --git a/robot/sercomm.h b/robot/sercomm.h
index bc9fc1e..44fdf08 100644
--- a/robot/sercomm.h
+++ b/robot/sercomm.h
@@ -1,7 +1,7 @@
#pragma once
-#include "bin.h"
-#include "consts.h"
+#include "../shared/bin.h"
+#include "../shared/consts.h"
#define W2_CMDDIR_RX (0)
#define W2_CMDDIR_TX (1)
diff --git a/robot/setup.c b/robot/setup.c
index 36c5da1..6af1a05 100644
--- a/robot/setup.c
+++ b/robot/setup.c
@@ -1,7 +1,7 @@
#include <stdlib.h>
-#include "bin.h"
-#include "consts.h"
+#include "../shared/bin.h"
+#include "../shared/consts.h"
#include "halt.h"
#include "modes.h"
#include "orangutan_shim.h"
diff --git a/robot/sim.c b/robot/sim.c
index 47c0c78..b061c9a 100644
--- a/robot/sim.c
+++ b/robot/sim.c
@@ -6,7 +6,7 @@
#include <unistd.h>
#include "sim.h"
-#include "consts.h"
+#include "../shared/consts.h"
#include "sercomm.h"
struct timespec reference_time; // NOLINT
diff --git a/robot/bin.c b/shared/bin.c
index a2c91a4..a2c91a4 100644
--- a/robot/bin.c
+++ b/shared/bin.c
diff --git a/robot/bin.h b/shared/bin.h
index 1c9b951..1c9b951 100644
--- a/robot/bin.h
+++ b/shared/bin.h
diff --git a/robot/consts.h b/shared/consts.h
index 70efcac..70efcac 100644
--- a/robot/consts.h
+++ b/shared/consts.h
diff --git a/shared/makefile b/shared/makefile
new file mode 100644
index 0000000..815d33c
--- /dev/null
+++ b/shared/makefile
@@ -0,0 +1,2 @@
+SOURCES += $(wildcard ../shared/*.c)
+HEADERS += $(wildcard ../shared/*.h)
diff --git a/shared/readme.md b/shared/readme.md
new file mode 100644
index 0000000..870f015
--- /dev/null
+++ b/shared/readme.md
@@ -0,0 +1,8 @@
+# shared code
+
+this is the subdirectory for all code that is shared between the robot code and
+the client code. to use these, include the .h files with a relative path (e.g.
+`#include "../shared/consts.h"`). makefiles should add `include
+../shared/makefile` to add the .c and .h files to `$SOURCES` and `$HEADERS` in
+the makefile targets (this is already done for the robot and client
+subdirectories).