--- glib/build/win32/setup.py	Mon Jul  4 21:19:54 2011
+++ glib.new/build/win32/setup.py	Mon Jul  4 21:08:05 2011
@@ -13,7 +13,7 @@
     with open(os.path.join(srcroot, 'configure.ac'), 'r') as ac:
         for i in ac:
             mo = RE_VERSION.search(i)
-           if mo:
+            if mo:
                 ver[mo.group(1).upper()] = int(mo.group(2))
     ver['GLIB_BINARY_AGE'] = 100 * ver['GLIB_MINOR_VERSION'] + ver['GLIB_MICRO_VERSION']
     ver['GLIB_VERSION'] = '%d.%d.%d' % (ver['GLIB_MAJOR_VERSION'], 
@@ -38,15 +38,15 @@
     RE_INCLUDE = re.compile(r'^\s*#include\s+"(.*)"')
     with open(src, 'r') as s:
         with open(dest, 'w') as d:
-           for i in s:
+            for i in s:
                 mo = RE_INCLUDE.search(i)
                 if mo:
-                   target = ''
+                    target = ''
                     for j in includes:
                         #print "searching in ", j
                         if mo.group(1) in os.listdir(j):
                             target = os.path.join(j, mo.group(1))
-                           break
+                            break
                     if not target:
                         raise Exception("Couldn't fine include file %s" % mo.group(1))
                     else:
@@ -56,23 +56,33 @@
                 else:
                     d.write(i)
 
-def generate_libgio_sourcefiles(srcroot, dest):
+def generate_libgio_sourcefiles(srcroot, dest, type):
     vars = read_vars_from_AM(os.path.join(srcroot, 'gio', 'Makefile.am'),
                              vars = {'top_srcdir': srcroot},
                              conds = {'OS_WIN32': True},
-                             filters = ['libgio_2_0_la_SOURCES', 'win32_actual_sources', 'win32_actual_more_sources_for_vcproj'])
+                             filters = ['libgio_2_0_la_SOURCES', 'win32_more_sources_for_vcproj'])
 
     files = vars['libgio_2_0_la_SOURCES'].split() + \
-            vars['win32_actual_sources'].split() + \
-            vars['win32_actual_more_sources_for_vcproj'].split()
+            vars['win32_more_sources_for_vcproj'].split()
 
     sources = [i for i in files \
                     if i != 'gdesktopappinfo.c' and \
                        not (i.startswith('gunix') and i.endswith('.c')) \
                        and i.endswith('.c') ]
-    with open(dest, 'w') as d:
-        for i in sources:
-            d.write('\t\t\t<File RelativePath="..\\..\\..\\gio\\' + i.replace('/', '\\') + '"/>\n')
+    if type == '9':
+       with open(dest, 'w') as d:
+           for i in sources:
+               d.write('\t\t\t<File RelativePath="..\\..\\..\\gio\\' + i.replace('/', '\\') + '"/>\n')
+    elif type == '10':
+       with open(dest, 'w') as d:
+           for i in sources:
+               d.write('\t\t\t<ClCompile Include="..\\..\\..\\gio\\' + i.replace('/', '\\') + '"/>\n')
+    elif type == '10f':
+       with open(dest, 'w') as d:
+           for i in sources:
+               d.write('\t\t\t<ClCompile Include="..\\..\\..\\gio\\' + i.replace('/', '\\') + '"><Filter>Source Files</Filter></ClCompile>\n')
+    else:
+       raise Exception("Must specify project type (9, 10 or 10f)")
 
 def generate_libgio_enumtypes(srcroot, perl):
     vars = read_vars_from_AM(os.path.join(srcroot, 'gio', 'Makefile.am'),
@@ -82,13 +92,12 @@
     cwd = os.getcwd()
     os.chdir(os.path.join(srcroot, 'gio'))
     for suffix in ['.c', '.h']:
-        cmd = [perl, os.path.join(srcroot, 'gobject', 'glib-mkenums'),
+        cmd = [perl, os.path.join(srcroot, 'gobject', 'glib-mkenums.in'),
                '--template', 'gioenumtypes' + suffix + '.template'] + vars['gio_headers'].split()
         with open('gioenumtypes' + suffix, 'w') as d:
             subprocess.Popen(cmd, stdout = d).communicate()
     os.chdir(cwd)
-
-def generate_libglib_sourcefiles(srcroot, dest):
+def generate_libglib_sourcefiles(srcroot, dest, type):
     vars = read_vars_from_AM(os.path.join(srcroot, 'glib', 'Makefile.am'),
                              vars = {'top_srcdir': srcroot},
                              conds = {'OS_WIN32': True,
@@ -99,12 +108,23 @@
 
     sources = [i for i in files \
                     if not (i.endswith('-gcc.c') or i.endswith('-unix.c')) \
-                      and i.endswith('.c') ]
-    with open(dest, 'w') as d:
-        for i in sources:
-            d.write('\t\t\t<File RelativePath="..\\..\\..\\glib\\' + i.replace('/', '\\') + '"/>\n')
+                       and i.endswith('.c') ]
+    if type == '9':
+       with open(dest, 'w') as d:
+           for i in sources:
+               d.write('\t\t\t<File RelativePath="..\\..\\..\\glib\\' + i.replace('/', '\\') + '"/>\n')
+    elif type == '10':
+       with open(dest, 'w') as d:
+           for i in sources:
+               d.write('\t\t\t<ClCompile Include="..\\..\\..\\glib\\' + i.replace('/', '\\') + '"/>\n')
+    elif type == '10f':
+       with open(dest, 'w') as d:
+           for i in sources:
+               d.write('\t\t\t<ClCompile Include="..\\..\\..\\glib\\' + i.replace('/', '\\') + '"><Filter>Source Files</Filter></ClCompile>\n')
+    else:
+       raise Exception("Must specify project type (9, 10 or 10f)")
 
-def generate_libgobject_sourcefiles(srcroot, dest):
+def generate_libgobject_sourcefiles(srcroot, dest, type):
     vars = read_vars_from_AM(os.path.join(srcroot, 'gobject', 'Makefile.am'),
                              vars = {'top_srcdir': srcroot},
                              conds = {'OS_WIN32': True},
@@ -113,9 +133,20 @@
     files = vars['libgobject_2_0_la_SOURCES'].split()
 
     sources = [i for i in files if i.endswith('.c') ]
-    with open(dest, 'w') as d:
-        for i in sources:
-            d.write('\t\t\t<File RelativePath="..\\..\\..\\gobject\\' + i.replace('/', '\\') + '"/>\n')
+    if type == '9':
+       with open(dest, 'w') as d:
+           for i in sources:
+               d.write('\t\t\t<File RelativePath="..\\..\\..\\gobject\\' + i.replace('/', '\\') + '"/>\n')
+    elif type == '10':
+       with open(dest, 'w') as d:
+           for i in sources:
+               d.write('\t\t\t<ClCompile Include="..\\..\\..\\gobject\\' + i.replace('/', '\\') + '"/>\n')
+    elif type == '10f':
+       with open(dest, 'w') as d:
+           for i in sources:
+               d.write('\t\t\t<ClCompile Include="..\\..\\..\\gobject\\' + i.replace('/', '\\') + '"><Filter>Source Files</Filter></ClCompile>\n')
+    else:
+       raise Exception("Must specify project type (9, 10 or 10f)")
 
 def read_vars_from_AM(path, vars = {}, conds = {}, filters = None):
     '''
@@ -156,7 +187,7 @@
             i += 1
         ncont.append(line)
 
-   #include, var define, var evaluation
+    #include, var define, var evaluation
     i = -1
     skip = False
     oldskip = []
@@ -227,20 +258,44 @@
                    ver)
     #submodule gio
     generate_libgio_sourcefiles(srcroot,
-                                os.path.join(srcroot, 'build', 'win32', 'libgio.sourcefiles'))
+                                os.path.join(srcroot, 'build', 'win32', 'libgio.sourcefiles'), '9')
+    generate_libgio_sourcefiles(srcroot,
+                                os.path.join(srcroot, 'build', 'win32', 'libgio.vs10.sourcefiles'), '10')
+    generate_libgio_sourcefiles(srcroot,
+                                os.path.join(srcroot, 'build', 'win32', 'libgio.vs10.sourcefiles.filters'), '10f')
     process_include(os.path.join(srcroot, 'build', 'win32', 'vs9', 'gio.vcprojin'),
                     os.path.join(srcroot, 'build', 'win32', 'vs9', 'gio.vcproj'),
                     includes = [os.path.join(srcroot, 'build', 'win32')])
+    process_include(os.path.join(srcroot, 'build', 'win32', 'vs10', 'gio.vcxprojin'),
+                    os.path.join(srcroot, 'build', 'win32', 'vs10', 'gio.vcxproj'),
+                    includes = [os.path.join(srcroot, 'build', 'win32')])
+    process_include(os.path.join(srcroot, 'build', 'win32', 'vs10', 'gio.vcxproj.filtersin'),
+                    os.path.join(srcroot, 'build', 'win32', 'vs10', 'gio.vcxproj.filters'),
+                    includes = [os.path.join(srcroot, 'build', 'win32')])
     os.unlink(os.path.join(srcroot, 'build', 'win32', 'libgio.sourcefiles'))
+    os.unlink(os.path.join(srcroot, 'build', 'win32', 'libgio.vs10.sourcefiles'))
+    os.unlink(os.path.join(srcroot, 'build', 'win32', 'libgio.vs10.sourcefiles.filters'))
     generate_libgio_enumtypes(srcroot, opt.perl)
     
     #submodule glib
     generate_libglib_sourcefiles(srcroot,
-                                os.path.join(srcroot, 'build', 'win32', 'libglib.sourcefiles'))
+                                os.path.join(srcroot, 'build', 'win32', 'libglib.sourcefiles'), '9')
+    generate_libglib_sourcefiles(srcroot,
+                                os.path.join(srcroot, 'build', 'win32', 'libglib.vs10.sourcefiles'), '10')
+    generate_libglib_sourcefiles(srcroot,
+                                os.path.join(srcroot, 'build', 'win32', 'libglib.vs10.sourcefiles.filters'), '10f')
     process_include(os.path.join(srcroot, 'build', 'win32', 'vs9', 'glib.vcprojin'),
                     os.path.join(srcroot, 'build', 'win32', 'vs9', 'glib.vcproj'),
                     includes = [os.path.join(srcroot, 'build', 'win32')])
+    process_include(os.path.join(srcroot, 'build', 'win32', 'vs10', 'glib.vcxprojin'),
+                    os.path.join(srcroot, 'build', 'win32', 'vs10', 'glib.vcxproj'),
+                    includes = [os.path.join(srcroot, 'build', 'win32')])
+    process_include(os.path.join(srcroot, 'build', 'win32', 'vs10', 'glib.vcxproj.filtersin'),
+                    os.path.join(srcroot, 'build', 'win32', 'vs10', 'glib.vcxproj.filters'),
+                    includes = [os.path.join(srcroot, 'build', 'win32')])
     os.unlink(os.path.join(srcroot, 'build', 'win32', 'libglib.sourcefiles'))
+    os.unlink(os.path.join(srcroot, 'build', 'win32', 'libglib.vs10.sourcefiles'))
+    os.unlink(os.path.join(srcroot, 'build', 'win32', 'libglib.vs10.sourcefiles.filters'))
     with open(os.path.join(srcroot, 'glib', 'gspawn-win32-helper-console.c'), 'w') as c:
         c.write('#define HELPER_CONSOLE\n')
         c.write('#include "gspawn-win32-helper.c"\n')
@@ -252,14 +307,26 @@
 
     #submodule gobject
     generate_libgobject_sourcefiles(srcroot,
-                                os.path.join(srcroot, 'build', 'win32', 'libgobject.sourcefiles'))
+                                os.path.join(srcroot, 'build', 'win32', 'libgobject.sourcefiles'), '9')
+    generate_libgobject_sourcefiles(srcroot,
+                                os.path.join(srcroot, 'build', 'win32', 'libgobject.vs10.sourcefiles'), '10')
+    generate_libgobject_sourcefiles(srcroot,
+                                os.path.join(srcroot, 'build', 'win32', 'libgobject.vs10.sourcefiles.filters'), '10f')
     process_include(os.path.join(srcroot, 'build', 'win32', 'vs9', 'gobject.vcprojin'),
                     os.path.join(srcroot, 'build', 'win32', 'vs9', 'gobject.vcproj'),
                     includes = [os.path.join(srcroot, 'build', 'win32')])
+    process_include(os.path.join(srcroot, 'build', 'win32', 'vs10', 'gobject.vcxprojin'),
+                    os.path.join(srcroot, 'build', 'win32', 'vs10', 'gobject.vcxproj'),
+                    includes = [os.path.join(srcroot, 'build', 'win32')])
+    process_include(os.path.join(srcroot, 'build', 'win32', 'vs10', 'gobject.vcxproj.filtersin'),
+                    os.path.join(srcroot, 'build', 'win32', 'vs10', 'gobject.vcxproj.filters'),
+                    includes = [os.path.join(srcroot, 'build', 'win32')])
     os.unlink(os.path.join(srcroot, 'build', 'win32', 'libgobject.sourcefiles'))
+    os.unlink(os.path.join(srcroot, 'build', 'win32', 'libgobject.vs10.sourcefiles'))
+    os.unlink(os.path.join(srcroot, 'build', 'win32', 'libgobject.vs10.sourcefiles.filters'))
 
     #submodule gmodule
     return 0
 
 if __name__ == '__main__':
-    sys.exit(main(sys.argv))
\ No newline at end of file
+    sys.exit(main(sys.argv))
