From 0b1f5e0537bde10f3f48cbf25965f736a18db720 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Wed, 7 Sep 2022 14:27:10 -0700 Subject: [PATCH] Add Wasm assets for .NET 7 Resolves dotnet/efcore#28999 --- gen_lib_nuspecs/Program.cs | 70 +++++++++++-------- .../SQLitePCLRaw.lib.e_sqlcipher.nuspec | 4 +- .../SQLitePCLRaw.lib.e_sqlcipher.targets | 7 ++ .../SQLitePCLRaw.lib.e_sqlite3.nuspec | 5 +- .../net7.0/SQLitePCLRaw.lib.e_sqlite3.targets | 7 ++ 5 files changed, 60 insertions(+), 33 deletions(-) create mode 100644 src/SQLitePCLRaw.lib.e_sqlcipher/net7.0/SQLitePCLRaw.lib.e_sqlcipher.targets create mode 100644 src/SQLitePCLRaw.lib.e_sqlite3/net7.0/SQLitePCLRaw.lib.e_sqlite3.targets diff --git a/gen_lib_nuspecs/Program.cs b/gen_lib_nuspecs/Program.cs index 7cbbce7e..0cdf284b 100644 --- a/gen_lib_nuspecs/Program.cs +++ b/gen_lib_nuspecs/Program.cs @@ -27,6 +27,7 @@ public enum TFM NETSTANDARD20, NET461, NET60, + NET70, MACCATALYST, XAMARINMAC20, } @@ -44,6 +45,7 @@ public static string AsString(this TFM e) case TFM.NETSTANDARD20: return "netstandard2.0"; case TFM.NET461: return "net461"; case TFM.NET60: return "net6.0"; + case TFM.NET70: return "net7.0"; case TFM.MACCATALYST: return "net6.0-maccatalyst15.2"; case TFM.XAMARINMAC20: return "xamarin.mac20"; default: @@ -246,12 +248,13 @@ string cpu } static string make_cb_path_wasm( - WhichLib lib + WhichLib lib, + TFM tfm ) { var dir_name = lib.AsString_basename_in_cb(); var lib_name = lib.AsString_libname_in_cb(LibSuffix.A); - return nuget_path_combine("$cb_bin_path$", dir_name, "wasm", lib_name); + return nuget_path_combine("$cb_bin_path$", dir_name, "wasm", tfm.AsString(), lib_name); } static string make_cb_path_mac( @@ -292,14 +295,15 @@ XmlWriter f static void write_nuspec_file_entry_native_wasm( WhichLib lib, + TFM tfm, XmlWriter f ) { var filename = lib.AsString_libname_in_nupkg(LibSuffix.A); write_nuspec_file_entry_nativeassets( - make_cb_path_wasm(lib), + make_cb_path_wasm(lib, tfm), "browser-wasm", - TFM.NET60, + tfm, filename, f ); @@ -415,7 +419,29 @@ XmlWriter f write_nuspec_file_entry_native_linux(lib, "mips64", "linux-mips64", f); write_nuspec_file_entry_native_linux(lib, "s390x", "linux-s390x", f); - write_nuspec_file_entry_native_wasm(lib, f); + write_nuspec_file_entry_native_wasm(lib, TFM.NET60, f); + write_nuspec_file_entry_native_wasm(lib, TFM.NET70, f); + } + + static void write_nuspec_wasm_targets_file_entry( + string dir_src, + string id, + WhichLib lib, + TFM tfm, + XmlWriter f + ) + { + var tname = string.Format("{0}.targets", id); + var dir_proj = Path.Combine(dir_src, id); + Directory.CreateDirectory(Path.Combine(dir_proj, tfm.AsString())); + var path_targets = Path.Combine(dir_proj, tfm.AsString(), tname); + var relpath_targets = nuget_path_combine(".", tfm.AsString(), tname); + gen_nuget_targets_wasm(path_targets, tfm, lib); + common.write_nuspec_file_entry( + relpath_targets, + string.Format("buildTransitive\\{0}", tfm.AsString()), + f + ); } private static void gen_nuspec_lib_e_sqlite3(string dir_src) @@ -469,18 +495,6 @@ private static void gen_nuspec_lib_e_sqlite3(string dir_src) f ); } - { - var tname = string.Format("{0}.targets", id); - Directory.CreateDirectory(Path.Combine(dir_proj, "net6.0")); - var path_targets = Path.Combine(dir_proj, "net6.0", tname); - var relpath_targets = nuget_path_combine(".", "net6.0", tname); - gen_nuget_targets_wasm(path_targets, WhichLib.E_SQLITE3); - common.write_nuspec_file_entry( - relpath_targets, - string.Format("buildTransitive\\{0}", TFM.NET60.AsString()), - f - ); - } #if not { var tname = string.Format("{0}.targets", id); @@ -510,6 +524,9 @@ private static void gen_nuspec_lib_e_sqlite3(string dir_src) } #endif + write_nuspec_wasm_targets_file_entry(dir_src, id, WhichLib.E_SQLITE3, TFM.NET60, f); + write_nuspec_wasm_targets_file_entry(dir_src, id, WhichLib.E_SQLITE3, TFM.NET70, f); + // TODO need a comment here to explain these common.write_empty(f, TFM.NET461); common.write_empty(f, TFM.NETSTANDARD20); @@ -565,18 +582,9 @@ private static void gen_nuspec_lib_e_sqlcipher(string dir_src) f ); } - { - var tname = string.Format("{0}.targets", id); - Directory.CreateDirectory(Path.Combine(dir_proj, "net6.0")); - var path_targets = Path.Combine(dir_proj, "net6.0", tname); - var relpath_targets = nuget_path_combine(".", "net6.0", tname); - gen_nuget_targets_wasm(path_targets, WhichLib.E_SQLCIPHER); - common.write_nuspec_file_entry( - relpath_targets, - string.Format("buildTransitive\\{0}", TFM.NET60.AsString()), - f - ); - } + + write_nuspec_wasm_targets_file_entry(dir_src, id, WhichLib.E_SQLCIPHER, TFM.NET60, f); + write_nuspec_wasm_targets_file_entry(dir_src, id, WhichLib.E_SQLCIPHER, TFM.NET70, f); // TODO need a comment here to explain these common.write_empty(f, TFM.NET461); @@ -784,7 +792,7 @@ private static void gen_nuget_targets_legacy_xamarin_mac(string dest, WhichLib l } #endif - private static void gen_nuget_targets_wasm(string dest, WhichLib lib) + private static void gen_nuget_targets_wasm(string dest, TFM tfm, WhichLib lib) { var settings = common.XmlWriterSettings_default(); settings.OmitXmlDeclaration = false; @@ -803,7 +811,7 @@ private static void gen_nuget_targets_wasm(string dest, WhichLib lib) var filename = lib.AsString_libname_in_nupkg(LibSuffix.A); f.WriteStartElement("NativeFileReference"); - f.WriteAttributeString("Include", string.Format("$(MSBuildThisFileDirectory)..\\..\\runtimes\\browser-wasm\\nativeassets\\net6.0\\{0}", filename)); + f.WriteAttributeString("Include", string.Format("$(MSBuildThisFileDirectory)..\\..\\runtimes\\browser-wasm\\nativeassets\\{0}\\{1}", tfm.AsString(), filename)); f.WriteEndElement(); // NativeFileReference f.WriteEndElement(); // ItemGroup diff --git a/src/SQLitePCLRaw.lib.e_sqlcipher/SQLitePCLRaw.lib.e_sqlcipher.nuspec b/src/SQLitePCLRaw.lib.e_sqlcipher/SQLitePCLRaw.lib.e_sqlcipher.nuspec index f74f8c6b..d35a2368 100644 --- a/src/SQLitePCLRaw.lib.e_sqlcipher/SQLitePCLRaw.lib.e_sqlcipher.nuspec +++ b/src/SQLitePCLRaw.lib.e_sqlcipher/SQLitePCLRaw.lib.e_sqlcipher.nuspec @@ -40,9 +40,11 @@ - + + + diff --git a/src/SQLitePCLRaw.lib.e_sqlcipher/net7.0/SQLitePCLRaw.lib.e_sqlcipher.targets b/src/SQLitePCLRaw.lib.e_sqlcipher/net7.0/SQLitePCLRaw.lib.e_sqlcipher.targets new file mode 100644 index 00000000..a965fe12 --- /dev/null +++ b/src/SQLitePCLRaw.lib.e_sqlcipher/net7.0/SQLitePCLRaw.lib.e_sqlcipher.targets @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/SQLitePCLRaw.lib.e_sqlite3/SQLitePCLRaw.lib.e_sqlite3.nuspec b/src/SQLitePCLRaw.lib.e_sqlite3/SQLitePCLRaw.lib.e_sqlite3.nuspec index 3915fd4e..163a4150 100644 --- a/src/SQLitePCLRaw.lib.e_sqlite3/SQLitePCLRaw.lib.e_sqlite3.nuspec +++ b/src/SQLitePCLRaw.lib.e_sqlite3/SQLitePCLRaw.lib.e_sqlite3.nuspec @@ -40,9 +40,12 @@ - + + + + diff --git a/src/SQLitePCLRaw.lib.e_sqlite3/net7.0/SQLitePCLRaw.lib.e_sqlite3.targets b/src/SQLitePCLRaw.lib.e_sqlite3/net7.0/SQLitePCLRaw.lib.e_sqlite3.targets new file mode 100644 index 00000000..3919304f --- /dev/null +++ b/src/SQLitePCLRaw.lib.e_sqlite3/net7.0/SQLitePCLRaw.lib.e_sqlite3.targets @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file