Bug 2910202: Code::Blocks building C files as C++

This commit is contained in:
starkos 2009-12-31 16:14:07 +00:00
parent a744d46384
commit c24a0a94ad
3 changed files with 4 additions and 3 deletions

View File

@ -16,6 +16,7 @@
- Bug 2910639: Nil reference on dylib project dependency
- Bug 2872066: Two test failures in 4.1.2
- Bug 2912756: dylibs missing lib prefix
- Bug 2910202: Code::Blocks building C files as C++
- Clean action now removes MonoDevelop .pidb files correctly
- Added os.executef()

View File

@ -117,8 +117,8 @@
_p(2,'<Unit filename="%s">', premake.esc(fname))
if path.isresourcefile(fname) then
_p(3,'<Option compilerVar="WINDRES" />')
elseif path.iscppfile(fname) then
_p(3,'<Option compilerVar="%s" />', iif(prj.language == "C", "CC", "CPP"))
elseif path.iscfile(fname) and prj.language == "C++" then
_p(3,'<Option compilerVar="CC" />')
end
if not prj.flags.NoPCH and fname == pchheader then
_p(3,'<Option compilerVar="%s" />', iif(prj.language == "C", "CC", "CPP"))

View File

@ -25,7 +25,7 @@ const char* builtin_scripts[] = {
"function premake.showhelp()\nprintf(\"Premake %s, a build script generator\", _PREMAKE_VERSION)\nprintf(_PREMAKE_COPYRIGHT)\nprintf(\"%s %s\", _VERSION, _COPYRIGHT)\nprintf(\"\")\nprintf(\"Usage: premake4 [options] action [arguments]\")\nprintf(\"\")\nprintf(\"OPTIONS\")\nprintf(\"\")\nfor option in premake.option.each() do\nlocal trigger = option.trigger\nlocal description = option.description\nif (option.value) then trigger = trigger .. \"=\" .. option.value end\nif (option.allowed) then description = description .. \"; one of:\" end\nprintf(\" --%-15s %s\", trigger, description) \nif (option.allowed) then\nfor _, value in ipairs(option.allowed) do\nprintf(\" %-14s %s\", value[1], value[2])\nend\nend\nprintf(\"\")\nend\nprintf(\"ACTIONS\")\nprintf(\"\")\nfor action in premake.action.each() do\nprintf(\" %-17s %s\", action.trigger, action.description)\nend\nprintf(\"\")\nprintf(\"For additional information, see http://industriousone.com/premake\")\nend\n",
"function premake.generate(obj, filename, callback)\nfilename = premake.project.getfilename(obj, filename)\nprintf(\"Generating %s...\", filename)\nlocal f, err = io.open(filename, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nio.output(f)\ncallback(obj)\nf:close()\nend\n",
"function premake.codeblocks_workspace(sln)\n_p('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>')\n_p('<CodeBlocks_workspace_file>')\n_p(1,'<Workspace title=\"%s\">', sln.name)\nfor prj in premake.solution.eachproject(sln) do\nlocal fname = path.join(path.getrelative(sln.location, prj.location), prj.name)\nlocal active = iif(prj.project == sln.projects[1], ' active=\"1\"', '')\n_p(2,'<Project filename=\"%s.cbp\"%s>', fname, active)\nfor _,dep in ipairs(premake.getdependencies(prj)) do\n_p(3,'<Depends filename=\"%s.cbp\" />', path.join(path.getrelative(sln.location, dep.location), dep.name))\nend\n_p(2,'</Project>')\nend\n_p(1,'</Workspace>')\n_p('</CodeBlocks_workspace_file>')\nend\n",
"function premake.codeblocks_cbp(prj)\nlocal cc = premake.gettool(prj)\n_p('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>')\n_p('<CodeBlocks_project_file>')\n_p(1,'<FileVersion major=\"1\" minor=\"6\" />')\n_p(1,'<Project>')\n_p(2,'<Option title=\"%s\" />', premake.esc(prj.name))\n_p(2,'<Option pch_mode=\"2\" />')\n_p(2,'<Option compiler=\"%s\" />', _OPTIONS.cc)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\nfor i = #platforms, 1, -1 do\nif premake.platforms[platforms[i]].iscrosscompiler then\ntable.remove(platforms, i)\nend\nend \n_p(2,'<Build>')\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\n_p(3,'<Target title=\"%s\">', premake.esc(cfg.longname))\n_p(4,'<Option output=\"%s\" prefix_auto=\"0\" extension_auto=\"0\" />', premake.esc(cfg.buildtarget.fullpath))\n_p(4,'<Option object_output=\"%s\" />', premake.esc(cfg.objectsdir))\nlocal types = { WindowedApp = 0, ConsoleApp = 1, StaticLib = 2, SharedLib = 3 }\n_p(4,'<Option type=\"%d\" />', types[cfg.kind])\n_p(4,'<Option compiler=\"%s\" />', _OPTIONS.cc)\nif (cfg.kind == \"SharedLib\") then\n_p(4,'<Option createDefFile=\"0\" />')\n_p(4,'<Option createStaticLib=\"%s\" />', iif(cfg.flags.NoImportLib, 0, 1))\nend\n_p(4,'<Compiler>')\nfor _,flag in ipairs(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cc.getdefines(cfg.defines), cfg.buildoptions)) do\n_p(5,'<Add option=\"%s\" />', premake.esc(flag))\nend\nif not cfg.flags.NoPCH and cfg.pchheader then\n_p(5,'<Add option=\"-Winvalid-pch\" />')\n_p(5,'<Add option=\"-include &quot;%s&quot;\" />', premake.esc(cfg.pchheader))\nend\nfor _,v in ipairs(cfg.includedirs) do\n_p(5,'<Add directory=\"%s\" />', premake.esc(v))\nend\n_p(4,'</Compiler>')\n_p(4,'<Linker>')\nfor _,flag in ipairs(table.join(cc.getldflags(cfg), cfg.linkoptions)) do\n_p(5,'<Add option=\"%s\" />', premake.esc(flag))\nend\nfor _,v in ipairs(premake.getlinks(cfg, \"all\", \"directory\")) do\n_p(5,'<Add directory=\"%s\" />', premake.esc(v))\nend\nfor _,v in ipairs(premake.getlinks(cfg, \"all\", \"basename\")) do\n_p(5,'<Add library=\"%s\" />', premake.esc(v))\nend\n_p(4,'</Linker>')\nif premake.findfile(cfg, \".rc\") then\n_p(4,'<ResourceCompiler>')\nfor _,v in ipairs(cfg.includedirs) do\n_p(5,'<Add directory=\"%s\" />', premake.esc(v))\nend\nfor _,v in ipairs(cfg.resincludedirs) do\n_p(5,'<Add directory=\"%s\" />', premake.esc(v))\nend\n_p(4,'</ResourceCompiler>')\nend\nif #cfg.prebuildcommands > 0 or #cfg.postbuildcommands > 0 then\n_p(4,'<ExtraCommands>')\nfor _,v in ipairs(cfg.prebuildcommands) do\n_p(5,'<Add before=\"%s\" />', premake.esc(v))\nend\nfor _,v in ipairs(cfg.postbuildcommands) do\n_p(5,'<Add after=\"%s\" />', premake.esc(v))\nend\n_p(4,'</ExtraCommands>')\nend\n_p(3,'</Target>')\nend\nend\n_p(2,'</Build>')\nlocal pchheader\nif (prj.pchheader) then\npchheader = path.getrelative(prj.location, prj.pchheader)\nend\nfor _,fname in ipairs(prj.files) do\n_p(2,'<Unit filename=\"%s\">', premake.esc(fname))\nif path.isresourcefile(fname) then\n_p(3,'<Option compilerVar=\"WINDRES\" />')\nelseif path.iscppfile(fname) then\n_p(3,'<Option compilerVar=\"%s\" />', iif(prj.language == \"C\", \"CC\", \"CPP\"))\nend\nif not prj.flags.NoPCH and fname == pchheader then\n_p(3,'<Option compilerVar=\"%s\" />', iif(prj.language == \"C\", \"CC\", \"CPP\"))\n_p(3,'<Option compile=\"1\" />')\n_p(3,'<Option weight=\"0\" />')\n_p(3,'<Add option=\"-x c++-header\" />')\nend\n_p(2,'</Unit>')\nend\n_p(2,'<Extensions />')\n_p(1,'</Project>')\n_p('</CodeBlocks_project_file>')\n_p('')\nend\n",
"function premake.codeblocks_cbp(prj)\nlocal cc = premake.gettool(prj)\n_p('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>')\n_p('<CodeBlocks_project_file>')\n_p(1,'<FileVersion major=\"1\" minor=\"6\" />')\n_p(1,'<Project>')\n_p(2,'<Option title=\"%s\" />', premake.esc(prj.name))\n_p(2,'<Option pch_mode=\"2\" />')\n_p(2,'<Option compiler=\"%s\" />', _OPTIONS.cc)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\nfor i = #platforms, 1, -1 do\nif premake.platforms[platforms[i]].iscrosscompiler then\ntable.remove(platforms, i)\nend\nend \n_p(2,'<Build>')\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\n_p(3,'<Target title=\"%s\">', premake.esc(cfg.longname))\n_p(4,'<Option output=\"%s\" prefix_auto=\"0\" extension_auto=\"0\" />', premake.esc(cfg.buildtarget.fullpath))\n_p(4,'<Option object_output=\"%s\" />', premake.esc(cfg.objectsdir))\nlocal types = { WindowedApp = 0, ConsoleApp = 1, StaticLib = 2, SharedLib = 3 }\n_p(4,'<Option type=\"%d\" />', types[cfg.kind])\n_p(4,'<Option compiler=\"%s\" />', _OPTIONS.cc)\nif (cfg.kind == \"SharedLib\") then\n_p(4,'<Option createDefFile=\"0\" />')\n_p(4,'<Option createStaticLib=\"%s\" />', iif(cfg.flags.NoImportLib, 0, 1))\nend\n_p(4,'<Compiler>')\nfor _,flag in ipairs(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cc.getdefines(cfg.defines), cfg.buildoptions)) do\n_p(5,'<Add option=\"%s\" />', premake.esc(flag))\nend\nif not cfg.flags.NoPCH and cfg.pchheader then\n_p(5,'<Add option=\"-Winvalid-pch\" />')\n_p(5,'<Add option=\"-include &quot;%s&quot;\" />', premake.esc(cfg.pchheader))\nend\nfor _,v in ipairs(cfg.includedirs) do\n_p(5,'<Add directory=\"%s\" />', premake.esc(v))\nend\n_p(4,'</Compiler>')\n_p(4,'<Linker>')\nfor _,flag in ipairs(table.join(cc.getldflags(cfg), cfg.linkoptions)) do\n_p(5,'<Add option=\"%s\" />', premake.esc(flag))\nend\nfor _,v in ipairs(premake.getlinks(cfg, \"all\", \"directory\")) do\n_p(5,'<Add directory=\"%s\" />', premake.esc(v))\nend\nfor _,v in ipairs(premake.getlinks(cfg, \"all\", \"basename\")) do\n_p(5,'<Add library=\"%s\" />', premake.esc(v))\nend\n_p(4,'</Linker>')\nif premake.findfile(cfg, \".rc\") then\n_p(4,'<ResourceCompiler>')\nfor _,v in ipairs(cfg.includedirs) do\n_p(5,'<Add directory=\"%s\" />', premake.esc(v))\nend\nfor _,v in ipairs(cfg.resincludedirs) do\n_p(5,'<Add directory=\"%s\" />', premake.esc(v))\nend\n_p(4,'</ResourceCompiler>')\nend\nif #cfg.prebuildcommands > 0 or #cfg.postbuildcommands > 0 then\n_p(4,'<ExtraCommands>')\nfor _,v in ipairs(cfg.prebuildcommands) do\n_p(5,'<Add before=\"%s\" />', premake.esc(v))\nend\nfor _,v in ipairs(cfg.postbuildcommands) do\n_p(5,'<Add after=\"%s\" />', premake.esc(v))\nend\n_p(4,'</ExtraCommands>')\nend\n_p(3,'</Target>')\nend\nend\n_p(2,'</Build>')\nlocal pchheader\nif (prj.pchheader) then\npchheader = path.getrelative(prj.location, prj.pchheader)\nend\nfor _,fname in ipairs(prj.files) do\n_p(2,'<Unit filename=\"%s\">', premake.esc(fname))\nif path.isresourcefile(fname) then\n_p(3,'<Option compilerVar=\"WINDRES\" />')\nelseif path.iscfile(fname) and prj.language == \"C++\" then\n_p(3,'<Option compilerVar=\"CC\" />')\nend\nif not prj.flags.NoPCH and fname == pchheader then\n_p(3,'<Option compilerVar=\"%s\" />', iif(prj.language == \"C\", \"CC\", \"CPP\"))\n_p(3,'<Option compile=\"1\" />')\n_p(3,'<Option weight=\"0\" />')\n_p(3,'<Add option=\"-x c++-header\" />')\nend\n_p(2,'</Unit>')\nend\n_p(2,'<Extensions />')\n_p(1,'</Project>')\n_p('</CodeBlocks_project_file>')\n_p('')\nend\n",
"newaction {\ntrigger = \"codeblocks\",\nshortname = \"Code::Blocks\",\ndescription = \"Generate Code::Blocks project files\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\nvalid_languages = { \"C\", \"C++\" },\nvalid_tools = {\ncc = { \"gcc\", \"ow\" },\n},\nonsolution = function(sln)\npremake.generate(sln, \"%%.workspace\", premake.codeblocks_workspace)\nend,\nonproject = function(prj)\npremake.generate(prj, \"%%.cbp\", premake.codeblocks_cbp)\nend,\noncleansolution = function(sln)\npremake.clean.file(sln, \"%%.workspace\")\nend,\noncleanproject = function(prj)\npremake.clean.file(prj, \"%%.cbp\")\npremake.clean.file(prj, \"%%.depend\")\npremake.clean.file(prj, \"%%.layout\")\nend\n}\n",
"function premake.codelite_workspace(sln)\n_p('<?xml version=\"1.0\" encoding=\"utf-8\"?>')\n_p('<CodeLite_Workspace Name=\"%s\" Database=\"./%s.tags\">', premake.esc(sln.name), premake.esc(sln.name))\nfor i,prj in ipairs(sln.projects) do\nlocal name = premake.esc(prj.name)\nlocal fname = path.join(path.getrelative(sln.location, prj.location), prj.name)\nlocal active = iif(i==1, \"Yes\", \"No\")\n_p(' <Project Name=\"%s\" Path=\"%s.project\" Active=\"%s\" />', name, fname, active)\nend\nlocal platforms = premake.filterplatforms(sln, premake[_OPTIONS.cc].platforms, \"Native\")\nfor i = #platforms, 1, -1 do\nif premake.platforms[platforms[i]].iscrosscompiler then\ntable.remove(platforms, i)\nend\nend \n_p(' <BuildMatrix>')\nfor _, platform in ipairs(platforms) do\nfor _, cfgname in ipairs(sln.configurations) do\nlocal name = premake.getconfigname(cfgname, platform)\n_p(' <WorkspaceConfiguration Name=\"%s\" Selected=\"yes\">', name)\nfor _,prj in ipairs(sln.projects) do\n_p(' <Project Name=\"%s\" ConfigName=\"%s\"/>', prj.name, name)\nend\n_p(' </WorkspaceConfiguration>')\nend\nend\n_p(' </BuildMatrix>')\n_p('</CodeLite_Workspace>')\nend\n",
"function premake.codelite_project(prj)\n_p('<?xml version=\"1.0\" encoding=\"utf-8\"?>')\n_p('<CodeLite_Project Name=\"%s\">', premake.esc(prj.name))\npremake.walksources(prj, premake.codelite_files)\nlocal types = { \nConsoleApp = \"Executable\", \nWindowedApp = \"Executable\", \nStaticLib = \"Static Library\",\nSharedLib = \"Dynamic Library\",\n}\n_p(' <Settings Type=\"%s\">', types[prj.kind])\nlocal platforms = premake.filterplatforms(prj.solution, premake[_OPTIONS.cc].platforms, \"Native\")\nfor i = #platforms, 1, -1 do\nif premake.platforms[platforms[i]].iscrosscompiler then\ntable.remove(platforms, i)\nend\nend \nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\nlocal name = premake.esc(cfg.longname)\nlocal compiler = iif(cfg.language == \"C\", \"gcc\", \"g++\")\n_p(' <Configuration Name=\"%s\" CompilerType=\"gnu %s\" DebuggerType=\"GNU gdb debugger\" Type=\"%s\">', name, compiler, types[cfg.kind])\nlocal fname = premake.esc(cfg.buildtarget.fullpath)\nlocal objdir = premake.esc(cfg.objectsdir)\nlocal runcmd = cfg.buildtarget.name\nlocal rundir = cfg.buildtarget.directory\nlocal pause = iif(cfg.kind == \"WindowedApp\", \"no\", \"yes\")\n_p(' <General OutputFile=\"%s\" IntermediateDirectory=\"%s\" Command=\"./%s\" CommandArguments=\"\" WorkingDirectory=\"%s\" PauseExecWhenProcTerminates=\"%s\"/>', fname, objdir, runcmd, rundir, pause)\nlocal flags = premake.esc(table.join(premake.gcc.getcflags(cfg), premake.gcc.getcxxflags(cfg), cfg.buildoptions))\n_p(' <Compiler Required=\"yes\" Options=\"%s\">', table.concat(flags, \";\"))\nfor _,v in ipairs(cfg.includedirs) do\n_p(' <IncludePath Value=\"%s\"/>', premake.esc(v))\nend\nfor _,v in ipairs(cfg.defines) do\n_p(' <Preprocessor Value=\"%s\"/>', premake.esc(v))\nend\n_p(' </Compiler>')\nflags = premake.esc(table.join(premake.gcc.getldflags(cfg), cfg.linkoptions))\n_p(' <Linker Required=\"yes\" Options=\"%s\">', table.concat(flags, \";\"))\nfor _,v in ipairs(premake.getlinks(cfg, \"all\", \"directory\")) do\n_p(' <LibraryPath Value=\"%s\" />', premake.esc(v))\nend\nfor _,v in ipairs(premake.getlinks(cfg, \"all\", \"basename\")) do\n_p(' <Library Value=\"%s\" />', premake.esc(v))\nend\n_p(' </Linker>')\nif premake.findfile(cfg, \".rc\") then\nlocal defines = table.implode(table.join(cfg.defines, cfg.resdefines), \"-D\", \";\", \"\")\nlocal options = table.concat(cfg.resoptions, \";\")\n_p(' <ResourceCompiler Required=\"yes\" Options=\"%s%s\">', defines, options)\nfor _,v in ipairs(table.join(cfg.includedirs, cfg.resincludedirs)) do\n_p(' <IncludePath Value=\"%s\"/>', premake.esc(v))\nend\n_p(' </ResourceCompiler>')\nelse\n_p(' <ResourceCompiler Required=\"no\" Options=\"\"/>')\nend\nif #cfg.prebuildcommands > 0 then\n_p(' <PreBuild>')\nfor _,v in ipairs(cfg.prebuildcommands) do\n_p(' <Command Enabled=\"yes\">%s</Command>', premake.esc(v))\nend\n_p(' </PreBuild>')\nend\nif #cfg.postbuildcommands > 0 then\n_p(' <PostBuild>')\nfor _,v in ipairs(cfg.postbuildcommands) do\n_p(' <Command Enabled=\"yes\">%s</Command>', premake.esc(v))\nend\n_p(' </PostBuild>')\nend\n_p(' <CustomBuild Enabled=\"no\">')\n_p(' <CleanCommand></CleanCommand>')\n_p(' <BuildCommand></BuildCommand>')\n_p(' <SingleFileCommand></SingleFileCommand>')\n_p(' <MakefileGenerationCommand></MakefileGenerationCommand>')\n_p(' <ThirdPartyToolName>None</ThirdPartyToolName>')\n_p(' <WorkingDirectory></WorkingDirectory>')\n_p(' </CustomBuild>')\n_p(' <AdditionalRules>')\n_p(' <CustomPostBuild></CustomPostBuild>')\n_p(' <CustomPreBuild></CustomPreBuild>')\n_p(' </AdditionalRules>')\n_p(' </Configuration>')\nend\nend\n_p(' </Settings>')\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\n_p(' <Dependencies name=\"%s\">', cfg.longname)\nfor _,dep in ipairs(premake.getdependencies(prj)) do\n_p(' <Project Name=\"%s\"/>', dep.name)\nend\n_p(' </Dependencies>')\nend\nend\n_p('</CodeLite_Project>')\nend\nfunction premake.codelite_files(prj, fname, state, nestlevel)\nlocal indent = string.rep(\" \", nestlevel + 1)\nif (state == \"GroupStart\") then\nio.write(indent .. '<VirtualDirectory Name=\"' .. path.getname(fname) .. '\">\\n')\nelseif (state == \"GroupEnd\") then\nio.write(indent .. '</VirtualDirectory>\\n')\nelse\nio.write(indent .. '<File Name=\"' .. fname .. '\"/>\\n')\nend\nend\n",