use static library instead of object

This commit is contained in:
grimhilt 2023-11-13 13:06:47 +01:00
parent c7d011b301
commit 60c6c6b8c4
5 changed files with 33 additions and 12 deletions

16
.gitignore vendored Normal file
View File

@ -0,0 +1,16 @@
*
!/**/
!*.*
!Makefile
*~
*.swp
*.swo
*.o
*.a
*.so
*.class
*.log
*.core
*.gcno
*.tar*

View File

@ -1,21 +1,24 @@
CC = gcc
CFLAGS := -std=c99 -Wall -Wextra -Werror -pedantic -Wvla
OBJ_RUN := src/student.c src/main.o src/pin_handler.o
OBJ_RUN := src/student.c
all: run
%.o: %.c
@$(CC) $(LFLAGS) $(CFLAGS) -c -o $@ $<
prepare: CFLAGS += -shared
prepare: src/main.o src/pin_handler.o
ar crs src/pin_handler.a $^
tar czf student.tar.gz src/pin_handler.a src/student.c src/default_student.c Makefile student.ino src/parser.c
parser: src/parser.o student.ino
@$(CC) $(CFLAGS) -o $@ src/parser.o
@./parser ./student.ino
run: parser $(OBJ_RUN) student.ino
@$(CC) -o main $(OBJ_RUN)
@$(CC) -o main $(OBJ_RUN) src/pin_handler.a
@./main
%.o: %.c
@$(CC) $(LFLAGS) $(CFLAGS) -c -o $@ $<
clean:
$(RM) src/*.o main parser

View File

@ -9,8 +9,10 @@
*Note that the passcode must end with a '#'*
2. Run the command ``make prepare``
3. Give this repository to your student but make sure not to give the ``src/pin_handler.h`` file or to change the passcode you compiled with
4. To test the ``student.ino`` just run ``make run``
*This will create a ``student.tar.gz`` that will contain the static library used to run the student code and the parser code*
3. To test the ``student.ino`` just run ``make run``
## Warning
@ -18,4 +20,6 @@ This is a very very basic parser, and so it will not work with a certain number
* if you don't use the variable for the pin numbers
* if you write 'digitalWrite()' on several lines
* if you move the loop() opening bracket on the next line
* ...
* if the main loop() call others functions
* if you use arduino or c++ specific functions
* ...

View File

@ -1,4 +1,3 @@
#include "pin_handler.h"
#include <stddef.h>
#define L1 1
@ -10,7 +9,7 @@
#define C3 7
#define C4 8
void set_pin(int id, short state, size_t *row, size_t *col, char *sequence, size_t *pointer);
void student(char *sequence, size_t *pointer)
{

View File

@ -1,4 +1,3 @@
#include "pin_handler.h"
#include <stddef.h>
#define L1 1
@ -10,7 +9,7 @@
#define C3 7
#define C4 8
void set_pin(int id, short state, size_t *row, size_t *col, char *sequence, size_t *pointer);
void student(char *sequence, size_t *pointer)
{