@@ -74,15 +74,18 @@ def test(self, sandbox_profile, stdout=sys.stdout, stderr=sys.stderr,
7474class XcodeTarget (ProjectTarget ):
7575 """An Xcode workspace scheme."""
7676
77- def __init__ (self , swiftc , project , target , destination ,
78- added_xcodebuild_flags , is_workspace , has_scheme ):
77+ def __init__ (self , swiftc , project , target , destination , env ,
78+ added_xcodebuild_flags , is_workspace , has_scheme ,
79+ clean_build ):
7980 self ._swiftc = swiftc
8081 self ._project = project
8182 self ._target = target
8283 self ._destination = destination
84+ self ._env = env
8385 self ._added_xcodebuild_flags = added_xcodebuild_flags
8486 self ._is_workspace = is_workspace
8587 self ._has_scheme = has_scheme
88+ self ._clean_build = clean_build
8689
8790 @property
8891 def project_param (self ):
@@ -108,14 +111,17 @@ def get_build_command(self, incremental=False):
108111
109112 build_dir = os .path .join (build_parent_dir , 'build' )
110113
111- build = ['clean' , 'build' ]
112- if incremental :
113- build = ['build' ]
114+ build = []
115+ if self ._clean_build and not incremental :
116+ build += ['clean' ]
117+ build += ['build' ]
118+
114119 dir_override = []
115120 if self ._has_scheme :
116- dir_override = ['-derivedDataPath' , build_dir ]
117- else :
118- dir_override = ['SYMROOT=' + build_dir ]
121+ dir_override += ['-derivedDataPath' , build_dir ]
122+ elif not 'SYMROOT' in self ._env :
123+ dir_override += ['SYMROOT=' + build_dir ]
124+ dir_override += [k + "=" + v for k , v in self ._env .items ()]
119125 command = (['xcodebuild' ]
120126 + build
121127 + [project_param , self ._project ,
@@ -321,6 +327,10 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
321327 initial_xcodebuild_flags += ['-configuration' ,
322328 action ['configuration' ]]
323329
330+ build_env = {}
331+ if 'environment' in action :
332+ build_env = action ['environment' ]
333+
324334 other_swift_flags = []
325335 if swift_version :
326336 if '.' not in swift_version :
@@ -346,14 +356,19 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
346356 project_path = os .path .join (root_path , repo ['path' ],
347357 action [match .group (2 ).lower ()])
348358 has_scheme = match .group (3 ).lower () == 'scheme'
359+ clean_build = True
360+ if 'clean_build' in action :
361+ clean_build = action ['clean_build' ]
349362 xcode_target = \
350363 XcodeTarget (swiftc ,
351364 project_path ,
352365 action [match .group (3 ).lower ()],
353366 action ['destination' ],
367+ build_env ,
354368 initial_xcodebuild_flags + added_xcodebuild_flags ,
355369 is_workspace ,
356- has_scheme )
370+ has_scheme ,
371+ clean_build )
357372 if should_strip_resource_phases :
358373 strip_resource_phases (os .path .join (root_path , repo ['path' ]),
359374 stdout = stdout , stderr = stderr )
0 commit comments