Anonymous avatar Anonymous committed 73ad56e

Fix in Visual Studio project generation. When project contains only one *.cpp or only one *.h file, incorrect paths are generated.

Comments (0)

Files changed (2)

QMTest/TestSConsMSVS.py

 \t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
 \t</PropertyGroup>
 \t<ItemGroup>
-\t\t<ClInclude Include="sdk.h" />
+\t\t<ClInclude Include="sdk_dir\sdk.h" />
 \t</ItemGroup>
 \t<ItemGroup>
 \t\t<ClInclude Include="test.h" />
                 HOST_ARCH='%(HOST_ARCH)s')
 
 testsrc = ['test1.cpp', 'test2.cpp']
-testincs = ['sdk.h']
+testincs = ['sdk_dir\sdk.h']
 testlocalincs = ['test.h']
 testresources = ['test.rc']
 testmisc = ['readme.txt']

src/engine/SCons/Tool/msvs.py

 
             # First remove any common prefix
             commonprefix = None
-            if len(sources) > 1:
-                s = list(map(os.path.normpath, sources))
-                # take the dirname because the prefix may include parts
-                # of the filenames (e.g. if you have 'dir\abcd' and
-                # 'dir\acde' then the cp will be 'dir\a' )
-                cp = os.path.dirname( os.path.commonprefix(s) )
-                if cp and s[0][len(cp)] == os.sep:
-                    # +1 because the filename starts after the separator
-                    sources = [s[len(cp)+1:] for s in sources]
-                    commonprefix = cp
-            elif len(sources) == 1:
-                commonprefix = os.path.dirname( sources[0] )
-                sources[0] = os.path.basename( sources[0] )
+            s = list(map(os.path.normpath, sources))
+            # take the dirname because the prefix may include parts
+            # of the filenames (e.g. if you have 'dir\abcd' and
+            # 'dir\acde' then the cp will be 'dir\a' )
+            cp = os.path.dirname( os.path.commonprefix(s) )
+            if cp and s[0][len(cp)] == os.sep:
+                # +1 because the filename starts after the separator
+                sources = [s[len(cp)+1:] for s in sources]
+                commonprefix = cp
 
             hierarchy = makeHierarchy(sources)
             self.printSources(hierarchy, commonprefix=commonprefix)
             # First remove any common prefix
             sources = self.sources[kind]
             commonprefix = None
-            if len(sources) > 1:
-                s = list(map(os.path.normpath, sources))
-                # take the dirname because the prefix may include parts
-                # of the filenames (e.g. if you have 'dir\abcd' and
-                # 'dir\acde' then the cp will be 'dir\a' )
-                cp = os.path.dirname( os.path.commonprefix(s) )
-                if cp and s[0][len(cp)] == os.sep:
-                    # +1 because the filename starts after the separator
-                    sources = [s[len(cp)+1:] for s in sources]
-                    commonprefix = cp
-            elif len(sources) == 1:
-                commonprefix = os.path.dirname( sources[0] )
-                sources[0] = os.path.basename( sources[0] )
+            s = list(map(os.path.normpath, sources))
+            # take the dirname because the prefix may include parts
+            # of the filenames (e.g. if you have 'dir\abcd' and
+            # 'dir\acde' then the cp will be 'dir\a' )
+            cp = os.path.dirname( os.path.commonprefix(s) )
+            if cp and s[0][len(cp)] == os.sep:
+                # +1 because the filename starts after the separator
+                sources = [s[len(cp)+1:] for s in sources]
+                commonprefix = cp
             
             hierarchy = makeHierarchy(sources)
             self.printFilters(hierarchy, kind)
             # First remove any common prefix
             sources = self.sources[kind]
             commonprefix = None
-            if len(sources) > 1:
-                s = list(map(os.path.normpath, sources))
-                # take the dirname because the prefix may include parts
-                # of the filenames (e.g. if you have 'dir\abcd' and
-                # 'dir\acde' then the cp will be 'dir\a' )
-                cp = os.path.dirname( os.path.commonprefix(s) )
-                if cp and s[0][len(cp)] == os.sep:
-                    # +1 because the filename starts after the separator
-                    sources = [s[len(cp)+1:] for s in sources]
-                    commonprefix = cp
-            elif len(sources) == 1:
-                commonprefix = os.path.dirname( sources[0] )
-                sources[0] = os.path.basename( sources[0] )
+            s = list(map(os.path.normpath, sources))
+            # take the dirname because the prefix may include parts
+            # of the filenames (e.g. if you have 'dir\abcd' and
+            # 'dir\acde' then the cp will be 'dir\a' )
+            cp = os.path.dirname( os.path.commonprefix(s) )
+            if cp and s[0][len(cp)] == os.sep:
+                # +1 because the filename starts after the separator
+                sources = [s[len(cp)+1:] for s in sources]
+                commonprefix = cp
             
             hierarchy = makeHierarchy(sources)
             self.printSources(hierarchy, kind, commonprefix, kind)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.