rayh / xcoder

ruby wrapper for Xcode build tools to aid automating builds
MIT License
412 stars 70 forks source link

Allow a user to pass custom environment variables to the build call #48

Closed jayzes closed 11 years ago

jayzes commented 12 years ago

In one of my projects, I ran into a need to pass custom environment variables to a build operation and patched xcoder to handle that. Figured I'd push the change back upstream as well. A spec is included.

burtlo commented 12 years ago

Rayh and I have talked about this issue before when I wanted to add the ability to use Cedar for testing or something like that. I remember trying to attack this problem. Let me think on this with some feedback about creating a robust system to handle all different types of environment variables, flags, and such.

rayh commented 12 years ago

I think we started talking about having some sort of DSL or such like for constructing Xcode command lines. You have several different types of arguments you can pass... perhaps something like:

cmd = Xcode::Command.new 'xcodebuild' do |cmd|
  cmd.env['FOO'] = 'BAR'
  cmd.args << 'build'
  cmd.params['-project'] = 'MyProject.xcodeproj'
end

cmd.invoke do |line|
  puts line
end

And then when you are invoking it from builder:

builder.build do |cmd|
  cmd.env['ANOTHER_FLAG'] = 'VALUE'
end

Or perhaps some other mechanism to hook into the process. I'm not that happy with the way the builder class is done right now... it mostly to provide common utility functions to a Rakefile for automating builds, so I'm open to suggestions.

rayh commented 11 years ago

@jayzes Could you take a look at the newer approach to Xcode::Shell::Command and see if that helps? The builder has a build_environment method that is expected to return additional environment vars, but could be extended through a property, or pick up from ENV[]

rayh commented 11 years ago

Please reopen if this is still relevant

jayzes commented 11 years ago

Cool, sounds good. Looks good to me at first glance - I'll try to dig in more this weekend.