Skip to content

Commit

Permalink
Merge pull request #515 from bricelam/wasm7
Browse files Browse the repository at this point in the history
Add Wasm assets for .NET 7
  • Loading branch information
ericsink authored Sep 9, 2022
2 parents 2e1baf6 + 0b1f5e0 commit 2cc5bff
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 33 deletions.
70 changes: 39 additions & 31 deletions gen_lib_nuspecs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public enum TFM
NETSTANDARD20,
NET461,
NET60,
NET70,
MACCATALYST,
XAMARINMAC20,
}
Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@
<file src="$cb_bin_path$\e_sqlcipher\linux\musl-arm64\libe_sqlcipher.so" target="runtimes\alpine-arm64\native\libe_sqlcipher.so" />
<file src="$cb_bin_path$\e_sqlcipher\linux\mips64\libe_sqlcipher.so" target="runtimes\linux-mips64\native\libe_sqlcipher.so" />
<file src="$cb_bin_path$\e_sqlcipher\linux\s390x\libe_sqlcipher.so" target="runtimes\linux-s390x\native\libe_sqlcipher.so" />
<file src="$cb_bin_path$\e_sqlcipher\wasm\e_sqlcipher.a" target="runtimes\browser-wasm\nativeassets\net6.0\e_sqlcipher.a" />
<file src="$cb_bin_path$\e_sqlcipher\wasm\net6.0\e_sqlcipher.a" target="runtimes\browser-wasm\nativeassets\net6.0\e_sqlcipher.a" />
<file src="$cb_bin_path$\e_sqlcipher\wasm\net7.0\e_sqlcipher.a" target="runtimes\browser-wasm\nativeassets\net7.0\e_sqlcipher.a" />
<file src=".\net461\SQLitePCLRaw.lib.e_sqlcipher.targets" target="buildTransitive\net461" />
<file src=".\net6.0\SQLitePCLRaw.lib.e_sqlcipher.targets" target="buildTransitive\net6.0" />
<file src=".\net7.0\SQLitePCLRaw.lib.e_sqlcipher.targets" target="buildTransitive\net7.0" />
<!--empty directory in lib to avoid nuget adding a reference-->
<file src="_._" target="lib/net461/_._" />
<!--empty directory in lib to avoid nuget adding a reference-->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Automatically generated-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(RuntimeIdentifier)' == 'browser-wasm' ">
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\..\runtimes\browser-wasm\nativeassets\net7.0\e_sqlcipher.a" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@
<file src="$cb_bin_path$\e_sqlite3\linux\musl-arm64\libe_sqlite3.so" target="runtimes\alpine-arm64\native\libe_sqlite3.so" />
<file src="$cb_bin_path$\e_sqlite3\linux\mips64\libe_sqlite3.so" target="runtimes\linux-mips64\native\libe_sqlite3.so" />
<file src="$cb_bin_path$\e_sqlite3\linux\s390x\libe_sqlite3.so" target="runtimes\linux-s390x\native\libe_sqlite3.so" />
<file src="$cb_bin_path$\e_sqlite3\wasm\e_sqlite3.a" target="runtimes\browser-wasm\nativeassets\net6.0\e_sqlite3.a" />
<file src="$cb_bin_path$\e_sqlite3\wasm\net6.0\e_sqlite3.a" target="runtimes\browser-wasm\nativeassets\net6.0\e_sqlite3.a" />
<file src="$cb_bin_path$\e_sqlite3\wasm\net7.0\e_sqlite3.a" target="runtimes\browser-wasm\nativeassets\net7.0\e_sqlite3.a" />
<file src=".\SQLitePCLRaw.lib.e_sqlite3.props" target="buildTransitive\" />
<file src=".\net461\SQLitePCLRaw.lib.e_sqlite3.targets" target="buildTransitive\net461" />
<file src=".\net6.0\SQLitePCLRaw.lib.e_sqlite3.targets" target="buildTransitive\net6.0" />
<file src=".\net7.0\SQLitePCLRaw.lib.e_sqlite3.targets" target="buildTransitive\net7.0" />
<!--empty directory in lib to avoid nuget adding a reference-->
<file src="_._" target="lib/net461/_._" />
<!--empty directory in lib to avoid nuget adding a reference-->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Automatically generated-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(RuntimeIdentifier)' == 'browser-wasm' ">
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\..\runtimes\browser-wasm\nativeassets\net7.0\e_sqlite3.a" />
</ItemGroup>
</Project>

0 comments on commit 2cc5bff

Please sign in to comment.