From 11902762a8002add276fdff183f09bc7a3666396 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Mon, 13 May 2013 19:48:50 +0200 Subject: [PATCH] Various small tweaks. --- lib/Makefile | 9 +++++++++ lib/c/Makefile | 16 ++++++++-------- lib/c/labcomm_fd_reader.c | 7 +++++-- lib/c/labcomm_fd_writer.c | 4 ++++ lib/c/test/generated_encoding.lc | 2 ++ lib/java/Makefile | 27 +++++++++++++++++++++++++++ 6 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 lib/Makefile create mode 100644 lib/java/Makefile diff --git a/lib/Makefile b/lib/Makefile new file mode 100644 index 0000000..3fa0e1f --- /dev/null +++ b/lib/Makefile @@ -0,0 +1,9 @@ +all: + cd c ; make + cd csharp ; make + cd java ; make + +clean: + cd c ; make clean + cd csharp ; make clean + cd java ; make clean diff --git a/lib/c/Makefile b/lib/c/Makefile index 4f578ee..83f350f 100644 --- a/lib/c/Makefile +++ b/lib/c/Makefile @@ -7,8 +7,8 @@ LDFLAGS = -L. LDLIBS_TEST = -Tlabcomm.linkscript -lcunit -llabcomm OBJS= labcomm.o labcomm_dynamic_buffer_writer.o labcomm_fd_reader.o labcomm_fd_writer.o labcomm_mem_reader.o labcomm_mem_writer.o -LABCOMMC_PATH=../../compiler -LABCOMMC_JAR=$(LABCOMMC_PATH)/labComm.jar +LABCOMM_JAR=../../compiler/labComm.jar +LABCOMM=java -jar $(LABCOMM_JAR) TESTS=test_labcomm_basic_type_encoding test_labcomm_generated_encoding test_labcomm #FIXME: test_labcomm_errors @@ -33,7 +33,7 @@ endif .PHONY: all run-test clean distclean -all: liblabcomm.a test/test_labcomm_errors +all: liblabcomm.a liblabcomm.a: $(OBJS) ar -r liblabcomm.a $^ @@ -68,19 +68,19 @@ $(TEST_DIR)/gen: mkdir -p $@ $(TEST_DIR)/gen/%.c $(TEST_DIR)/gen/%.h: $(TEST_DIR)/%.lc | $(TEST_DIR)/gen - java -jar $(LABCOMMC_JAR) \ + $(LABCOMM) \ --c=$(TEST_DIR)/gen/$*.c \ --h=$(TEST_DIR)/gen/$*.h \ $< $(TEST_GEN_DIR)/%.c $(TEST_GEN_DIR)/%.h: $(TESTDATA_DIR)/%.lc \ - $(LABCOMMC_JAR) | $(TEST_GEN_DIR) - java -jar $(LABCOMMC_JAR) \ + $(LABCOMM_JAR) | $(TEST_GEN_DIR) + $(LABCOMM) \ --c=$(patsubst %.h,%.c,$@) --h=$(patsubst %.c,%.h,$@) $< -$(LABCOMMC_JAR): +$(LABCOMM_JAR): @echo "======Building LabComm compiler======" - cd $(LABCOMMC_PATH); ant jar + cd $(shell dirname $(LABCOMM_JAR)); ant jar @echo "======End building LabComm compiler======" %.o: %.c %.h diff --git a/lib/c/labcomm_fd_reader.c b/lib/c/labcomm_fd_reader.c index 62cb6b4..6940e1c 100644 --- a/lib/c/labcomm_fd_reader.c +++ b/lib/c/labcomm_fd_reader.c @@ -16,6 +16,7 @@ int labcomm_fd_reader( switch (action) { case labcomm_reader_alloc: { +#ifndef LABCOMM_FD_OMIT_VERSION va_list ap; va_start(ap, action); char *version = va_arg(ap, char *); @@ -23,7 +24,7 @@ int labcomm_fd_reader( read(*fd, tmp, strlen(version)); free(tmp); - +#endif r->data = malloc(BUFFER_SIZE); if (r->data) { r->data_size = BUFFER_SIZE; @@ -34,7 +35,9 @@ int labcomm_fd_reader( } r->count = 0; r->pos = 0; - va_end(ap); +#ifndef LABCOMM_FD_OMIT_VERSION + va_end(ap); +#endif } break; case labcomm_reader_start: case labcomm_reader_continue: { diff --git a/lib/c/labcomm_fd_writer.c b/lib/c/labcomm_fd_writer.c index 196e18f..0eecccd 100644 --- a/lib/c/labcomm_fd_writer.c +++ b/lib/c/labcomm_fd_writer.c @@ -17,11 +17,13 @@ int labcomm_fd_writer( switch (action) { case labcomm_writer_alloc: { +#ifndef LABCOMM_FD_OMIT_VERSION va_list ap; va_start(ap, action); char *version = va_arg(ap, char *); write(*fd, version, strlen(version)); +#endif w->data = malloc(BUFFER_SIZE); if (! w->data) { result = -ENOMEM; @@ -33,7 +35,9 @@ int labcomm_fd_writer( w->count = BUFFER_SIZE; w->pos = 0; } +#ifndef LABCOMM_FD_OMIT_VERSION va_end(ap); +#endif } break; case labcomm_writer_free: { free(w->data); diff --git a/lib/c/test/generated_encoding.lc b/lib/c/test/generated_encoding.lc index 99cc300..f1f4b9b 100644 --- a/lib/c/test/generated_encoding.lc +++ b/lib/c/test/generated_encoding.lc @@ -3,3 +3,5 @@ sample byte B; sample struct { int i; } S1; +sample int I[_]; +sample struct { int i; } P[_]; diff --git a/lib/java/Makefile b/lib/java/Makefile new file mode 100644 index 0000000..e5394d6 --- /dev/null +++ b/lib/java/Makefile @@ -0,0 +1,27 @@ +MODULES=LabCommDispatcher \ + LabCommDecoderRegistry \ + LabComm \ + LabCommSample \ + LabCommHandler \ + LabCommEncoderRegistry \ + LabCommDecoder \ + LabCommType \ + LabCommEncoderChannel \ + LabCommEncoder \ + LabCommDecoderChannel \ + +all: labcomm.jar + +labcomm.jar: gen/JAVAC + echo $@ + cd gen ; jar cf ../$@ se/lth/control/labcomm/*.class + +gen: + mkdir gen + +gen/JAVAC: $(MODULES:%=se/lth/control/labcomm/%.java) Makefile | gen + javac -d gen $(filter %.java, $^) + touch $@ + +clean: + rm -rf labcomm.jar gen -- GitLab