Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ParadoxConfig.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.IO;
6 using SharpDX.Text;
7 using SiliconStudio.Assets;
8 using SiliconStudio.Core;
9 using SiliconStudio.Core.VisualStudio;
10 using SiliconStudio.Paradox.Graphics;
11 
12 namespace SiliconStudio.Paradox.Assets
13 {
14  [DataContract("Paradox")]
15  public sealed class ParadoxConfig
16  {
17  private const string XamariniOSBuild = @"MSBuild\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets";
18  private const string XamarinAndroidBuild = @"MSBuild\Xamarin\Android\Xamarin.Android.CSharp.targets";
19  private const string WindowsRuntimeBuild = @"MSBuild\Microsoft\WindowsXaml\v12.0\8.1\Microsoft.Windows.UI.Xaml.Common.Targets";
20  private static readonly string ProgramFilesX86 = Environment.GetEnvironmentVariable(Environment.Is64BitOperatingSystem ? "ProgramFiles(x86)" : "ProgramFiles");
21 
23 
25 
27 
29 
30  public static readonly PackageVersion LatestPackageVersion = new PackageVersion(ParadoxVersion.CurrentAsText);
31 
33  {
34  return new PackageDependency("Paradox", new PackageVersionRange()
35  {
36  MinVersion = LatestPackageVersion,
37  IsMinInclusive = true
38  });
39  }
40 
41  /// <summary>
42  /// Registers the solution platforms supported by Paradox.
43  /// </summary>
44  internal static void RegisterSolutionPlatforms()
45  {
46  var solutionPlatforms = new List<SolutionPlatform>();
47 
48  // Windows
49  var windowsPlatform = new SolutionPlatform()
50  {
51  Name = PlatformType.Windows.ToString(),
52  IsAvailable = true,
53  Alias = "Any CPU",
54  Type = PlatformType.Windows
55  };
56  windowsPlatform.PlatformsPart.Add(new SolutionPlatformPart("Any CPU") { InheritConfigurations = true });
57  windowsPlatform.PlatformsPart.Add(new SolutionPlatformPart("Mixed Platforms") { Alias = "Any CPU"});
58  windowsPlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_WINDOWS");
59  windowsPlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP");
60  windowsPlatform.Properties[GraphicsPlatform] = Graphics.GraphicsPlatform.Direct3D11;
61  windowsPlatform.Properties[GraphicsProfile] = Graphics.GraphicsProfile.Level_9_1;
62  windowsPlatform.Configurations.Add(new SolutionConfiguration("Testing"));
63  windowsPlatform.Configurations.Add(new SolutionConfiguration("AppStore"));
64 
65  foreach (var part in windowsPlatform.PlatformsPart)
66  {
67  part.Configurations.Clear();
68  part.Configurations.AddRange(windowsPlatform.Configurations);
69  }
70  solutionPlatforms.Add(windowsPlatform);
71 
72  var parts = windowsPlatform.GetParts();
73 
74  // Windows Store
75  var windowsStorePlatform = new SolutionPlatform()
76  {
77  Name = PlatformType.WindowsStore.ToString(),
78  DisplayName = "Windows Store",
79  Type = PlatformType.WindowsStore,
80  IsAvailable = IsFileInProgramFilesx86Exist(WindowsRuntimeBuild),
81  UseWithExecutables = false,
82  IncludeInSolution = false,
83  };
84 
85  windowsStorePlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_WINDOWS");
86  windowsStorePlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME");
87  windowsStorePlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_WINDOWS_STORE");
88  windowsStorePlatform.Properties[GraphicsPlatform] = Graphics.GraphicsPlatform.Direct3D11;
89  windowsStorePlatform.Properties[GraphicsProfile] = Graphics.GraphicsProfile.Level_9_1;
90  windowsStorePlatform.Configurations.Add(new SolutionConfiguration("Testing"));
91  windowsStorePlatform.Configurations.Add(new SolutionConfiguration("AppStore"));
92  windowsStorePlatform.Configurations["Release"].Properties.Add("<NoWarn>;2008</NoWarn>");
93  windowsStorePlatform.Configurations["Debug"].Properties.Add("<NoWarn>;2008</NoWarn>");
94  windowsStorePlatform.Configurations["Testing"].Properties.Add("<NoWarn>;2008</NoWarn>");
95  windowsStorePlatform.Configurations["AppStore"].Properties.Add("<NoWarn>;2008</NoWarn>");
96 
97  var windowsStorePlatformx86 = new SolutionPlatformPart(windowsStorePlatform.Name + "-x86")
98  {
99  LibraryProjectName = windowsStorePlatform.Name,
100  ExecutableProjectName = "x86",
101  Cpu = "x86",
102  InheritConfigurations = true,
103  UseWithLibraries = false,
104  UseWithExecutables = true,
105  };
106  windowsStorePlatformx86.Configurations.Clear();
107  windowsStorePlatformx86.Configurations.AddRange(windowsStorePlatform.Configurations);
108 
109  var windowsStorePlatformx64 = new SolutionPlatformPart(windowsStorePlatform.Name + "-x64")
110  {
111  LibraryProjectName = windowsStorePlatform.Name,
112  ExecutableProjectName = "x64",
113  Cpu = "x64",
114  InheritConfigurations = true,
115  UseWithLibraries = false,
116  UseWithExecutables = true
117  };
118  windowsStorePlatformx64.Configurations.Clear();
119  windowsStorePlatformx64.Configurations.AddRange(windowsStorePlatform.Configurations);
120 
121  var windowsStorePlatformARM = new SolutionPlatformPart(windowsStorePlatform.Name + "-ARM")
122  {
123  LibraryProjectName = windowsStorePlatform.Name,
124  ExecutableProjectName = "ARM",
125  Cpu = "ARM",
126  InheritConfigurations = true,
127  UseWithLibraries = false,
128  UseWithExecutables = true
129  };
130  windowsStorePlatformARM.Configurations.Clear();
131  windowsStorePlatformARM.Configurations.AddRange(windowsStorePlatform.Configurations);
132 
133  windowsStorePlatform.PlatformsPart.Add(windowsStorePlatformx86);
134  windowsStorePlatform.PlatformsPart.Add(windowsStorePlatformx64);
135  windowsStorePlatform.PlatformsPart.Add(windowsStorePlatformARM);
136  solutionPlatforms.Add(windowsStorePlatform);
137 
138  // Windows Phone
139  var windowsPhonePlatform = new SolutionPlatform()
140  {
141  Name = PlatformType.WindowsPhone.ToString(),
142  DisplayName = "Windows Phone",
143  Type = PlatformType.WindowsPhone,
144  IsAvailable = IsFileInProgramFilesx86Exist(WindowsRuntimeBuild),
145  UseWithExecutables = false,
146  IncludeInSolution = false,
147  };
148 
149  windowsPhonePlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_WINDOWS");
150  windowsPhonePlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_WINDOWS_RUNTIME");
151  windowsPhonePlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_WINDOWS_PHONE");
152  windowsPhonePlatform.Properties[GraphicsPlatform] = Graphics.GraphicsPlatform.Direct3D11;
153  windowsPhonePlatform.Properties[GraphicsProfile] = Graphics.GraphicsProfile.Level_9_1;
154  windowsPhonePlatform.Configurations.Add(new SolutionConfiguration("Testing"));
155  windowsPhonePlatform.Configurations.Add(new SolutionConfiguration("AppStore"));
156 
157  windowsPhonePlatform.Configurations["Release"].Properties.Add("<NoWarn>;2008</NoWarn>");
158  windowsPhonePlatform.Configurations["Debug"].Properties.Add("<NoWarn>;2008</NoWarn>");
159  windowsPhonePlatform.Configurations["Testing"].Properties.Add("<NoWarn>;2008</NoWarn>");
160  windowsPhonePlatform.Configurations["AppStore"].Properties.Add("<NoWarn>;2008</NoWarn>");
161 
162  var windowsPhonePlatformx86 = new SolutionPlatformPart(windowsPhonePlatform.Name + "-x86")
163  {
164  LibraryProjectName = windowsPhonePlatform.Name,
165  ExecutableProjectName = "x86",
166  Cpu = "x86",
167  InheritConfigurations = true,
168  UseWithLibraries = false,
169  UseWithExecutables = true
170  };
171  windowsPhonePlatformx86.Configurations.Clear();
172  windowsPhonePlatformx86.Configurations.AddRange(windowsPhonePlatform.Configurations);
173 
174  var windowsPhonePlatformARM = new SolutionPlatformPart(windowsPhonePlatform.Name + "-ARM")
175  {
176  LibraryProjectName = windowsPhonePlatform.Name,
177  ExecutableProjectName = "ARM",
178  Cpu = "ARM",
179  InheritConfigurations = true,
180  UseWithLibraries = false,
181  UseWithExecutables = true
182  };
183  windowsPhonePlatformARM.Configurations.Clear();
184  windowsPhonePlatformARM.Configurations.AddRange(windowsPhonePlatform.Configurations);
185 
186  windowsPhonePlatform.PlatformsPart.Add(windowsPhonePlatformx86);
187  windowsPhonePlatform.PlatformsPart.Add(windowsPhonePlatformARM);
188  solutionPlatforms.Add(windowsPhonePlatform);
189 
190  // Android
191  var androidPlatform = new SolutionPlatform()
192  {
193  Name = PlatformType.Android.ToString(),
194  Type = PlatformType.Android,
195  IsAvailable = IsFileInProgramFilesx86Exist(XamarinAndroidBuild)
196  };
197  androidPlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_MONO");
198  androidPlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_MONO_MOBILE");
199  androidPlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_ANDROID");
200  androidPlatform.Properties[GraphicsPlatform] = Graphics.GraphicsPlatform.OpenGLES;
201  androidPlatform.Properties[GraphicsProfile] = Graphics.GraphicsProfile.Level_9_1;
202  androidPlatform.Configurations.Add(new SolutionConfiguration("Testing"));
203  androidPlatform.Configurations.Add(new SolutionConfiguration("AppStore"));
204  androidPlatform.Configurations["Debug"].Properties.AddRange(new[]
205  {
206  "<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>",
207  "<AndroidLinkMode>None</AndroidLinkMode>",
208  });
209  androidPlatform.Configurations["Release"].Properties.AddRange(new[]
210  {
211  "<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>",
212  "<AndroidLinkMode>SdkOnly</AndroidLinkMode>",
213  });
214  androidPlatform.Configurations["Testing"].Properties.AddRange(androidPlatform.Configurations["Release"].Properties);
215  androidPlatform.Configurations["AppStore"].Properties.AddRange(androidPlatform.Configurations["Release"].Properties);
216  solutionPlatforms.Add(androidPlatform);
217 
218  // iOS: iPhone
219  var iphonePlatform = new SolutionPlatform()
220  {
221  Name = PlatformType.iOS.ToString(),
222  SolutionName = "iPhone", // For iOS, we need to use iPhone as a solution name
223  Type = PlatformType.iOS,
224  IsAvailable = IsFileInProgramFilesx86Exist(XamariniOSBuild)
225  };
226  iphonePlatform.PlatformsPart.Add(new SolutionPlatformPart("iPhoneSimulator"));
227  iphonePlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_MONO");
228  iphonePlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_MONO_MOBILE");
229  iphonePlatform.DefineConstants.Add("SILICONSTUDIO_PLATFORM_IOS");
230  iphonePlatform.Properties[GraphicsPlatform] = Graphics.GraphicsPlatform.OpenGLES;
231  iphonePlatform.Properties[GraphicsProfile] = Graphics.GraphicsProfile.Level_9_1;
232  iphonePlatform.Configurations.Add(new SolutionConfiguration("Testing"));
233  iphonePlatform.Configurations.Add(new SolutionConfiguration("AppStore"));
234  var iPhoneCommonProperties = new List<string>()
235  {
236  "<ConsolePause>false</ConsolePause>",
237  "<MtouchUseSGen>True</MtouchUseSGen>",
238  };
239 
240  iphonePlatform.Configurations["Debug"].Properties.AddRange(iPhoneCommonProperties);
241  iphonePlatform.Configurations["Debug"].Properties.AddRange(new []
242  {
243  "<MtouchDebug>True</MtouchDebug>",
244  "<CodesignKey>iPhone Developer</CodesignKey>",
245  "<MtouchUseSGen>True</MtouchUseSGen>",
246  });
247  iphonePlatform.Configurations["Release"].Properties.AddRange(iPhoneCommonProperties);
248  iphonePlatform.Configurations["Release"].Properties.AddRange(new[]
249  {
250  "<CodesignKey>iPhone Developer</CodesignKey>",
251  });
252  iphonePlatform.Configurations["Testing"].Properties.AddRange(iPhoneCommonProperties);
253  iphonePlatform.Configurations["Testing"].Properties.AddRange(new[]
254  {
255  "<MtouchDebug>True</MtouchDebug>",
256  "<CodesignKey>iPhone Distribution</CodesignKey>",
257  "<BuildIpa>True</BuildIpa>",
258  });
259  iphonePlatform.Configurations["AppStore"].Properties.AddRange(iPhoneCommonProperties);
260  iphonePlatform.Configurations["AppStore"].Properties.AddRange(new[]
261  {
262  "<CodesignKey>iPhone Distribution</CodesignKey>",
263  });
264  solutionPlatforms.Add(iphonePlatform);
265 
266  // iOS: iPhoneSimulator
267  var iPhoneSimulatorPlatform = iphonePlatform.PlatformsPart["iPhoneSimulator"];
268  iPhoneSimulatorPlatform.Configurations["Debug"].Properties.AddRange(new[]
269  {
270  "<MtouchLink>None</MtouchLink>"
271  });
272  iPhoneSimulatorPlatform.Configurations["Release"].Properties.AddRange(new[]
273  {
274  "<MtouchLink>None</MtouchLink>"
275  });
276 
277  AssetRegistry.RegisterSupportedPlatforms(solutionPlatforms);
278  }
279 
280  internal static bool IsFileInProgramFilesx86Exist(string path)
281  {
282  return (ProgramFilesX86 != null && File.Exists(Path.Combine(ProgramFilesX86, path)));
283  }
284  }
285 }
Defines a solution platform.
PlatformType
Describes the platform operating system.
Definition: PlatformType.cs:9
Class SolutionAlternativePlatform.
GraphicsPlatform
The graphics platform.
DisplayOrientation
Describes the orientation of the display.
TextureQuality
The desired texture quality.
System.IO.File File
A solution configuration used by SolutionPlatform
A reference to a package either internal (directly to a Package inside the same solution) or external...
static PackageDependency GetLatestPackageDependency()
A class that represents a tag propety.
Definition: PropertyKey.cs:17
A hybrid implementation of SemVer that supports semantic versioning as described at http://semver...
GraphicsProfile
Identifies the set of supported devices for the demo based on device capabilities.
A dependency to a range of version.