Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get it working on general Mono and ARM devices #18

Closed
galvesribeiro opened this issue Feb 23, 2016 · 17 comments
Closed

Get it working on general Mono and ARM devices #18

galvesribeiro opened this issue Feb 23, 2016 · 17 comments

Comments

@galvesribeiro
Copy link

Hi,

Would be good if we have SkiaSharp working on general Mono instead of just on Xamarin iOS/Android. I know that nothing on current binding stop us to have it working on Mono however, build Skia native libs is a process not very well documented and with lots of tricks. If we could have guide on how to build it (at least the SkiaSharp fork) to ARMv6/v7 and other platforms, would be perfect.

As SkiaSharp home page said, we have lots of problems with Cairo that just can't be fixed today so would be perfect to remove it with Skia and SkiaSharp.

Good work!

Thanks!

@mattleibow
Copy link
Contributor

@galvesribeiro I am working on that... You can try the WindowsDesktop sample on Mac. It should run and everything. Linux is next after Windows RT.

@mattleibow
Copy link
Contributor

@galvesribeiro I have updated the build script in SkiaShap and you should be able to build the externals-ios or externals-android targets. This will produce a native iOS or Android library that can be included in any native app. The SkiaSharp repo does all the wo as I don't actually build on skia side.

https://github.com/mono/SkiaSharp/blob/master/build.cake#L295-L338

// helper function just to run xcode builds
var buildArch = new Action<string, string> ((sdk, arch) => {
    XCodeBuild (new XCodeBuildSettings {
        Project = "native-builds/libskia_ios/libskia_ios.xcodeproj",
        Target = "libskia_ios",
        Sdk = sdk,
        Arch = arch,
        Configuration = "Release",
    });
    if (!DirectoryExists ("native-builds/lib/ios/" + arch)) {
        CreateDirectory ("native-builds/lib/ios/" + arch);
    }
    CopyDirectory ("native-builds/libskia_ios/build/Release-" + sdk, "native-builds/lib/ios/" + arch);
});

// helper function to "build" skia whatnots
var RunGyp = new Action (() =>
{
    Information ("Running 'sync-and-gyp'...");
    Information ("\tGYP_GENERATORS = " + EnvironmentVariable ("GYP_GENERATORS"));
    Information ("\tGYP_DEFINES = " + EnvironmentVariable ("GYP_DEFINES"));

    StartProcess ("python", new ProcessSettings {
        Arguments = SKIA_PATH.CombineWithFilePath("bin/sync-and-gyp").FullPath,
        WorkingDirectory = SKIA_PATH.FullPath,
    });
});

// set up the gyp environment variables
AppendEnvironmentVariable ("PATH", DEPOT_PATH.FullPath);
SetEnvironmentVariable ("GYP_DEFINES", "skia_os='ios' skia_arch_type='arm' armv7=1 arm_neon=0");
SetEnvironmentVariable ("GYP_GENERATORS", "ninja,xcode");

// build skia whatnots
RunGyp ();

// actually un the build for each iOS arch
buildArch ("iphonesimulator", "i386");
buildArch ("iphonesimulator", "x86_64");
buildArch ("iphoneos", "armv7");
buildArch ("iphoneos", "armv7s");
buildArch ("iphoneos", "arm64");

// create the fat framework
CopyDirectory ("native-builds/lib/ios/armv7/libskia_ios.framework/", "native-builds/lib/ios/libskia_ios.framework/");
DeleteFile ("native-builds/lib/ios/libskia_ios.framework/libskia_ios");
RunLipo ("native-builds/lib/ios/", "libskia_ios.framework/libskia_ios", new [] {
    (FilePath) "i386/libskia_ios.framework/libskia_ios", 
    (FilePath) "x86_64/libskia_ios.framework/libskia_ios", 
    (FilePath) "armv7/libskia_ios.framework/libskia_ios", 
    (FilePath) "armv7s/libskia_ios.framework/libskia_ios", 
    (FilePath) "arm64/libskia_ios.framework/libskia_ios"
});

// BOOM: done! you should have a fat dynamic framework in "native-builds/lib/ios/"

@mattleibow
Copy link
Contributor

To build for "general" mono, it is the same process. If you build externals-osx this produces a dylib that is usable everywhere on a mac, whether in vanilla Mono or in Xamarin.Mac (and probably in MonoMac as well).

The next bit for Linux will be the same, except that there is only a vanilla mono... Unless there is a Xamarin.Linux out there 😄

@galvesribeiro
Copy link
Author

I don't understood @mattleibow... How am I suppose to use that to build for armv6? Our device is an embedded ARMv6 device running Linux...

@galvesribeiro
Copy link
Author

@mattleibow sorry for the dumb questions but I'm not familiar with those build scripts... I wonder how can we use our ARMv6 toolchain to build that for it...

@mattleibow
Copy link
Contributor

@galvesribeiro I understand. As you are running Linux, the current build script is not going to help, but you can check this out until I manage to get it all going: https://skia.org/user/quick/linux That is what I will look at first, but you probably did already.

I haven't looked at this, but you could set the skia_arch_type='arm'. This might just wok as I see this comment:

# The code in SkUtilsArm.cpp can be used on an ARM-based Linux system, not only Android.

@galvesribeiro
Copy link
Author

@mattleibow any update on that?

@JimSEOW
Copy link

JimSEOW commented Jul 14, 2017

Now the latest Windows IoT Core supports ARMv7 212 Snapdragon? What need to be done to have UWP SkiaSharp support for this CPU?

@mattleibow
Copy link
Contributor

I may be wrong, but the UWP already supports ARM? Have you been able to run it at all?

@JimSEOW
Copy link

JimSEOW commented Jul 14, 2017

@mattleibow I will give it a try. thx

@galvesribeiro
Copy link
Author

Hello folks.

Are we able now to build on linux using our own toolchains and those build scripts? I tried to follow https://github.com/mono/SkiaSharp/wiki/Building-on-Linux without success. It looks like all the variables passed are being ignored (even thought I see the build script printing the variables there). I've set the following:

GYP_DEFINES='skia_gpu=0 skia_pdf= skia_os=linux skia_arch_type=arm' SK_SUPPORT_PDF=0 ./bootstrapper.sh -t everything --host=$CROSS

As I'm following the build output, it is building with GPU support :(

It looks like it is ignoring the GYP_DEFINES and also, doesn't take in consideration the --host which should set the prefix for the compiler (in this case my cross-compiler).

I think I'll have to do all that hackerish we did before, again, @mattleibow :(

@mattleibow
Copy link
Contributor

the same comment from the other issue:

@galvesribeiro The new version no longer uses gyp, but gn instead. You can check out what I am doing here: https://github.com/mono/SkiaSharp/blob/master/cake/BuildExternals.cake#L715

What I really now do is just build Linux as Google specifies as a static archive, and then I create a dynamic library that links out everything except what SkiaSharp uses - ie: just the public C API is preserved.

@mattleibow
Copy link
Contributor

As Google has dropped support for gyp, and switched over to gn, there is nothing I can really do to get the old build process working. In fact, the later version are removing all traces of the old gyp system.

@galvesribeiro
Copy link
Author

I know, check my PM on gitter when you find some time.

@mattleibow
Copy link
Contributor

mattleibow commented Feb 21, 2018

Just asking this question in multiple places:

Right now I have a x64 build for Linux that was compiled on Ubuntu 14.04. I am thinking of adding a few more to help the average dev use SkiaSharp without having to build their own. What other distros or CPUs would be helpful?

Leave a comment on this issue and track progress: #453

@mattleibow
Copy link
Contributor

To make life easier for everyone, I moved code around and added a new target to the GN files. Now, the native libSkiaSharp build is done with GN and ninja directly: https://github.com/mono/SkiaSharp/wiki/Building-on-Linux

@mattleibow
Copy link
Contributor

Closing this issue as the Linux topic is getting a bit duplicated.

mattleibow pushed a commit that referenced this issue Jun 11, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Aug 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants