Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8520943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:40:30+00:00 2026-06-11T06:40:30+00:00

In Android NDK, I build JNI files generated automatically by SWIG. callmanager_wrap.cpp is part

  • 0

In Android NDK, I build JNI files generated automatically by SWIG. callmanager_wrap.cpp is part of a shared library:

LOCAL_SRC_FILES += callmanager_wrap.cpp
include $(BUILD_SHARED_LIBRARY)

But I would like to append/edit callmanager_wrap.cpp before compiling. To be more explicit:

cat jnistuff.txt >> callmanager_wrap.cpp

Content I need to add is known in advance but callmanager_wrap.cpp is not. It is generated by SWIG. Ultimately, my custom rule will have to run following command to generate callmanager_wrap.cpp:

swig -c++ -java -package com.package.my -o callmanager_wrap.cpp callmanager.i

According to this post, it is not possible to add custom rules to Android.mk. But in Android sources, I believe there are some Android.mk handling steps after BUILT or INSTALLED. I tried the following:

MY_JNI_WRAP=callmanager_wrap.cpp

include $(CLEAR_VARS)

LOCAL_SRC_FILES += callmanager_wrap.cpp

LOCAL_INTERMEDIATE_TARGETS += myjni
myjni:
    echo "in myjni target"
    swig -c++ -java -package com.package.my -o $(MY_JNI_WRAP) callmanager.i
    cat jnistuff.txt >> $(MY_JNI_WRAP)

include $(BUILD_SHARED_LIBRARY)

But myjni target is never called.

  1. What is LOCAL_INTERMEDIATE_TARGETS used for?
  2. Can I possibly achieve what I want to do here without writing an external script or makefile?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:40:31+00:00Added an answer on June 11, 2026 at 6:40 am

    I would suggest the following:

    include $(CLEAR_VARS)
    
    LOCAL_SRC_FILES += callmanager_wrap.cpp
    MY_JNI_WRAP := $(LOCAL_PATH)/callmanager_wrap.cpp
    
    $(MY_JNI_WRAP):
        echo "in myjni target"
        swig -c++ -java -package com.package.my -o $(MY_JNI_WRAP) callmanager.i
        cat jnistuff.txt >> $(MY_JNI_WRAP)
    .PHONY: $(MY_JNI_WRAP)
    
    include $(BUILD_SHARED_LIBRARY)
    

    That’s it.

    I probably owe you some explanations. So here we go:

    1. $(LOCAL_SRC_FILES) is a list of file names relative to $(LOCAL_PATH), so to address a file from outside the standard NDK actions, you need the full path for your file, which is $(LOCAL_PATH)/callmanager_wrap.cpp.

    2. We specify the file as .PHONY to guarantee that the custom action is executed every time you run ndk-build. But if you know which are actual dependencies of callmanager_wrap.cpp, you can specify them instead, like

      $(MY_JNI_WRAP): callmanager.i jnistuff.txt $(LOCAL_PATH)/../src/com/package/my/Something.java

      In this case, you will not need the .PHONY line.

    3. If you want your source directory to remain clean, you can declare the wrapper file as .INTERMEDIATE like this:

      .INTERMEDIATE: $(MY_JNI_WRAP)

    Now make will delete the wrapper file after build, if it did not exist before the build.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android JNI project I'd like to compile with ndk-build . The
I am following the steps on http://developer.android.com/sdk/ndk/overview.html to build the hello-jni sample, however when
I try to build my project. but, it gives error: C:\svn\my-ndk-project>c:\development\android-ndk-r8\ndk-build.cmd SharedLibrary : libsprat-jni.so
I'm using the Android NDK to build a library. I had everything working well,
I am trying to compile the following for the android ndk #include <jni.h> #include
I'm building a C library we have using the Android NDK build chain. Things
I build PHP for android using the NDK. Most functions tested so far run
i want to build my android project with ndk so i created my make
I'm beginning with android NDK. I have to compile a native library for the
How can I build libsdl using the Android NDK's standalone toolchain? I can't use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.