@@ -44,20 +44,22 @@ LOCAL_CLANG := false
4444# Android only provides a 32bit version of python.
4545LOCAL_32_BIT_ONLY := true
4646
47- LOCAL_SHARED_LIBRARIES := libparameter_host
48- LOCAL_STATIC_LIBRARIES := libxmlserializer_host
47+ LOCAL_SHARED_LIBRARIES := libxmlserializer_host libparameter_host
48+
49+ # python is only available in 32bits for now, thus arch is forced to 32bits
50+ PYTHON_INSTALL_PATH := prebuilts/python/$(HOST_OS ) -x86/2.7.5/
51+ PYTHON_INCLUDES_PATH := $(PYTHON_INSTALL_PATH ) /include/python2.7
52+ PYTHON_BIN_PATH := $(PYTHON_INSTALL_PATH ) /bin
4953
5054LOCAL_C_INCLUDES := \
51- prebuilts/python/linux-x86/2.7.5/include/python2.7 \
55+ $( PYTHON_INCLUDES_PATH ) \
5256 $(HOST_OUT_HEADERS ) /parameter
5357
54- # The 'unused-but-set-variable' warning must be disabled because SWIG generates
55- # files that do not respect that constraint.
5658# '-DSWIG_PYTHON_SILENT_MEMLEAK' is needed because the "memleak" warning
5759# pollutes the standard output. At the time of writing, the only warning is
5860# spurious anyway, as it relates to "ILogger *" which is an abstract
5961# class/interface class and as such cannot be destroyed.
60- LOCAL_CFLAGS := -Wno-unused-but-set-variable - fexceptions -DSWIG_PYTHON_SILENT_MEMLEAK
62+ LOCAL_CFLAGS := -fexceptions -DSWIG_PYTHON_SILENT_MEMLEAK
6163
6264# Undefined symbols will be resolved at runtime
6365LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
@@ -74,6 +76,26 @@ LOCAL_GENERATED_SOURCES := $(generated-sources-dir)/pfw_wrap.cxx $(generated-sou
7476
7577LOCAL_EXPORT_C_INCLUDE_DIRS := $(generated-sources-dir )
7678
79+ # Get the interpreter ld options.
80+ ifeq ($(HOST_OS ) , darwin)
81+ # Contrary to linux, on darwin, a python 64 bit executable is installed
82+ # in the x86 prebuild directory,
83+ # As all host libraries are 32 bit in android. We can not link and host
84+ # python module against the prebuild python library.
85+ #
86+ # As a *dirty* workaround, use the system's python configuration and hope
87+ # it will be compatible with the prebuild python interpreter used at runtime.
88+ # To summarize the prebuild python (64 bit?) interpreter will load a
89+ # python native module (32bit) linked with the host (32 bit ?) python library.
90+ LOCAL_LDLIBS += $(shell python-config --ldflags)
91+ else
92+ # Careful, we need to invoke the android python config not the host's one.
93+ # Unfortunately, the internal install directory of python is hardcoded to a dummy value,
94+ # As a workaround, we need to manually add the correct path to libs to the library list.
95+ LOCAL_LDLIBS += $(shell $(PYTHON_BIN_PATH ) /python $(PYTHON_BIN_PATH ) /python-config --ldflags) \
96+ -L $(PYTHON_INSTALL_PATH ) /lib/
97+ endif
98+
7799$(generated-sources-dir ) /pfw_wrap.h : $(generated-sources-dir ) /pfw_wrap.cxx
78100
79101# The PyPfw.py file is generated in the directory given by -outdir switch, thus
@@ -82,7 +104,7 @@ $(generated-sources-dir)/pfw_wrap.cxx: $(LOCAL_PATH)/pfw.i
82104 @echo " Generating Python binding files"
83105 mkdir -p $(dir $@ ) # surprisingly, path is not generated by build system
84106 mkdir -p $(HOST_LIBRARY_PATH )
85- prebuilts/misc/linux-x86_64 /swig/swig \
107+ prebuilts/misc/$( HOST_OS ) - $( HOST_ARCH ) /swig/swig \
86108 -Iprebuilts/misc/common/swig/include/2.0.11/python/ \
87109 -Iprebuilts/misc/common/swig/include/2.0.11/ \
88110 -Wall -Werror -v -python -c++ -outdir $(HOST_LIBRARY_PATH ) / -o $@ $^
0 commit comments