Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_make_pch.lua « make « actions « tests - github.com/windirstat/premake-4.x.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6d30ef1e1a7345d47979a78d5f3cc6e58e4efff9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
--
-- tests/actions/make/test_make_pch.lua
-- Validate the setup for precompiled headers in makefiles.
-- Copyright (c) 2010 Jason Perkins and the Premake project
--

	T.make_pch = { }
	local suite = T.make_pch
	local _ = premake.make.cpp


--
-- Setup and teardown
--

	local sln, prj, cfg
	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 }
		prepare()
		_.pchconfig(cfg)
		test.capture [[]]
	end


	function suite.ConfigBlock_OnPchEnabled()
		pchheader "include/myproject.h"
		prepare()
		_.pchconfig(cfg)
		test.capture [[
  PCH        = include/myproject.h
  GCH        = $(OBJDIR)/$(notdir $(PCH)).gch
		]]
	end


--
-- Build rule tests
--

	function suite.BuildRules_OnCpp()
		pchheader "include/myproject.h"
		prepare()
		_.pchrules(prj)
		test.capture [[
ifneq (,$(PCH))
.NOTPARALLEL: $(GCH) $(PCH)
$(GCH): $(PCH)
	@echo $(notdir $<)
	$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
		]]
	end

	function suite.BuildRules_OnC()
		language "C"
		pchheader "include/myproject.h"
		prepare()
		_.pchrules(prj)
		test.capture [[
ifneq (,$(PCH))
.NOTPARALLEL: $(GCH) $(PCH)
$(GCH): $(PCH)
	@echo $(notdir $<)
	$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -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) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
		]]
	end


--
-- If the header is located on one of the include file
-- search directories, it should get found automatically.
--

	function suite.findsPCH_onIncludeDirs()
		location "MyProject"
		pchheader "premake.h"
		includedirs { "../src/host" }
		prepare()
		_.pchconfig(cfg)
		test.capture [[
  PCH        = ../../src/host/premake.h
		]]
	end