]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add cgreen unit test library and makefile
authorFred Sundvik <fsundvik@gmail.com>
Sat, 13 Feb 2016 22:05:58 +0000 (00:05 +0200)
committerFred Sundvik <fsundvik@gmail.com>
Sat, 13 Feb 2016 22:05:58 +0000 (00:05 +0200)
.gitmodules [new file with mode: 0644]
cgreen/Makefile [new file with mode: 0644]
cgreen/Makefile.build [new file with mode: 0644]
cgreen/cgreen [new submodule]
serial_link.mk [new file with mode: 0644]

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..991cfe9
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "cgreen/cgreen"]
+       path = cgreen/cgreen
+       url = http://github.com/cgreen-devs/cgreen
diff --git a/cgreen/Makefile b/cgreen/Makefile
new file mode 100644 (file)
index 0000000..6b31a3f
--- /dev/null
@@ -0,0 +1,38 @@
+# This Makefile ensures that the build is made out of source in a subdirectory called 'build'
+# If it doesn't exist, it is created and a Makefile created there (from Makefile.build)
+#
+# This Makefile also contains delegation of the most common make commands
+#
+# If you have cmake installed you should be able to do:
+#
+#      make
+#      make test
+#      make install
+#      make package
+#
+# That should build cgreen for C and C++, run some tests, install it locally and
+# generate two distributable packages.
+
+all: build
+       cd $(CGREEN_BUILD_DIR); make all
+
+test: build
+       cd $(CGREEN_BUILD_DIR); make test
+
+clean: build
+       cd $(CGREEN_BUILD_DIR); make clean
+
+package: build
+       cd $(CGREEN_BUILD_DIR); make package
+
+install:
+       cd $(CGREEN_BUILD_DIR); make install
+
+############# Internal
+
+build:
+       mkdir -p $(CGREEN_BUILD_DIR)
+       cp Makefile.build $(CGREEN_BUILD_DIR)/Makefile
+
+
+.SILENT:
diff --git a/cgreen/Makefile.build b/cgreen/Makefile.build
new file mode 100644 (file)
index 0000000..f761652
--- /dev/null
@@ -0,0 +1,33 @@
+# This Makefile is copied from the cgreen top directory (where it is
+# named Makefile.build) and put in a subdirectory called 'build' where
+# builds are made This Makefile then automatically creates
+# subdirectories for C and C++ builds configuring them using the cmake
+# command. Once created you can always tweak the cmake setup as with
+# any cmake build directory
+
+all: build-c build-c++
+       for d in build-* ; do cd $$d; make ; cd .. ; done
+
+clean:
+       for d in build-* ; do cd $$d; make clean ; cd .. ; done
+
+check test:
+       for d in build-* ; do cd $$d; make check ; cd .. ; done
+
+package:
+       for d in build-* ; do cd $$d; make package ; cd .. ; done
+
+install:
+       for d in build-* ; do cd $$d; make install ; cd .. ; done
+
+############ Internal
+
+build-c:
+       mkdir build-c
+       cd build-c; cmake -G "Unix Makefiles" $(CGREEN_DIR)
+
+build-c++:
+       mkdir build-c++
+       cd build-c++; cmake -G "Unix Makefiles" -DWITH_CXX:bool=ON $(CGREEN_DIR)
+
+.SILENT:
diff --git a/cgreen/cgreen b/cgreen/cgreen
new file mode 160000 (submodule)
index 0000000..d4d438d
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit d4d438dda1b7131f0bd0530b2c258e9dea6a2a9f
diff --git a/serial_link.mk b/serial_link.mk
new file mode 100644 (file)
index 0000000..51d33fc
--- /dev/null
@@ -0,0 +1,11 @@
+CGREEN_LIB = $(BUILDDIR)/cgreen/build-c/src/libcgreen.a
+
+.phony testserial:
+testserial: $(CGREEN_LIB)
+
+CGREEN_DIR = "$(CURDIR)/$(SERIAL_DIR)/cgreen/cgreen"
+CGREEN_BUILD_DIR = "$(CURDIR)/$(BUILDDIR)/cgreen"
+export CGREEN_DIR
+export CGREEN_BUILD_DIR
+$(CGREEN_LIB):
+       make -C $(SERIAL_DIR)/cgreen
\ No newline at end of file