bin/createVSProjects in bake-toolkit-2.20.4 vs bin/createVSProjects in bake-toolkit-2.21.0
- old
+ new
@@ -1,214 +1,214 @@
-#!/usr/bin/env ruby
-$:.unshift(File.dirname(__FILE__)+"/../lib")
-
-require "securerandom"
-require "vs/options"
-require 'common/version'
-
-puts "-- bake #{Bake::Version.number}, ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}, platform #{RUBY_PLATFORM} --"
-
-module Bake
-
-PATH = 0
-UUID = 1
-
-def self.writeProjects(f,projects)
- projects.each do |k,v|
- f.puts "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" + k + "\", \"" + v[PATH] + "/" + k + ".vcxproj\", \"{" + v[UUID] + "}\""
- f.puts "EndProject"
- end
-end
-
-def self.writeCfg(f,projects)
- projects.each do |k,v|
- f.puts " {" + v[UUID] + "}.bake|Win32.ActiveCfg = bake|Win32"
- f.puts " {" + v[UUID] + "}.bake|Win32.Build.0 = bake|Win32"
- end
-end
-
-@options = VsOptions.new(ARGV)
-@options.parse_options
-
-version = "13.00"
-toolset = "v120"
-if @options.version == "2010"
- version = "11.00"
- toolset = "v100"
-elsif @options.version == "2012"
- version = "12.00"
- toolset = "v110"
-end
-
-
-slnFilename = @options.roots[0] + "/" + File.basename(@options.roots[0]) + ".sln"
-appendProjects = (File.exist?(slnFilename) and @options.rewriteSolution)
-
-puts "Scanning for bake projects...."
-
-projects = {}
-@options.roots.each do |r|
- Dir.glob(r + "/**/Project.meta").each do |m|
- projects[File.basename(File.dirname(m))] = [File.dirname(m), SecureRandom.uuid.upcase]
- end
-end
-
-#if not @options.rewriteProjects
-# projects.delete_if { |k,v| File.exist?(v[PATH]+"/"+k+".vcxproj") or File.exist?(v[PATH]+"/"+k+".vcxproj.filters") }
-#end
-
-@options.rewriteSolution = true unless File.exist?(slnFilename)
-
-slnText = ""
-if not @options.rewriteSolution
- pattern = /Project.*[\\\/]([^\\\/]*)\.vcxproj/
- slnText=File.open(slnFilename).read
- slnText.gsub!(/\r\n?/, "\n")
- slnText.each_line do |line|
- x = line.match(pattern)
- projects.delete(x[1]) if x
- end
-end
-
-if projects.length == 0
- puts "Nothing to do."
- exit(0)
-end
-
-if not @options.rewriteSolution
-
- puts "Adding new projects to " + slnFilename + "... "
- File.open(slnFilename, 'w') do |f|
-
- addedProjects = false
- slnText.each_line do |line|
- if line.include?"Project("
- writeProjects(f,projects)
- addedProjects = true
- end
-
- f.puts line
-
- if line.include?"postSolution"
- writeCfg(f,projects)
- end
- end
-
- end
-
-else
-
- puts "Rewriting " + slnFilename + "... "
- File.open(slnFilename, 'w') do |f|
- f.puts "Microsoft Visual Studio Solution File, Format Version " + version
-
- writeProjects(f,projects)
-
- f.puts "Global"
- f.puts " GlobalSection(SolutionConfigurationPlatforms) = preSolution"
- f.puts " bake|Win32 = bake|Win32"
- f.puts " EndGlobalSection"
- f.puts " GlobalSection(ProjectConfigurationPlatforms) = postSolution"
-
- writeCfg(f,projects)
-
- f.puts " EndGlobalSection"
- f.puts " GlobalSection(SolutionProperties) = preSolution"
- f.puts " HideSolutionNode = FALSE"
- f.puts " EndGlobalSection"
- f.puts "EndGlobal"
- end
-
-end
-
-projects.each do |k,v|
-
- filename = v[PATH] + "/" + k + ".vcxproj"
- puts "Writing " + filename + "... "
- File.open(filename, 'w') do |f|
-
- f.puts "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- f.puts "<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
- f.puts " <ItemGroup Label=\"ProjectConfigurations\">"
- f.puts " <ProjectConfiguration Include=\"bake|Win32\">"
- f.puts " <Configuration>bake</Configuration>"
- f.puts " <Platform>Win32</Platform>"
- f.puts " </ProjectConfiguration>"
- f.puts " </ItemGroup>"
- f.puts " <PropertyGroup Label=\"Globals\">"
- f.puts " <Keyword>MakeFileProj</Keyword>"
- f.puts " <ProjectGuid>{" + v[UUID] + "}</ProjectGuid>"
- f.puts " </PropertyGroup>"
- f.puts " <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />"
- f.puts " <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='bake|Win32'\" Label=\"Configuration\">"
- f.puts " <ConfigurationType>Makefile</ConfigurationType>"
- f.puts " <PlatformToolset>" + toolset + "</PlatformToolset>"
- f.puts " </PropertyGroup>"
- f.puts " <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='bake|Win32'\">"
- f.puts " <ExecutablePath>$(PATH)</ExecutablePath>"
- f.puts " </PropertyGroup>"
- f.puts " <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />"
- f.puts " <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='bake|Win32'\">"
- f.puts " <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />"
- f.puts " </ImportGroup>"
-
-
- f.puts " <ItemGroup>"
- Dir.chdir(v[PATH]) do
- files = Dir.glob("**/*")
- files.each do |item|
- if (item[0..5] != ".bake") and not File.directory?(item)
- f.puts " <None Include=\"" + item + "\" />"
- end
- end
- end
- f.puts " </ItemGroup>"
-
- f.puts " <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />"
- f.puts "</Project>"
-
- end
-
- filename = filename + ".filters"
- puts "Writing " + filename + "... "
- File.open(filename, 'w') do |f|
-
- f.puts "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
- f.puts "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
-
- fileList = []
- f.puts " <ItemGroup>"
- Dir.chdir(v[PATH]) do
- files = Dir.glob("**/*")
- files.each do |item|
- if (item[0..5] != ".bake")
- if (File.directory? item)
- f.puts " <Filter Include=\"" + item.gsub(/\//,"\\") + "\" />"
- else
- fileList << item
- end
- end
- end
- end
- f.puts " </ItemGroup>"
-
- f.puts " <ItemGroup>"
- fileList.each do |i|
- if File.dirname(i) != "."
- f.puts " <None Include=\"" + i + "\">"
- f.puts " <Filter>" + File.dirname(i).gsub(/\//,"\\") + "</Filter>"
- f.puts " </None>"
- else
- f.puts " <None Include=\"" + i + "\" />"
- end
- end
- f.puts " </ItemGroup>"
-
- f.puts "</Project>"
-
- end
-
-end
-
-puts "Finished."
-
+#!/usr/bin/env ruby
+$:.unshift(File.dirname(__FILE__)+"/../lib")
+
+require "securerandom"
+require "vs/options"
+require 'common/version'
+
+Bake::Version.printBakeVersion
+
+module Bake
+
+PATH = 0
+UUID = 1
+
+def self.writeProjects(f,projects)
+ projects.each do |k,v|
+ f.puts "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" + k + "\", \"" + v[PATH] + "/" + k + ".vcxproj\", \"{" + v[UUID] + "}\""
+ f.puts "EndProject"
+ end
+end
+
+def self.writeCfg(f,projects)
+ projects.each do |k,v|
+ f.puts " {" + v[UUID] + "}.bake|Win32.ActiveCfg = bake|Win32"
+ f.puts " {" + v[UUID] + "}.bake|Win32.Build.0 = bake|Win32"
+ end
+end
+
+@options = VsOptions.new(ARGV)
+@options.parse_options
+
+version = "13.00"
+toolset = "v120"
+if @options.version == "2010"
+ version = "11.00"
+ toolset = "v100"
+elsif @options.version == "2012"
+ version = "12.00"
+ toolset = "v110"
+end
+
+
+slnFilename = @options.roots[0] + "/" + File.basename(@options.roots[0]) + ".sln"
+appendProjects = (File.exist?(slnFilename) and @options.rewriteSolution)
+
+puts "Scanning for bake projects...."
+
+projects = {}
+@options.roots.each do |r|
+ Dir.glob(r + "/**/Project.meta").each do |m|
+ projects[File.basename(File.dirname(m))] = [File.dirname(m), SecureRandom.uuid.upcase]
+ end
+end
+
+#if not @options.rewriteProjects
+# projects.delete_if { |k,v| File.exist?(v[PATH]+"/"+k+".vcxproj") or File.exist?(v[PATH]+"/"+k+".vcxproj.filters") }
+#end
+
+@options.rewriteSolution = true unless File.exist?(slnFilename)
+
+slnText = ""
+if not @options.rewriteSolution
+ pattern = /Project.*[\\\/]([^\\\/]*)\.vcxproj/
+ slnText=File.open(slnFilename).read
+ slnText.gsub!(/\r\n?/, "\n")
+ slnText.each_line do |line|
+ x = line.match(pattern)
+ projects.delete(x[1]) if x
+ end
+end
+
+if projects.length == 0
+ puts "Nothing to do."
+ exit(0)
+end
+
+if not @options.rewriteSolution
+
+ puts "Adding new projects to " + slnFilename + "... "
+ File.open(slnFilename, 'w') do |f|
+
+ addedProjects = false
+ slnText.each_line do |line|
+ if line.include?"Project("
+ writeProjects(f,projects)
+ addedProjects = true
+ end
+
+ f.puts line
+
+ if line.include?"postSolution"
+ writeCfg(f,projects)
+ end
+ end
+
+ end
+
+else
+
+ puts "Rewriting " + slnFilename + "... "
+ File.open(slnFilename, 'w') do |f|
+ f.puts "Microsoft Visual Studio Solution File, Format Version " + version
+
+ writeProjects(f,projects)
+
+ f.puts "Global"
+ f.puts " GlobalSection(SolutionConfigurationPlatforms) = preSolution"
+ f.puts " bake|Win32 = bake|Win32"
+ f.puts " EndGlobalSection"
+ f.puts " GlobalSection(ProjectConfigurationPlatforms) = postSolution"
+
+ writeCfg(f,projects)
+
+ f.puts " EndGlobalSection"
+ f.puts " GlobalSection(SolutionProperties) = preSolution"
+ f.puts " HideSolutionNode = FALSE"
+ f.puts " EndGlobalSection"
+ f.puts "EndGlobal"
+ end
+
+end
+
+projects.each do |k,v|
+
+ filename = v[PATH] + "/" + k + ".vcxproj"
+ puts "Writing " + filename + "... "
+ File.open(filename, 'w') do |f|
+
+ f.puts "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ f.puts "<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
+ f.puts " <ItemGroup Label=\"ProjectConfigurations\">"
+ f.puts " <ProjectConfiguration Include=\"bake|Win32\">"
+ f.puts " <Configuration>bake</Configuration>"
+ f.puts " <Platform>Win32</Platform>"
+ f.puts " </ProjectConfiguration>"
+ f.puts " </ItemGroup>"
+ f.puts " <PropertyGroup Label=\"Globals\">"
+ f.puts " <Keyword>MakeFileProj</Keyword>"
+ f.puts " <ProjectGuid>{" + v[UUID] + "}</ProjectGuid>"
+ f.puts " </PropertyGroup>"
+ f.puts " <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />"
+ f.puts " <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='bake|Win32'\" Label=\"Configuration\">"
+ f.puts " <ConfigurationType>Makefile</ConfigurationType>"
+ f.puts " <PlatformToolset>" + toolset + "</PlatformToolset>"
+ f.puts " </PropertyGroup>"
+ f.puts " <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='bake|Win32'\">"
+ f.puts " <ExecutablePath>$(PATH)</ExecutablePath>"
+ f.puts " </PropertyGroup>"
+ f.puts " <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />"
+ f.puts " <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='bake|Win32'\">"
+ f.puts " <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />"
+ f.puts " </ImportGroup>"
+
+
+ f.puts " <ItemGroup>"
+ Dir.chdir(v[PATH]) do
+ files = Dir.glob("**/*")
+ files.each do |item|
+ if (item[0..5] != ".bake") and not File.directory?(item)
+ f.puts " <None Include=\"" + item + "\" />"
+ end
+ end
+ end
+ f.puts " </ItemGroup>"
+
+ f.puts " <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />"
+ f.puts "</Project>"
+
+ end
+
+ filename = filename + ".filters"
+ puts "Writing " + filename + "... "
+ File.open(filename, 'w') do |f|
+
+ f.puts "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ f.puts "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
+
+ fileList = []
+ f.puts " <ItemGroup>"
+ Dir.chdir(v[PATH]) do
+ files = Dir.glob("**/*")
+ files.each do |item|
+ if (item[0..5] != ".bake")
+ if (File.directory? item)
+ f.puts " <Filter Include=\"" + item.gsub(/\//,"\\") + "\" />"
+ else
+ fileList << item
+ end
+ end
+ end
+ end
+ f.puts " </ItemGroup>"
+
+ f.puts " <ItemGroup>"
+ fileList.each do |i|
+ if File.dirname(i) != "."
+ f.puts " <None Include=\"" + i + "\">"
+ f.puts " <Filter>" + File.dirname(i).gsub(/\//,"\\") + "</Filter>"
+ f.puts " </None>"
+ else
+ f.puts " <None Include=\"" + i + "\" />"
+ end
+ end
+ f.puts " </ItemGroup>"
+
+ f.puts "</Project>"
+
+ end
+
+end
+
+puts "Finished."
+
end
\ No newline at end of file