Travis-CI supports D. No need this ad-hoc approach. See: http://blog.travis-ci.com/2014-12-10-community-driven-language-support-comes-to-travis-ci/
It's simple. Download dmd and run Makefile.
.travis.yml
language: d
install:
- DMD_VERSION=2.062
- wget http://ftp.digitalmars.com/dmd.${DMD_VERSION}.zip
- unzip dmd.${DMD_VERSION}.zip
script:
- DMD=./dmd2/linux/bin64/dmd MODEL=64 make -f posix.mak unittest
branches:
only:
- master
script
depends on your build system. Travis CI uses 64bit environment, so you should use 64bit code generation.
Makefile
Sample Makefile for above use-case. Use ?=
instead of =
to assign variable from command line.
# build mode: 32bit or 64bit
MODEL ?= $(shell getconf LONG_BIT)
DMD ?= dmd
NAMES = foo
FILES = $(addsuffix .d, $(NAMES))
SRCS = $(addprefix src/, $(FILES))
LIB = libfoo.a
DFLAGS = -Isrc -m$(MODEL) -w -d -property -O -release -nofloat -inline
target: $(LIB)
$(LIB):
$(DMD) $(DFLAGS) -lib -of$(LIB) $(SRCS)
MAIN_FILE = "empty_foo_unittest.d"
unittest:
echo 'import foo; void main(){}' > $(MAIN_FILE)
$(DMD) $(DFLAGS) -unittest -of$(LIB) $(SRCS) -run $(MAIN_FILE)
rm $(MAIN_FILE)