8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

How to test D project on Travis CI

Last updated at Posted at 2013-06-20

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)
8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?