Android generator includes non-existent base_rules.mk in .mk for targets of type none

241 views
Skip to first unread message

callo...@artspark.co.jp

unread,
Dec 4, 2014, 3:23:20 AM12/4/14
to gyp-de...@googlegroups.com
I am adding GYP generation of Android projects(?) to a project. 2 of my targets are of type: none. The generated .mk files for these targets include $(BUILD_SYSTEM)/base_rules.mk but there is no base_rules.mk in the NDK. I have looked at version 8, 9 & 10.

From what I have found searching the net, this file is part of the Android build tools. I'd much prefer to use the standard NDK. Is there an equivalent in NDK? Is there a way to stop GYP from using this file?

I actually can't see much point to these .mk files. They just generate a file called gyp_stamp. The ldflags and includes exported from these type: none  GYP targets are added in myapp.target.mk. What is the purpose of creating gyp_stamp? Can I just delete these files from GypAndroid.mk?

Torne (Richard Coles)

unread,
Dec 4, 2014, 5:14:33 AM12/4/14
to callo...@artspark.co.jp, gyp-developer


On 4 Dec 2014 8:23 am, <callo...@artspark.co.jp> wrote:
>
> I am adding GYP generation of Android projects(?) to a project.

Don't do this. :)

The android backend for gyp is buggy, weird and only supports the absolute minimum functionality to be able to build the chromium webview. I plan to drop support for it entirely and remove it from gyp in the next month or two.

> 2 of my targets are of type: none. The generated .mk files for these targets include $(BUILD_SYSTEM)/base_rules.mk but there is no base_rules.mk in the NDK. I have looked at version 8, 9 & 10.
>
> From what I have found searching the net, this file is part of the Android build tools. I'd much prefer to use the standard NDK. Is there an equivalent in NDK? Is there a way to stop GYP from using this file?

The android generator is not intended for use with ndk-build and you will experience many other issues as well, not just this one. ndk-build is a weird fork of an ancient version of the AOSP build system. The android generator requires numerous very recent changes to AOSP to work correctly. The only reason to use the android generator is to integrate your code as part of the android OS build; if you are using the NDK, you don't need to suffer this much :)

ndk-build is not a particularly good build system; it's meant as a quick way for a Java project to include a small amount of JNI code and is not recommended for building existing native code projects. You don't need to use it to build with the NDK; you can use any build system you like (e.g. you could generate ninja files with gyp) as the NDK's toolchain and headers are easily reusable. Chrome for Android is built using gyp and ninja with the NDK toolchain and headers. The NDK's included documentation talks about how to use the toolchain separately.

> I actually can't see much point to these .mk files. They just generate a file called gyp_stamp. The ldflags and includes exported from these type: none  GYP targets are added in myapp.target.mk. What is the purpose of creating gyp_stamp? Can I just delete these files from GypAndroid.mk?

No, these are needed to express the correct ordering between dependent gyp targets.

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

callo...@artspark.co.jp

unread,
Dec 4, 2014, 5:35:47 AM12/4/14
to gyp-de...@googlegroups.com, callo...@artspark.co.jp
 
On Thursday, 4 December 2014 19:14:33 UTC+9, Torne (Richard Coles) wrote:


Don't do this. :)

The android backend for gyp is buggy, weird and only supports the absolute minimum functionality to be able to build the chromium webview. I plan to drop support for it entirely and remove it from gyp in the next month or two.

Thanks for the heads-up and the useful information.

What I really want to do is generate an Eclipse project so we can use an IDE when debugging on Android. Can I generate standard makefiles using the native tools in the NDK and link an Eclipse project to those makefiles for it to use to rebuild the native part?  Since I will have only a single Java file, I'm okay with generating the Eclipse project by hand and linking it to the generated make files. Possible? I suppose that is what those eclipse_cdt_settings.xml files, that are generated by the eclipse generator, are for.

Will there eventually be a generator for the new AndroidStudio?

Torne (Richard Coles)

unread,
Dec 4, 2014, 5:58:24 AM12/4/14
to callo...@artspark.co.jp, gyp-developer
On 4 December 2014 at 10:35, <callo...@artspark.co.jp> wrote:
 
On Thursday, 4 December 2014 19:14:33 UTC+9, Torne (Richard Coles) wrote:


Don't do this. :)

The android backend for gyp is buggy, weird and only supports the absolute minimum functionality to be able to build the chromium webview. I plan to drop support for it entirely and remove it from gyp in the next month or two.

Thanks for the heads-up and the useful information.

What I really want to do is generate an Eclipse project so we can use an IDE when debugging on Android. Can I generate standard makefiles using the native tools in the NDK and link an Eclipse project to those makefiles for it to use to rebuild the native part? 

There is a make backend for gyp, but it's not used by the chromium project any more, and so it doesn't get as much use or testing as the ninja backend. If you have a gyp-based project, I suggest you generate ninja files and define a custom build step in Eclipse which invokes ninja; this will be much better supported in the long term. Eclipse should be able to develop/debug native code no matter what build system is actually used (in fact, the build need not even take place inside eclipse; eclipse's native code debugger is just using gdb underneath and so as long as the binary you are debugging has full symbol information and you have all the source code available it should work fine).
 
Since I will have only a single Java file, I'm okay with generating the Eclipse project by hand and linking it to the generated make files. Possible? I suppose that is what those eclipse_cdt_settings.xml files, that are generated by the eclipse generator, are for.

The eclipse generator is not really supported and doesn't generate any actual makefiles; all it does is make lists of source files, include paths, and preprocessor definitions from the gyp files which can be used to create an Eclipse CDT project so that source code browsing, crossreferences, etc will work. You can't actually build the code this way; it's just to make the IDE aware of which macros are defined and so on for a more comfortable editing experience. It doesn't set up any link to an actual build system.

Will there eventually be a generator for the new AndroidStudio?

I doubt it. Android Studio doesn't currently support native code development at all, and most gyp developers tend to work only on things that are used by chromium. If the IDE actually gains equivalent native code editing/debugging facilities to Eclipse then someone might write a generator similar to the current eclipse generator, but again it probably won't work to actually build the code, only for source code browsing.

Chromium is such a massive project that IDEs generally do a very bad job dealing with it, and only the ninja build is fast enough for most developers, so the vast majority of gyp usage only uses the ninja backend.

--
Torne (Richard Coles)
to...@google.com

callo...@artspark.co.jp

unread,
Dec 7, 2014, 8:59:49 PM12/7/14
to gyp-de...@googlegroups.com, callo...@artspark.co.jp
Thanks Richard for the amazingly helpful information and preventing me wasting time pursuing the android & eclipse generators. I will try make or ninja as you suggest.

Reply all
Reply to author
Forward
0 new messages