Skip to content

Commit

Permalink
Merge pull request #1326 from dawgfoto/sharedUT
Browse files Browse the repository at this point in the history
shared library tests for linux
  • Loading branch information
andralex committed Aug 16, 2013
2 parents 85661ad + 442cbde commit 86e8a49
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions posix.mak
Expand Up @@ -107,7 +107,7 @@ else
endif

# Set CFLAGS
CFLAGS :=
CFLAGS=
ifneq (,$(filter cc% gcc% clang% icc% egcc%, $(CC)))
CFLAGS += $(MODEL_FLAG) $(PIC)
ifeq ($(BUILD),debug)
Expand All @@ -118,7 +118,7 @@ ifneq (,$(filter cc% gcc% clang% icc% egcc%, $(CC)))
endif

# Set DFLAGS
DFLAGS := -I$(DRUNTIME_PATH)/import $(DMDEXTRAFLAGS) -w -d $(MODEL_FLAG) $(PIC)
DFLAGS=-I$(DRUNTIME_PATH)/import $(DMDEXTRAFLAGS) -w -d $(MODEL_FLAG) $(PIC)
ifeq ($(BUILD),debug)
DFLAGS += -g -debug
else
Expand Down Expand Up @@ -274,7 +274,7 @@ $(LIB) : $(OBJS) $(ALL_D_FILES) $(DRUNTIME)
dll : $(ROOT)/libphobos2.so

$(ROOT)/libphobos2.so: $(ROOT)/$(SONAME)
ln -sf $(notdir $(LIBSO)) $@
ln -sf $(notdir $(LIBSO)) $@

$(ROOT)/$(SONAME): $(LIBSO)
ln -sf $(notdir $(LIBSO)) $@
Expand All @@ -291,23 +291,43 @@ endif
$(addprefix $(ROOT)/unittest/,$(DISABLED_TESTS)) :
@echo Testing $@ - disabled

$(ROOT)/unittest/%$(DOTEXE) : %.d $(LIB) $(ROOT)/emptymain.d
@echo Testing $@
$(QUIET)$(DMD) $(DFLAGS) -unittest $(LINKOPTS) $(subst /,$(PATHSEP),"-of$@") \
$(ROOT)/emptymain.d $<
UT_D_OBJS:=$(addprefix $(ROOT)/unittest/,$(addsuffix .o,$(D_MODULES)))
$(UT_D_OBJS): $(ROOT)/unittest/%.o: $(D_FILES)
$(DMD) $(DFLAGS) -unittest -c -of$@ $*.d

ifneq (linux,$(OS))

$(ROOT)/unittest/test_runner: $(DRUNTIME_PATH)/src/test_runner.d $(UT_D_OBJS) $(OBJS) $(DRUNTIME)
$(DMD) $(DFLAGS) -unittest -of$@ $(DRUNTIME_PATH)/src/test_runner.d $(UT_D_OBJS) $(OBJS) $(DRUNTIME) -defaultlib= -debuglib= -L-lcurl

else

UT_LIBSO:=$(ROOT)/unittest/libphobos2-ut.so

$(UT_LIBSO): override PIC:=-fPIC
$(UT_LIBSO): $(UT_D_OBJS) $(OBJS) $(DRUNTIMESO)
$(DMD) $(DFLAGS) -shared -unittest -of$@ $(UT_D_OBJS) $(OBJS) $(DRUNTIMESO) -defaultlib= -debuglib= -L-lcurl

$(ROOT)/unittest/test_runner: $(DRUNTIME_PATH)/src/test_runner.d $(UT_LIBSO)
$(DMD) $(DFLAGS) -of$@ $< -L$(UT_LIBSO) -defaultlib= -debuglib=

endif

# macro that returns the module name given the src path
moduleName=$(subst /,.,$(1))

$(ROOT)/unittest/%$(DOTEXE) : $(ROOT)/unittest/test_runner
@mkdir -p $(dir $@)
# make the file very old so it builds and runs again if it fails
@touch -t 197001230123 $@
# run unittest in its own directory
$(QUIET)$(RUN) $@
$(QUIET)$(RUN) $< $(call moduleName,$*)
# succeeded, render the file new again
@touch $@

# Disable implicit rule
%$(DOTEXE) : %$(DOTOBJ)

$(ROOT)/emptymain.d : $(ROOT)/.directory
@echo 'void main(){}' >$@

$(ROOT)/.directory :
mkdir -p $(ROOT) || exists $(ROOT)
touch $@
Expand All @@ -328,7 +348,7 @@ install2 : release
cp -r etc/* $(INSTALL_DIR)/import/etc/
cp LICENSE_1_0.txt $(INSTALL_DIR)/phobos-LICENSE.txt

$(DRUNTIME) :
$(DRUNTIME) $(DRUNTIMESO) :
$(MAKE) -C $(DRUNTIME_PATH) -f posix.mak MODEL=$(MODEL)

###########################################################
Expand Down

0 comments on commit 86e8a49

Please sign in to comment.