Diff of /trunk/wharfie/Makefile [000000] .. [r27]  Maximize  Restore

Switch to side-by-side view

--- a
+++ b/trunk/wharfie/Makefile
@@ -0,0 +1,123 @@
+# Copyright 2017 Ingo Hornberger <ingo_@gmx.net>
+#
+# This software is licensed under the MIT License
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this
+# software and associated documentation files (the "Software"), to deal in the Software
+# without restriction, including without limitation the rights to use, copy, modify,
+# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to the following
+# conditions:
+#
+# The above copyright notice and this permission notice shall be included in all copies
+# or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+# OR OTHER DEALINGS IN THE SOFTWARE.
+#
+################################################################################
+
+QEMU_IMAGE:=qemu/qwharfie.qcow
+QEMU_OUTPUT:=qemu/qwharfie.output.raw
+QEMU_CACHE:=qemu/qwharfie.cache.qcow
+QEMU_ALL:=${QEMU_IMAGE} ${QEMU_OUTPUT} ${QEMU_CACHE}
+
+QEMU_OUTPUT_SIZE?=2G
+QEMU_CACHE_SIZE?=20G
+
+help:
+	@echo "usage: make <target>"
+	@echo "targets:"
+	@echo "- help: print this message"
+	@echo "- qemu: build qemu image"
+	@echo "- install: install wharfie on linux host"
+	@echo "- clean: delete qemu image"
+	@echo "- test: run a test build on all Wharfiles in the 'tests/' directory."
+	@echo "        these tests are running with and without qemu."
+	@echo
+	@echo "Note: To control the size of the qemu output and cache images, you"
+	@echo "      can pass the parameters QEMU_CACHE_SIZE and QEMU_OUTPUT_SIZE."
+	@echo "e.g.: make QEMU_OUTPUT_SIZE=1G QEMU_CACHE_SIZE=10G qemu"
+
+#
+# Build qemu image.
+# This can be used on windows, as well as linux.
+# By default Wharfie uses qemu, as soon as it is available.
+#
+qemu: ${QEMU_ALL}
+
+#
+# Build a bootable Qemu image with Wharfie
+#
+${QEMU_IMAGE}:
+	cd qemu; \
+	../wharfie.py --no-qemu --no-proc
+
+#
+# Create an empty output image, which can be copied to a build folder.
+# In fact this is just an empty file, where the qemu VM can write a raw
+# tar archive to.
+#
+${QEMU_OUTPUT}:
+	qemu-img create -f raw $@ ${QEMU_OUTPUT_SIZE}
+
+#
+# Create an empty ext3 cache partition, which can be copied into a build folder
+# to cache intermediate files.
+#
+${QEMU_CACHE}:
+# create raw image
+	qemu-img create -f raw $@.raw ${QEMU_CACHE_SIZE}
+# create partitions
+	( \
+	    echo o; \
+	    echo n; \
+	    echo p; \
+	    echo 1; \
+	    echo; \
+	    echo; \
+	    echo w; \
+	) | sudo fdisk $@.raw
+# create ext3 filesystem in partition
+	l=$$(sudo /sbin/kpartx -l $@.raw | sed -n '/loop/ s,.*/dev/\(loop[0-9]\+\).*,\1, p;q;') && \
+	sudo /sbin/kpartx -as $@.raw && \
+	sudo mkfs.ext3 /dev/mapper/$${l}p1 && \
+	sudo /sbin/kpartx -ds $@.raw
+# convert raw image to qcow
+	qemu-img convert -O qcow2 $@.raw $@
+	rm -f $@.raw
+
+#
+# Remove the qemu image and intermediate build files
+#
+clean:
+	cd qemu; \
+	../wharfie.py --clean
+	rm ${QEMU_IMAGE}
+	rm ${QEMU_OUTPUT}
+	rm ${QEMU_CACHE}
+
+#
+# Run a test on all Wharfiles in the subdirectory "test/"
+# The test depends on qemu, as they are running with and without qemu
+#
+TEST_IMAGES=$(addsuffix .test.tar, $(wildcard tests/*))
+TEST_IMAGES_QEMU=$(addsuffix .qemu.test.tar, $(wildcard tests/*))
+
+test: ${QEMU_ALL} ${TEST_IMAGES_QEMU}
+
+
+%.test.tar:
+	cd $*; \
+	../../wharfie.py --clean; \
+	../../wharfie.py --no-qemu && cp result.tar ../$$(basename $@)
+
+%.qemu.test.tar:
+	cd $*; \
+	../../wharfie.py --clean; \
+	../../wharfie.py && cp result.tar ../$$(basename $@)
+