Adds basic support for Code::Blocks on the Mac and Linux.

The Project structure is still a bit strange, but it builds successfully
now.

This was SVN commit r10521.
This commit is contained in:
Yves 2011-11-12 23:58:35 +00:00
parent f865401136
commit fc9e89647b
6 changed files with 21 additions and 7 deletions

View File

@ -56,8 +56,10 @@ local function pkgconfig_libs(lib, alternative_cmd)
result_libs = string.gsub(result_libs, ",", " ")
result_libs = string.gsub(result_libs, "\n", "")
linkoptions { result_libs }
else
elseif _ACTION == "gmake" then
gnuexternals { "`"..cmd_libs.."`" }
else
linkoptions { "`"..cmd_libs.."`" }
end
end

View File

@ -262,8 +262,12 @@ function project_set_build_flags()
if _OPTIONS["libdir"] then
linkoptions {"-Wl,-rpath=" .. _OPTIONS["libdir"] }
else
-- Add the executable path:
linkoptions { "-Wl,-rpath='$$ORIGIN'" } -- use Makefile escaping of '$'
-- Adding the executable path and taking care of correct escaping
if _ACTION == "gmake" then
linkoptions { "-Wl,-rpath='$$ORIGIN'" }
elseif _ACTION == "codeblocks" then
linkoptions { "-Wl,-R\\\\$$ORIGIN" }
end
end
end

View File

@ -63,13 +63,18 @@
-- begin linker block --
_p(4,'<Linker>')
_p(5,'<Add option="-Wl,--start-group" />')
for _,v in ipairs(premake.getlinks(cfg, "siblings", "fullpath")) do
_p(5,'<Add option="%s" />', premake.esc(v))
end
_p(5,'<Add option="-Wl,--end-group" />')
for _,flag in ipairs(table.join(cc.getldflags(cfg), cfg.linkoptions)) do
_p(5,'<Add option="%s" />', premake.esc(flag))
end
for _,v in ipairs(premake.getlinks(cfg, "all", "directory")) do
_p(5,'<Add directory="%s" />', premake.esc(v))
end
for _,v in ipairs(premake.getlinks(cfg, "all", "basename")) do
for _,v in ipairs(premake.getlinks(cfg, "system", "basename")) do
_p(5,'<Add library="%s" />', premake.esc(v))
end
_p(4,'</Linker>')

View File

@ -114,9 +114,9 @@ const char* builtin_scripts[] = {
/* actions/codeblocks/codeblocks_cbp.lua */
"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 ipair"
"s(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 com"
"pilerVar=\"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",
"<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>')\n_p(5,'<Add option=\"-Wl,--start-group\" />')\nfor _,v in ipairs(premake.getlinks(cfg, \"siblings\", \"fullpath\")) do\n_p(5,'<Add option=\"%s\" />', premake.esc(v))\nend\n_p(5,'<Add option=\"-Wl,--end-group\" />')\nfor _,flag in ipairs(table.join(cc.getldflags(cfg), cf"
"g.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, \"system\", \"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.pchhe"
"ader) 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",
/* actions/codelite/_codelite.lua */
"newaction {\ntrigger = \"codelite\",\nshortname = \"CodeLite\",\ndescription = \"Generate CodeLite project files\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\" },\nvalid_languages = { \"C\", \"C++\" },\nvalid_tools = {\ncc = { \"gcc\" },\n},\nonsolution = function(sln)\npremake.generate(sln, \"%%.workspace\", premake.codelite_workspace)\nend,\nonproject = function(prj)\npremake.generate(prj, \"%%.project\", premake.codelite_project)\nend,\noncleansolution = function(sln)\npremake.clean.file(sln, \"%%.workspace\")\npremake.clean.file(sln, \"%%_wsp.mk\")\npremake.clean.file(sln, \"%%.tags\")\nend,\noncleanproject = function(prj)\npremake.clean.file(prj, \"%%.project\")\npremake.clean.file(prj, \"%%.mk\")\npremake.clean.file(prj, \"%%.list\")\npremake.clean.file(prj, \"%%.out\")\nend\n}\n",

View File

@ -20,6 +20,8 @@ echo "Cleaning build output..."
# Remove workspaces/gcc if present
rm -rf ./gcc
# Remove workspaces/codeblocks if present
rm -rf ./codeblocks
# Remove workspaces/xcode3 if present
rm -rf ./xcode3

View File

@ -67,6 +67,7 @@ cd ..
export HOSTTYPE="$HOSTTYPE"
premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed"
premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/codeblocks/" ${premake_args} codeblocks || die "Premake failed"
# Also generate xcode3 workspaces if on OS X
if [ "`uname -s`" = "Darwin" ]