[C# API] [Samples] Reworked the structure / references

- bindings now reference the files in the ./native-builds/lib/ directory
 - OS X no longer needs an explicit .dylib references, it just needs the .targets file
 - cleaned up the unnecessary Android references
 - moved Desktop & Driver projects into samples for later
 - Cake now builds the C# libraries and samples
This commit is contained in:
Matthew Leibowitz 2016-01-15 02:18:32 +02:00
Родитель 64ccc57ec5
Коммит ec58b7752d
22 изменённых файлов: 150 добавлений и 174 удалений

Просмотреть файл

@ -25,5 +25,6 @@
<Compile Include="$(MSBuildThisFileDirectory)SKTypeface.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SKStream.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SKManagedStream.cs" />
<Compile Include="$(MSBuildThisFileDirectory)..\SkiaSharp\Properties\SkiaSharpAssemblyInfo.cs" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1 @@


Просмотреть файл

@ -1,44 +0,0 @@
Images, layout descriptions, binary blobs and string dictionaries can be included
in your application as resource files. Various Android APIs are designed to
operate on the resource IDs instead of dealing with images, strings or binary blobs
directly.
For example, a sample Android app that contains a user interface layout (main.axml),
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
would keep its resources in the "Resources" directory of the application:
Resources/
drawable/
icon.png
layout/
main.axml
values/
strings.xml
In order to get the build system to recognize Android resources, set the build action to
"AndroidResource". The native Android APIs do not operate directly with filenames, but
instead operate on resource IDs. When you compile an Android application that uses resources,
the build system will package the resources for distribution and generate a class called "R"
(this is an Android convention) that contains the tokens for each one of the resources
included. For example, for the above Resources layout, this is what the R class would expose:
public class R {
public class drawable {
public const int icon = 0x123;
}
public class layout {
public const int main = 0x456;
}
public class strings {
public const int first_string = 0xabc;
public const int second_string = 0xbcd;
}
}
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
to reference the layout/main.axml file, or R.strings.first_string to reference the first
string in the dictionary file values/strings.xml.

Просмотреть файл

@ -1,57 +0,0 @@
#pragma warning disable 1591
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 4.0.30319.17020
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
[assembly: Android.Runtime.ResourceDesignerAttribute("SkiaSharp.Android.Resource", IsApplication=false)]
namespace SkiaSharp.Android
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{
static Resource()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
public partial class Attribute
{
static Attribute()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Attribute()
{
}
}
public partial class String
{
// aapt resource value: 0x7f020000
public static int library_name = 2130837504;
static String()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private String()
{
}
}
}
}
#pragma warning restore 1591

Просмотреть файл

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="library_name">SkiaSharp.Android</string>
</resources>

Просмотреть файл

@ -45,15 +45,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Resources\Resource.designer.cs" />
<Compile Include="..\SharedProps\SkiaSharpAssemblyInfo.cs">
<Link>Properties\SkiaSharpAssemblyInfo.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\values\Strings.xml" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="..\Binding\Binding.projitems" Label="Shared" Condition="Exists('..\Binding\Binding.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
@ -61,19 +53,19 @@
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<EmbeddedNativeLibrary Include="..\..\native-builds\libskia_android\libs\arm64-v8a\libskia_android.so">
<EmbeddedNativeLibrary Include="..\..\native-builds\lib\android\arm64-v8a\libskia_android.so">
<Link>libs\arm64-v8a\libskia_android.so</Link>
</EmbeddedNativeLibrary>
<EmbeddedNativeLibrary Include="..\..\native-builds\libskia_android\libs\armeabi\libskia_android.so">
<EmbeddedNativeLibrary Include="..\..\native-builds\lib\android\armeabi\libskia_android.so">
<Link>libs\armeabi\libskia_android.so</Link>
</EmbeddedNativeLibrary>
<EmbeddedNativeLibrary Include="..\..\native-builds\libskia_android\libs\armeabi-v7a\libskia_android.so">
<EmbeddedNativeLibrary Include="..\..\native-builds\lib\android\armeabi-v7a\libskia_android.so">
<Link>libs\armeabi-v7a\libskia_android.so</Link>
</EmbeddedNativeLibrary>
<EmbeddedNativeLibrary Include="..\..\native-builds\libskia_android\libs\x86\libskia_android.so">
<EmbeddedNativeLibrary Include="..\..\native-builds\lib\android\x86\libskia_android.so">
<Link>libs\x86\libskia_android.so</Link>
</EmbeddedNativeLibrary>
<EmbeddedNativeLibrary Include="..\..\native-builds\libskia_android\libs\x86_64\libskia_android.so">
<EmbeddedNativeLibrary Include="..\..\native-builds\lib\android\x86_64\libskia_android.so">
<Link>libs\x86_64\libskia_android.so</Link>
</EmbeddedNativeLibrary>
</ItemGroup>

Просмотреть файл

@ -0,0 +1 @@


Просмотреть файл

@ -58,8 +58,15 @@
<Import Project="..\Binding\Binding.projitems" Label="Shared" Condition="Exists('..\Binding\Binding.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
<ItemGroup>
<Compile Include="..\SharedProps\SkiaSharpAssemblyInfo.cs">
<Link>Properties\SkiaSharpAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="SkiaSharp.OSX.targets">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\native-builds\lib\osx\liblibskia_osx.dylib">
<Link>liblibskia_osx.dylib</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<NativeReference Include="$(MSBuildThisFileDirectory)liblibskia_osx.dylib">
<IsCxx>False</IsCxx>
<Kind>Dynamic</Kind>
</NativeReference>
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,4 @@
using System.Runtime.CompilerServices;
// this is to let the runtime know that there is no real logic in this assembly.
[assembly: ReferenceAssembly]

Просмотреть файл

@ -30,10 +30,11 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\SharedProps\SkiaSharpAssemblyInfo.cs">
<Compile Include="SkiaPortable.cs" />
<Compile Include="..\SkiaSharp\Properties\SkiaSharpAssemblyInfo.cs">
<Link>Properties\SkiaSharpAssemblyInfo.cs</Link>
</Compile>
<Compile Include="SkiaPortable.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<ItemGroup>

Просмотреть файл

@ -0,0 +1,7 @@
using Foundation;
// This attribute allows you to mark your assemblies as “safe to link”.
// When the attribute is present, the linker—if enabled—will process the assembly
// even if youre using the “Link SDK assemblies only” option, which is the default for device builds.
[assembly: LinkerSafe]

Просмотреть файл

@ -42,9 +42,7 @@
<Compile Include="AllLibs.linkwith.cs">
<DependentUpon>libjpeg-turbo.a</DependentUpon>
</Compile>
<Compile Include="..\SharedProps\SkiaSharpAssemblyInfo.cs">
<Link>Properties\SkiaSharpAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
@ -53,7 +51,7 @@
<ObjcBindingCoreSource Include="StructsAndEnums.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingNativeFramework Include="..\..\native-builds\ios\libskia_ios.framework" />
<ObjcBindingNativeFramework Include="..\..\native-builds\lib\ios\libskia_ios.framework" />
</ItemGroup>
<Import Project="..\Binding\Binding.projitems" Label="Shared" Condition="Exists('..\Binding\Binding.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.ObjCBinding.CSharp.targets" />

Просмотреть файл

@ -1,25 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Driver", "Driver.csproj", "{8C27B6E9-2980-447E-B887-17D185ACF539}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Binding", "Binding\Binding.shproj", "{9C502B9A-25D4-473F-89BD-5A13DDE16354}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desktop", "Desktop\Desktop.csproj", "{467FA6DC-C3FB-4EF8-8B8F-338C13CC8A71}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{467FA6DC-C3FB-4EF8-8B8F-338C13CC8A71}.Debug|x86.ActiveCfg = Debug|Any CPU
{467FA6DC-C3FB-4EF8-8B8F-338C13CC8A71}.Debug|x86.Build.0 = Debug|Any CPU
{467FA6DC-C3FB-4EF8-8B8F-338C13CC8A71}.Release|x86.ActiveCfg = Release|Any CPU
{467FA6DC-C3FB-4EF8-8B8F-338C13CC8A71}.Release|x86.Build.0 = Release|Any CPU
{8C27B6E9-2980-447E-B887-17D185ACF539}.Debug|x86.ActiveCfg = Debug|x86
{8C27B6E9-2980-447E-B887-17D185ACF539}.Debug|x86.Build.0 = Debug|x86
{8C27B6E9-2980-447E-B887-17D185ACF539}.Release|x86.ActiveCfg = Release|x86
{8C27B6E9-2980-447E-B887-17D185ACF539}.Release|x86.Build.0 = Release|x86
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Binding", "Binding\Binding.shproj", "{9C502B9A-25D4-473F-89BD-5A13DDE16354}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.Android", "SkiaSharp.Android\SkiaSharp.Android.csproj", "{C737DC80-5B71-4B26-A2DC-DA30421788B0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.iOS", "SkiaSharp.iOS\SkiaSharp.iOS.csproj", "{6A678CFB-21A7-4E81-8909-FD72ABBFD408}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.OSX", "SkiaSharp.OSX\SkiaSharp.OSX.csproj", "{4588A759-3853-49B8-8A68-6C7917BE9220}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.Portable", "SkiaSharp.Portable\SkiaSharp.Portable.csproj", "{7AA90628-2FDD-4585-AF2F-CC51CFA8B52A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4588A759-3853-49B8-8A68-6C7917BE9220}.Debug|x86.ActiveCfg = Debug|Any CPU
{4588A759-3853-49B8-8A68-6C7917BE9220}.Debug|x86.Build.0 = Debug|Any CPU
{4588A759-3853-49B8-8A68-6C7917BE9220}.Release|x86.ActiveCfg = Release|Any CPU
{4588A759-3853-49B8-8A68-6C7917BE9220}.Release|x86.Build.0 = Release|Any CPU
{6A678CFB-21A7-4E81-8909-FD72ABBFD408}.Debug|x86.ActiveCfg = Debug|Any CPU
{6A678CFB-21A7-4E81-8909-FD72ABBFD408}.Debug|x86.Build.0 = Debug|Any CPU
{6A678CFB-21A7-4E81-8909-FD72ABBFD408}.Release|x86.ActiveCfg = Release|Any CPU
{6A678CFB-21A7-4E81-8909-FD72ABBFD408}.Release|x86.Build.0 = Release|Any CPU
{7AA90628-2FDD-4585-AF2F-CC51CFA8B52A}.Debug|x86.ActiveCfg = Debug|Any CPU
{7AA90628-2FDD-4585-AF2F-CC51CFA8B52A}.Debug|x86.Build.0 = Debug|Any CPU
{7AA90628-2FDD-4585-AF2F-CC51CFA8B52A}.Release|x86.ActiveCfg = Release|Any CPU
{7AA90628-2FDD-4585-AF2F-CC51CFA8B52A}.Release|x86.Build.0 = Release|Any CPU
{C737DC80-5B71-4B26-A2DC-DA30421788B0}.Debug|x86.ActiveCfg = Debug|Any CPU
{C737DC80-5B71-4B26-A2DC-DA30421788B0}.Debug|x86.Build.0 = Debug|Any CPU
{C737DC80-5B71-4B26-A2DC-DA30421788B0}.Release|x86.ActiveCfg = Release|Any CPU
{C737DC80-5B71-4B26-A2DC-DA30421788B0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

Просмотреть файл

@ -1,26 +1,13 @@
using System.Reflection;
using System.Runtime.CompilerServices;
#if MONOTOUCH
using Foundation;
// This attribute allows you to mark your assemblies as “safe to link”.
// When the attribute is present, the linker—if enabled—will process the assembly
// even if youre using the “Link SDK assemblies only” option, which is the default for device builds.
[assembly: LinkerSafe]
#endif
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("SkiaSharp.iOS")]
[assembly: AssemblyTitle ("SkiaSharp")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyProduct ("SkiaSharp")]
[assembly: AssemblyCopyright ("Xamarin Inc.")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
@ -30,6 +17,7 @@ using Foundation;
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.0.0")]
[assembly: AssemblyFileVersion ("1.0.0.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

Просмотреть файл

@ -26,6 +26,41 @@ var AppendEnvironmentVariable = new Action<string, string> ((name, value) => {
SetEnvironmentVariable (name, value);
});
CakeSpec.Libs = new ISolutionBuilder [] {
new IOSSolutionBuilder {
SolutionPath = "binding/SkiaSharp.sln",
OutputFiles = new [] {
new OutputFileCopy {
FromFile = "./binding/SkiaSharp.Android/bin/Release/SkiaSharp.dll",
ToDirectory = "./output/android/"
},
new OutputFileCopy {
FromFile = "./binding/SkiaSharp.iOS/bin/Release/SkiaSharp.dll",
ToDirectory = "./output/ios/"
},
new OutputFileCopy {
FromFile = "./binding/SkiaSharp.OSX/bin/Release/SkiaSharp.dll",
ToDirectory = "./output/osx/"
},
new OutputFileCopy {
FromFile = "./binding/SkiaSharp.Portable/bin/Release/SkiaSharp.dll",
ToDirectory = "./output/portable/"
},
}
},
};
CakeSpec.Samples = new ISolutionBuilder [] {
new IOSSolutionBuilder {
SolutionPath = "./samples/Skia.OSX.Demo/Skia.OSX.Demo.sln"
},
new IOSSolutionBuilder {
SolutionPath = "./samples/Skia.Forms.Demo/Skia.Forms.Demo.sln"
},
};
Task ("externals")
.IsDependentOn ("externals-windows")
.IsDependentOn ("externals-osx")
@ -177,6 +212,8 @@ Task ("externals-android").WithCriteria (IsRunningOnUnix ()).Does (() =>
// set up the gyp environment variables
AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath);
SetEnvironmentVariable ("GYP_DEFINES", "");
SetEnvironmentVariable ("GYP_GENERATORS", "");
SetEnvironmentVariable ("BUILDTYPE", "Release");
SetEnvironmentVariable ("ANDROID_HOME", ANDROID_HOME);
SetEnvironmentVariable ("ANDROID_SDK_ROOT", ANDROID_SDK_ROOT);
@ -195,6 +232,32 @@ Task ("externals-android").WithCriteria (IsRunningOnUnix ()).Does (() =>
});
});
Task ("clean")
.IsDependentOn ("clean-externals")
.Does (() =>
{
});
Task ("clean-externals").Does (() =>
{
// skia
CleanDirectories ("skia/out");
CleanDirectories ("skia/xcodebuild");
// all
CleanDirectories ("native-builds/lib");
// android
CleanDirectories ("native-builds/libskia_android/obj");
CleanDirectories ("native-builds/libskia_android/libs");
// ios
CleanDirectories ("native-builds/libskia_ios/build");
// osx
CleanDirectories ("native-builds/libskia_osx/build");
// windows
CleanDirectories ("native-builds/libskia_windows/Release");
CleanDirectories ("native-builds/libskia_windows/x64/Release");
});
DefineDefaultTasks ();

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -98,12 +98,7 @@
<Name>SkiaSharp.OSX</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<NativeReference Include="..\..\native-builds\osx\liblibskia_osx.dylib">
<IsCxx>False</IsCxx>
<Kind>Dynamic</Kind>
</NativeReference>
</ItemGroup>
<Import Project="..\..\binding\SkiaSharp.OSX\bin\$(Configuration)\SkiaSharp.OSX.targets" />
<ItemGroup>
<BundleResource Include="..\weblysleekuil.ttf">
<Link>Resources\weblysleekuil.ttf</Link>