Commits

Alexey Petruchik  committed a956d8e

Custom configurations inital commit

  • Participants
  • Parent commits 1f8b07b

Comments (0)

Files changed (1)

File src/engine/SCons/Tool/xcodeproj.py

         return ext in ['.c', '.cpp', '.cc', '.m', '.mm', '.cxx']
 
 class PBXLegacyTarget(XcodeNode):
-    def __init__(self, context, description, buildSettings, buildtarget):
+    def __init__(self, context, description, buildSettings):
         XcodeNode.__init__(self, context, description)
 
-        self.buildArgumentsString = '"--xcode=${ACTION} %s"' % buildtarget
+        self.buildArgumentsString = '"--xcode=${ACTION} ${SCONS_BUILD_TARGET}"'
         self.buildWorkingDirectory = os.getcwd()
         self.buildConfigurationList = XCConfigurationList(context, 'Build configuration list for PBXLegacyTarget "%s"' % description, buildSettings)
         self.buildPhases = []
         self.productType = '"com.apple.product-type.tool"'
 
 class PBXProject(XcodeNode):
-    def __init__(self, context, description, project_name, buildSettings, buildtarget):
+    def __init__(self, context, description, project_name, buildSettings):
         XcodeNode.__init__(self, context, description)
 
-        self.targets = [PBXLegacyTarget(context, project_name, buildSettings, buildtarget)]
+        self.targets = [PBXLegacyTarget(context, project_name, buildSettings)]
         if context.generate_codenav_targets:
             self.targets.append(PBXNativeTarget(context, project_name + '-codenav', buildSettings))
 
     def __init__(self, context, description, buildSettings = {}):
         XcodeNode.__init__(self, context, description)
 
-        self.buildConfigurations = [XCBuildConfiguration(context, 'Debug', buildSettings), XCBuildConfiguration(context, 'Release', buildSettings)]
+        self.buildConfigurations = map(lambda key: XCBuildConfiguration(context, key, buildSettings[key]), buildSettings)
         self.defaultConfigurationIsVisible = 0
-        self.defaultConfigurationName = 'Release'
+        self.defaultConfigurationName = buildSettings.keys()[0]
 
 def XcodeProjectAction(target, source, env):
     project_filename = str(target[0].srcnode())
     project_name = os.path.basename(project_filename).split('.')[0]
 
     print 'Generating Xcode project \"%s\"' % project_filename
-    print env.get('buildtarget', [])
 
     def custom_sort(x):
         if isinstance(x, PBXGroup):
     context.generate_codenav_targets = env.get('generate_codenav_targets', 1)
     context.project_dir = os.path.dirname(project_filename)
 
+    configurations = env.get('configurations', ['Default'])
+    buildtarget = env.get('buildtarget', [''])
+    runfile = env.get('runfile', [''])
+
     include_search_path = map(os.path.abspath, env.get('CPPPATH', []))
 
-    buildSettings = {
-        'BUILT_PRODUCTS_DIR': os.getcwd(),
-        'ARCHS': '"$(ARCHS_STANDARD_64_BIT)"',
-        'HEADER_SEARCH_PATHS': include_search_path,
-        'USER_HEADER_SEARCH_PATHS': include_search_path,
-        'PRODUCT_NAME': '"$(TARGET_NAME)"'
-    }
+    # TODO: Check configuration, buildtarget and runfile must have same length
+
+    configurationBuildSettings = {}
+    for i in range(len(configurations)):
+        bs = {
+            'BUILT_PRODUCTS_DIR': os.path.dirname(os.path.abspath(runfile[i])),
+            'ARCHS': '"$(ARCHS_STANDARD_64_BIT)"',
+            'HEADER_SEARCH_PATHS': include_search_path,
+            'USER_HEADER_SEARCH_PATHS': include_search_path,
+            'PRODUCT_NAME': '"$(TARGET_NAME)"',
+            'SCONS_BUILD_TARGET': buildtarget[i]
+        }
+        configurationBuildSettings[configurations[i]] = bs
+
+
+
+    print configurations
+    print map(str, buildtarget)
+    print runfile
+
+    # buildSettings = {
+    #     'BUILT_PRODUCTS_DIR': os.path.dirname(os.path.abspath(env.get('runfile', ''))),
+    #     'ARCHS': '"$(ARCHS_STANDARD_64_BIT)"',
+    #     'HEADER_SEARCH_PATHS': include_search_path,
+    #     'USER_HEADER_SEARCH_PATHS': include_search_path,
+    #     'PRODUCT_NAME': '"$(TARGET_NAME)"',
+    #     'SCONS_BUILD_TARGET': env.get('buildtarget', ''),
+    # }
 
     # Create project
-    project = PBXProject(context, 'Project object', project_name, buildSettings, env.get('buildtarget', ''))
+    project = PBXProject(context, 'Project object', project_name,configurationBuildSettings)# buildSettings)
     sourcesGroup = project.mainGroup.subgroup_by_name(project_name)
     
     # Add all source files to project's source group