-
Notifications
You must be signed in to change notification settings - Fork 263
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
Supplying per-file compiler flags #164
Comments
Does objs/local/%/objs-debug/main/file1.o: LOCAL_CPPFLAGS += -DFILE1_DEFINE work? |
No. I have the following setup:
file2.cpp
I tried your example, but it still fails, because the define is missing. Even when I specify armeabi-v7a instead of %.
The method of printing:
(When I try to use |
The way to do this in Note that you can do what you described with cmake: http://stackoverflow.com/a/13639476/632035 |
Rather than "wontfix", let's keep this open in unplanned. I don't think any of us will get to this any time soon, but if cmake fails to take over then we may want to reconsider that. |
So as you labeled the issue with "help wanted" I decided to make some progress for it. I added a new function, that makes a request to the developer to specify the "per-file-flags" for the current source:
This creates a new dependency on a target named
The The function sould be called in definitions.mk, before the build command is executed. This solution adds the following command line argument to the build command:
This is fixed in definitions.mk in 4 places. |
First, thanks for looking in to this :) I don't think this is how we want to present this option to the user. It doesn't match with the rest of the Android.mk language. Instead of FLAGS_path/to/my/file.cpp:
$(eval PER_FILE_FLAGS_$@ := -DFILE1_DEFINE) I was thinking this would take the form of LOCAL_CFLAGS_filename.cpp :+= -Dfoo One thing to remember here is that it will need to support This is also going to require a test. You'll need to check out the NDK to run the tests: https://android.googlesource.com/platform/ndk/ (the README.md there should get you started, also note the link at the top pointing at our testing docs). Only a build test is needed here; a device test wouldn't add any additional value. You should be able to clone just that project to run the tests against your locally modified NDK (i.e. you shouldn't need to do the |
Thanks, I'll have a look at it soon. |
Whoops, thought I replied to this.
|
Some while ago, I published a hack that seems to work until r16. This, for example, will define t_DEFINE and qq_DEFINE, respectively:
|
Taking inspiration from @Sipkab above I edited the 'ndk-bundle\build\core\definitions.mk' file in the NDK as follows: Find the following code and add this line:
Like so:
Do the same for the CPP (define ev-compile-cpp-source) a bit further down. Now in your Android.mk file you can add extra flags like so: (source name)_CFLAGS := -DMY_DEFINE e.g:
Forward slash path separators are turned into underscores:
|
https://stackoverflow.com/questions/7679363/android-build-system-neon-and-non-neon-builds |
@mm-longcheng: it seems that this old trick of mine still works in r17! |
This is probably going to sound awful, but the work-arounds are awful. None of them scale the way we need them to when converting/porting a makefile like In our regular makefile, we have recipes like the following.
Notice we don't have to build separate static libraries or jump through other hoops. (I do have to use the static library trick in Autotools. It does not scale.) Since the user owns
If Android supplies its flags in Or maybe better, allow us to drop this in our
|
@noloader what's wrong with the following? This can be generated from your GNUmakefile easily:
|
I doubt this is something we'll ever do. There doesn't seem to be much demand for it, and understandably so (if you need it, that's probably a symptom of a different problem or a different missing feature). If something changes that makes this worth adding we can reopen, but for now I'm closing. |
Missing feature
It is currently very hackish, to add per-file compiler flags using the Android.mk makefile.
Consider the following scenario:
Hackish solution
There's no public API for doing this, and it could be useful in the future releases.
At the moment, it could be done like this, but upcoming versions can break it:
(the solution was created by examining definitions.mk, and creating these targets in Android.mk)
Proposed Solution
This problem could be solved, if the build targets would depend on some phony targets, like the following:
And in the Android.mk:
This way the developer could supply different flags for different architectures, and-or common flags for all the architectures.
(The targets have the format FLAGS_arch_path/to/object/file.o)
The text was updated successfully, but these errors were encountered: