This function allows to define new platform in your project for cross-compilation with GCC:
function newplatform(plf) local name = plf.name local description = plf.description -- Register new platform premake.platforms[name] = { cfgsuffix = "_"..name, iscrosscompiler = true } -- Allow use of new platform in --platfroms table.insert(premake.option.list["platform"].allowed, { name, description }) table.insert(premake.fields.platforms.allowed, name) -- Add compiler support -- gcc premake.gcc.platforms[name] = plf.gcc --other compilers (?) end function newgcctoolchain(toolchain) newplatform { name = toolchain.name, description = toolchain.description, gcc = { cc = toolchain.prefix .. "gcc", cxx = toolchain.prefix .. "g++", ar = toolchain.prefix .. "ar", cppflags = "-MMD " .. toolchain.cppflags } } end
Example usage:
newplatform { name = "amino110", description = "Amino 110", gcc = { cc = "/opt/hardhat/devkit/ppc/405/bin/ppc_405-gcc", cxx = "/opt/hardhat/devkit/ppc/405/bin/ppc_405-g++", cppflags = "-MMD -DAMINO_110" } } newgcctoolchain { name = "amino110", description = "Amino 110", prefix = "/opt/hardhat/devkit/ppc/405/bin/ppc_405-", cppflags = "-DAMINO_110" }

Can you submit this as a patch? Would be handy to have.
It has a dirty hack inside (at least in my opinion):
it overwrites list of allowed platforms for "platform" option declared in cmdline.lua. Otherwise new platform name won't pass validatation.
Or it's fine for you?
Can you table.insert() the new value instead?
this doesn't seem to work for codeblocks.
gmake generator generates a couple more configs with the name "xxxxx_amino110" which are not in codeblocks or codelite projects.
how to add platform specific defines?
>how to add platform specific defines?
To add platform define for everything, just add it to cppflags of gcc. But you can also use
configuration "platformname"inside any project/solution
@starkos: It works. I've updated function definition, and added separate version of function for "platforms" which are defined by standard gcc (cross-)toolchain.
Or maybe something like this instead of newgcctoolchain:
@starkos: As for patch, I'm in doubt in which file should I place these functions (api.lua?). Feel free to copy and paste it where you like :)
How do I include platform specific files?
For example, this way:
Platform-specific files will be built if you call premake4 with
--platform=somelpatformoption.