Skip to content

Commit

Permalink
Merge pull request #563 from bricelam/sqlite3mc
Browse files Browse the repository at this point in the history
Add packages for SQLite3 Multiple Ciphers
  • Loading branch information
ericsink authored Nov 9, 2023
2 parents 6f4b3ec + 5b771b6 commit 07c8837
Show file tree
Hide file tree
Showing 23 changed files with 359 additions and 0 deletions.
10 changes: 10 additions & 0 deletions build/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ let main argv =
let nuspec_dirs = [
"lib.e_sqlite3"
"lib.e_sqlcipher"
"lib.e_sqlite3mc"
]

for s in nuspec_dirs do
Expand All @@ -48,18 +49,24 @@ let main argv =
"provider.winsqlite3"
"provider.e_sqlite3"
"provider.e_sqlcipher"
"provider.e_sqlite3mc"
"provider.sqlite3"
"provider.sqlcipher"
"provider.sqlite3mc"
"lib.e_sqlite3.android"
"lib.e_sqlite3.ios"
"lib.e_sqlite3.tvos"
"lib.e_sqlcipher.android"
"lib.e_sqlcipher.ios"
"lib.e_sqlite3mc.android"
"lib.e_sqlite3mc.ios"
"lib.e_sqlite3"
"lib.e_sqlcipher"
"lib.e_sqlite3mc"
"bundle_green"
"bundle_e_sqlite3"
"bundle_e_sqlcipher"
"bundle_e_sqlite3mc"
"bundle_zetetic"
"bundle_winsqlite3"
"bundle_sqlite3"
Expand All @@ -86,6 +93,7 @@ let main argv =
let real_xunit_dirs = [
yield "e_sqlite3"
yield "e_sqlcipher"
yield "e_sqlite3mc"
// TODO do bundle_sqlite3 real_xunit here?
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then yield "winsqlite3"
]
Expand All @@ -99,6 +107,7 @@ let main argv =
let fake_xunit_dirs = [
yield "e_sqlite3"
yield "e_sqlcipher"
yield "e_sqlite3mc"
if RuntimeInformation.IsOSPlatform(OSPlatform.Windows) then yield "winsqlite3"
yield "sqlite3"
]
Expand All @@ -116,6 +125,7 @@ let main argv =
let args = "run -f net6.0-windows -r win-x86 --no-self-contained"
exec "dotnet" args (Path.Combine(top, "test_nupkgs", "e_sqlite3", "fake_xunit"))
exec "dotnet" args (Path.Combine(top, "test_nupkgs", "e_sqlcipher", "fake_xunit"))
exec "dotnet" args (Path.Combine(top, "test_nupkgs", "e_sqlite3mc", "fake_xunit"))
#endif

printfn "generating push.bat"
Expand Down
61 changes: 61 additions & 0 deletions gen_lib_nuspecs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ static string AsString_basename_in_cb(this WhichLib e)
{
case WhichLib.E_SQLITE3: return "e_sqlite3";
case WhichLib.E_SQLCIPHER: return "e_sqlcipher"; // TODO no e_ prefix in cb yet
case WhichLib.E_SQLITE3MC: return "e_sqlite3mc";
default:
throw new NotImplementedException(string.Format("WhichLib.AsString for {0}", e));
}
Expand All @@ -175,6 +176,7 @@ static string AsString_basename_in_nupkg(this WhichLib e)
{
case WhichLib.E_SQLITE3: return "e_sqlite3";
case WhichLib.E_SQLCIPHER: return "e_sqlcipher";
case WhichLib.E_SQLITE3MC: return "e_sqlite3mc";
default:
throw new NotImplementedException(string.Format("WhichLib.AsString for {0}", e));
}
Expand Down Expand Up @@ -600,11 +602,69 @@ private static void gen_nuspec_lib_e_sqlcipher(string dir_src)
}
}

private static void gen_nuspec_lib_e_sqlite3mc(string dir_src)
{
string id = string.Format("{0}.lib.e_sqlite3mc", common.ROOT_NAME);

var settings = common.XmlWriterSettings_default();
settings.OmitXmlDeclaration = false;

var dir_proj = Path.Combine(dir_src, id);
Directory.CreateDirectory(dir_proj);
common.gen_dummy_csproj(dir_proj, id);

using (XmlWriter f = XmlWriter.Create(Path.Combine(dir_proj, string.Format("{0}.nuspec", id)), settings))
{
f.WriteStartDocument();
f.WriteComment("Automatically generated");

f.WriteStartElement("package", "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd");

f.WriteStartElement("metadata");
common.write_nuspec_common_metadata(id, f);
f.WriteElementString("description", "This package contains platform-specific native code builds of SQLite3 Multiple Ciphers (see utelle/SQLite3MultipleCiphers on GitHub) for use with SQLitePCLRaw. To use this package, you need SQLitePCLRaw.core as well as one of the SQLitePCLRaw.provider.* packages. Convenience packages are named SQLitePCLRaw.bundle_*.");

f.WriteEndElement(); // metadata

f.WriteStartElement("files");

write_nuspec_file_entries_from_cb(WhichLib.E_SQLITE3MC, "v142", f);

{
var tname = string.Format("{0}.targets", id);
Directory.CreateDirectory(Path.Combine(dir_proj, "net461"));
var path_targets = Path.Combine(dir_proj, "net461", tname);
var relpath_targets = nuget_path_combine(".", "net461", tname);
gen_nuget_targets(path_targets, WhichLib.E_SQLITE3MC);
common.write_nuspec_file_entry(
relpath_targets,
string.Format("buildTransitive\\{0}", TFM.NET461.AsString()),
f
);
}

write_nuspec_wasm_targets_file_entry(dir_src, id, WhichLib.E_SQLITE3MC, TFM.NET60, f);
write_nuspec_wasm_targets_file_entry(dir_src, id, WhichLib.E_SQLITE3MC, TFM.NET70, f);
write_nuspec_wasm_targets_file_entry(dir_src, id, WhichLib.E_SQLITE3MC, TFM.NET80, f);

// TODO need a comment here to explain these
common.write_empty(f, TFM.NET461);
common.write_empty(f, TFM.NETSTANDARD20);

f.WriteEndElement(); // files

f.WriteEndElement(); // package

f.WriteEndDocument();
}
}

enum WhichLib
{
NONE,
E_SQLITE3,
E_SQLCIPHER,
E_SQLITE3MC,
}

static LibSuffix get_lib_suffix_from_rid(string rid)
Expand Down Expand Up @@ -879,6 +939,7 @@ public static void Main(string[] args)

gen_nuspec_lib_e_sqlite3(dir_src);
gen_nuspec_lib_e_sqlcipher(dir_src);
gen_nuspec_lib_e_sqlite3mc(dir_src);
}
}

6 changes: 6 additions & 0 deletions gen_providers/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,11 @@ let main argv =
gen_provider s s (Some subname_funcptrs_win) "Cdecl" "dllimport" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/callingconv" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/true"
gen_provider s s (Some subname_funcptrs_notwin) "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/plain" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/true"

for s in ["e_sqlite3mc"; "sqlite3mc"; ] do
gen_provider s s (Some subname_prenet5_win) "Cdecl" "dllimport" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/false" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_prenet5_notwin) "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/false" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/false"
gen_provider s s (Some subname_funcptrs_win) "Cdecl" "dllimport" "FEATURE_WIN32DIR/true" "FEATURE_FUNCPTRS/callingconv" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/true"
gen_provider s s (Some subname_funcptrs_notwin) "Cdecl" "dllimport" "FEATURE_WIN32DIR/false" "FEATURE_FUNCPTRS/plain" "FEATURE_KEY/true" "FEATURE_LOADEXTENSION/true"

0 // return an integer exit code

Binary file added sn/SQLitePCLRaw.lib.e_sqlite3mc.snk
Binary file not shown.
Binary file added sn/SQLitePCLRaw.provider.e_sqlite3mc.snk
Binary file not shown.
Binary file added sn/SQLitePCLRaw.provider.sqlite3mc.snk
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Xamarin.Legacy.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;$(tfm_net6_ios);$(tfm_net6_maccatalyst);$(tfm_net6_android);$(tfm_classic_ios);$(tfm_classic_android);net461</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<PackageId>SQLitePCLRaw.bundle_e_sqlite3mc</PackageId>
<AssemblyName>SQLitePCLRaw.batteries_v2</AssemblyName>
<AssemblyOriginatorKeyFile>..\..\sn\SQLitePCLRaw.batteries_v2.snk</AssemblyOriginatorKeyFile>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<PackageDescription>This 'batteries-included' bundle brings in SQLitePCLRaw.core and the necessary stuff for certain common use cases. Call SQLitePCL.Batteries.Init(). Policy of this bundle: e_sqlite3mc included</PackageDescription>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\src\common\batteries_v2.cs" />
</ItemGroup>

<Import Condition=" '$(TargetFramework)' == 'netstandard2.0' " Project="..\msbuild_bundle_fragments\e_sqlite3mc_dllimport.xml" />
<Import Condition=" '$(TargetFramework)' == '$(tfm_net6_ios)' " Project="..\msbuild_bundle_fragments\e_sqlite3mc_ios.xml" />
<Import Condition=" '$(TargetFramework)' == '$(tfm_net6_maccatalyst)' " Project="..\msbuild_bundle_fragments\e_sqlite3mc_dllimport.xml" />
<Import Condition=" '$(TargetFramework)' == '$(tfm_net6_android)' " Project="..\msbuild_bundle_fragments\e_sqlite3mc_android.xml" />
<Import Condition=" '$(TargetFramework)' == '$(tfm_classic_ios)' " Project="..\msbuild_bundle_fragments\e_sqlite3mc_ios.xml" />
<Import Condition=" '$(TargetFramework)' == '$(tfm_classic_android)' " Project="..\msbuild_bundle_fragments\e_sqlite3mc_android.xml" />
<Import Condition=" '$(TargetFramework)' == 'net461' " Project="..\msbuild_bundle_fragments\e_sqlite3mc_dynamic.xml" />

</Project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<Project Sdk="Xamarin.Legacy.Sdk">
<PropertyGroup>
<TargetFrameworks>$(tfm_net6_android);$(tfm_classic_android)</TargetFrameworks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\sn\SQLitePCLRaw.lib.e_sqlite3mc.snk</AssemblyOriginatorKeyFile>
<PackageDescription>This package contains platform-specific native code builds of SQLite3 Multiple Ciphers (see utelle/SQLite3MultipleCiphers on GitHub) for use with SQLitePCLRaw. To use this package, you need SQLitePCLRaw.core as well as one of the SQLitePCLRaw.provider.* packages. Convenience packages are named SQLitePCLRaw.bundle_*.</PackageDescription>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\src\common\embedded_init.cs" />
</ItemGroup>

<PropertyGroup Label="Android DesignTimeBuild error workaround">
<DesignTimeBuild>false</DesignTimeBuild>
</PropertyGroup>

<ItemGroup>
<EmbeddedNativeLibrary Include="$([System.IO.Path]::Combine($(cb_bin_path), 'e_sqlite3mc', 'android', 'x86', 'libe_sqlite3mc.so'))">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>x86\libe_sqlite3mc.so</Link>
</EmbeddedNativeLibrary>
<EmbeddedNativeLibrary Include="$([System.IO.Path]::Combine($(cb_bin_path), 'e_sqlite3mc', 'android', 'x86_64', 'libe_sqlite3mc.so'))">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>x86_64\libe_sqlite3mc.so</Link>
</EmbeddedNativeLibrary>
<EmbeddedNativeLibrary Include="$([System.IO.Path]::Combine($(cb_bin_path), 'e_sqlite3mc', 'android', 'arm64-v8a', 'libe_sqlite3mc.so'))">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>arm64-v8a\libe_sqlite3mc.so</Link>
</EmbeddedNativeLibrary>
<EmbeddedNativeLibrary Include="$([System.IO.Path]::Combine($(cb_bin_path), 'e_sqlite3mc', 'android', 'armeabi-v7a', 'libe_sqlite3mc.so'))">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>armeabi-v7a\libe_sqlite3mc.so</Link>
</EmbeddedNativeLibrary>
</ItemGroup>

</Project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Xamarin.Legacy.Sdk">
<PropertyGroup>
<TargetFrameworks>$(tfm_net6_ios);$(tfm_classic_ios)</TargetFrameworks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\sn\SQLitePCLRaw.lib.e_sqlite3mc.snk</AssemblyOriginatorKeyFile>
<PackageDescription>This package contains platform-specific native code builds of SQLite3 Multiple Ciphers (see utelle/SQLite3MultipleCiphers on GitHub) for use with SQLitePCLRaw. To use this package, you need SQLitePCLRaw.core as well as one of the SQLitePCLRaw.provider.* packages. Convenience packages are named SQLitePCLRaw.bundle_*.</PackageDescription>
</PropertyGroup>

<ItemGroup>
<None Include="$(cb_bin_path)\e_sqlite3mc\ios\device\e_sqlite3mc.a" Pack="true" PackagePath="static\device" />
<None Include="$(cb_bin_path)\e_sqlite3mc\ios\simulator\e_sqlite3mc.a" Pack="true" PackagePath="static\simulator" />
<None Include="SQLitePCLRaw.lib.e_sqlite3mc.ios.targets" Pack="true" PackagePath="build" />
<None Include="SQLitePCLRaw.lib.e_sqlite3mc.ios.targets" Pack="true" PackagePath="buildTransitive" />
</ItemGroup>
</Project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="'$(RuntimeIdentifier)'=='ios-arm64' or '$(ComputedPlatform)'=='iPhone'">
<NativeReference Include="$(MSBuildThisFileDirectory)..\static\device\e_sqlite3mc.a">
<Kind>Static</Kind>
<SmartLink>False</SmartLink>
<ForceLoad>true</ForceLoad>
</NativeReference>
</ItemGroup>
<ItemGroup Condition="'$(RuntimeIdentifier)'=='iossimulator-arm64' or '$(RuntimeIdentifier)'=='iossimulator-x64' or '$(ComputedPlatform)'=='iPhoneSimulator'">
<NativeReference Include="$(MSBuildThisFileDirectory)..\static\simulator\e_sqlite3mc.a">
<Kind>Static</Kind>
<SmartLink>False</SmartLink>
<ForceLoad>true</ForceLoad>
</NativeReference>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net6.0-windows</TargetFrameworks>
<LangVersion>$(ProviderLangVersion)</LangVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\sn\SQLitePCLRaw.provider.e_sqlite3mc.snk</AssemblyOriginatorKeyFile>
<PackageDescription>SQLitePCLRaw is a Portable Class Library (PCL) for low-level (raw) access to SQLite. Packages named 'SQLitePCLRaw.provider.*' (like this one) are 'plugins' that allow SQLitePCLRaw.core to access the native SQLite library. This provider does DllImport of 'e_sqlite3mc', the SQLite3 Multiple Ciphers builds provided with SQLitePCLRaw.</PackageDescription>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SQLitePCLRaw.core\SQLitePCLRaw.core.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<Compile Include="Generated\provider_e_sqlite3mc_prenet5_win.cs" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<Compile Include="Generated\provider_e_sqlite3mc_funcptrs_notwin.cs" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0-windows' ">
<Compile Include="Generated\provider_e_sqlite3mc_funcptrs_win.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net6.0-windows</TargetFrameworks>
<LangVersion>$(ProviderLangVersion)</LangVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\sn\SQLitePCLRaw.provider.sqlite3mc.snk</AssemblyOriginatorKeyFile>
<PackageDescription>SQLitePCLRaw is a Portable Class Library (PCL) for low-level (raw) access to SQLite. Packages named 'SQLitePCLRaw.provider.*' (like this one) are 'plugins' that allow SQLitePCLRaw.core to access the native SQLite library. This provider does DllImport of 'sqlite3mc', to reference the 'system' SQLite3 Multiple Ciphers. One common use for this provider is to access the SQLite3 Multiple Ciphers library installed from source.</PackageDescription>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SQLitePCLRaw.core\SQLitePCLRaw.core.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<Compile Include="Generated\provider_sqlite3mc_prenet5_win.cs" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<Compile Include="Generated\provider_sqlite3mc_funcptrs_notwin.cs" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0-windows' ">
<Compile Include="Generated\provider_sqlite3mc_funcptrs_win.cs" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions src/common/batteries_v2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public static void Init()
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_e_sqlite3());
#elif PROVIDER_e_sqlcipher
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_e_sqlcipher());
#elif PROVIDER_e_sqlite3mc
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_e_sqlite3mc());
#elif PROVIDER_sqlcipher
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlcipher());
#elif PROVIDER_winsqlite3
Expand All @@ -105,6 +107,8 @@ public static void Init()
DoDynamic_cdecl("e_sqlite3", NativeLibrary.WHERE_RUNTIME_RID | NativeLibrary.WHERE_ADJACENT | NativeLibrary.WHERE_CODEBASE);
#elif PROVIDER_NAME_e_sqlcipher
DoDynamic_cdecl("e_sqlcipher", NativeLibrary.WHERE_RUNTIME_RID | NativeLibrary.WHERE_ADJACENT);
#elif PROVIDER_NAME_e_sqlite3mc
DoDynamic_cdecl("e_sqlite3mc", NativeLibrary.WHERE_RUNTIME_RID | NativeLibrary.WHERE_ADJACENT);
#elif PROVIDER_NAME_sqlcipher
DoDynamic_cdecl("sqlcipher", NativeLibrary.WHERE_ARCH); // TODO coordinate with zetetic
#elif PROVIDER_NAME_winsqlite3
Expand Down
2 changes: 2 additions & 0 deletions src/common/tests_xunit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ public void test_sqlite3_memory()
#endif
}

#if TODO
[Fact]
public void test_sqlite3_soft_heap_limit64()
{
Expand Down Expand Up @@ -849,6 +850,7 @@ public void test_sqlite3_hard_heap_limit64()
query = raw.sqlite3_hard_heap_limit64(-1);
Assert.Equal(limit, query);
}
#endif

[Fact]
public void test_sqlite3_status()
Expand Down
5 changes: 5 additions & 0 deletions src/global.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"sdk":
{
"version": "6.0.100",
"rollForward": "latestFeature"
},
"msbuild-sdks":
{
"MSBuild.Sdk.Extras": "3.0.44",
Expand Down
13 changes: 13 additions & 0 deletions src/msbuild_bundle_fragments/e_sqlite3mc_android.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

<Project>

<PropertyGroup>
<DefineConstants>$(DefineConstants);PROVIDER_e_sqlite3mc</DefineConstants>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SQLitePCLRaw.lib.e_sqlite3mc.android\SQLitePCLRaw.lib.e_sqlite3mc.android.csproj" />
<ProjectReference Include="..\SQLitePCLRaw.provider.e_sqlite3mc\SQLitePCLRaw.provider.e_sqlite3mc.csproj" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions src/msbuild_bundle_fragments/e_sqlite3mc_dllimport.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>

<PropertyGroup>
<DefineConstants>$(DefineConstants);PROVIDER_e_sqlite3mc</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SQLitePCLRaw.lib.e_sqlite3mc" Version="$(version)" />
<ProjectReference Include="..\SQLitePCLRaw.provider.e_sqlite3mc\SQLitePCLRaw.provider.e_sqlite3mc.csproj" />
</ItemGroup>

</Project>

Loading

0 comments on commit 07c8837

Please sign in to comment.