Class: NxBuild::Generator::VS2015
- Defined in:
- lib/nxbuild/generator/vs2015.rb
Constant Summary collapse
- CONFIGS =
['Debug', 'Release']
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #generate ⇒ Object
- #generate_sln ⇒ Object
- #generate_sln_target(tree, target) ⇒ Object
- #generate_vcxproj(target) ⇒ Object
- #generate_vcxproj_config(xml, target) ⇒ Object
- #generate_vcxproj_cpp_config(xml, target) ⇒ Object
- #generate_vcxproj_globals(xml, target) ⇒ Object
-
#initialize ⇒ VS2015
constructor
A new instance of VS2015.
- #target_uuid(name, escaped = true) ⇒ Object
Constructor Details
#initialize ⇒ VS2015
Returns a new instance of VS2015.
11 12 13 |
# File 'lib/nxbuild/generator/vs2015.rb', line 11 def initialize @targets_uuid = {} end |
Instance Method Details
#generate ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/nxbuild/generator/vs2015.rb', line 28 def generate super generate_sln @config.targets.each do |target| generate_vcxproj target end end |
#generate_sln ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nxbuild/generator/vs2015.rb', line 36 def generate_sln tree = Sln.new buffer = "Microsoft Visual Studio Solution File, Format Version 12.00\n" buffer << "# Visual Studio 14\n" @config.targets.each do |t| generate_sln_target tree, t end tree.dump(buffer) File.write("build/" + @config.name + ".sln", buffer) end |
#generate_sln_target(tree, target) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/nxbuild/generator/vs2015.rb', line 47 def generate_sln_target(tree, target) cpp_uuid = %["{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"] node = SlnNode.new 'Project' node.key = cpp_uuid node.values << %{"#{target.name}"} node.values << %{"#{target.name}.vcxproj"} node.values << target_uuid(target.name) tree.children << node end |
#generate_vcxproj(target) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/nxbuild/generator/vs2015.rb', line 57 def generate_vcxproj(target) name = target.name vcx = name + ".vcxproj" xml = Xml.new('Project') xml['DefaultTargets'] = 'Build' xml['ToolsVersion'] = '14.0' xml['xmlns'] = "http://schemas.microsoft.com/developer/msbuild/2003" generate_vcxproj_config(xml, target) generate_vcxproj_globals(xml, target) generate_vcxproj_cpp_config(xml, target) buffer = "" xml.dump(buffer) File.write("build/" + vcx, buffer) end |
#generate_vcxproj_config(xml, target) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/nxbuild/generator/vs2015.rb', line 72 def generate_vcxproj_config(xml, target) node = XmlNode.new 'ItemGroup' node['Label'] = 'ProjectConfigurations' CONFIGS.each do |config| pc = XmlNode.new 'ProjectConfiguration' pc['Include'] = "#{config}|x64" conf = XmlNode.new 'Configuration' conf << config platform = XmlNode.new 'Platform' platform << 'x64' pc << conf pc << platform node << pc end xml << node end |
#generate_vcxproj_cpp_config(xml, target) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/nxbuild/generator/vs2015.rb', line 107 def generate_vcxproj_cpp_config(xml, target) import = XmlNode.new 'Import' import['Project'] = "$(VCTargetsPath)\\Microsoft.Cpp.Default.props" xml << import CONFIGS.each do |conf| pg = XmlNode.new 'PropertyGroup' pg['Condition'] = "'$(Configuration)|$(Platform)'=='#{conf}|x64'" pg['Label'] = "Configuration" ctype = XmlNode.new 'ConfigurationType' ctype << 'Application' pg << ctype mfc = XmlNode.new 'UseOfMfc' mfc << 'false' pg << mfc character_set = XmlNode.new 'CharacterSet' character_set << 'MultiByte' pg << character_set toolset = XmlNode.new 'PlatformToolset' toolset << 'v140' pg << toolset xml << pg end import = XmlNode.new 'Import' import['Project'] = "$(VCTargetsPath)\\Microsoft.Cpp.props" xml << import end |
#generate_vcxproj_globals(xml, target) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/nxbuild/generator/vs2015.rb', line 89 def generate_vcxproj_globals(xml, target) pg = XmlNode.new 'PropertyGroup' pg['Label'] = 'Globals' guid = XmlNode.new 'ProjectGUID' guid << target_uuid(target.name, false) pg << guid keyword = XmlNode.new 'Keyword' keyword << 'Win32Proj' pg << keyword platform = XmlNode.new 'Platform' platform << 'x64' pg << platform project_name = XmlNode.new 'ProjectName' project_name << target.name pg << project_name xml << pg end |
#target_uuid(name, escaped = true) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nxbuild/generator/vs2015.rb', line 15 def target_uuid(name, escaped = true) unless @targets_uuid.include? name @targets_uuid[name] = NxBuild::UUID.create end uuid = @targets_uuid[name] if escaped uuid = %["{#{uuid}}"] else uuid = %[{#{uuid}}] end return uuid end |