gmake2: Add unit tests for PCH include
local wks, prj
function suite.setup()
os.chdir(_TESTS_DIR)
+ gmake2.cpp.initialize()
wks, prj = test.createWorkspace()
end
gmake2.cpp.pchRules(cfg.project)
end
+ local function prepareFlags()
+ local project = test.getproject(wks, 1)
+ gmake2.cpp.createRuleTable(project)
+ gmake2.cpp.createFileTable(project)
+ gmake2.cpp.outputFileRuleSection(project)
+ end
--
-- If no header has been set, nothing should be output.
function suite.noConfig_onHeaderAndNoPCHFlag()
pchheader "include/myproject.h"
flags "NoPCH"
- prepareVars()
- test.isemptycapture()
+
+ files { 'a.cpp', 'b.cpp' }
+
+ prepareFlags()
+ test.capture [[
+# File Rules
+# #############################################
+
+$(OBJDIR)/a.o: a.cpp
+ @echo $(notdir $<)
+ $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
+$(OBJDIR)/b.o: b.cpp
+ @echo $(notdir $<)
+ $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
+]]
end
@@ -156,3 +176,49 @@ endif
PCH = ../../../../src/host/premake.h
]]
end
+
+--
+-- If the header is located on one of the include file
+-- search directories, it should get found automatically.
+--
+
+ function suite.PCHFlag()
+ pchheader "include/myproject.h"
+
+ files { 'a.cpp', 'b.cpp' }
+
+ prepareFlags()
+ test.capture [[
+# File Rules
+# #############################################
+
+$(OBJDIR)/a.o: a.cpp
+ @echo $(notdir $<)
+ $(SILENT) $(CXX) -include $(PCH_PLACEHOLDER) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
+$(OBJDIR)/b.o: b.cpp
+ @echo $(notdir $<)
+ $(SILENT) $(CXX) -include $(PCH_PLACEHOLDER) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
+]]
+ end
+
+ function suite.PCHFlag_PerFile()
+ pchheader "include/myproject.h"
+
+ files { 'a.cpp', 'b.cpp' }
+
+ filter { "files:a.cpp" }
+ flags "NoPCH"
+
+ prepareFlags()
+ test.capture [[
+# File Rules
+# #############################################
+
+$(OBJDIR)/a.o: a.cpp
+ @echo $(notdir $<)
+ $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
+$(OBJDIR)/b.o: b.cpp
+ @echo $(notdir $<)
+ $(SILENT) $(CXX) -include $(PCH_PLACEHOLDER) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
+]]
+ end
