Merge branch 'master' into master

This commit is contained in:
Erin Catto 2018-06-03 10:05:26 -07:00 committed by GitHub
commit 273c506d52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 181 additions and 114 deletions

View File

@ -73,18 +73,6 @@
end
end)
--
-- Don't create $(OBJDIR) in the d-file rules
--
p.override(make, "objDirInFileRules", function(oldfn, prj, node)
-- node is nil when making pch rules
if not node or not path.isdfile(node.abspath) then
oldfn(prj, node)
end
end)
---
-- Add namespace for element definition lists for p.callarray()

View File

@ -274,12 +274,9 @@
function make.shellType()
_p('SHELLTYPE := msdos')
_p('ifeq (,$(ComSpec)$(COMSPEC))')
_p(' SHELLTYPE := posix')
_p('endif')
_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')
_p(' SHELLTYPE := posix')
_p('SHELLTYPE := posix')
_p('ifeq (.exe,$(findstring .exe,$(ComSpec)))')
_p('\tSHELLTYPE := msdos')
_p('endif')
_p('')
end

View File

@ -34,6 +34,9 @@
make.cppObjects,
make.shellType,
make.cppTargetRules,
make.cppCustomFilesRules,
make.cppTargetDirRules,
make.cppObjDirRules,
make.cppCleanRules,
make.preBuildRules,
make.preLinkRules,
@ -69,10 +72,6 @@
_p('\t@echo $(notdir $<)')
end
function make.objDirInFileRules(prj, node)
make.mkdir('$(OBJDIR)')
end
function make.cpp.generate(prj)
p.eol("\n")
p.callArray(cpp.elements.makefile, prj)
@ -85,7 +84,6 @@
cpp.elements.standardFileRules = function(prj, node)
return {
make.fileDependency,
make.objDirInFileRules,
cpp.standardFileRules,
}
end
@ -93,7 +91,6 @@
cpp.elements.customFileRules = function(prj, node)
return {
make.fileDependency,
make.objDirInFileRules,
cpp.customFileRules,
}
end
@ -454,14 +451,31 @@ end
function make.cppTargetRules(prj)
_p('$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES)')
_p('$(TARGET): $(GCH) ${CUSTOMFILES} $(OBJECTS) $(LDDEPS) $(RESOURCES) | $(TARGETDIR)')
_p('\t@echo Linking %s', prj.name)
make.mkdir('$(TARGETDIR)')
_p('\t$(SILENT) $(LINKCMD)')
_p('\t$(POSTBUILDCMDS)')
_p('')
end
function make.cppCustomFilesRules(prj)
_p('$(CUSTOMFILES): | $(OBJDIR)')
_p('')
end
function make.cppTargetDirRules(prj)
_p('$(TARGETDIR):')
_p('\t@echo Creating $(TARGETDIR)')
make.mkdir('$(TARGETDIR)')
_p('')
end
function make.cppObjDirRules(prj)
_p('$(OBJDIR):')
_p('\t@echo Creating $(OBJDIR)')
make.mkdir('$(OBJDIR)')
_p('')
end
function make.cppTools(cfg, toolset)
local tool = toolset.gettoolname(cfg, "cc")
@ -600,14 +614,15 @@ end
function make.pchRules(prj)
_p('ifneq (,$(PCH))')
_p('$(OBJECTS): $(GCH) $(PCH)')
_p('$(GCH): $(PCH)')
_p('$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR)')
_p('$(GCH): $(PCH) | $(OBJDIR)')
_p('\t@echo $(notdir $<)')
make.objDirInFileRules(prj, nil)
local cmd = iif(prj.language == "C", "$(CC) -x c-header $(ALL_CFLAGS)", "$(CXX) -x c++-header $(ALL_CXXFLAGS)")
_p('\t$(SILENT) %s -o "$@" -MF "$(@:%%.gch=%%.d)" -c "$<"', cmd)
_p('else')
_p('$(OBJECTS): | $(OBJDIR)')
_p('endif')
_p('')
end

View File

@ -37,19 +37,9 @@
test.capture [[
$(OBJDIR)/hello.o: src/greetings/hello.cpp
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/hello1.o: src/hello.cpp
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
]]
@ -66,19 +56,9 @@ endif
test.capture [[
$(OBJDIR)/hello.o: src/hello.c
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
$(OBJDIR)/test.o: src/test.cpp
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
]]
@ -96,11 +76,6 @@ endif
test.capture [[
$(OBJDIR)/hello.o: src/hello.c
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
ifeq ($(config),debug)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
endif
@ -109,11 +84,6 @@ ifeq ($(config),release)
endif
$(OBJDIR)/test.o: src/test.c
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
]]
end
@ -130,11 +100,6 @@ endif
test.capture [[
$(OBJDIR)/hello.o: src/hello.c
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
ifeq ($(config),debug)
$(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
endif
@ -143,11 +108,6 @@ ifeq ($(config),release)
endif
$(OBJDIR)/test.o: src/test.c
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
]]
end

View File

@ -93,15 +93,12 @@
prepareRules()
test.capture [[
ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH)
$(GCH): $(PCH)
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
else
$(OBJECTS): | $(OBJDIR)
endif
]]
end
@ -117,15 +114,12 @@ endif
prepareRules()
test.capture [[
ifneq (,$(PCH))
$(OBJECTS): $(GCH) $(PCH)
$(GCH): $(PCH)
$(OBJECTS): $(GCH) $(PCH) | $(OBJDIR)
$(GCH): $(PCH) | $(OBJDIR)
@echo $(notdir $<)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
else
$(OBJECTS): | $(OBJDIR)
endif
]]
end

View File

@ -273,12 +273,9 @@
function gmake2.shellType()
_p('SHELLTYPE := msdos')
_p('ifeq (,$(ComSpec)$(COMSPEC))')
_p(' SHELLTYPE := posix')
_p('endif')
_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')
_p(' SHELLTYPE := posix')
_p('SHELLTYPE := posix')
_p('ifeq (.exe,$(findstring .exe,$(ComSpec)))')
_p('\tSHELLTYPE := msdos')
_p('endif')
_p('')
end

View File

@ -60,13 +60,13 @@
fileExtension { ".cc", ".cpp", ".cxx", ".mm" }
buildoutputs { "$(OBJDIR)/%{premake.modules.gmake2.cpp.makeUnique(cfg, file.objname)}.o" }
buildmessage '$(notdir $<)'
buildcommands {'$(CXX) $(%{premake.modules.gmake2.cpp.fileFlags(cfg, file)}) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'}
buildcommands {'$(CXX) %{premake.modules.gmake2.cpp.fileFlags(cfg, file)} $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'}
rule 'cc'
fileExtension {".c", ".s", ".m"}
buildoutputs { "$(OBJDIR)/%{premake.modules.gmake2.cpp.makeUnique(cfg, file.objname)}.o" }
buildmessage '$(notdir $<)'
buildcommands {'$(CC) $(%{premake.modules.gmake2.cpp.fileFlags(cfg, file)}) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'}
buildcommands {'$(CC) %{premake.modules.gmake2.cpp.fileFlags(cfg, file)} $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'}
rule 'resource'
fileExtension ".rc"
@ -443,9 +443,6 @@
function cpp.forceInclude(cfg, toolset)
local includes = toolset.getforceincludes(cfg)
if not cfg.flags.NoPCH and cfg.pchheader then
table.insert(includes, 1, "-include $(PCH_PLACEHOLDER)")
end
p.outln('FORCE_INCLUDE +=' .. gmake2.list(includes))
end
@ -603,23 +600,25 @@
function cpp.fileFlags(cfg, file)
local fcfg = fileconfig.getconfig(file, cfg)
if fcfg and fcfg.flagsVariable then
return fcfg.flagsVariable
local flags = {}
if cfg.pchheader and not cfg.flags.NoPCH and (not fcfg or not fcfg.flags.NoPCH) then
table.insert(flags, "-include $(PCH_PLACEHOLDER)")
end
if fcfg and fcfg.compileas then
if p.languages.isc(fcfg.compileas) then
return 'ALL_CFLAGS'
elseif p.languages.iscpp(fcfg.compileas) then
return 'ALL_CXXFLAGS'
if fcfg and fcfg.flagsVariable then
table.insert(flags, string.format("$(%s)", fcfg.flagsVariable))
else
local fileExt = cpp.determineFiletype(cfg, file)
if path.iscfile(fileExt) then
table.insert(flags, "$(ALL_CFLAGS)")
elseif path.iscppfile(fileExt) then
table.insert(flags, "$(ALL_CXXFLAGS)")
end
end
if path.iscfile(file.name) then
return 'ALL_CFLAGS'
else
return 'ALL_CXXFLAGS'
end
return table.concat(flags, ' ')
end
--

View File

@ -21,6 +21,7 @@
local wks, prj
function suite.setup()
os.chdir(_TESTS_DIR)
gmake2.cpp.initialize()
wks, prj = test.createWorkspace()
end
@ -34,6 +35,12 @@
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.
@ -53,8 +60,21 @@
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

View File

@ -292,4 +292,53 @@
<PlatformToolset>v100</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
]]
end
end
--
-- Check the WindowsSDKDesktopARMSupport element
--
function suite.WindowsSDKDesktopARMSupport_off()
system "ios"
architecture "ARM"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v100</PlatformToolset>
</PropertyGroup>
]]
end
function suite.WindowsSDKDesktopARMSupport_on()
system "windows"
architecture "ARM"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v100</PlatformToolset>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
</PropertyGroup>
]]
end
function suite.WindowsSDKDesktopARM64Support()
system "windows"
architecture "ARM64"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v100</PlatformToolset>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
</PropertyGroup>
]]
end

View File

@ -2159,11 +2159,13 @@
function m.windowsSDKDesktopARMSupport(cfg)
if cfg.architecture == p.ARM then
p.w('<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>')
end
if cfg.architecture == p.ARM64 then
p.w('<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>')
if cfg.system == p.WINDOWS then
if cfg.architecture == p.ARM then
p.w('<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>')
end
if cfg.architecture == p.ARM64 then
p.w('<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>')
end
end
end