2012-06-19 19:58:16 +00:00
|
|
|
--
|
|
|
|
-- tests/actions/make/cpp/test_file_rules.lua
|
|
|
|
-- Validate the makefile source building rules.
|
|
|
|
-- Copyright (c) 2009-2012 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
T.make_cpp_file_rules = { }
|
|
|
|
local suite = T.make_cpp_file_rules
|
|
|
|
local cpp = premake.make.cpp
|
|
|
|
local project = premake5.project
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2013-01-23 16:50:54 +00:00
|
|
|
-- Setup
|
2012-06-19 19:58:16 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
local sln, prj
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-06-19 19:58:16 +00:00
|
|
|
function suite.setup()
|
|
|
|
sln = test.createsolution()
|
|
|
|
end
|
2013-01-23 16:50:54 +00:00
|
|
|
|
2012-06-19 19:58:16 +00:00
|
|
|
local function prepare()
|
|
|
|
prj = premake.solution.getproject_ng(sln, 1)
|
|
|
|
cpp.filerules(prj)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Two files with the same base name should have different object files.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.uniqueObjNames_onBaseNameCollision()
|
|
|
|
files { "src/hello.cpp", "src/greetings/hello.cpp" }
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
$(OBJDIR)/hello.o: src/greetings/hello.cpp
|
2012-06-22 21:15:17 +00:00
|
|
|
@echo $(notdir $<)
|
2013-01-23 16:50:54 +00:00
|
|
|
$(SILENT) $(CXX) $(ALL_CXXFLAGS) -o "$@" -MF $(@:%.o=%.d) -c "$<"
|
2012-06-19 19:58:16 +00:00
|
|
|
$(OBJDIR)/hello1.o: src/hello.cpp
|
2012-06-22 21:15:17 +00:00
|
|
|
@echo $(notdir $<)
|
2013-01-23 16:50:54 +00:00
|
|
|
$(SILENT) $(CXX) $(ALL_CXXFLAGS) -o "$@" -MF $(@:%.o=%.d) -c "$<"
|
2012-06-19 19:58:16 +00:00
|
|
|
|
|
|
|
]]
|
|
|
|
end
|
2012-06-29 13:05:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If a custom build rule is supplied, it should be used.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.customBuildRule()
|
|
|
|
files { "hello.x" }
|
|
|
|
configuration "**.x"
|
2013-04-09 19:12:04 +00:00
|
|
|
buildmessage "Compiling %{file.name}"
|
|
|
|
buildcommands {
|
|
|
|
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
|
|
|
|
'c2o -c "%{cfg.objdir}/%{file.basename}.xo" -o "%{cfg.objdir}/%{file.basename}.obj"'
|
2012-06-29 13:05:20 +00:00
|
|
|
}
|
2013-04-09 19:12:04 +00:00
|
|
|
buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" }
|
2012-06-29 13:05:20 +00:00
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
ifeq ($(config),debug)
|
|
|
|
obj/Debug/hello.obj: hello.x
|
|
|
|
@echo "Compiling hello.x"
|
|
|
|
$(SILENT) cxc -c "hello.x" -o "obj/Debug/hello.xo"
|
|
|
|
$(SILENT) c2o -c "obj/Debug/hello.xo" -o "obj/Debug/hello.obj"
|
|
|
|
endif
|
|
|
|
ifeq ($(config),release)
|
|
|
|
obj/Release/hello.obj: hello.x
|
|
|
|
@echo "Compiling hello.x"
|
|
|
|
$(SILENT) cxc -c "hello.x" -o "obj/Release/hello.xo"
|
|
|
|
$(SILENT) c2o -c "obj/Release/hello.xo" -o "obj/Release/hello.obj"
|
|
|
|
endif
|
|
|
|
]]
|
|
|
|
end
|