Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
path = external/mxe
url = https://github.com/xamarin/mxe.git
branch = xamarin
[submodule "external/sqlite"]
path = external/sqlite
url = https://github.com/xamarin/sqlite.git
1 change: 1 addition & 0 deletions external/sqlite
Submodule sqlite added at 382b7b
161 changes: 161 additions & 0 deletions src/Mono.Data.Sqlite/Mono.Data.Sqlite.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>{26781D3A-FF20-4F55-9824-C8A06AA9E484}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Mono.Data.Sqlite</RootNamespace>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
<AssemblyName>Mono.Data.Sqlite</AssemblyName>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the <Import/> of Configuration.props to the top of the file, and set <TargetFrameworkVersion/> to $(AndroidFrameworkVersion). This will ensure that when $(AndroidFrameworkVersion) changes in the future (e.g. to v6.1 for Android-N, or whatever it will be called), this project won't break.

</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid\v1.0</OutputPath>
<DefineConstants>DEBUG;TRACE;NET_4_0;NET_4_5;MONO;DISABLE_CAS_USE;SQLITE_STANDARD;MONODROID</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidLinkMode>None</AndroidLinkMode>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>..\..\bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid\v1.0</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>NET_4_0;NET_4_5;MONO;DISABLE_CAS_USE;SQLITE_STANDARD;MONODROID</DefineConstants>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Transactions" />
<Reference Include="Mono.Android" />
</ItemGroup>
<ItemGroup>
<None Include="Mono.Data.Sqlite.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Compile Include="$(XamarinAndroidSourcePath)\src\Mono.Android\Android.Runtime\CPUArchitecture.cs">
<Link>Android.Runtime\CPUArchitecture.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Assembly\AssemblyInfo.cs">
<Link>Assembly\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\MonoPInvokeCallbackAttribute.cs">
<Link>Mono.Data.Sqlite_2.0\MonoPInvokeCallbackAttribute.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLite3.cs">
<Link>Mono.Data.Sqlite_2.0\SQLite3.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLite3_UTF16.cs">
<Link>Mono.Data.Sqlite_2.0\SQLite3_UTF16.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteBase.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteBase.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteCommandBuilder.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteCommandBuilder.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteCommand.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteCommand.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteConnection.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteConnection.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\LINQ\SQLiteConnection_Linq.cs">
<Link>Mono.Data.Sqlite_2.0\LINQ\SQLiteConnection_Linq.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteConnectionPool.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteConnectionPool.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteConnectionStringBuilder.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteConnectionStringBuilder.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteConvert.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteConvert.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteDataAdapter.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteDataAdapter.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteDataReader.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteDataReader.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SqliteDataSourceEnumerator.cs">
<Link>Mono.Data.Sqlite_2.0\SqliteDataSourceEnumerator.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteEnlistment.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteEnlistment.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteException.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteException.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteFactory.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteFactory.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\LINQ\SQLiteFactory_Linq.cs">
<Link>Mono.Data.Sqlite_2.0\LINQ\SQLiteFactory_Linq.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteFunctionAttribute.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteFunctionAttribute.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteFunction.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteFunction.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteKeyReader.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteKeyReader.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteMetaDataCollectionNames.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteMetaDataCollectionNames.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteParameterCollection.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteParameterCollection.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteParameter.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteParameter.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteStatement.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteStatement.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SQLiteTransaction.cs">
<Link>Mono.Data.Sqlite_2.0\SQLiteTransaction.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\SR.Designer.cs">
<Link>Mono.Data.Sqlite_2.0\SR.Designer.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\class\Mono.Data.Sqlite\Mono.Data.Sqlite_2.0\UnsafeNativeMethods.cs">
<Link>Mono.Data.Sqlite_2.0\UnsafeNativeMethods.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\build\common\Locale.cs">
<Link>Locale.cs</Link>
</Compile>
<Compile Include="$(MonoSourceDirectory)\mcs\build\common\Consts.cs">
<Link>Consts.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$(OutputPath)\..\..\..\xbuild\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<ItemGroup>
<Folder Include="Assembly\" />
<Folder Include="Mono.Data.Sqlite\" />
</ItemGroup>
<ItemGroup>
<_SupportedAbi Include="$(AndroidSupportedAbis)" />
<EmbeddedNativeLibrary Include="@(_SuppportedAbi->'..\sqlite-xamarin\src\main\libs\@(_SupportedAbi)\libsqlite3_xamarin.so')" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions src/Mono.Data.Sqlite/Mono.Data.Sqlite.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<configuration>
<dllmap dll="sqlite3" target="libsqlite3_xamarin.so" />
</configuration>
7 changes: 7 additions & 0 deletions src/sqlite-xamarin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.stamp
build.gradle
gradle/
gradlew
gradlew.bat
src/

60 changes: 60 additions & 0 deletions src/sqlite-xamarin/sqlite-xamarin.mdproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ItemType>GenericProject</ItemType>
<ProjectGuid>{B8F799C5-D7CE-4E09-9CE6-BAA4173E7EC8}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<OutputPath>..\..\bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<OutputPath>..\..\bin\Release\</OutputPath>
</PropertyGroup>

<PropertyGroup>
<BuildDependsOn>
_CreateProject;
_NdkBuild;
</BuildDependsOn>
</PropertyGroup>

<Import Project="..\..\Configuration.props" />

<!-- Build target and co. -->

<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />

<Target Name="_CreateProject">
<Exec Condition="!Exists('src')"
Command="$(AndroidSdkDirectory)\tools\android create project -g -n sqlitesample -p . -a MainActivity -t android-10 --package com.xamarin.sqlitesample -v 1.0.0" />
<Copy Condition="!Exists('src\stamp')"
SourceFiles="src-jni\Application.mk;src-jni\Android.mk"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in jni, not src-jni? I've never heard or seen of a src-jni directory before, while jni seems conventional:

The Android.mk file resides in a subdirectory of your project's jni/ directory

That's also what src/monodroid uses: src/monodroid/jni.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The directory jni is part of automatically created src directory, by android create project.
This src-jni holds the copied sources which will be copied to the newly created src/main/jni, after this command is done. Hence it has different name.

DestinationFiles="src\main\jni\Application.mk;src\main\jni\Android.mk" />
<Touch Files="src\stamp" AlwaysCreate="true" />
</Target>

<Target Name="_NdkBuild">
<Exec Command="$(AndroidNdkDirectory)\ndk-build"
WorkingDirectory="src\main\jni" />

<!-- build outputs are:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are the build outputs, then you should add an <ItemGroup/> and corresponding Inputs and Ouputs to the Target:

<ItemGroup>
  <_NativeLib Include="src\main\libs\x86\libsqlite3_xamarin.so />
  <_NativeLib Include="src\main\libs\x86_64\libsqlite3_xamarin.so />
  <_NativeLib Include="src\main\libs\armeabi\libsqlite3_xamarin.so />
  <_NativeLib Include="src\main\libs\armeabi-v7a\libsqlite3_xamarin.so />
  <_NativeLib Include="src\main\libs\aarch64-v8a\libsqlite3_xamarin.so />
</ItemGroup>
<Target Name="_NdkBuild"
    Inputs="src\main\jni\Android.mk"
    Outputs="@(_NativeLib)">
  <Exec .../>
</Target>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is really no need for that, ndk-build has efficient caching, and invoking ndk-build every time is non-issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will find out why it's not really an issue if you actually run it. It's much faster than running mono build script every time.

src/main/libs/x86/libsqlite3_xamarin.so
src/main/libs/armeabi-v7a/libsqlite3_xamarin.so
src/main/libs/armeabi/libsqlite3_xamarin.so
src/main/libs/arm64-v8a/libsqlite3_xamarin.so
src/main/libs/x86_64/libsqlite3_xamarin.so
-->
</Target>

<!-- Clean target -->

<Target Name="Clean">
<Delete
Files="build.gradle;gradlew;gradlew.bat;local.properties" />
<RemoveDir Directories="gradle;src" />
</Target>
</Project>


61 changes: 61 additions & 0 deletions src/sqlite-xamarin/src-jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# It is based on sqlite/dist/Android.mk with some changes.

##
##
## Build the library
##
##

LOCAL_PATH:= $(call my-dir)

# NOTE the following flags,
# SQLITE_TEMP_STORE=3 causes all TEMP files to go into RAM. and thats the behavior we want
# SQLITE_ENABLE_FTS3 enables usage of FTS3 - NOT FTS1 or 2.
# SQLITE_DEFAULT_AUTOVACUUM=1 causes the databases to be subject to auto-vacuum
minimal_sqlite_flags := \
-DNO_ANDROID_FUNCS=1 \
-DHAVE_POSIX_FALLOCATE=0 \
-DNDEBUG=1 \
-DHAVE_USLEEP=1 \
-DSQLITE_HAVE_ISNAN \
-DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \
-DSQLITE_THREADSAFE=2 \
-DSQLITE_TEMP_STORE=3 \
-DSQLITE_POWERSAFE_OVERWRITE=1 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
-DSQLITE_DEFAULT_AUTOVACUUM=1 \
-DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 \
-DSQLITE_ENABLE_FTS3 \
-DSQLITE_ENABLE_FTS3_BACKWARDS \
-DSQLITE_ENABLE_FTS4 \
-DSQLITE_OMIT_BUILTIN_TEST \
-DSQLITE_OMIT_COMPILEOPTION_DIAGS \
-DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_DEFAULT_FILE_PERMISSIONS=0600

device_sqlite_flags := $(minimal_sqlite_flags) \
-DHAVE_MALLOC_H=1

common_src_files := ../../../../../external/sqlite/dist/sqlite3.c

# the device library
include $(CLEAR_VARS)

LOCAL_SRC_FILES := $(common_src_files)

LOCAL_CFLAGS += $(device_sqlite_flags)

LOCAL_SHARED_LIBRARIES := libdl

LOCAL_MODULE:= libsqlite3_xamarin

LOCAL_C_INCLUDES += $(call include-path-for, system-core)/cutils

LOCAL_SHARED_LIBRARIES += liblog

# include android specific methods
#LOCAL_WHOLE_STATIC_LIBRARIES := libsqlite3_xamarin

include $(BUILD_SHARED_LIBRARY)


1 change: 1 addition & 0 deletions src/sqlite-xamarin/src-jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_ABI := armeabi armeabi-v7a arm64-v8a x86 x86_64