Commits

Alexey Petruchik committed a33f252

Xcode project generation work in progress

Comments (0)

Files changed (3)

src/engine/SCons/Script/Main.py

     global this_build_status
 
     options = parser.values
+    if options.xcode == 'clean':
+        options.clean = True
 
     # Here's where everything really happens.
 

src/engine/SCons/Script/SConsOptions.py

                   action="callback", callback=opt_ignore,
                   help="Ignored for compatibility.")
 
+    op.add_option('--xcode',
+                  dest="xcode", type="string",
+                  default="", action="store")
+
     op.add_option('-c', '--clean', '--remove',
                   dest="clean", default=False,
                   action="store_true",

src/engine/SCons/Tool/xcodeproj.py

         return ext in ['.c', '.cpp', '.cc', '.m', '.mm', '.cxx']
 
 class PBXLegacyTarget(XcodeNode):
-    def __init__(self, context, description):
+    def __init__(self, context, description, buildSettings = {}):
         XcodeNode.__init__(self, context, description)
 
-        self.buildArgumentsString = '""'#'"${ACTION)"'
-        self.buildConfigurationList = XCConfigurationList(context, 'Build configuration list for PBXLegacyTarget "%s"' % description)
+        self.buildArgumentsString = '"--xcode=${ACTION}"'
+        self.buildConfigurationList = XCConfigurationList(context, 'Build configuration list for PBXLegacyTarget "%s"' % description, buildSettings)
         self.buildPhases = []
         self.buildToolPath = 'scons'
         self.dependencies = []
         #self.productType = '"com.apple.product-type.library.dynamic"'
 
 class PBXNativeTarget(XcodeNode):
-    def __init__(self, context, description):
+    def __init__(self, context, description, buildSettings = {}):
         XcodeNode.__init__(self, context, description)
 
-        self.buildConfigurationList = XCConfigurationList(context, 'Build configuration list for PBXNativeTarget "%s"' % description)
+        self.buildConfigurationList = XCConfigurationList(context, 'Build configuration list for PBXNativeTarget "%s"' % description, buildSettings)
         self.buildPhases = [PBXSourcesBuildPhase(context, 'Sources')]
         self.buildRules = []
         self.dependencies = []
         self.productType = '"com.apple.product-type.tool"'
 
 class PBXProject(XcodeNode):
-    def __init__(self, context, description, project_name):
+    def __init__(self, context, description, project_name, buildSettings = {}):
         XcodeNode.__init__(self, context, description)
 
-        self.targets = [PBXLegacyTarget(context, project_name.split('.')[0])]
+        self.targets = [PBXLegacyTarget(context, project_name.split('.')[0], buildSettings)]
         if context.generate_codenav_targets:
-            self.targets.append(PBXNativeTarget(context, project_name.split('.')[0] + '-codenav'))
+            self.targets.append(PBXNativeTarget(context, project_name.split('.')[0] + '-codenav', buildSettings))
 
-        self.buildConfigurationList = XCConfigurationList(context, 'Build configuration list for PBXProject "%s"' % project_name)
+        self.buildConfigurationList = XCConfigurationList(context, 'Build configuration list for PBXProject "%s"' % project_name, buildSettings)
         self.compatibilityVersion = '"Xcode 3.2"'
         self.projectDirPath = '""';
         self.projectRoot = '""'
         self.fileRef = ref
 
 class XCBuildConfiguration(XcodeNode):
-    def __init__(self, context, description):
+    def __init__(self, context, description, buildSettings):
         XcodeNode.__init__(self, context, description)
 
-        self.buildSettings = {
-            'BUILT_PRODUCTS_DIR': '"/Users/stopiccot/code/other/scons-xcode"', 
-            'ARCHS': '"$(ARCHS_STANDARD_64_BIT)"',
-            'HEADER_SEARCH_PATHS': '/Users/stopiccot/code/other/scons-xcode/uber_lib',
-            'USER_HEADER_SEARCH_PATHS': '/Users/stopiccot/code/other/scons-xcode/uber_lib',
-            'PRODUCT_NAME': '"$(TARGET_NAME)"'
-        }
-
+        self.buildSettings = buildSettings
         self.name = self._name
 
 class XCConfigurationList(XcodeNode):
-    def __init__(self, context, description):
+    def __init__(self, context, description, buildSettings = {}):
         XcodeNode.__init__(self, context, description)
 
-        self.buildConfigurations = [XCBuildConfiguration(context, 'Debug'), XCBuildConfiguration(context, 'Release')]
+        self.buildConfigurations = [XCBuildConfiguration(context, 'Debug', buildSettings), XCBuildConfiguration(context, 'Release', buildSettings)]
         self.defaultConfigurationIsVisible = 0
         self.defaultConfigurationName = 'Release'
 
 def XcodeProjectAction(target, source, env):
     project_name = str(target[0].srcnode())
+    print 'Generating Xcode project \"%s\"' % project_name
     os.mkdir(project_name)
 
     # Generate xxx.xcodeproj/project/project.xcworkspace/contents.xcworkspacedata
 
     context = XcodeProjectBuildContext()
     context.generate_codenav_targets = env.get('generate_codenav_targets', 1)
-    p = PBXProject(context, 'Project object', project_name)
+
+    include_search_path = map(os.path.abspath, env.get('CPPPATH', []))
+
+    buildSettings = {
+        'BUILT_PRODUCTS_DIR': os.getcwd(),#'"/Users/stopiccot/code/other/scons-xcode"', 
+        'ARCHS': '"$(ARCHS_STANDARD_64_BIT)"',
+        'HEADER_SEARCH_PATHS': include_search_path,
+        'USER_HEADER_SEARCH_PATHS': include_search_path,
+        'PRODUCT_NAME': '"$(TARGET_NAME)"'
+    }
+
+    for i in env.get('CPPPATH', []):
+        print os.path.abspath(i)
+
+    p = PBXProject(context, 'Project object', project_name, buildSettings)
     
     for i in env['srcs']:
         p.mainGroup.add_source(i)
 
 projectBuilder = SCons.Builder.Builder(
 #    emitter = XcodeProjectEmitter,
-    action = XcodeProjectAction,
+    action = SCons.Action.Action(XcodeProjectAction, None),
     suffix = '.xcodeproj',
     target_factory = SCons.Node.FS.Dir
 )