- Timestamp:
- 07/15/11 19:48:21 (13 years ago)
- Location:
- ps/trunk/build/premake/premake4/src
- Files:
-
- 6 edited
-
actions/make/make_cpp.lua (modified) (11 diffs)
-
actions/vstudio/_vstudio.lua (modified) (1 diff)
-
actions/vstudio/vs2010_vcxproxj.lua (modified) (19 diffs)
-
actions/xcode/xcode_common.lua (modified) (4 diffs)
-
actions/xcode/xcode_project.lua (modified) (1 diff)
-
base/api.lua (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/build/premake/premake4/src/actions/make/make_cpp.lua
r9828 r9829 27 27 _p('OBJECTS := \\') 28 28 for _, file in ipairs(prj.files) do 29 if path.iscppfile(file) then29 if path.iscppfile(file) or path.getextension(file) == ".asm" then 30 30 _p('\t$(OBJDIR)/%s.o \\', _MAKE.esc(path.getbasename(file))) 31 31 end … … 56 56 57 57 if os.is("MacOSX") and prj.kind == "WindowedApp" then 58 _p('all: $(TARGET DIR) $(OBJDIR) prebuild prelink $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist')58 _p('all: $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist') 59 59 else 60 _p('all: $(TARGET DIR) $(OBJDIR) prebuild prelink $(TARGET)')60 _p('all: $(TARGET)') 61 61 end 62 62 _p('\t@:') … … 64 64 65 65 -- target build rule 66 _p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES) ')66 _p('$(TARGET): $(GCH) $(OBJECTS) $(LDDEPS) $(RESOURCES) | prelink') 67 67 _p('\t@echo Linking %s', prj.name) 68 68 _p('\t$(SILENT) $(LINKCMD)') … … 98 98 99 99 -- custom build step targets 100 _p('prebuild: ')100 _p('prebuild: $(TARGETDIR) $(OBJDIR)') 101 101 _p('\t$(PREBUILDCMDS)') 102 102 _p('') … … 112 112 for _, file in ipairs(prj.files) do 113 113 if path.iscppfile(file) then 114 _p('$(OBJDIR)/%s.o: %s ', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file))114 _p('$(OBJDIR)/%s.o: %s | prebuild', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file)) 115 115 _p('\t@echo $(notdir $<)') 116 116 if (path.iscfile(file)) then … … 123 123 _p('\t@echo $(notdir $<)') 124 124 _p('\t$(SILENT) windres $< -O coff -o "$@" $(RESFLAGS)') 125 end 126 end 127 _p('') 125 elseif (path.getextension(file) == ".asm") then 126 _p('$(OBJDIR)/%s.o: %s', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file)) 127 _p('\t@echo $(notdir $<)') 128 129 local opts = '' 130 if os.is('windows') then 131 opts = '' 132 elseif os.is('macosx') then 133 opts = '-D OS_UNIX=1' 134 else 135 opts = '-D DONT_USE_UNDERLINE=1 -D OS_UNIX=1' 136 end 137 138 if not (prj.solution.nasmpath) then 139 prj.solution.nasmpath = 'nasm' 140 end 141 142 _p('\t$(SILENT)'.._MAKE.esc(prj.solution.nasmpath)..' '..opts..' -i'.._MAKE.esc(path.getdirectory(file))..'/'..' -f '.. 143 _MAKE.esc(prj.solution.nasmformat)..' -o $@ $<\n\t') 144 145 _p('\t$(SILENT)'.._MAKE.esc(prj.solution.nasmpath)..' '..opts..' -i'.._MAKE.esc(path.getdirectory(file))..'/'.. 146 ' -M -o $@ $< >$(OBJDIR)/$(<F:%%.asm=%%.d)\n') 147 end 148 149 end 150 _p('') 151 152 -- output for test-generation 153 -- test generation only works if all required parameters are set! 154 if(prj.solution.cxxtestpath and prj.cxxtestrootfile and prj.cxxtesthdrfiles and prj.cxxtestsrcfiles) then 155 156 if not(prj.cxxtestrootoptions) then 157 prj.cxxtestrootoptions = '' 158 end 159 if not(prj.cxxtestoptions) then 160 prj.cxxtestoptions = '' 161 end 162 163 _p(prj.cxxtestrootfile..': ') 164 _p('\t@echo $(notdir $<)') 165 _p('\t$(SILENT)'.._MAKE.esc(prj.solution.cxxtestpath)..' --root '..prj.cxxtestrootoptions..' -o '.._MAKE.esc(prj.cxxtestrootfile)) 166 _p('') 167 168 for i, file in ipairs(prj.cxxtesthdrfiles) do 169 _p('%s: %s', _MAKE.esc(prj.cxxtestsrcfiles[i]), _MAKE.esc(file)) 170 _p('\t@echo $(notdir $<)') 171 _p('\t$(SILENT)'.._MAKE.esc(prj.solution.cxxtestpath)..' --part '..prj.cxxtestoptions..' -o ' .._MAKE.esc(prj.cxxtestsrcfiles[i])..' '.._MAKE.esc(file)) 172 end 173 _p('') 174 end 128 175 129 176 -- include the dependencies, built by GCC (with the -MMD flag) … … 175 222 176 223 _p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname)) 224 177 225 178 226 -- if this platform requires a special compiler or linker, list it now … … 187 235 _p(' AR = %s', platform.ar) 188 236 end 237 if not(cfg.gnuexternals) then 238 cfg.gnuexternal = { } 239 end 189 240 190 241 _p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir)) … … 201 252 _p(' CXXFLAGS += $(CFLAGS) %s', table.concat(cc.getcxxflags(cfg), " ")) 202 253 _p(' LDFLAGS += %s', table.concat(table.join(cc.getldflags(cfg), cfg.linkoptions, cc.getlibdirflags(cfg)), " ")) 203 _p(' LIBS += %s ', table.concat(cc.getlinkflags(cfg), " "))254 _p(' LIBS += %s %s', table.concat(cc.getlinkflags(cfg), " "), table.concat(cfg.gnuexternals, " ")) 204 255 _p(' RESFLAGS += $(DEFINES) $(INCLUDES) %s', table.concat(table.join(cc.getdefines(cfg.resdefines), cc.getincludedirs(cfg.resincludedirs), cfg.resoptions), " ")) 205 256 _p(' LDDEPS += %s', table.concat(_MAKE.esc(premake.getlinks(cfg, "siblings", "fullpath")), " ")) … … 214 265 -- this was $(TARGET) $(LDFLAGS) $(OBJECTS) ... but was having trouble linking to certain 215 266 -- static libraries so $(OBJECTS) was moved up 216 _p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) $(LIBS)', iif(cfg.language == "C", "CC", "CXX")) 267 local lddeps = '' 268 269 -- on osx, --start-group and --end-group aren't supported by ld 270 if os.is('macosx') then 271 lddeps = '$(LDDEPS)' 272 else 273 lddeps = '-Xlinker --start-group $(LDDEPS) -Xlinker --end-group' 274 end 275 _p(' LINKCMD = $(%s) -o $(TARGET) $(OBJECTS) $(LDFLAGS) $(RESOURCES) $(ARCH) %s $(LIBS)', 276 iif(cfg.language == "C", "CC", "CXX"), lddeps) 217 277 end 218 278 … … 257 317 function _.pchrules(prj) 258 318 _p('ifneq (,$(PCH))') 259 _p('$(GCH): $(PCH) ')319 _p('$(GCH): $(PCH) | $(OBJDIR)') 260 320 _p('\t@echo $(notdir $<)') 261 321 _p('\t-$(SILENT) cp $< $(OBJDIR)') -
ps/trunk/build/premake/premake4/src/actions/vstudio/_vstudio.lua
r9828 r9829 228 228 end 229 229 end 230 231 if (path.getextension(fname) == ".asm") then 232 for _, cfginfo in ipairs(prj.solution.vstudio_configs) do 233 if cfginfo.isreal then 234 235 -- set defaults if required parameters are not set 236 if not (prj.solution.nasmformat) then 237 prj.solution.nasmformat = 'win32' 238 end 239 if not (prj.solution.nasmpath) then 240 prj.solution.nasmpath = 'nasm' 241 end 242 243 local nasmpath = path.translate(path.getrelative(prj.location, prj.solution.nasmpath), "\\") 244 local command = nasmpath.." -i "..path.translate(path.getdirectory(fname), "\\").."\\ -f "..prj.solution.nasmformat.. 245 " "$(InputPath)" -o "$(IntDir)\$(InputName).obj"" 246 247 output(indent, "\t<FileConfiguration") 248 attrib(indent, "\tName", cfginfo.name) 249 output(indent, "\t\t>") 250 output(indent, "\t\t<Tool") 251 attrib(indent, "\t\tName", "VCCustomBuildTool") 252 attrib(indent, "\t\tDescription", "Assembling $(InputPath)") 253 attrib(indent, "\t\tCommandLine", command) 254 attrib(indent, "\t\tOutputs", "$(IntDir)\$(InputName).obj") 255 output(indent, "\t\t/>") 256 output(indent, "\t</FileConfiguration>") 257 end 258 end 259 end 260 230 261 output(indent, "</File>") 231 262 end -
ps/trunk/build/premake/premake4/src/actions/vstudio/vs2010_vcxproxj.lua
r9828 r9829 5 5 6 6 function vs10_helpers.remove_relative_path(file) 7 file = file:gsub("%.%.\\",'') 8 file = file:gsub("%.\\",'') 7 file = file:gsub("%.%./",'') 8 file = file:gsub("%./",'') 9 file = file:gsub("^source/",'') 9 10 return file 10 11 end … … 12 13 function vs10_helpers.file_path(file) 13 14 file = vs10_helpers.remove_relative_path(file) 14 local path = string.find(file,' \\[%w%.%_%-]+$')15 local path = string.find(file,'/[%w%.%_%-]+$') 15 16 if path then 16 17 return string.sub(file,1,path-1) … … 24 25 path = vs10_helpers.remove_relative_path(path) 25 26 if path then 26 for dir in string.gmatch(path,"[%w%-%_%.]+ \\")do27 for dir in string.gmatch(path,"[%w%-%_%.]+/")do 27 28 if #list == 0 then 28 29 list[1] = dir:sub(1,#dir-1) 29 30 else 30 list[#list +1] = list[#list] .." \\" ..dir:sub(1,#dir-1)31 list[#list +1] = list[#list] .."/" ..dir:sub(1,#dir-1) 31 32 end 32 33 end … … 60 61 61 62 62 63 --also translates file paths from '/' to '\\'64 63 function vs10_helpers.sort_input_files(files,sorted_container) 65 64 local types = … … 72 71 cxx = "ClCompile", 73 72 cc = "ClCompile", 74 rc = "ResourceCompile" 73 rc = "ResourceCompile", 74 asm = "ClASM" 75 75 } 76 76 77 77 for _, current_file in ipairs(files) do 78 local translated_path = path.translate(current_file, '\\') 79 local ext = vs10_helpers.get_file_extension(translated_path) 78 local ext = vs10_helpers.get_file_extension(current_file) 80 79 if ext then 81 80 local type = types[ext] 82 81 if type then 83 table.insert(sorted_container[type], translated_path)82 table.insert(sorted_container[type],current_file) 84 83 else 85 table.insert(sorted_container.None, translated_path)84 table.insert(sorted_container.None,current_file) 86 85 end 87 86 end … … 389 388 390 389 391 local function event_hooks(cfg )390 local function event_hooks(cfg, prj) 392 391 if #cfg.postbuildcommands> 0 then 393 392 _p(2,'<PostBuildEvent>') … … 396 395 end 397 396 398 if #cfg.prebuildcommands> 0 then397 if #cfg.prebuildcommands> 0 or prj.cxxtestrootfile then 399 398 _p(2,'<PreBuildEvent>') 400 399 _p(3,'<Command>%s</Command>',premake.esc(table.implode(cfg.prebuildcommands, "", "", "\r\n"))) 400 401 -- test generation only works if all required parameters are set! 402 if(prj.solution.cxxtestpath and prj.cxxtestrootfile and prj.cxxtesthdrfiles and prj.cxxtestsrcfiles) then 403 local cxxtestpath = path.translate(path.getrelative(prj.location, prj.solution.cxxtestpath),"\\") 404 local cxxtestrootfile = path.translate(prj.cxxtestrootfile,"\\") 405 _p(3,'<Command>%s --root %s > %s</Command>', cxxtestpath, prj.cxxtestrootoptions, cxxtestrootfile) 406 end 401 407 _p(2,'</PreBuildEvent>') 402 408 end … … 504 510 item_def_lib(cfg) 505 511 item_link(cfg) 506 event_hooks(cfg )512 event_hooks(cfg, prj) 507 513 _p(1,'</ItemDefinitionGroup>') 508 509 510 514 end 511 515 end … … 519 523 -- </ProjectReference> 520 524 -- </ItemGroup> 521 -- 525 526 local function write_cxxtestgen_block(prj) 527 -- test generation only works if all required parameters are set! 528 if(prj.solution.cxxtestpath and prj.cxxtestrootfile and prj.cxxtesthdrfiles and prj.cxxtestsrcfiles) then 529 local cxxtestpath = path.translate(path.getrelative(prj.location, prj.solution.cxxtestpath),"\\") 530 _p(1,'<ItemGroup>') 531 for i, file in ipairs(prj.cxxtesthdrfiles) do 532 local cxxtesthdrfile = path.translate(file,"\\") 533 local cxxtestsrcfile = path.translate(prj.cxxtestsrcfiles[i],"\\") 534 _p(2,'<CustomBuild Include=\"%s\">', cxxtesthdrfile) 535 _p(3,'<Message>Generating %s</Message>', path.getname(prj.cxxtestsrcfiles[i])) 536 _p(3,'<Command>%s --part %s -o \"%s\" \"%s\"</Command>', 537 cxxtestpath, prj.cxxtestoptions, cxxtestsrcfile, cxxtesthdrfile) 538 _p(3,'<Outputs>%s;%%(Outputs)</Outputs>', cxxtestsrcfile) 539 _p(2,'</CustomBuild>') 540 end 541 _p(1,'</ItemGroup>') 542 end 543 end 522 544 523 545 local function write_file_type_block(files,group_type) … … 525 547 _p(1,'<ItemGroup>') 526 548 for _, current_file in ipairs(files) do 527 _p(2,'<%s Include=\"%s\" />', group_type, current_file)549 _p(2,'<%s Include=\"%s\" />', group_type,path.translate(current_file,"\\")) 528 550 end 529 551 _p(1,'</ItemGroup>') … … 532 554 533 555 local function write_file_compile_block(files,prj,configs) 534 535 556 if #files > 0 then 536 537 557 local config_mappings = {} 538 558 for _, cfginfo in ipairs(configs) do 539 559 local cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform) 540 560 if cfg.pchheader and cfg.pchsource and not cfg.flags.NoPCH then 541 config_mappings[cfginfo] = path.translate(cfg.pchsource, "\\")561 config_mappings[cfginfo] = cfg.pchsource 542 562 end 543 563 end … … 546 566 _p(1,'<ItemGroup>') 547 567 for _, current_file in ipairs(files) do 548 _p(2,'<ClCompile Include=\"%s\">', current_file)568 _p(2,'<ClCompile Include=\"%s\">', path.translate(current_file, "\\")) 549 569 for _, cfginfo in ipairs(configs) do 550 570 if config_mappings[cfginfo] and current_file == config_mappings[cfginfo] then … … 560 580 end 561 581 end 582 583 local function write_nasm_asm_block(files, prj, configs) 584 -- set defaults if required parameters are not set 585 if not (prj.solution.nasmformat) then 586 prj.solution.nasmformat = 'win32' 587 end 588 589 if not (prj.solution.nasmpath) then 590 prj.solution.nasmpath = 'nasm' 591 end 592 593 if #files > 0 then 594 _p(1,'<ItemGroup>') 595 local nasmpath = path.translate(path.getrelative(prj.location, prj.solution.nasmpath),"\\") 596 for _, current_file in ipairs(files) do 597 _p(2,'<CustomBuild Include=\"%s\">', path.translate(current_file,"\\")) 598 _p(3,'<Message>Assembling %%(FullPath)</Message>') 599 _p(3,'<Command>%s -i %s -f %s \"%%(FullPath)\" -o \"$(IntDir)%%(Filename).obj\"</Command>', 600 nasmpath, 601 path.translate(path.getdirectory(current_file),"\\").."\\", 602 prj.solution.nasmformat) 603 _p(3,'<Outputs>$(IntDir)%%(Filename).obj;%%(Outputs)</Outputs>') 604 _p(2,'</CustomBuild>') 605 end 606 _p(1,'</ItemGroup>') 607 end 608 end 562 609 563 610 … … 567 614 ClCompile ={}, 568 615 ClInclude ={}, 616 ClASM ={}, 569 617 None ={}, 570 618 ResourceCompile ={} … … 573 621 cfg = premake.getconfig(prj) 574 622 vs10_helpers.sort_input_files(cfg.files,sorted) 623 write_cxxtestgen_block(prj) 575 624 write_file_type_block(sorted.ClInclude,"ClInclude") 576 625 write_file_compile_block(sorted.ClCompile,prj,prj.solution.vstudio_configs) 626 write_nasm_asm_block(sorted.ClASM, prj, prj.solution.vstudion_configs) 577 627 write_file_type_block(sorted.None,'None') 578 628 write_file_type_block(sorted.ResourceCompile,'ResourceCompile') … … 588 638 _p(1,'<ItemGroup>') 589 639 for _, dir in pairs(directories) do 590 _p(2,'<Filter Include="%s">', dir)640 _p(2,'<Filter Include="%s">',path.translate(dir,"\\")) 591 641 _p(3,'<UniqueIdentifier>{%s}</UniqueIdentifier>',os.uuid()) 592 642 _p(2,'</Filter>') … … 603 653 if path_to_file then 604 654 _p(2,'<%s Include=\"%s\">', group_type,path.translate(current_file, "\\")) 605 _p(3,'<Filter>%s</Filter>',path _to_file)655 _p(3,'<Filter>%s</Filter>',path.translate(path_to_file,"\\")) 606 656 _p(2,'</%s>',group_type) 607 657 else … … 621 671 ClCompile ={}, 622 672 ClInclude ={}, 673 ClASM ={}, 623 674 None ={}, 624 675 ResourceCompile ={} … … 634 685 write_file_filter_block(sorted.ClInclude,"ClInclude") 635 686 write_file_filter_block(sorted.ClCompile,"ClCompile") 687 write_file_filter_block(prj.cxxtesthdrfiles,"CustomBuild") 688 write_file_filter_block(sorted.ClASM,"ClASM") 636 689 write_file_filter_block(sorted.None,"None") 637 690 write_file_filter_block(sorted.ResourceCompile,"ResourceCompile") -
ps/trunk/build/premake/premake4/src/actions/xcode/xcode_common.lua
r9828 r9829 33 33 [".xib"] = "Resources", 34 34 [".icns"] = "Resources", 35 [".asm"] = "Sources" 35 36 } 36 37 return categories[path.getextension(node.name)] … … 86 87 [".xib"] = "file.xib", 87 88 [".icns"] = "image.icns", 89 [".asm"] = "sourcecode.asm", 88 90 } 89 91 return types[path.getextension(node.path)] or "text" … … 261 263 _p('/* End PBXBuildFile section */') 262 264 _p('') 265 end 266 267 268 function xcode.PBXBuildRule(tr) 269 if not (tr.project.solution.nasmpath) then 270 tr.project.solution.nasmpath = 'nasm' 271 end 272 _p('/* Begin PBXBuildRule section */') 273 _p(2,'28AD1E6E1336798800207177 /* PBXBuildRule */ = {') 274 _p(3,'isa = PBXBuildRule;') 275 _p(3,'compilerSpec = com.apple.compilers.proxy.script;') 276 _p(3,'fileType = sourcecode.asm;') 277 _p(3,'isEditable = 1;') 278 _p(3,'outputFiles = (') 279 _p(4,'"$(DERIVED_FILES_DIR)/$(INPUT_FILE_BASE).o",') 280 _p(3,');') 281 _p(3,'script = "%s -D OS_UNIX=1 -i${INPUT_FILE_DIR}/ -f %s ${INPUT_FILE_PATH} -o ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.o";', tr.project.solution.nasmpath, tr.project.solution.nasmformat) 282 _p(2,'};') 283 _p('/* End PBXBuildRule section */') 263 284 end 264 285 … … 433 454 _p(3,');') 434 455 _p(3,'buildRules = (') 456 _p(4,'28AD1E6E1336798800207177 /* PBXBuildRule */,') 435 457 _p(3,');') 436 458 -
ps/trunk/build/premake/premake4/src/actions/xcode/xcode_project.lua
r9828 r9829 148 148 xcode.Header(tr) 149 149 xcode.PBXBuildFile(tr) 150 xcode.PBXBuildRule(tr) 150 151 xcode.PBXContainerItemProxy(tr) 151 152 xcode.PBXFileReference(tr) -
ps/trunk/build/premake/premake4/src/base/api.lua
r9828 r9829 41 41 kind = "list", 42 42 scope = "solution", 43 }, 44 45 cxxtesthdrfiles = 46 { 47 kind = "filelist", 48 scope = "config", 49 }, 50 51 cxxtestsrcfiles = 52 { 53 kind = "filelist", 54 scope = "config", 55 }, 56 57 cxxtestoptions = 58 { 59 kind = "string", 60 scope = "config", 61 }, 62 63 cxxtestpath = 64 { 65 kind = "path", 66 scope = "solution", 67 }, 68 69 cxxtestrootfile = 70 { 71 kind = "path", 72 scope = "config", 73 }, 74 75 cxxtestrootoptions = 76 { 77 kind = "string", 78 scope = "config", 43 79 }, 44 80 … … 117 153 } 118 154 }, 155 156 gnuexternals = 157 { 158 kind = "list", 159 scope = "config", 160 }, 119 161 120 162 imagepath = … … 219 261 kind = "path", 220 262 scope = "container", 263 }, 264 265 nasmformat = 266 { 267 kind = "string", 268 scope = "solution", 269 }, 270 271 nasmpath = 272 { 273 kind = "path", 274 scope = "solution" 221 275 }, 222 276
Note:
See TracChangeset
for help on using the changeset viewer.
