From fc3d38a1670e9f549a1b60d8290a906b2b2b388e Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Fri, 12 Jul 2013 10:20:57 -0400 Subject: Improved handling of precompiled headers across toolsets --- tests/actions/make/test_make_pch.lua | 50 +++++++++++++++++++----------------- tests/actions/make/test_wiidev.lua | 2 +- tests/test_gmake_cpp.lua | 8 +++--- 3 files changed, 32 insertions(+), 28 deletions(-) (limited to 'tests') diff --git a/tests/actions/make/test_make_pch.lua b/tests/actions/make/test_make_pch.lua index c471e09..75d9d9d 100644 --- a/tests/actions/make/test_make_pch.lua +++ b/tests/actions/make/test_make_pch.lua @@ -7,7 +7,7 @@ T.make_pch = { } local suite = T.make_pch local _ = premake.make.cpp - + -- -- Setup and teardown @@ -17,24 +17,25 @@ function suite.setup() sln, prj = test.createsolution() end - + local function prepare() premake.bake.buildconfigs() + prj = premake.getconfig(prj) cfg = premake.getconfig(prj, "Debug") end - + -- -- Configuration block tests -- - + function suite.NoConfig_OnNoHeaderSet() prepare() _.pchconfig(cfg) test.capture [[]] end - + function suite.NoConfig_OnHeaderAndNoPCHFlag() pchheader "include/myproject.h" flags { NoPCH } @@ -50,13 +51,12 @@ _.pchconfig(cfg) test.capture [[ PCH = include/myproject.h - GCH = $(OBJDIR)/myproject.h.gch - ALL_CPPFLAGS += -I$(OBJDIR) -include $(OBJDIR)/myproject.h + GCH = $(OBJDIR)/$(notdir $(PCH)).gch ]] end --- +-- -- Build rule tests -- @@ -68,13 +68,7 @@ ifneq (,$(PCH)) $(GCH): $(PCH) @echo $(notdir $<) -ifeq (posix,$(SHELLTYPE)) - -$(SILENT) cp $< $(OBJDIR) -else - $(SILENT) xcopy /D /Y /Q "$(subst /,\,$<)" "$(subst /,\,$(OBJDIR))" 1>nul -endif - $(SILENT) $(CXX) $(ALL_CXXFLAGS) -o "$@" -MF $(@:%.gch=%.d) -c "$<" -endif + $(SILENT) $(CXX) -x c++-header $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" ]] end @@ -87,13 +81,23 @@ endif ifneq (,$(PCH)) $(GCH): $(PCH) @echo $(notdir $<) -ifeq (posix,$(SHELLTYPE)) - -$(SILENT) cp $< $(OBJDIR) -else - $(SILENT) xcopy /D /Y /Q "$(subst /,\,$<)" "$(subst /,\,$(OBJDIR))" 1>nul -endif - $(SILENT) $(CC) $(ALL_CFLAGS) -o "$@" -MF $(@:%.gch=%.d) -c "$<" -endif + $(SILENT) $(CC) -x c-header $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" ]] end - + +-- +-- Ensure that PCH is included on all files that use it. +-- + + function suite.includesPCH_onUse() + pchheader "include/myproject.h" + files { "main.cpp" } + prepare() + _.fileRules(prj) + test.capture [[ +$(OBJDIR)/main.o: main.cpp + @echo $(notdir $<) + $(SILENT) $(CXX) $(ALL_CXXFLAGS) -o "$@" -MF $(@:%.o=%.d) -c "$<" + ]] + end + diff --git a/tests/actions/make/test_wiidev.lua b/tests/actions/make/test_wiidev.lua index f3787a0..2b276f6 100644 --- a/tests/actions/make/test_wiidev.lua +++ b/tests/actions/make/test_wiidev.lua @@ -32,7 +32,7 @@ function suite.writesCorrectFlags() cpp.flags(cfg, premake.gcc) test.capture [[ - ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP -I$(LIBOGC_INC) $(MACHDEP) -MP $(DEFINES) $(INCLUDES) + ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP -I$(LIBOGC_INC) $(MACHDEP) -MP $(DEFINES) $(INCLUDES) $(FORCE_INCLUDE) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) diff --git a/tests/test_gmake_cpp.lua b/tests/test_gmake_cpp.lua index ec895bd..2844567 100644 --- a/tests/test_gmake_cpp.lua +++ b/tests/test_gmake_cpp.lua @@ -78,7 +78,7 @@ ifeq ($(config),debug) TARGET = $(TARGETDIR)/MyProject DEFINES += INCLUDES += - ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) + ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) $(FORCE_INCLUDE) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) @@ -112,7 +112,7 @@ ifeq ($(config),debugps3) TARGET = $(TARGETDIR)/MyProject.elf DEFINES += INCLUDES += - ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) + ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) $(FORCE_INCLUDE) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) @@ -143,7 +143,7 @@ ifeq ($(config),debug64) TARGET = $(TARGETDIR)/MyProject DEFINES += INCLUDES += - ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) + ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) $(FORCE_INCLUDE) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -m64 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) @@ -175,7 +175,7 @@ ifeq ($(config),debuguniv32) TARGET = $(TARGETDIR)/libMyProject.a DEFINES += INCLUDES += - ALL_CPPFLAGS += $(CPPFLAGS) $(DEFINES) $(INCLUDES) + ALL_CPPFLAGS += $(CPPFLAGS) $(DEFINES) $(INCLUDES) $(FORCE_INCLUDE) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -arch i386 -arch ppc ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) -- cgit v1.2.3