0

I use swig from my within Android.mk. I reference it directly relying on the $PATH variable to contain the path to it's executable.

The issue is that the $PATH variable is different depending on where the android-ndk tool is run from.

Background

In my Android.mk file:

# some stuff ...
@echo "$(PATH)"
swig # swig parameters here...
# more stuff ...

From the terminal, we see the system path includes the path to swig:

which swig
/usr/local/bin/swig
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:

Issue

When the android-ndk is run from within Android Studio I get the following for PATH (note: it's missing the swig path):

/usr/bin:/bin:/usr/sbin:/sbin

This causes my build to fail because "swig" isn't recognised:

make: swig: Command not found

However, if I run the android-ndk directly from the terminal, then the PATH used is the same as my system path and the build works fine:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:

Bad solution

Yes, I could add the path manually to my Android.mk file:

export PATH:=/usr/local/bin/:$(PATH)

However, I'd prefer not to define specific paths for my machine knowing that the whole team uses this file.

Question

I'd prefer the Android.mk file to use my systems PATH instead.

Any ideas how to do this?

Thanks!

Jon Bryant
  • 205
  • 2
  • 12

1 Answers1

0

The thing in my opinion is that environment variables may be different whether the process is launched from terminal or from the GUI (launchpad, spotlight, ...).

The former would use PATH as set in bashrc (or other shell related startup files) while the other will not.

I think you might find interesting information on how to change the environment variables for the launch deamon in the following question:

Setting environment variables in OS X?

Community
  • 1
  • 1
Lagf
  • 113
  • 11