How to build Skia with limited features/third-party libs?

836 views
Skip to first unread message

Jona

unread,
Mar 8, 2016, 4:35:21 PM3/8/16
to skia-discuss
I'm looking to build Skia lib for Android and iOS using minimum features. Mainly disable various third-party libraries. All I need is the PNG codec and all the other features just makes my binary too big. Looking at the build script and the code structure it seems like this would be possible...

Hal Canary

unread,
Mar 8, 2016, 4:45:47 PM3/8/16
to skia-discuss
Are you using Gyp or Cmake to build Skia?

On Tue, Mar 8, 2016 at 4:35 PM, Jona <medica...@gmail.com> wrote:
I'm looking to build Skia lib for Android and iOS using minimum features. Mainly disable various third-party libraries. All I need is the PNG codec and all the other features just makes my binary too big. Looking at the build script and the code structure it seems like this would be possible...

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Jona

unread,
Mar 8, 2016, 4:50:30 PM3/8/16
to skia-discuss
I been using Gyp.

Hal Canary

unread,
Mar 8, 2016, 5:07:36 PM3/8/16
to skia-discuss
One think I know you can turn off is:

    export GYP_DEFINES='skia_pdf=0'

There are probably more such flags in gyp/common_variables.gyp

On Tue, Mar 8, 2016 at 4:50 PM, Jona <medica...@gmail.com> wrote:
I been using Gyp.

Jona

unread,
Mar 9, 2016, 9:26:36 AM3/9/16
to skia-discuss
I tried using the variable as you provided for Android but didn't seem to work. The binary is the same size and some errors building the sample app.

--- SCRIPT ---

export GYP_DEFINES='skia_pdf=0'
./platform_tools/android/bin/android_ninja -d nexus_5

-----

I looked over the GYP files and I see there is only nopdf option. Other libs like jpeg, gif, v8 and others don't have the option to disable. :/ 

Somewhat related question. Is there a way to just build skia lib for android instead of having to build the entire sample app?

Mike Klein

unread,
Mar 9, 2016, 9:38:23 AM3/9/16
to skia-discuss
You can limit the targets you build by passing their names to Ninja.  I think you're looking for skia_lib.

Skia's GYP files are mostly arranged for our own testing convenience.  Skia's major users integrate Skia into their builds in their own custom idiosyncratic ways.

We've been toying with a CMake-based build system to produce a single libskia.{so,dll,dylib} suitable for people to actually use, but to date I don't think we've tried cross-compiling for Android.  If you're familiar with CMake, have a look at the cmake/ directory; we're testing that Linux and Mac builds work, and building on Windows worked at least at one point.

--

Jona

unread,
Mar 9, 2016, 10:58:34 AM3/9/16
to skia-discuss
Interesting... I might have to continue build Skia as I been doing it for now simply do to time constraints... However, looking at GYP, CMake, and xcode project modules I'm almost enticed to build the individual modules for Android using Android.mk. 

Before trying to create my own custom build scripts was the Skia lib written with the ability to exclude third-party libs? Or would I need to comment out code in the project? My ideal solution is simply build scripts without touching the source.

Jona

unread,
Mar 9, 2016, 11:00:23 AM3/9/16
to skia-discuss
Oh and I'm not sure I understand this: "You can limit the targets you build by passing their names to Ninja.  I think you're looking for skia_lib." Could you show me an example for doing this?

Mike Klein

unread,
Mar 9, 2016, 11:13:07 AM3/9/16
to skia-discuss
If you're sticking to what's currently available to you without doing much work, I would do this:

$ env CPPFLAGS="-g0" platform_tools/android/bin/android_ninja -t Release -d arm_v7_neon skia_lib
$ ls -l -h out/config/android-arm_v7_neon/Release/lib/libskia_android.so
-rwxr-xr-x  1 mtklein  staff   7.1M Mar  9 11:08 out/config/android-arm_v7_neon/Release/lib/libskia_android.so

On Wed, Mar 9, 2016 at 11:00 AM Jona <medica...@gmail.com> wrote:
Oh and I'm not sure I understand this: "You can limit the targets you build by passing their names to Ninja.  I think you're looking for skia_lib." Could you show me an example for doing this?

--

Jona

unread,
Mar 9, 2016, 5:19:46 PM3/9/16
to skia-discuss
Thanks Mike. Your post is actually very useful! :)

I hope you guys can make skia a bit more customizable when being built. Kinda like ffmpeg type of project.

Jona

unread,
Mar 14, 2016, 3:12:40 PM3/14/16
to skia-discuss
Hey Mike,

I'm having issues with your suggestion. I'm getting errors when trying to use the Release compiled library. However, with Debug everything is working fine. Could this be a bug on the build system or something I'm doing incorrectly?

Using this build on my project works perfect:
./platform_tools/android/bin/android_ninja -d nexus_5 skia_lib 

Using this build on my project doen't work and gives me errors:
./platform_tools/android/bin/android_ninja -t Release -d nexus_5 skia_lib

LOGS

/Developer/git/flipaclip-core/android/FcLibProject/fclib/src/main/jni/../../../../../../third_party/skia/include/core/SkString.h:39: error: undefined reference to 'SkToS32(long long)'

/Developer/git/flipaclip-core/android/FcLibProject/fclib/src/main/jni/../../../../../../third_party/skia/include/core/SkString.h:45: error: undefined reference to 'SkToS32(long long)'

/Developer/git/flipaclip-core/android/FcLibProject/fclib/src/main/jni/../../../../../../third_party/skia/include/core/SkString.h:39: error: undefined reference to 'SkToS32(long long)'

/Developer/git/flipaclip-core/android/FcLibProject/fclib/src/main/jni/../../../../../../third_party/skia/include/core/SkString.h:45: error: undefined reference to 'SkToS32(long long)'

/Developer/git/flipaclip-core/android/FcLibProject/fclib/src/main/jni/../../../../../../third_party/skia/include/core/SkPathRef.h:223: error: undefined reference to 'SkPathRef::validate() const'

/Developer/git/flipaclip-core/android/FcLibProject/fclib/src/main/jni/../../../../../../third_party/skia/include/core/SkPathRef.h:240: error: undefined reference to 'SkPathRef::validate() const'

/Developer/git/flipaclip-core/android/FcLibProject/fclib/src/main/jni/../../../../../../third_party/skia/include/core/SkPathRef.h:324: error: undefined reference to 'SkPathRef::validate() const'

collect2: error: ld returned 1 exit status

Jose Cruz

unread,
Mar 15, 2016, 2:59:07 PM3/15/16
to skia-discuss
Are those errors coming from skia's build output or from your project's build output?  If it's coming from your project then you need to make sure either "NDEBUG" or "SK_RELEASE" is defined when compiling your sources and linking against skia release builds.

Jona

unread,
Mar 15, 2016, 3:26:02 PM3/15/16
to skia-discuss
Build output was from my project. Thanks for the info! I will try that out.
Reply all
Reply to author
Forward
0 new messages