bkaradzic / GENie

GENie - Project generator tool
Other
897 stars 166 forks source link

Lua pre/post build steps. #18

Open vk2gpu opened 9 years ago

vk2gpu commented 9 years ago

At the moment I have various scripts setup to do some pre/post build steps, or run the pre build code when generating the projects (which isn't my preferred approach).

I was thinking it might be nice if these could actually just be Lua. Not sure on the best way to go about implementing this, but actually being able to have the Lua inline would be quite nice.

Currently in my game scripts I have this:

prebuildcommands {
  "python ../../Psybrus/reflection_parse.py " .. solution().name
}

It would be nice if I could replace it along the lines of:

function ProcessReflection( path )
    -- do the work here
end

prebuildcommands {
  {
    ProcessReflection,  // Function to call.
    solution().name  // First parameter.
  }
}

Any thoughts on this? I imagine what would need to be done is genie is invoked by the makefiles/vsproj on the pre/post build steps and told to run said Lua function. At a slightly more complex level, it would need to potentially pull out the Lua code referenced and generate new Lua files and tell Genie to invoke those instead.

bkaradzic commented 9 years ago

I think you could do something like this already:

function ProcessReflection( path, solutionname)

    do stuff and fill table

    prebuildcommands {
    }
end

configuration "something"
    ProcessReflection("<pathX>", solution().name)

configuration "something else"
    ProcessReflection("<pathY>", solution().name)
vk2gpu commented 9 years ago

Will this execute what happens in the ProcessReflection function at build time though?

My idea is to run this code when I type 'make', or hit build in Visual Studio, rather than at project generation time. Most of the reason for wanting this is just to unify what scripting language I use for all build related work and bring it all into Lua, potentially using the genie executable as a standalone Lua interpreter for it.

On 8 December 2014 at 11:06, Branimir Karadžić notifications@github.com wrote:

I think you could do something like this already:

function ProcessReflection( path, solutionname)

do stuff and fill table

prebuildcommands {
}

end

configuration "something" ProcessReflection("", solution().name)

configuration "something else" ProcessReflection("", solution().name)

— Reply to this email directly or view it on GitHub https://github.com/bkaradzic/genie/issues/18#issuecomment-65962537.

bkaradzic commented 9 years ago

Ah I thought you want to process something on project generation time... I wouldn't combine GENie functionality with this. Just build standalone Lua interpreter and script it that way.

vk2gpu commented 9 years ago

Yeah that is probably how itd need to end up. Was kinda hoping to be able to have code from within genie scripts be executed. Never mind though, there is no strict requirement of having that setup. Just thought it might be nice :)

-----Original Message----- From: "Branimir Karadžić" notifications@github.com Sent: ‎8/‎12/‎2014 11:23 AM To: "bkaradzic/genie" genie@noreply.github.com Cc: "Neil Richardson" richyneil@gmail.com Subject: Re: [genie] Lua pre/post build steps. (#18)

Ah I thought you want to process something on project generation time... I wouldn't combine GENie functionality with this. Just build standalone Lua interpreter and script it that way. — Reply to this email directly or view it on GitHub.=

jalgelind commented 9 years ago

Another idea would be to use the invoke genie to do pre/post-processing through actions. You still need to invoke the interpreter explicitly as you currently are, but you can use Lua without requiring a standalone binary.

I haven't looked at this in any depth, but the 'onproject' and 'onsolution' hooks looks interesting, see http://industriousone.com/topic/chaining-actions if this could be of any use to you.

Edit: The hooks probably aren't of any use for standalone actions though... but actions in general works great for invoking Lua-scripts during a build.

vk2gpu commented 9 years ago

Actions sound like it may be the way forward for this without modifying the code base to explicitly support it. I shall have to have a look!