Beispiel #1
0
	private static void write_section(config_pcl cfg, XmlWriter f, bool debug, List<string> defines)
	{
		string name = debug ? "debug" : "release";
		f.WriteStartElement("PropertyGroup");
		f.WriteAttributeString("Condition", string.Format(" '$(Configuration)|$(Platform)' == '{0}|{1}' ", name, cfg.cpu));

		f.WriteElementString("OutputPath", string.Format("{0}\\bin\\{1}\\", name, cfg.get_dest_subpath()));
		f.WriteElementString("IntermediateOutputPath", string.Format("{0}\\obj\\{1}\\", name, cfg.get_dest_subpath()));

		string defs;
		if (debug)
		{
			defs = "DEBUG;";
		}
		else
		{
			defs = "";
		}
		foreach (string d in defines)
		{
			defs += d;
			defs += ";";
		}
		f.WriteElementString("DefineConstants", defs);

		f.WriteElementString("DebugSymbols", debug ? "true" : "false");
		f.WriteElementString("Optimize", debug ? "false" : "true");
		f.WriteElementString("DebugType", debug ? "full" : "pdbonly");

		f.WriteEndElement(); // PropertyGroup
	}
Beispiel #2
0
	private static void write_nuspec_file_entry(config_pcl cfg, XmlWriter f, string where)
	{
		f.WriteComment(string.Format("{0}", cfg.get_name()));
		var a = new List<string>();
		cfg.get_products(a);

		foreach (string s in a)
		{
			f.WriteStartElement("file");
			f.WriteAttributeString("src", string.Format("release\\bin\\{0}", s));
			f.WriteAttributeString("target", cfg.get_nuget_target_path(where));
			f.WriteEndElement(); // file
		}
	}
Beispiel #3
0
	private static void gen_pcl(config_pcl cfg, string root, string top)
	{
		XmlWriterSettings settings = new XmlWriterSettings();
		settings.Indent = true;
		settings.OmitXmlDeclaration = false;

		using (XmlWriter f = XmlWriter.Create(Path.Combine(top, cfg.get_project_filename()), settings))
		{
			f.WriteStartDocument();
			f.WriteComment("Automatically generated");

			f.WriteStartElement("Project", "http://schemas.microsoft.com/developer/msbuild/2003");
			switch (cfg.env)
			{
				case "winrt81":
				case "wp81_rt":
				case "wp81_sl":
					f.WriteAttributeString("ToolsVersion", "12.0");
					break;
				default:
					f.WriteAttributeString("ToolsVersion", "4.0");
					break;
			}
			f.WriteAttributeString("DefaultTargets", "Build");

			switch (cfg.env)
			{
				case "wp81_sl":
					break;
				default:
					// TODO is this actually needed?
					f.WriteStartElement("Import");
					f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props");
					f.WriteAttributeString("Condition", "Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')");
					f.WriteEndElement(); // Import
					break;
			}

			f.WriteStartElement("PropertyGroup");

			f.WriteElementString("ProjectGuid", cfg.guid);
			if (cfg.is_portable())
			{
				write_project_type_guids(f, GUID_PCL, GUID_CSHARP);
			}
			else
			{
				switch (cfg.env)
				{
					case "ios":
						write_project_type_guids(f, GUID_IOS, GUID_CSHARP);
						break;
					case "unified_ios":
						write_project_type_guids(f, GUID_UNIFIED_IOS, GUID_CSHARP);
						break;
					case "unified_mac":
						write_project_type_guids(f, GUID_UNIFIED_MAC, GUID_CSHARP);
						break;
					case "android":
						write_project_type_guids(f, GUID_ANDROID, GUID_CSHARP);
						break;
					case "winrt80":
					case "winrt81":
						write_project_type_guids(f, GUID_WINRT, GUID_CSHARP);
						break;
					case "wp80":
						write_project_type_guids(f, GUID_WP8, GUID_CSHARP);
						break;
					case "wp81_rt":
						write_project_type_guids(f, GUID_WP81RT, GUID_CSHARP);
						break;
					case "wp81_sl":
						write_project_type_guids(f, GUID_WP8, GUID_CSHARP);
						break;
				}
			}

			f.WriteStartElement("Configuration");
			f.WriteAttributeString("Condition", " '$(Configuration)' == '' ");

			f.WriteString("Debug");

			f.WriteEndElement(); // Configuration

			if (cfg.env == "unified_mac") {
				f.WriteElementString ("TargetFrameworkVersion", "v2.0");
				f.WriteElementString ("TargetFrameworkIdentifier", "Xamarin.Mac");
			}

			f.WriteElementString("SchemaVersion", "2.0");
			f.WriteElementString("Platform", cfg.cpu.Replace(" ", ""));
			f.WriteElementString("DefaultLanguage", "en-us");
			//f.WriteElementString("FileAlignment", "512");
			f.WriteElementString("WarningLevel", "4");
			//f.WriteElementString("PlatformTarget", cfg.cpu.Replace(" ", ""));
			f.WriteElementString("OutputType", "Library");
			f.WriteElementString("RootNamespace", "SQLitePCL");
			f.WriteElementString("AssemblyName", "SQLitePCL.raw"); // match the name in get_products()

			List<string> defines = new List<string>();

			switch (cfg.env)
			{
				case "profile136":
				case "profile158":
					f.WriteElementString("TargetFrameworkVersion", "v4.0");
					break;
				case "profile111":
				case "profile78":
				case "profile259":
					f.WriteElementString("TargetFrameworkVersion", "v4.5");
					break;
				case "ios":
					defines.Add("PLATFORM_IOS");
					break;
				case "unified_ios":
				case "unified_mac":
					defines.Add("PLATFORM_UNIFIED");
					break;
				case "android":
					defines.Add("__MOBILE__");
					defines.Add("__ANDROID__");
					f.WriteElementString("AndroidUseLatestPlatformdk", "true");
					break;
				case "winrt80":
					//f.WriteElementString("TargetPlatformVersion", "8.0");
					f.WriteElementString("UseVSHostingProcess", "false");
					//f.WriteElementString("MinimumVisualStudioVersion", "11.0");
					// TargetFrameworkVersion?
					defines.Add("NETFX_CORE");
					break;
				case "winrt81":
					f.WriteElementString("TargetPlatformVersion", "8.1");
					f.WriteElementString("MinimumVisualStudioVersion", "12.0");
					f.WriteElementString("TargetFrameworkVersion", null);
					defines.Add("NETFX_CORE");
					break;
				case "net45":
					f.WriteElementString("ProductVersion", "12.0.0");
					f.WriteElementString("TargetFrameworkVersion", "v4.5");
					break;
				case "net40":
					f.WriteElementString("ProductVersion", "12.0.0");
					defines.Add("OLD_REFLECTION");
					f.WriteElementString("TargetFrameworkVersion", "v4.0");
					break;
				case "wp80":
					f.WriteElementString("TargetFrameworkIdentifier", "WindowsPhone");
					f.WriteElementString("TargetFrameworkVersion", "v8.0");
					f.WriteElementString("MinimumVisualStudioVersion", "11.0");
					f.WriteElementString("SilverlightVersion", "v8.0");
					f.WriteElementString("SilverlightApplication", "false");
					f.WriteElementString("ValidateXaml", "true");
					f.WriteElementString("ThrowErrorsInValidation", "true");
					defines.Add("WINDOWS_PHONE");
					defines.Add("SILVERLIGHT");
					defines.Add("NO_CONCURRENTDICTIONARY");
					f.WriteElementString("NoStdLib", "true");
					f.WriteElementString("NoConfig", "true");
					break;
				case "wp81_rt":
					f.WriteElementString("TargetPlatformVersion", "8.1");
					f.WriteElementString("MinimumVisualStudioVersion", "12.0");
					f.WriteElementString("UseVSHostingProcess", "false");
					defines.Add("NETFX_CORE");
					defines.Add("WINDOWS_PHONE_APP");
					break;
				case "wp81_sl":
					f.WriteElementString("TargetFrameworkIdentifier", "WindowsPhone");
					f.WriteElementString("TargetFrameworkVersion", "v8.1");
					f.WriteElementString("MinimumVisualStudioVersion", "12.0");
					f.WriteElementString("SilverlightVersion", "v8.1");
					f.WriteElementString("SilverlightApplication", "false");
					f.WriteElementString("ValidateXaml", "true");
					f.WriteElementString("ThrowErrorsInValidation", "true");
					defines.Add("WINDOWS_PHONE");
					defines.Add("SILVERLIGHT");
					defines.Add("NO_CONCURRENTDICTIONARY");
					f.WriteElementString("NoStdLib", "true");
					f.WriteElementString("NoConfig", "true");
					break;
			}

			if (cfg.is_pinvoke())
			{
				switch (cfg.what)
				{
					case "packaged_sqlite3":
						if (cfg.env == "android")
						{
							defines.Add("PINVOKE_FROM_PACKAGED_SQLITE3");
						}
                        else if (cfg.env == "net45")
						{
							defines.Add("PINVOKE_FROM_PACKAGED_SQLITE3");
						}
                        else if (cfg.env == "net40")
						{
							defines.Add("PINVOKE_FROM_PACKAGED_SQLITE3");
						}
						else if (cfg.env == "unified_ios")
						{
							defines.Add("PINVOKE_FROM_INTERNAL_SQLITE3");
						}
						else if (cfg.env == "unified_mac")
						{
							defines.Add("PINVOKE_FROM_INTERNAL_SQLITE3");
						}
						else if (cfg.env == "ios")
						{
							defines.Add("PINVOKE_FROM_INTERNAL_SQLITE3");
						}
						break;
					case "packaged_sqlcipher":
						if (cfg.env == "android")
						{
							defines.Add("PINVOKE_FROM_PACKAGED_SQLCIPHER");
						}
                        else if (cfg.env == "net45")
						{
							defines.Add("PINVOKE_FROM_PACKAGED_SQLCIPHER");
						}
                        else if (cfg.env == "net40")
						{
							defines.Add("PINVOKE_FROM_PACKAGED_SQLCIPHER");
						}
						else if (cfg.env == "unified_ios")
						{
							defines.Add("PINVOKE_FROM_INTERNAL_SQLCIPHER");
						}
						else if (cfg.env == "unified_mac")
						{
							defines.Add("PINVOKE_FROM_INTERNAL_SQLCIPHER");
						}
						else if (cfg.env == "ios")
						{
							defines.Add("PINVOKE_FROM_INTERNAL_SQLCIPHER");
						}
						break;
					case "sqlite3":
					default:
						if (cfg.cpu == "anycpu") {
							switch (cfg.env)
							{
#if not
// TODO I wish these would work.  They don't.  We can't build
// sqlite3.dll without a dependency on the VC++ runtime, which
// for RT platforms is only available as an extenson SDK, which
// refuses to build with AnyCPU.
								case "winrt80":
								case "winrt81":
									defines.Add("PINVOKE_ANYCPU_WINRT");
									break;
								case "wp81_rt":
									defines.Add("PINVOKE_ANYCPU_WP8");
									break;
#endif
								case "net45":
									defines.Add("PINVOKE_ANYCPU_NET45");
									break;
								case "net40":
									defines.Add("PINVOKE_ANYCPU_NET45"); // okay for net40
									break;
								default:
                                                                        // TODO are there any situations where this will work? 
									defines.Add("PINVOKE_FROM_SQLITE3");
									break;
							}
						}
						else {
							defines.Add("PINVOKE_FROM_SQLITE3");
						}
						break;
				}
			}

			if (cfg.is_portable())
			{
				f.WriteElementString("TargetFrameworkProfile", cfg.env);
			}

			f.WriteEndElement(); // PropertyGroup

			write_section(cfg, f, true, defines);
			write_section(cfg, f, false, defines);

			f.WriteStartElement("ItemGroup");
			switch (cfg.env)
			{
				case "ios":
				case "unified_ios":
				case "unified_mac":
				case "android":
				case "net45":
				case "net40":
					write_reference(f, "System");
					write_reference(f, "System.Core");
					break;
			}
			switch (cfg.env)
			{
				case "unified_ios":
					write_reference(f, "Xamarin.iOS");
					break;
				case "unified_mac":
					write_reference(f, "Xamarin.Mac");
					break;
				case "ios":
					write_reference(f, "monotouch");
					break;
				case "android":
					write_reference(f, "Mono.Android");
					break;
			}
			f.WriteEndElement(); // ItemGroup

			f.WriteStartElement("ItemGroup");
			write_cs_compile(f, root, "src\\cs\\AssemblyInfo.cs");
			write_cs_compile(f, root, "src\\cs\\raw.cs");
			write_cs_compile(f, root, "src\\cs\\intptrs.cs");
			write_cs_compile(f, root, "src\\cs\\isqlite3.cs");
			f.WriteEndElement(); // ItemGroup

			if (cfg.is_portable())
			{
				f.WriteStartElement("ItemGroup");
				write_cs_compile(f, root, "src\\cs\\sqlite3_bait.cs");
				f.WriteEndElement(); // ItemGroup
			}
			else if (cfg.is_cppinterop())
			{
				f.WriteStartElement("ItemGroup");
				write_cs_compile(f, root, "src\\cs\\sqlite3_cppinterop.cs");
				write_cs_compile(f, root, "src\\cs\\util.cs");
				f.WriteEndElement(); // ItemGroup
			}
			else if (cfg.is_pinvoke())
			{
				f.WriteStartElement("ItemGroup");
				write_cs_compile(f, root, "src\\cs\\sqlite3_pinvoke.cs");
				write_cs_compile(f, root, "src\\cs\\util.cs");
				f.WriteEndElement(); // ItemGroup
			}

			if (cfg.is_cppinterop())
			{
				f.WriteStartElement("ItemGroup");
				f.WriteStartElement("ProjectReference");
				{
					config_cppinterop other = cfg.get_cppinterop_item();
					f.WriteAttributeString("Include", other.get_project_filename());
					f.WriteElementString("Project", other.guid);
					f.WriteElementString("Name", other.get_name());
					//f.WriteElementString("Private", "true");
				}
				f.WriteEndElement(); // ProjectReference
				f.WriteEndElement(); // ItemGroup
			}

			if (cfg.is_portable())
			{
				f.WriteStartElement("Import");
				f.WriteAttributeString("Project", "$(MSBuildExtensionsPath32)\\Microsoft\\Portable\\$(TargetFrameworkVersion)\\Microsoft.Portable.CSharp.targets");
				f.WriteEndElement(); // Import
			}
			else
			{
				switch (cfg.env)
				{
					case "winrt80":
						f.WriteStartElement("PropertyGroup");
						f.WriteAttributeString("Condition", " '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0' ");
						f.WriteElementString("VisualStudioVersion", "11.0");
						f.WriteEndElement(); // PropertyGroup
						break;
					case "winrt81":
						f.WriteStartElement("PropertyGroup");
						f.WriteAttributeString("Condition", " '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ");
						f.WriteElementString("VisualStudioVersion", "12.0");
						f.WriteEndElement(); // PropertyGroup
						break;
					case "wp81_rt":
						f.WriteStartElement("PropertyGroup");
						f.WriteAttributeString("Condition", " '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ");
						f.WriteElementString("VisualStudioVersion", "12.0");
						f.WriteEndElement(); // PropertyGroup

						f.WriteStartElement("PropertyGroup");
						f.WriteAttributeString("Condition", " '$(TargetPlatformIdentifier)' == '' ");
						f.WriteElementString("TargetPlatformIdentifier", "WindowsPhoneApp");
						f.WriteEndElement(); // PropertyGroup
						break;
					case "wp81_sl":
						break;
				}

				switch (cfg.env)
				{
					case "unified_ios":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.iOS.CSharp.targets");
						f.WriteEndElement(); // Import

                        if (cfg.what == "packaged_sqlite3")
                        {
                            f.WriteStartElement("ItemGroup");
                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\packaged_sqlite3.a"));
                            f.WriteElementString("Link", "packaged_sqlite3.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture
                            f.WriteEndElement(); // ItemGroup
                        }
                        if (cfg.what == "packaged_sqlcipher")
                        {
                            f.WriteStartElement("ItemGroup");

                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\packaged_sqlcipher.a"));
                            f.WriteElementString("Link", "packaged_sqlcipher.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture

                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\libcrypto.a"));
                            f.WriteElementString("Link", "libcrypto.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture

                            f.WriteEndElement(); // ItemGroup
                        }
						break;
					case "unified_mac":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Xamarin\\Mac\\Xamarin.Mac.CSharp.targets");
						f.WriteEndElement(); // Import

						if (cfg.what == "packaged_sqlite3")
						{
							f.WriteStartElement("ItemGroup");
							// TODO warning says this is deprecated
							f.WriteStartElement("ManifestResourceWithNoCulture");
							f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\mac\\packaged_sqlite3.a"));
							f.WriteElementString("Link", "packaged_sqlite3.a");
							f.WriteEndElement(); // ManifestResourceWithNoCulture
							f.WriteEndElement(); // ItemGroup
						}
						if (cfg.what == "packaged_sqlcipher")
						{
							f.WriteStartElement("ItemGroup");

							// TODO warning says this is deprecated
							f.WriteStartElement("ManifestResourceWithNoCulture");
							f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\mac\\packaged_sqlcipher.a"));
							f.WriteElementString("Link", "packaged_sqlcipher.a");
							f.WriteEndElement(); // ManifestResourceWithNoCulture

							// TODO warning says this is deprecated
							f.WriteStartElement("ManifestResourceWithNoCulture");
							f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\mac\\libcrypto.a"));
							f.WriteElementString("Link", "libcrypto.a");
							f.WriteEndElement(); // ManifestResourceWithNoCulture

							f.WriteEndElement(); // ItemGroup
						}
						break;
					case "ios":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.MonoTouch.CSharp.targets");
						f.WriteEndElement(); // Import

                        if (cfg.what == "packaged_sqlite3")
                        {
                            f.WriteStartElement("ItemGroup");
                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\packaged_sqlite3.a"));
                            f.WriteElementString("Link", "packaged_sqlite3.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture
                            f.WriteEndElement(); // ItemGroup
                        }
                        if (cfg.what == "packaged_sqlcipher")
                        {
                            f.WriteStartElement("ItemGroup");

                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\packaged_sqlcipher.a"));
                            f.WriteElementString("Link", "packaged_sqlcipher.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture

                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\libcrypto.a"));
                            f.WriteElementString("Link", "libcrypto.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture

                            f.WriteEndElement(); // ItemGroup
                        }
						break;
					case "android":
						if (cfg.what == "packaged_sqlite3")
						{
                            f.WriteStartElement("ItemGroup");
                            write_android_native_libs(root, f, "sqlite3");
                            f.WriteEndElement(); // ItemGroup
						}

						if (cfg.what == "packaged_sqlcipher")
						{
                            f.WriteStartElement("ItemGroup");
                            write_android_native_libs(root, f, "sqlcipher");
                            f.WriteEndElement(); // ItemGroup
                        }

						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Novell\\Novell.MonoDroid.CSharp.targets");
						f.WriteEndElement(); // Import

						break;
					case "winrt80":
					case "winrt81":
					case "wp81_rt":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Microsoft\\WindowsXaml\\v$(VisualStudioVersion)\\Microsoft.Windows.UI.Xaml.CSharp.targets");
						f.WriteEndElement(); // Import
						break;
					case "net40":
					case "net45":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildToolsPath)\\Microsoft.CSharp.targets");
						f.WriteEndElement(); // Import
						break;
					case "wp80":
					case "wp81_sl":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Microsoft\\$(TargetFrameworkIdentifier)\\$(TargetFrameworkVersion)\\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets");
						f.WriteEndElement(); // Import

						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Microsoft\\$(TargetFrameworkIdentifier)\\$(TargetFrameworkVersion)\\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets");
						f.WriteEndElement(); // Import
						break;
				}
			}

			f.WriteEndElement(); // Project

			f.WriteEndDocument();
		}
	}
Beispiel #4
0
	private static void gen_pcl(config_pcl cfg, string root, string top)
	{
		XmlWriterSettings settings = new XmlWriterSettings();
		settings.Indent = true;
		settings.OmitXmlDeclaration = false;

		using (XmlWriter f = XmlWriter.Create(Path.Combine(top, cfg.get_project_filename()), settings))
		{
			f.WriteStartDocument();
			f.WriteComment("Automatically generated");

			f.WriteStartElement("Project", "http://schemas.microsoft.com/developer/msbuild/2003");
			switch (cfg.env)
			{
				default:
					f.WriteAttributeString("ToolsVersion", ToolsVersion);
					break;
			}
			f.WriteAttributeString("DefaultTargets", "Build");

			switch (cfg.env)
			{
				case "wp81_sl":
					break;
				default:
					// TODO is this actually needed?
					f.WriteStartElement("Import");
					f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props");
					f.WriteAttributeString("Condition", "Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')");
					f.WriteEndElement(); // Import
					break;
			}

			f.WriteStartElement("PropertyGroup");

			f.WriteElementString("ProjectGuid", cfg.guid);
			if (cfg.is_portable())
			{
				write_project_type_guids(f, GUID_PCL, GUID_CSHARP);
			}
			else
			{
			}

			f.WriteStartElement("Configuration");
			f.WriteAttributeString("Condition", " '$(Configuration)' == '' ");

			f.WriteString("Debug");

			f.WriteEndElement(); // Configuration

			f.WriteElementString("SchemaVersion", "2.0");
			f.WriteElementString("Platform", cfg.cpu.Replace(" ", ""));
			f.WriteElementString("DefaultLanguage", "en-us");
			//f.WriteElementString("FileAlignment", "512");
			f.WriteElementString("WarningLevel", "4");
			//f.WriteElementString("PlatformTarget", cfg.cpu.Replace(" ", ""));
			f.WriteElementString("OutputType", "Library");
			f.WriteElementString("RootNamespace", "SQLitePCL");
			f.WriteElementString("AssemblyName", "SQLitePCL.raw"); // match the name in get_products()
			f.WriteElementString("SignAssembly", "True");
			f.WriteElementString("AssemblyOriginatorKeyFile", "../key.snk");

			List<string> defines = new List<string>();

			switch (cfg.env)
			{
				case "profile158":
					f.WriteElementString("TargetFrameworkVersion", "v4.0");
					break;
				case "profile111":
				case "profile78":
				case "profile259":
					f.WriteElementString("TargetFrameworkVersion", "v4.5");
					break;
				case "net45":
					f.WriteElementString("ProductVersion", "12.0.0");
					f.WriteElementString("TargetFrameworkVersion", "v4.5");
					break;
			}

			if (cfg.is_pinvoke())
			{
				switch (cfg.what)
				{
					case "packaged_sqlite3":
						if (cfg.env == "android")
						{
							defines.Add("PINVOKE_FROM_PACKAGED_SQLITE3");
						}
                        else if (cfg.env == "net45")
						{
							defines.Add("PINVOKE_FROM_PACKAGED_SQLITE3");
						}
						else if (cfg.env == "unified")
						{
							defines.Add("PINVOKE_FROM_INTERNAL_SQLITE3");
						}
						else if (cfg.env == "ios")
						{
							defines.Add("PINVOKE_FROM_INTERNAL_SQLITE3");
						}
						break;
					case "packaged_sqlcipher":
						if (cfg.env == "android")
						{
							defines.Add("PINVOKE_FROM_PACKAGED_SQLCIPHER");
						}
                        else if (cfg.env == "net45")
						{
							defines.Add("PINVOKE_FROM_PACKAGED_SQLCIPHER");
						}
						else if (cfg.env == "unified")
						{
							defines.Add("PINVOKE_FROM_INTERNAL_SQLCIPHER");
						}
						else if (cfg.env == "ios")
						{
							defines.Add("PINVOKE_FROM_INTERNAL_SQLCIPHER");
						}
						break;
					case "sqlite3":
					default:
						if (cfg.cpu == "anycpu") {
							switch (cfg.env)
							{
#if not
// TODO I wish these would work.  They don't.  We can't build
// sqlite3.dll without a dependency on the VC++ runtime, which
// for RT platforms is only available as an extenson SDK, which
// refuses to build with AnyCPU.
								case "winrt80":
								case "winrt81":
									defines.Add("PINVOKE_ANYCPU_WINRT");
									break;
								case "wp81_rt":
									defines.Add("PINVOKE_ANYCPU_WP8");
									break;
#endif
								case "net45":
									defines.Add("PINVOKE_ANYCPU_NET45");
									break;
								default:
                                                                        // TODO are there any situations where this will work? 
									defines.Add("PINVOKE_FROM_SQLITE3");
									break;
							}
						}
						else {
							defines.Add("PINVOKE_FROM_SQLITE3");
						}
						break;
				}
			}

			if (cfg.is_portable())
			{
				f.WriteElementString("TargetFrameworkProfile", cfg.env);
			}

			f.WriteEndElement(); // PropertyGroup

			write_section(cfg, f, true, defines);
			write_section(cfg, f, false, defines);

			f.WriteStartElement("ItemGroup");
			switch (cfg.env)
			{
				case "ios":
				case "unified":
				case "android":
				case "net45":
					write_reference(f, "System");
					write_reference(f, "System.Core");
					break;
			}
			switch (cfg.env)
			{
				case "unified":
					write_reference(f, "Xamarin.iOS");
					break;
				case "ios":
					write_reference(f, "monotouch");
					break;
				case "android":
					write_reference(f, "Mono.Android");
					break;
			}
			f.WriteEndElement(); // ItemGroup

			f.WriteStartElement("ItemGroup");
			write_cs_compile(f, root, "src\\cs\\AssemblyInfo.cs");
			write_cs_compile(f, root, "src\\cs\\raw.cs");
			write_cs_compile(f, root, "src\\cs\\intptrs.cs");
			write_cs_compile(f, root, "src\\cs\\isqlite3.cs");
			f.WriteEndElement(); // ItemGroup

			if (cfg.is_portable())
			{
				f.WriteStartElement("ItemGroup");
				write_cs_compile(f, root, "src\\cs\\sqlite3_bait.cs");
				f.WriteEndElement(); // ItemGroup
			}
			else if (cfg.is_cppinterop())
			{
				f.WriteStartElement("ItemGroup");
				write_cs_compile(f, root, "src\\cs\\sqlite3_cppinterop.cs");
				write_cs_compile(f, root, "src\\cs\\util.cs");
				f.WriteEndElement(); // ItemGroup
			}
			else if (cfg.is_pinvoke())
			{
				f.WriteStartElement("ItemGroup");
				write_cs_compile(f, root, "src\\cs\\sqlite3_pinvoke.cs");
				write_cs_compile(f, root, "src\\cs\\util.cs");
				f.WriteEndElement(); // ItemGroup
			}

			if (cfg.is_cppinterop())
			{
				f.WriteStartElement("ItemGroup");
				f.WriteStartElement("ProjectReference");
				{
					config_cppinterop other = cfg.get_cppinterop_item();
					f.WriteAttributeString("Include", other.get_project_filename());
					f.WriteElementString("Project", other.guid);
					f.WriteElementString("Name", other.get_name());
					//f.WriteElementString("Private", "true");
				}
				f.WriteEndElement(); // ProjectReference
				f.WriteEndElement(); // ItemGroup
			}

			if (cfg.is_portable())
			{
				f.WriteStartElement("Import");
				f.WriteAttributeString("Project", "$(MSBuildExtensionsPath32)\\Microsoft\\Portable\\$(TargetFrameworkVersion)\\Microsoft.Portable.CSharp.targets");
				f.WriteEndElement(); // Import
			}
			else
			{
				switch (cfg.env)
				{
				}

				switch (cfg.env)
				{
					case "unified":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.iOS.CSharp.targets");
						f.WriteEndElement(); // Import

                        if (cfg.what == "packaged_sqlite3")
                        {
                            f.WriteStartElement("ItemGroup");
                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\packaged_sqlite3.a"));
                            f.WriteElementString("Link", "packaged_sqlite3.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture
                            f.WriteEndElement(); // ItemGroup
                        }
                        if (cfg.what == "packaged_sqlcipher")
                        {
                            f.WriteStartElement("ItemGroup");

                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\packaged_sqlcipher.a"));
                            f.WriteElementString("Link", "packaged_sqlcipher.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture

                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\libcrypto.a"));
                            f.WriteElementString("Link", "libcrypto.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture

                            f.WriteEndElement(); // ItemGroup
                        }
						break;
					case "ios":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.MonoTouch.CSharp.targets");
						f.WriteEndElement(); // Import

                        if (cfg.what == "packaged_sqlite3")
                        {
                            f.WriteStartElement("ItemGroup");
                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\packaged_sqlite3.a"));
                            f.WriteElementString("Link", "packaged_sqlite3.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture
                            f.WriteEndElement(); // ItemGroup
                        }
                        if (cfg.what == "packaged_sqlcipher")
                        {
                            f.WriteStartElement("ItemGroup");

                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\packaged_sqlcipher.a"));
                            f.WriteElementString("Link", "packaged_sqlcipher.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture

                            // TODO warning says this is deprecated
                            f.WriteStartElement("ManifestResourceWithNoCulture");
                            f.WriteAttributeString("Include", Path.Combine(root, "apple\\libs\\ios\\libcrypto.a"));
                            f.WriteElementString("Link", "libcrypto.a");
                            f.WriteEndElement(); // ManifestResourceWithNoCulture

                            f.WriteEndElement(); // ItemGroup
                        }
						break;
					case "android":
						if (cfg.what == "packaged_sqlite3")
						{
                            f.WriteStartElement("ItemGroup");
                            write_android_native_libs(root, f, "sqlite3");
                            f.WriteEndElement(); // ItemGroup
						}

						if (cfg.what == "packaged_sqlcipher")
						{
                            f.WriteStartElement("ItemGroup");
                            write_android_native_libs(root, f, "sqlcipher");
                            f.WriteEndElement(); // ItemGroup
                        }

						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Novell\\Novell.MonoDroid.CSharp.targets");
						f.WriteEndElement(); // Import

						break;
					case "net45":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildToolsPath)\\Microsoft.CSharp.targets");
						f.WriteEndElement(); // Import
						break;
				}
			}

			f.WriteEndElement(); // Project

			f.WriteEndDocument();
		}
	}
Beispiel #5
0
	private static void gen_pcl(config_pcl cfg, string root, string top)
	{
		XmlWriterSettings settings = new XmlWriterSettings();
		settings.Indent = true;
		settings.OmitXmlDeclaration = false;

		using (XmlWriter f = XmlWriter.Create(Path.Combine(top, cfg.get_project_filename()), settings))
		{
			f.WriteStartDocument();
			f.WriteComment("Automatically generated");

			f.WriteStartElement("Project", "http://schemas.microsoft.com/developer/msbuild/2003");
			switch (cfg.env)
			{
				case "winrt81":
				case "wp81_rt":
				case "wp81_sl":
					f.WriteAttributeString("ToolsVersion", "12.0");
					break;
				default:
					f.WriteAttributeString("ToolsVersion", "4.0");
					break;
			}
			f.WriteAttributeString("DefaultTargets", "Build");

			switch (cfg.env)
			{
				case "wp81_sl":
					break;
				default:
					// TODO is this actually needed?
					f.WriteStartElement("Import");
					f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props");
					f.WriteAttributeString("Condition", "Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')");
					f.WriteEndElement(); // Import
					break;
			}

			f.WriteStartElement("PropertyGroup");

			f.WriteElementString("ProjectGuid", cfg.guid);
			if (cfg.is_portable())
			{
				write_project_type_guids(f, GUID_PCL, GUID_CSHARP);
			}
			else
			{
				switch (cfg.env)
				{
					case "ios":
						write_project_type_guids(f, GUID_IOS, GUID_CSHARP);
						break;
					case "android":
						write_project_type_guids(f, GUID_ANDROID, GUID_CSHARP);
						break;
					case "winrt80":
					case "winrt81":
						write_project_type_guids(f, GUID_WINRT, GUID_CSHARP);
						break;
					case "wp80":
						write_project_type_guids(f, GUID_WP8, GUID_CSHARP);
						break;
					case "wp81_rt":
						write_project_type_guids(f, GUID_WP81RT, GUID_CSHARP);
						break;
					case "wp81_sl":
						write_project_type_guids(f, GUID_WP8, GUID_CSHARP);
						break;
				}
			}

			f.WriteStartElement("Configuration");
			f.WriteAttributeString("Condition", " '$(Configuration)' == '' ");

			f.WriteString("Debug");

			f.WriteEndElement(); // Configuration

			f.WriteElementString("SchemaVersion", "2.0");
			f.WriteElementString("Platform", cfg.cpu.Replace(" ", ""));
			f.WriteElementString("DefaultLanguage", "en-us");
			//f.WriteElementString("FileAlignment", "512");
			f.WriteElementString("WarningLevel", "4");
			//f.WriteElementString("PlatformTarget", cfg.cpu.Replace(" ", ""));
			f.WriteElementString("OutputType", "Library");
			f.WriteElementString("RootNamespace", "SQLitePCL");
			f.WriteElementString("AssemblyName", "SQLitePCL.raw"); // match the name in get_products()

			List<string> defines = new List<string>();

			switch (cfg.env)
			{
				case "profile158":
					f.WriteElementString("TargetFrameworkVersion", "v4.0");
					break;
				case "profile111":
				case "profile78":
				case "profile259":
					f.WriteElementString("TargetFrameworkVersion", "v4.5");
					break;
				case "ios":
					defines.Add("PLATFORM_IOS");
					break;
				case "android":
					defines.Add("__MOBILE__");
					defines.Add("__ANDROID__");
					f.WriteElementString("AndroidUseLatestPlatformdk", "true");
					break;
				case "winrt80":
					//f.WriteElementString("TargetPlatformVersion", "8.0");
					f.WriteElementString("UseVSHostingProcess", "false");
					//f.WriteElementString("MinimumVisualStudioVersion", "11.0");
					// TargetFrameworkVersion?
					defines.Add("NETFX_CORE");
					break;
				case "winrt81":
					f.WriteElementString("TargetPlatformVersion", "8.1");
					f.WriteElementString("MinimumVisualStudioVersion", "12.0");
					f.WriteElementString("TargetFrameworkVersion", null);
					defines.Add("NETFX_CORE");
					break;
				case "net45":
					f.WriteElementString("ProductVersion", "12.0.0");
					f.WriteElementString("TargetFrameworkVersion", "v4.5");
					break;
				case "wp80":
					f.WriteElementString("TargetFrameworkIdentifier", "WindowsPhone");
					f.WriteElementString("TargetFrameworkVersion", "v8.0");
					f.WriteElementString("MinimumVisualStudioVersion", "11.0");
					f.WriteElementString("SilverlightVersion", "v8.0");
					f.WriteElementString("SilverlightApplication", "false");
					f.WriteElementString("ValidateXaml", "true");
					f.WriteElementString("ThrowErrorsInValidation", "true");
					defines.Add("WINDOWS_PHONE");
					defines.Add("SILVERLIGHT");
					f.WriteElementString("NoStdLib", "true");
					f.WriteElementString("NoConfig", "true");
					break;
				case "wp81_rt":
					f.WriteElementString("TargetPlatformVersion", "8.1");
					f.WriteElementString("MinimumVisualStudioVersion", "12.0");
					f.WriteElementString("UseVSHostingProcess", "false");
					defines.Add("NETFX_CORE");
					defines.Add("WINDOWS_PHONE_APP");
					break;
				case "wp81_sl":
					f.WriteElementString("TargetFrameworkIdentifier", "WindowsPhone");
					f.WriteElementString("TargetFrameworkVersion", "v8.1");
					f.WriteElementString("MinimumVisualStudioVersion", "12.0");
					f.WriteElementString("SilverlightVersion", "v8.1");
					f.WriteElementString("SilverlightApplication", "false");
					f.WriteElementString("ValidateXaml", "true");
					f.WriteElementString("ThrowErrorsInValidation", "true");
					defines.Add("WINDOWS_PHONE");
					defines.Add("SILVERLIGHT");
					f.WriteElementString("NoStdLib", "true");
					f.WriteElementString("NoConfig", "true");
					break;
			}

			if (cfg.is_pinvoke())
			{
				switch (cfg.what)
				{
					case "internal_other":
						defines.Add("PINVOKE_FROM_INTERNAL");
						break;
					case "sqlite3":
					default:
						defines.Add("PINVOKE_FROM_SQLITE3");
						break;
				}
			}

			if (cfg.is_portable())
			{
				f.WriteElementString("TargetFrameworkProfile", cfg.env);
			}

			f.WriteEndElement(); // PropertyGroup

			write_section(cfg, f, true, defines);
			write_section(cfg, f, false, defines);

			f.WriteStartElement("ItemGroup");
			switch (cfg.env)
			{
				case "ios":
				case "android":
				case "net45":
					write_reference(f, "System");
					write_reference(f, "System.Core");
					break;
			}
			switch (cfg.env)
			{
				case "ios":
					write_reference(f, "monotouch");
					break;
				case "android":
					write_reference(f, "Mono.Android");
					break;
			}
			f.WriteEndElement(); // ItemGroup

			f.WriteStartElement("ItemGroup");
			write_cs_compile(f, root, "src\\cs\\AssemblyInfo.cs");
			write_cs_compile(f, root, "src\\cs\\raw.cs");
			write_cs_compile(f, root, "src\\cs\\intptrs.cs");
			write_cs_compile(f, root, "src\\cs\\isqlite3.cs");
			f.WriteEndElement(); // ItemGroup

			if (cfg.is_portable())
			{
				f.WriteStartElement("ItemGroup");
				write_cs_compile(f, root, "src\\cs\\sqlite3_bait.cs");
				f.WriteEndElement(); // ItemGroup
			}
			else if (cfg.is_cppinterop())
			{
				f.WriteStartElement("ItemGroup");
				write_cs_compile(f, root, "src\\cs\\sqlite3_cppinterop.cs");
				write_cs_compile(f, root, "src\\cs\\util.cs");
				f.WriteEndElement(); // ItemGroup
			}
			else if (cfg.is_pinvoke())
			{
				f.WriteStartElement("ItemGroup");
				write_cs_compile(f, root, "src\\cs\\sqlite3_pinvoke.cs");
				write_cs_compile(f, root, "src\\cs\\util.cs");
				f.WriteEndElement(); // ItemGroup
			}

			if (cfg.is_cppinterop())
			{
				f.WriteStartElement("ItemGroup");
				f.WriteStartElement("ProjectReference");
				{
					config_cppinterop other = cfg.get_cppinterop_item();
					f.WriteAttributeString("Include", other.get_project_filename());
					f.WriteElementString("Project", other.guid);
					f.WriteElementString("Name", other.get_name());
					//f.WriteElementString("Private", "true");
				}
				f.WriteEndElement(); // ProjectReference
				f.WriteEndElement(); // ItemGroup
			}

			if (cfg.is_portable())
			{
				f.WriteStartElement("Import");
				f.WriteAttributeString("Project", "$(MSBuildExtensionsPath32)\\Microsoft\\Portable\\$(TargetFrameworkVersion)\\Microsoft.Portable.CSharp.targets");
				f.WriteEndElement(); // Import
			}
			else
			{
				switch (cfg.env)
				{
					case "winrt80":
						f.WriteStartElement("PropertyGroup");
						f.WriteAttributeString("Condition", " '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0' ");
						f.WriteElementString("VisualStudioVersion", "11.0");
						f.WriteEndElement(); // PropertyGroup
						break;
					case "winrt81":
						f.WriteStartElement("PropertyGroup");
						f.WriteAttributeString("Condition", " '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ");
						f.WriteElementString("VisualStudioVersion", "12.0");
						f.WriteEndElement(); // PropertyGroup
						break;
					case "wp81_rt":
						f.WriteStartElement("PropertyGroup");
						f.WriteAttributeString("Condition", " '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ");
						f.WriteElementString("VisualStudioVersion", "12.0");
						f.WriteEndElement(); // PropertyGroup

						f.WriteStartElement("PropertyGroup");
						f.WriteAttributeString("Condition", " '$(TargetPlatformIdentifier)' == '' ");
						f.WriteElementString("TargetPlatformIdentifier", "WindowsPhoneApp");
						f.WriteEndElement(); // PropertyGroup
						break;
					case "wp81_sl":
						break;
				}

				switch (cfg.env)
				{
					case "ios":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Xamarin\\iOS\\Xamarin.MonoTouch.CSharp.targets");
						f.WriteEndElement(); // Import
						break;
					case "android":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Novell\\Novell.MonoDroid.CSharp.targets");
						f.WriteEndElement(); // Import
						break;
					case "winrt80":
					case "winrt81":
					case "wp81_rt":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Microsoft\\WindowsXaml\\v$(VisualStudioVersion)\\Microsoft.Windows.UI.Xaml.CSharp.targets");
						f.WriteEndElement(); // Import
						break;
					case "net45":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildToolsPath)\\Microsoft.CSharp.targets");
						f.WriteEndElement(); // Import
						break;
					case "wp80":
					case "wp81_sl":
						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Microsoft\\$(TargetFrameworkIdentifier)\\$(TargetFrameworkVersion)\\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets");
						f.WriteEndElement(); // Import

						f.WriteStartElement("Import");
						f.WriteAttributeString("Project", "$(MSBuildExtensionsPath)\\Microsoft\\$(TargetFrameworkIdentifier)\\$(TargetFrameworkVersion)\\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets");
						f.WriteEndElement(); // Import
						break;
				}
			}

			f.WriteEndElement(); // Project

			f.WriteEndDocument();
		}
	}