AI 149005: Change from ndk to platform's ndk (pndk), the ability to make your own java callable libraries to c code.
BUG=1857858 Automated import of CL 149005
This commit is contained in:
committed by
The Android Open Source Project
parent
c3c7479ab6
commit
429fbd82d8
12
pdk/Pdk.mk
12
pdk/Pdk.mk
@@ -15,12 +15,12 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Assemble the Platform Development Kit (PDK)
|
# Assemble the Platform Development Kit (PDK)
|
||||||
# (TODO) Figure out why $(ACP) builds with target ndk but not pdk_docs
|
# (TODO) Figure out why $(ACP) builds with target pndk but not pdk_docs
|
||||||
|
|
||||||
pdk:
|
pdk:
|
||||||
@echo "Package: $@ has targets ndk, pdk_docs and pdk_all"
|
@echo "Package: $@ has targets pndk, pdk_docs and pdk_all"
|
||||||
|
|
||||||
pdk_all: ndk pdk_docs
|
pdk_all: pndk pdk_docs
|
||||||
@echo "Package: $^"
|
@echo "Package: $^"
|
||||||
|
|
||||||
LOCAL_PATH := $(call my-dir)
|
LOCAL_PATH := $(call my-dir)
|
||||||
@@ -28,8 +28,8 @@ LOCAL_PATH := $(call my-dir)
|
|||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Make the Native Development Kit (Code examples)
|
# Make the Native Development Kit (Code examples)
|
||||||
# Allows vendors to build shared libraries without entire source tree.
|
# Allows vendors to build shared libraries without entire source tree.
|
||||||
# This include adds /ndk to LOCAL_PATH, so can't use it afterwards...
|
# This include adds /pndk to LOCAL_PATH, so can't use it afterwards...
|
||||||
include $(LOCAL_PATH)/ndk/Ndk.mk
|
include $(LOCAL_PATH)/pndk/Pndk.mk
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@@ -180,7 +180,7 @@ $(LOCAL_PATH)/pdk-timestamp: $(pdk_docs_intermediates)/pdk-timestamp
|
|||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_SRC_FILES := pdk-timestamp samples/samplejni/src/com/example/jniexample/JNIExample.java
|
LOCAL_SRC_FILES := pdk-timestamp samples/samplejni/src/com/example/jniexample/JNIExample.java
|
||||||
LOCAL_MODULE_CLASS := development/pdk/ndk/samples/samplejni/src/com/example/jniexample
|
LOCAL_MODULE_CLASS := development/pdk/pndk/samples/samplejni/src/com/example/jniexample
|
||||||
LOCAL_DROIDDOC_SOURCE_PATH := $(framework_docs_LOCAL_DROIDDOC_SOURCE_PATH)
|
LOCAL_DROIDDOC_SOURCE_PATH := $(framework_docs_LOCAL_DROIDDOC_SOURCE_PATH)
|
||||||
LOCAL_DROIDDOC_HTML_DIR := ../../../$(pdk_app_eng_root)
|
LOCAL_DROIDDOC_HTML_DIR := ../../../$(pdk_app_eng_root)
|
||||||
|
|
||||||
|
|||||||
12
pdk/README
12
pdk/README
@@ -28,7 +28,7 @@ then build everything:
|
|||||||
so you can have a record of the build commands in the logs directory.
|
so you can have a record of the build commands in the logs directory.
|
||||||
|
|
||||||
|
|
||||||
5) the pdk and ndk tar file is put in the dist directory.
|
5) the pdk and pndk tar file is put in the dist directory.
|
||||||
|
|
||||||
6) the pdk-docs are in
|
6) the pdk-docs are in
|
||||||
|
|
||||||
@@ -38,10 +38,10 @@ so you can have a record of the build commands in the logs directory.
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Build Notes
|
# Build Notes
|
||||||
|
|
||||||
The build target 'pdk' brings in the pdk/ndk make files into the build system.
|
The build target 'pdk' brings in the pdk/pndk make files into the build system.
|
||||||
Then there are three targets:
|
Then there are three targets:
|
||||||
pdk_docs - which builds just the pdk documentation
|
pdk_docs - which builds just the pdk documentation
|
||||||
ndk - which builds the native development kit (native compiler, linker, etc.)
|
pndk - which builds the platform's native development kit (native compiler, linker, etc.)
|
||||||
pdk_all - which builds the above two targets
|
pdk_all - which builds the above two targets
|
||||||
|
|
||||||
To change which version of doxygen runs you can pass in the variable:
|
To change which version of doxygen runs you can pass in the variable:
|
||||||
@@ -90,13 +90,13 @@ To add port forwarding
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Deployment
|
# Deployment
|
||||||
|
|
||||||
To host the pdk docs on the interanl appengine run:
|
To host the pdk docs on the internal appengine run:
|
||||||
/home/build/static/projects/apphosting/devtools/appcfg.py update <path_to_cupcake_src>/out/common/docs
|
/home/build/static/projects/apphosting/devtools/appcfg.py update <path_to_cupcake_src>/out/target/common/docs
|
||||||
where the docs directory contains: pdk.py, app.yaml, and the online-pdk directory,
|
where the docs directory contains: pdk.py, app.yaml, and the online-pdk directory,
|
||||||
all of which are tarred up by the Pdk.mk file when using the target pdk_docs.
|
all of which are tarred up by the Pdk.mk file when using the target pdk_docs.
|
||||||
|
|
||||||
To host the pdk docs on the external appengine run:
|
To host the pdk docs on the external appengine run:
|
||||||
/home/build/static/projects/apphosting/devtools/appcfg.py -s pdk-docs.appspot.com update <path_to_cupcake_src>/out/common/docs
|
/home/build/static/projects/apphosting/devtools/appcfg.py -s pdk-docs.appspot.com update <path_to_cupcake_src>/out/target/common/docs
|
||||||
where the docs directory contains: pdk.py, app.yaml, and the online-pdk directory,
|
where the docs directory contains: pdk.py, app.yaml, and the online-pdk directory,
|
||||||
all of which are tarred up by the Pdk.mk file when using the target pdk_docs.
|
all of which are tarred up by the Pdk.mk file when using the target pdk_docs.
|
||||||
|
|
||||||
|
|||||||
232
pdk/ndk/Ndk.mk
232
pdk/ndk/Ndk.mk
@@ -1,232 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (C) 2008 The Android Open Source Project
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Assemble the Native Development Kit
|
|
||||||
# Assembled using the generic build by default.
|
|
||||||
# (set in device/config/product_config.make)
|
|
||||||
|
|
||||||
# A macro to make rules to copy all newer files in a directory tree matching an
|
|
||||||
# optional find filter and add the files to a list variable for dependencies.
|
|
||||||
# Designed after copy_headers.make: Create a rule to copy each file;
|
|
||||||
# copy-one-file defines the actual rule.
|
|
||||||
# $(1): source directory tree root
|
|
||||||
# $(2): destination directory tree root
|
|
||||||
# $(3): list variable to append destination files to
|
|
||||||
# $(4): optional find(1) arguments
|
|
||||||
define define-tree-copy-rules
|
|
||||||
$(eval _src_files := $(shell find $(1) -type f $(4))) \
|
|
||||||
$(foreach _src, $(_src_files), \
|
|
||||||
$(eval _dest := $(patsubst $(1)%,$(2)%,$(_src))) \
|
|
||||||
$(eval $(3) := $($(3)) $(_dest)) \
|
|
||||||
$(eval $(call copy-one-file,$(_src),$(_dest))) \
|
|
||||||
)
|
|
||||||
endef
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# Install all the files needed to build the ndk.
|
|
||||||
# We build three versions of the NDK
|
|
||||||
# (1) The full version, with source.
|
|
||||||
# (2) The full version, without source.
|
|
||||||
# (3) A JNI-only version, with source.
|
|
||||||
#
|
|
||||||
# We make five sets of trees:
|
|
||||||
# (A) Common files used in all versions of the NDK
|
|
||||||
# (B) Common files used in the full versions of the NDK
|
|
||||||
# (C) Files used in the standard ndk (no source files included)
|
|
||||||
# (D) Files used in both the JNI-only and full-with-source version
|
|
||||||
# (E) Files used in just the full-with-source version
|
|
||||||
#
|
|
||||||
# Each NDK version is created by combining the appropriate trees:
|
|
||||||
#
|
|
||||||
# (A) (B) (C) (D) (E)
|
|
||||||
# (1) yes yes yes yes
|
|
||||||
# (2) yes yes yes
|
|
||||||
# (3) yes yes
|
|
||||||
#
|
|
||||||
# Source is provided for partners who want to recompile our libraries for optimization.
|
|
||||||
# The JNI-only version is provided for partners that want to create shared
|
|
||||||
# libraries that can be packaged with APK files and called from Java code.
|
|
||||||
|
|
||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
|
|
||||||
# Source trees for the ndk
|
|
||||||
samples_src_dir := $(LOCAL_PATH)/samples
|
|
||||||
sample_src_dir := $(samples_src_dir)/sample
|
|
||||||
samplejni_src_dir := $(samples_src_dir)/samplejni
|
|
||||||
config_src_dir := $(LOCAL_PATH)/config
|
|
||||||
kernel_common_src_dir := $(KERNEL_HEADERS_COMMON)
|
|
||||||
kernel_arch_src_dir := $(KERNEL_HEADERS_ARCH)
|
|
||||||
bionic_src_dir := bionic
|
|
||||||
jni_src_dir := $(JNI_H_INCLUDE)
|
|
||||||
|
|
||||||
# Workspace directory
|
|
||||||
ndk_intermediates := $(call intermediates-dir-for,PACKAGING,ndk)
|
|
||||||
|
|
||||||
# Common destination trees for the ndk
|
|
||||||
ndk_common_tree := $(ndk_intermediates)/common
|
|
||||||
ndk_common_dest_dir := $(ndk_common_tree)/ndk
|
|
||||||
samplejni_dest_dir := $(ndk_common_dest_dir)/samples/samplejni
|
|
||||||
config_dest_dir := $(ndk_common_dest_dir)/config
|
|
||||||
kernel_dest_dir := $(ndk_common_dest_dir)/include/kernel/include
|
|
||||||
gcc_dest_dir := $(ndk_common_dest_dir)/toolchain
|
|
||||||
jni_dest_dir := $(ndk_common_dest_dir)/include/nativehelper
|
|
||||||
|
|
||||||
# Common-full destination trees for the ndk
|
|
||||||
ndk_common_full_tree := $(ndk_intermediates)/common_full
|
|
||||||
ndk_common_full_dest_dir := $(ndk_common_full_tree)/ndk
|
|
||||||
sample_dest_dir := $(ndk_common_full_dest_dir)/samples/sample
|
|
||||||
|
|
||||||
# Destination trees without source for the standard ndk (without source)
|
|
||||||
ndk_no_src_tree := $(ndk_intermediates)/no_src
|
|
||||||
ndk_no_src_dest_dir := $(ndk_no_src_tree)/ndk
|
|
||||||
bionic_no_src_dest_dir := $(ndk_no_src_dest_dir)/include/bionic
|
|
||||||
|
|
||||||
# Destination trees including source for the ndk with source
|
|
||||||
ndk_src_tree := $(ndk_intermediates)/with_src
|
|
||||||
ndk_src_dest_dir := $(ndk_src_tree)/ndk
|
|
||||||
bionic_src_dest_dir := $(ndk_src_dest_dir)/include/bionic
|
|
||||||
|
|
||||||
# Destinations of all common files (not picked up by tree rules below)
|
|
||||||
ndk_common_dest_files := $(ndk_common_dest_dir)/Android_NDK_README.html \
|
|
||||||
$(ndk_common_dest_dir)/config/armelf.x \
|
|
||||||
$(ndk_common_dest_dir)/config/armelflib.x \
|
|
||||||
$(ndk_common_dest_dir)/lib/crtbegin_dynamic.o \
|
|
||||||
$(ndk_common_dest_dir)/lib/crtend_android.o \
|
|
||||||
$(ndk_common_dest_dir)/lib/libc.so \
|
|
||||||
$(ndk_common_dest_dir)/lib/libm.so
|
|
||||||
|
|
||||||
# Destinations of files used by the full, non-jni-only configurations
|
|
||||||
ndk_common_full_dest_files := \
|
|
||||||
$(ndk_common_full_dest_dir)/lib/libdl.so \
|
|
||||||
$(ndk_common_full_dest_dir)/lib/libstdc++.so
|
|
||||||
|
|
||||||
# Install common files outside common trees
|
|
||||||
$(ndk_common_dest_dir)/Android_NDK_README.html: $(LOCAL_PATH)/Android_NDK_README.html | $(ACP)
|
|
||||||
@echo "NDK Android_NDK_README.html: from $? to $@"
|
|
||||||
$(copy-file-to-target)
|
|
||||||
|
|
||||||
$(ndk_common_dest_dir)/config/armelf.x: $(BUILD_SYSTEM)/armelf.x | $(ACP)
|
|
||||||
@echo "NDK config: $@"
|
|
||||||
$(copy-file-to-target)
|
|
||||||
|
|
||||||
$(ndk_common_dest_dir)/config/armelflib.x: $(BUILD_SYSTEM)/armelflib.x | $(ACP)
|
|
||||||
@echo "NDK config: $@"
|
|
||||||
$(copy-file-to-target)
|
|
||||||
|
|
||||||
$(ndk_common_dest_dir)/lib/%: $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/% | $(ACP)
|
|
||||||
@echo "NDK lib: $@"
|
|
||||||
$(copy-file-to-target)
|
|
||||||
|
|
||||||
# Install common_full files outside common trees
|
|
||||||
$(ndk_common_full_dest_dir)/lib/%: $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/% | $(ACP)
|
|
||||||
@echo "NDK lib full: $@"
|
|
||||||
$(copy-file-to-target)
|
|
||||||
|
|
||||||
# Install files in common trees
|
|
||||||
listvar := ndk_common_dest_files
|
|
||||||
$(call define-tree-copy-rules,$(samplejni_src_dir),$(samplejni_dest_dir),$(listvar))
|
|
||||||
$(call define-tree-copy-rules,$(config_src_dir),$(config_dest_dir),$(listvar))
|
|
||||||
$(call define-tree-copy-rules,$(kernel_common_src_dir),$(kernel_dest_dir),$(listvar))
|
|
||||||
$(call define-tree-copy-rules,$(kernel_arch_src_dir),$(kernel_dest_dir),$(listvar))
|
|
||||||
$(call define-tree-copy-rules,$(jni_src_dir),$(jni_dest_dir),$(listvar), -name jni.h)
|
|
||||||
|
|
||||||
# Install files common to the full builds but not the JNI build
|
|
||||||
listvar := ndk_common_full_dest_files
|
|
||||||
$(call define-tree-copy-rules,$(sample_src_dir),$(sample_dest_dir),$(listvar))
|
|
||||||
|
|
||||||
# Install files without sources
|
|
||||||
listvar := ndk_no_src_dest_files
|
|
||||||
$(call define-tree-copy-rules,$(bionic_src_dir),$(bionic_no_src_dest_dir),$(listvar),-name '*.h')
|
|
||||||
|
|
||||||
# Install files including sources
|
|
||||||
listvar := ndk_with_src_dest_files
|
|
||||||
$(call define-tree-copy-rules,$(bionic_src_dir),$(bionic_src_dest_dir),$(listvar))
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# Create the multiple versions of the ndk:
|
|
||||||
# ndk_no_src all files without source
|
|
||||||
# ndk_with_source all files with source
|
|
||||||
# ndk_jni_with_source just files for building JNI shared libraries with source.
|
|
||||||
|
|
||||||
# Name the tar files
|
|
||||||
name := android_ndk-$(TARGET_PRODUCT)
|
|
||||||
ifeq ($(TARGET_BUILD_TYPE),debug)
|
|
||||||
name := $(name)_debug
|
|
||||||
endif
|
|
||||||
name := $(name)-$(BUILD_NUMBER)
|
|
||||||
ndk_tarfile := $(ndk_intermediates)/$(name).tar
|
|
||||||
ndk_tarfile_zipped := $(ndk_tarfile).gz
|
|
||||||
ndk_with_src_tarfile := $(ndk_intermediates)/$(name)-src.tar
|
|
||||||
ndk_with_src_tarfile_zipped := $(ndk_with_src_tarfile).gz
|
|
||||||
ndk_jni_with_src_tarfile := $(ndk_intermediates)/$(name)-jni-src.tar
|
|
||||||
ndk_jni_with_src_tarfile_zipped := $(ndk_jni_with_src_tarfile).gz
|
|
||||||
|
|
||||||
.PHONY: ndk ndk_with_src ndk_no_src ndk_jni_with_src ndk_debug
|
|
||||||
|
|
||||||
ndk: ndk_no_src ndk_with_src ndk_jni_with_src
|
|
||||||
ndk_no_src: $(ndk_tarfile_zipped)
|
|
||||||
ndk_with_src: $(ndk_with_src_tarfile_zipped)
|
|
||||||
ndk_jni_with_src: $(ndk_jni_with_src_tarfile_zipped)
|
|
||||||
|
|
||||||
# Put the ndk zip files in the distribution directory
|
|
||||||
$(call dist-for-goals,ndk,$(ndk_tarfile_zipped))
|
|
||||||
$(call dist-for-goals,ndk,$(ndk_with_src_tarfile_zipped))
|
|
||||||
$(call dist-for-goals,ndk,$(ndk_jni_with_src_tarfile_zipped))
|
|
||||||
|
|
||||||
# zip up tar files
|
|
||||||
%.tar.gz: %.tar
|
|
||||||
@echo "NDK: zipped $<"
|
|
||||||
$(hide) gzip -cf $< > $@
|
|
||||||
|
|
||||||
# tar up the files without our sources to make the ndk.
|
|
||||||
$(ndk_tarfile): $(ndk_common_dest_files) $(ndk_common_full_dest_files) $(ndk_no_src_dest_files)
|
|
||||||
@echo "NDK: $@"
|
|
||||||
@mkdir -p $(dir $@)
|
|
||||||
@rm -f $@
|
|
||||||
$(hide) tar rf $@ -C $(ndk_common_tree) ndk
|
|
||||||
$(hide) tar rf $@ -C $(ndk_common_full_tree) ndk
|
|
||||||
$(hide) tar rf $@ -C $(ndk_no_src_tree) ndk
|
|
||||||
|
|
||||||
# tar up the full sources to make the ndk with sources.
|
|
||||||
$(ndk_with_src_tarfile): $(ndk_common_dest_files) $(ndk_common_full_dest_files) $(ndk_with_src_dest_files) $(ndk_full_with_src_dest_files)
|
|
||||||
@echo "NDK: $@"
|
|
||||||
@mkdir -p $(dir $@)
|
|
||||||
@rm -f $@
|
|
||||||
$(hide) tar rf $@ -C $(ndk_common_tree) ndk
|
|
||||||
$(hide) tar rf $@ -C $(ndk_common_full_tree) ndk
|
|
||||||
$(hide) tar rf $@ -C $(ndk_src_tree) ndk
|
|
||||||
|
|
||||||
# tar up the sources to make the ndk with JNI support.
|
|
||||||
$(ndk_jni_with_src_tarfile): $(ndk_common_dest_files) $(ndk_with_src_dest_files)
|
|
||||||
@echo "NDK: $@"
|
|
||||||
@mkdir -p $(dir $@)
|
|
||||||
@rm -f $@
|
|
||||||
$(hide) tar rf $@ -C $(ndk_common_tree) ndk
|
|
||||||
$(hide) tar rf $@ -C $(ndk_src_tree) ndk
|
|
||||||
|
|
||||||
# Debugging reporting can go here, add it as a target to get output.
|
|
||||||
ndk_debug: ndk
|
|
||||||
@echo "You are here: $@"
|
|
||||||
@echo "ndk tar file: $(ndk_tarfile_zipped)"
|
|
||||||
@echo "ndk_with_src tar file: $(ndk_with_src_tarfile_zipped)"
|
|
||||||
@echo "ndk_jni_with_src tar file: $(ndk_jni_with_src_tarfile_zipped)"
|
|
||||||
@echo "ndk_files: $(ndk_no_src_dest_files)"
|
|
||||||
@echo "ndk_with_src files: $(ndk_with_src_dest_files)"
|
|
||||||
@echo "ndk_full_with_src files: $(ndk_full_with_src_dest_files)"
|
|
||||||
@echo "ndk_common_files: $(ndk_common_dest_files)"
|
|
||||||
@echo "ndk_common_full_dest_files: $(ndk_common_full_dest_files)"
|
|
||||||
|
|
||||||
@@ -456,286 +456,286 @@ ol.writely-toc-subheading {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h1>
|
<h1>
|
||||||
Using the Android Native Development Kit (NDK)
|
Using the Android Native Development Kit (NDK)
|
||||||
</h1>
|
</h1>
|
||||||
version 1.3<br>
|
version 1.3<br>
|
||||||
<br>
|
<br>
|
||||||
<h2>
|
<h2>
|
||||||
Introduction
|
Introduction
|
||||||
</h2>
|
</h2>
|
||||||
The Android Native Development Kit enables developers to write shared libraries
|
The Android Native Development Kit enables developers to write shared libraries
|
||||||
in C or C++ and call them from Java code. The native shared libraries can be
|
in C or C++ and call them from Java code. The native shared libraries can be
|
||||||
packaged into apk files along with a normal Android application written in Java,
|
packaged into apk files along with a normal Android application written in Java,
|
||||||
so that the resulting Android application can be downloaded and installed on an
|
so that the resulting Android application can be downloaded and installed on an
|
||||||
Android phone.<br>
|
Android phone.<br>
|
||||||
<br>
|
<br>
|
||||||
The Native Development Kit consists of:<br>
|
The Native Development Kit consists of:<br>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
C/C++ headers for native APIs<br>
|
C/C++ headers for native APIs<br>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
C/C++ libraries for native APIs<br>
|
C/C++ libraries for native APIs<br>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Documentation
|
Documentation
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Sample Code
|
Sample Code
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
The Native Development Kit is designed to be used with the Android SDK:<br>
|
The Native Development Kit is designed to be used with the Android SDK:<br>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
The NDK is used to create a shared library containing native code.
|
The NDK is used to create a shared library containing native code.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
The SDK is used to create an Android application written in Java that calls
|
The SDK is used to create an Android application written in Java that calls
|
||||||
into the native code shared library.
|
into the native code shared library.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h1>
|
<h1>
|
||||||
</h1>
|
</h1>
|
||||||
<h2>
|
<h2>
|
||||||
Setting up your machine<br>
|
Setting up your machine<br>
|
||||||
</h2>
|
</h2>
|
||||||
The Native Development Kit may be installed on either Linux or OS X. Developing
|
The Native Development Kit may be installed on either Linux or OS X. Developing
|
||||||
under Windows is not yet supported.<br>
|
under Windows is not yet supported.<br>
|
||||||
<div>
|
<div>
|
||||||
<h3>
|
<h3>
|
||||||
Linux Installation
|
Linux Installation
|
||||||
</h3>
|
</h3>
|
||||||
The
|
The
|
||||||
Android build is routinely tested on recent versions of Ubuntu (6.06 and later), but
|
Android build is routinely tested on recent versions of Ubuntu (6.06 and later), but
|
||||||
may work on other distributions as well.<br>
|
may work on other distributions as well.<br>
|
||||||
<h4>
|
<h4>
|
||||||
<a name=TOC-Ubuntu-Linux-i386-></a><span style=FONT-FAMILY:Verdana>Ubuntu
|
<a name=TOC-Ubuntu-Linux-i386-></a><span style=FONT-FAMILY:Verdana>Ubuntu
|
||||||
Linux (i386)</span>
|
Linux (i386)</span>
|
||||||
</h4>
|
</h4>
|
||||||
<div style=FONT-FAMILY:Verdana>
|
<div style=FONT-FAMILY:Verdana>
|
||||||
To set up your Linux development environment, make sure you have the
|
To set up your Linux development environment, make sure you have the
|
||||||
following:<span style="WORD-SPACING:0px; FONT-STYLE:normal; FONT-VARIANT:normal; FONT-WEIGHT:normal; font-size-adjust:none; font-stretch:normal; TEXT-TRANSFORM:none; COLOR:#000000; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate"><font size=2>
|
following:<span style="WORD-SPACING:0px; FONT-STYLE:normal; FONT-VARIANT:normal; FONT-WEIGHT:normal; font-size-adjust:none; font-stretch:normal; TEXT-TRANSFORM:none; COLOR:#000000; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate"><font size=2>
|
||||||
</font></span>
|
</font></span>
|
||||||
</div>
|
</div>
|
||||||
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana">
|
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana">
|
||||||
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px">
|
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px">
|
||||||
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px">
|
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px">
|
||||||
<ul style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px">
|
<ul style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px">
|
||||||
<li style="MARGIN-TOP:8px; MARGIN-BOTTOM:8px">
|
<li style="MARGIN-TOP:8px; MARGIN-BOTTOM:8px">
|
||||||
Git 1.5.4 or
|
Git 1.5.4 or
|
||||||
newer<span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"><font size=2>. </font></span>
|
newer<span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"><font size=2>. </font></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<blockquote style="BORDER:medium none ; MARGIN:0pt 0pt 0pt 40px; PADDING:0px">
|
<blockquote style="BORDER:medium none ; MARGIN:0pt 0pt 0pt 40px; PADDING:0px">
|
||||||
<span style=FONT-FAMILY:arial><span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"><span style="FONT-FAMILY:courier new,monospace">$
|
<span style=FONT-FAMILY:arial><span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"><span style="FONT-FAMILY:courier new,monospace">$
|
||||||
</span></span><span style="FONT-FAMILY:courier new,monospace">sudo apt-get
|
</span></span><span style="FONT-FAMILY:courier new,monospace">sudo apt-get
|
||||||
install git-core<br>
|
install git-core<br>
|
||||||
</span></span>
|
</span></span>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<div>
|
<div>
|
||||||
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px">
|
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px">
|
||||||
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:arial,sans-serif">
|
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:arial,sans-serif">
|
||||||
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px">
|
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px">
|
||||||
<h4>
|
<h4>
|
||||||
<a name=TOC-Ubuntu-Linux-amd64-></a><span style=FONT-FAMILY:Verdana>Ubuntu
|
<a name=TOC-Ubuntu-Linux-amd64-></a><span style=FONT-FAMILY:Verdana>Ubuntu
|
||||||
Linux (amd64)</span>
|
Linux (amd64)</span>
|
||||||
</h4>
|
</h4>
|
||||||
<span style=FONT-FAMILY:Verdana>This has not been as well
|
<span style=FONT-FAMILY:Verdana>This has not been as well
|
||||||
tested.</span>
|
tested.</span>
|
||||||
</div>
|
</div>
|
||||||
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana">
|
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana">
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana">
|
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana">
|
||||||
The Android build requires a 32-bit build environment:
|
The Android build requires a 32-bit build environment:
|
||||||
</div>
|
</div>
|
||||||
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana">
|
<div style="MARGIN-TOP:0px; MARGIN-BOTTOM:0px; FONT-FAMILY:Verdana">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
Get the packages as listed above in the i386
|
Get the packages as listed above in the i386
|
||||||
instructions:<span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"> </span>
|
instructions:<span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"> </span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<blockquote style="BORDER:medium none ; MARGIN:0pt 0pt 0pt 40px; PADDING:0px">
|
<blockquote style="BORDER:medium none ; MARGIN:0pt 0pt 0pt 40px; PADDING:0px">
|
||||||
<span style=FONT-FAMILY:arial><span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"><span style="FONT-FAMILY:courier new,monospace">$ </span></span><span style="FONT-FAMILY:courier new,monospace">sudo
|
<span style=FONT-FAMILY:arial><span style="FONT-WEIGHT:normal; WORD-SPACING:0px; TEXT-TRANSFORM:none; COLOR:#000000; FONT-STYLE:normal; WHITE-SPACE:normal; LETTER-SPACING:normal; border-collapse:separate; FONT-VARIANT:normal"><span style="FONT-FAMILY:courier new,monospace">$ </span></span><span style="FONT-FAMILY:courier new,monospace">sudo
|
||||||
apt-get install git-core<br>
|
apt-get install git-core<br>
|
||||||
</span></span>
|
</span></span>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<h4>
|
<h4>
|
||||||
<a name=TOC-Other-Linux></a>Other Linux
|
<a name=TOC-Other-Linux></a>Other Linux
|
||||||
</h4>
|
</h4>
|
||||||
<p>
|
<p>
|
||||||
There's
|
There's
|
||||||
no reason why Android cannot be built on non-Ubuntu systems<span style=FONT-WEIGHT:normal><font size=2>. In general you will need:</font></span>
|
no reason why Android cannot be built on non-Ubuntu systems<span style=FONT-WEIGHT:normal><font size=2>. In general you will need:</font></span>
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
Git 1.5.4 or newer. You can find it at <a href=http://git.or.cz/ rel=nofollow>http://git.or.cz/</a><span style=FONT-FAMILY:arial></span>
|
Git 1.5.4 or newer. You can find it at <a href=http://git.or.cz/ rel=nofollow>http://git.or.cz/</a><span style=FONT-FAMILY:arial></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div>
|
<div>
|
||||||
<h3>
|
<h3>
|
||||||
Mac OS Installation
|
Mac OS Installation
|
||||||
</h3>
|
</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<span style=FONT-FAMILY:arial,sans-serif>To build the Android files in a
|
<span style=FONT-FAMILY:arial,sans-serif>To build the Android files in a
|
||||||
Mac OS environment, you need an Intel/x86 machine. The Android build
|
Mac OS environment, you need an Intel/x86 machine. The Android build
|
||||||
system and tools do not support the older PowerPC architecture.</span>
|
system and tools do not support the older PowerPC architecture.</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<span style=FONT-FAMILY:arial,sans-serif>Android must be built on a
|
<span style=FONT-FAMILY:arial,sans-serif>Android must be built on a
|
||||||
case-sensitive file system.<br>
|
case-sensitive file system.<br>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
We recommend that you build Android on a partition that has been
|
We recommend that you build Android on a partition that has been
|
||||||
formatted with the "Case-sensitive Journaled HFS+" file system:
|
formatted with the "Case-sensitive Journaled HFS+" file system:
|
||||||
</li>
|
</li>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
A case-sensitive file system is required because the sources contain
|
A case-sensitive file system is required because the sources contain
|
||||||
files that differ only in case.
|
files that differ only in case.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Journaled systems are more robust. (This is optional, but
|
Journaled systems are more robust. (This is optional, but
|
||||||
recommended.)
|
recommended.)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
HFS+ is required to successfully build Mac OS applications such as
|
HFS+ is required to successfully build Mac OS applications such as
|
||||||
the Android Emulator for OS X.
|
the Android Emulator for OS X.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<li>
|
<li>
|
||||||
If you want to avoid partitioning/formatting your hard drive, you can
|
If you want to avoid partitioning/formatting your hard drive, you can
|
||||||
use a case-sensitive disk image instead.
|
use a case-sensitive disk image instead.
|
||||||
</li>
|
</li>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
To create the image:<br>
|
To create the image:<br>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
launch /Applications/Utilities/Disk Utility
|
launch /Applications/Utilities/Disk Utility
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
select "New Image"
|
select "New Image"
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
size: 8 GB (this will work, but you can choose more if you want
|
size: 8 GB (this will work, but you can choose more if you want
|
||||||
to)
|
to)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
volume format: case sensitive, journaled
|
volume format: case sensitive, journaled
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
This will create a .dmg file which, once mounted, acts as a drive
|
This will create a .dmg file which, once mounted, acts as a drive
|
||||||
with the required formatting for Android development. For a disk
|
with the required formatting for Android development. For a disk
|
||||||
image named "android.dmg" stored in your home directory, you can add
|
image named "android.dmg" stored in your home directory, you can add
|
||||||
the following to your ~/.bash_profile to mount the image when you
|
the following to your ~/.bash_profile to mount the image when you
|
||||||
execute "mountAndroid":<br>
|
execute "mountAndroid":<br>
|
||||||
<br>
|
<br>
|
||||||
<div style=MARGIN-LEFT:40px>
|
<div style=MARGIN-LEFT:40px>
|
||||||
<span style="FONT-FAMILY:courier new,monospace"># command to mount
|
<span style="FONT-FAMILY:courier new,monospace"># command to mount
|
||||||
the android file
|
the android file
|
||||||
image</span><br style="FONT-FAMILY:courier new,monospace">
|
image</span><br style="FONT-FAMILY:courier new,monospace">
|
||||||
<span style="FONT-FAMILY:courier new,monospace">function
|
<span style="FONT-FAMILY:courier new,monospace">function
|
||||||
mountAndroid { hdiutil attach ~/android.dmg
|
mountAndroid { hdiutil attach ~/android.dmg
|
||||||
-mountpoint /Volumes/android; }</span><br>
|
-mountpoint /Volumes/android; }</span><br>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
Once mounted, you'll do all your work in the "android" volume. You
|
Once mounted, you'll do all your work in the "android" volume. You
|
||||||
can eject it (unmount it) just like you would with an external
|
can eject it (unmount it) just like you would with an external
|
||||||
drive.
|
drive.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
<div>
|
<div>
|
||||||
<br>
|
<br>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
Install git 1.5.4 or newer. You can find it at
|
Install git 1.5.4 or newer. You can find it at
|
||||||
<a href=http://git.or.cz/ rel=nofollow>http://git.or.cz/</a>
|
<a href=http://git.or.cz/ rel=nofollow>http://git.or.cz/</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h2>
|
<h2>
|
||||||
Installing the Android SDK
|
Installing the Android SDK
|
||||||
</h2>
|
</h2>
|
||||||
The Android NDK uses the Android SDK. You can find the Android SDK at
|
The Android NDK uses the Android SDK. You can find the Android SDK at
|
||||||
<a href=http://code.google.com/android/download.html id=a.-o title=http://code.google.com/android/download.html>http://code.google.com/android/download.html</a><br>
|
<a href=http://code.google.com/android/download.html id=a.-o title=http://code.google.com/android/download.html>http://code.google.com/android/download.html</a><br>
|
||||||
This version of the Android NDK requires the Cupcake version of the
|
This version of the Android NDK requires the Cupcake version of the
|
||||||
Android SDK.<br>
|
Android SDK.<br>
|
||||||
<br>
|
<br>
|
||||||
<h2>
|
<h2>
|
||||||
Installing the Prebuilt Native Toolchain<br>
|
Installing the Prebuilt Native Toolchain<br>
|
||||||
</h2>
|
</h2>
|
||||||
The NDK uses the prebuilt native toolchain from the Android Open Source
|
The NDK uses the prebuilt native toolchain from the Android Open Source
|
||||||
git repository.<br>
|
git repository.<br>
|
||||||
<br>
|
<br>
|
||||||
To download the prebuilt native toolchain to your working directory,
|
To download the prebuilt native toolchain to your working directory,
|
||||||
execute the following commands:<br>
|
execute the following commands:<br>
|
||||||
<br>
|
<br>
|
||||||
<span style="FONT-FAMILY:Courier New"></span>
|
<span style="FONT-FAMILY:Courier New"></span>
|
||||||
<div style=MARGIN-LEFT:40px>
|
<div style=MARGIN-LEFT:40px>
|
||||||
<span style="FONT-FAMILY:Courier New">git clone
|
<span style="FONT-FAMILY:Courier New">git clone
|
||||||
git://android.git.kernel.org/platform/prebuilt.git</span><br>
|
git://android.git.kernel.org/platform/prebuilt.git</span><br>
|
||||||
<span style="FONT-FAMILY:Courier New">cd prebuilt</span><br>
|
<span style="FONT-FAMILY:Courier New">cd prebuilt</span><br>
|
||||||
<span style="FONT-FAMILY:Courier New">git checkout -b cupcake -t
|
<span style="FONT-FAMILY:Courier New">git checkout -b cupcake -t
|
||||||
origin/cupcake</span><br>
|
origin/cupcake</span><br>
|
||||||
</div>
|
</div>
|
||||||
<div style=MARGIN-LEFT:40px>
|
<div style=MARGIN-LEFT:40px>
|
||||||
<span style="FONT-FAMILY:Courier New"></span>
|
<span style="FONT-FAMILY:Courier New"></span>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<h2>
|
<h2>
|
||||||
Setting Environment Variables
|
Setting Environment Variables
|
||||||
</h2>
|
</h2>
|
||||||
The NDK requires that you set two environment variables:<br>
|
The NDK requires that you set two environment variables:<br>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
PREBUILT must be set to the directory that contains the prebuilt
|
PREBUILT must be set to the directory that contains the prebuilt
|
||||||
toolchain. Include the "prebuilt" directory in the path. Example:
|
toolchain. Include the "prebuilt" directory in the path. Example:
|
||||||
/Volumes/android/prebuilt<br>
|
/Volumes/android/prebuilt<br>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
ANDROID_SDK_BASE must be set to the directory that contains the
|
ANDROID_SDK_BASE must be set to the directory that contains the
|
||||||
Android SDK. Example: ~/AndroidSDK<br>
|
Android SDK. Example: ~/AndroidSDK<br>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
<h2>
|
<h2>
|
||||||
<span style=FONT-FAMILY:Verdana>Unpacking the NDK</span>
|
<span style=FONT-FAMILY:Verdana>Unpacking the NDK</span>
|
||||||
</h2>
|
</h2>
|
||||||
Unpack the android_ndk.tar.gz into your working directory<br>
|
Unpack the android_pndk.tar.gz into your working directory<br>
|
||||||
<br>
|
<br>
|
||||||
<div style=MARGIN-LEFT:40px>
|
<div style=MARGIN-LEFT:40px>
|
||||||
<span style="FONT-FAMILY:Courier New">tar -zxvf
|
<span style="FONT-FAMILY:Courier New">tar -zxvf
|
||||||
android_ndk.tar.gz</span><br>
|
android_pndk.tar.gz</span><br>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
This will create a directory called ndk. It should contain a README.html
|
This will create a directory called pndk. It should contain a README.html
|
||||||
file (this file) and the following directories: config, include, lib, and
|
file (this file) and the following directories: config, include, lib, and
|
||||||
sample.<br>
|
sample.<br>
|
||||||
<br>
|
<br>
|
||||||
Look in the "samples" directory for samples showing how to use the NDK.<br>
|
Look in the "samples" directory for samples showing how to use the NDK.<br>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
<br></body>
|
<br></body>
|
||||||
</html>
|
</html>
|
||||||
232
pdk/pndk/Pndk.mk
Normal file
232
pdk/pndk/Pndk.mk
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2008 The Android Open Source Project
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Assemble the Native Development Kit
|
||||||
|
# Assembled using the generic build by default.
|
||||||
|
# (set in device/config/product_config.make)
|
||||||
|
|
||||||
|
# A macro to make rules to copy all newer files in a directory tree matching an
|
||||||
|
# optional find filter and add the files to a list variable for dependencies.
|
||||||
|
# Designed after copy_headers.make: Create a rule to copy each file;
|
||||||
|
# copy-one-file defines the actual rule.
|
||||||
|
# $(1): source directory tree root
|
||||||
|
# $(2): destination directory tree root
|
||||||
|
# $(3): list variable to append destination files to
|
||||||
|
# $(4): optional find(1) arguments
|
||||||
|
define define-tree-copy-rules
|
||||||
|
$(eval _src_files := $(shell find $(1) -type f $(4))) \
|
||||||
|
$(foreach _src, $(_src_files), \
|
||||||
|
$(eval _dest := $(patsubst $(1)%,$(2)%,$(_src))) \
|
||||||
|
$(eval $(3) := $($(3)) $(_dest)) \
|
||||||
|
$(eval $(call copy-one-file,$(_src),$(_dest))) \
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Install all the files needed to build the pndk.
|
||||||
|
# We build three versions of the pndk
|
||||||
|
# (1) The full version, with source.
|
||||||
|
# (2) The full version, without source.
|
||||||
|
# (3) A JNI-only version, with source.
|
||||||
|
#
|
||||||
|
# We make five sets of trees:
|
||||||
|
# (A) Common files used in all versions of the pndk
|
||||||
|
# (B) Common files used in the full versions of the pndk
|
||||||
|
# (C) Files used in the standard pndk (no source files included)
|
||||||
|
# (D) Files used in both the JNI-only and full-with-source version
|
||||||
|
# (E) Files used in just the full-with-source version
|
||||||
|
#
|
||||||
|
# Each pndk version is created by combining the appropriate trees:
|
||||||
|
#
|
||||||
|
# (A) (B) (C) (D) (E)
|
||||||
|
# (1) yes yes yes yes
|
||||||
|
# (2) yes yes yes
|
||||||
|
# (3) yes yes
|
||||||
|
#
|
||||||
|
# Source is provided for partners who want to recompile our libraries for optimization.
|
||||||
|
# The JNI-only version is provided for partners that want to create shared
|
||||||
|
# libraries that can be packaged with APK files and called from Java code.
|
||||||
|
|
||||||
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
# Source trees for the pndk
|
||||||
|
samples_src_dir := $(LOCAL_PATH)/samples
|
||||||
|
sample_src_dir := $(samples_src_dir)/sample
|
||||||
|
samplejni_src_dir := $(samples_src_dir)/samplejni
|
||||||
|
config_src_dir := $(LOCAL_PATH)/config
|
||||||
|
kernel_common_src_dir := $(KERNEL_HEADERS_COMMON)
|
||||||
|
kernel_arch_src_dir := $(KERNEL_HEADERS_ARCH)
|
||||||
|
bionic_src_dir := bionic
|
||||||
|
jni_src_dir := $(JNI_H_INCLUDE)
|
||||||
|
|
||||||
|
# Workspace directory
|
||||||
|
pndk_intermediates := $(call intermediates-dir-for,PACKAGING,pndk)
|
||||||
|
|
||||||
|
# Common destination trees for the pndk
|
||||||
|
pndk_common_tree := $(pndk_intermediates)/common
|
||||||
|
pndk_common_dest_dir := $(pndk_common_tree)/pndk
|
||||||
|
samplejni_dest_dir := $(pndk_common_dest_dir)/samples/samplejni
|
||||||
|
config_dest_dir := $(pndk_common_dest_dir)/config
|
||||||
|
kernel_dest_dir := $(pndk_common_dest_dir)/include/kernel/include
|
||||||
|
gcc_dest_dir := $(pndk_common_dest_dir)/toolchain
|
||||||
|
jni_dest_dir := $(pndk_common_dest_dir)/include/nativehelper
|
||||||
|
|
||||||
|
# Common-full destination trees for the pndk
|
||||||
|
pndk_common_full_tree := $(pndk_intermediates)/common_full
|
||||||
|
pndk_common_full_dest_dir := $(pndk_common_full_tree)/pndk
|
||||||
|
sample_dest_dir := $(pndk_common_full_dest_dir)/samples/sample
|
||||||
|
|
||||||
|
# Destination trees without source for the standard pndk (without source)
|
||||||
|
pndk_no_src_tree := $(pndk_intermediates)/no_src
|
||||||
|
pndk_no_src_dest_dir := $(pndk_no_src_tree)/pndk
|
||||||
|
bionic_no_src_dest_dir := $(pndk_no_src_dest_dir)/include/bionic
|
||||||
|
|
||||||
|
# Destination trees including source for the pndk with source
|
||||||
|
pndk_src_tree := $(pndk_intermediates)/with_src
|
||||||
|
pndk_src_dest_dir := $(pndk_src_tree)/pndk
|
||||||
|
bionic_src_dest_dir := $(pndk_src_dest_dir)/include/bionic
|
||||||
|
|
||||||
|
# Destinations of all common files (not picked up by tree rules below)
|
||||||
|
pndk_common_dest_files := $(pndk_common_dest_dir)/Android_PNDK_README.html \
|
||||||
|
$(pndk_common_dest_dir)/config/armelf.x \
|
||||||
|
$(pndk_common_dest_dir)/config/armelflib.x \
|
||||||
|
$(pndk_common_dest_dir)/lib/crtbegin_dynamic.o \
|
||||||
|
$(pndk_common_dest_dir)/lib/crtend_android.o \
|
||||||
|
$(pndk_common_dest_dir)/lib/libc.so \
|
||||||
|
$(pndk_common_dest_dir)/lib/libm.so
|
||||||
|
|
||||||
|
# Destinations of files used by the full, non-jni-only configurations
|
||||||
|
pndk_common_full_dest_files := \
|
||||||
|
$(pndk_common_full_dest_dir)/lib/libdl.so \
|
||||||
|
$(pndk_common_full_dest_dir)/lib/libstdc++.so
|
||||||
|
|
||||||
|
# Install common files outside common trees
|
||||||
|
$(pndk_common_dest_dir)/Android_PNDK_README.html: $(LOCAL_PATH)/Android_PNDK_README.html | $(ACP)
|
||||||
|
@echo "pndk Android_PNDK_README.html: from $? to $@"
|
||||||
|
$(copy-file-to-target)
|
||||||
|
|
||||||
|
$(pndk_common_dest_dir)/config/armelf.x: $(BUILD_SYSTEM)/armelf.x | $(ACP)
|
||||||
|
@echo "pndk config: $@"
|
||||||
|
$(copy-file-to-target)
|
||||||
|
|
||||||
|
$(pndk_common_dest_dir)/config/armelflib.x: $(BUILD_SYSTEM)/armelflib.x | $(ACP)
|
||||||
|
@echo "pndk config: $@"
|
||||||
|
$(copy-file-to-target)
|
||||||
|
|
||||||
|
$(pndk_common_dest_dir)/lib/%: $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/% | $(ACP)
|
||||||
|
@echo "pndk lib: $@"
|
||||||
|
$(copy-file-to-target)
|
||||||
|
|
||||||
|
# Install common_full files outside common trees
|
||||||
|
$(pndk_common_full_dest_dir)/lib/%: $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/% | $(ACP)
|
||||||
|
@echo "pndk lib full: $@"
|
||||||
|
$(copy-file-to-target)
|
||||||
|
|
||||||
|
# Install files in common trees
|
||||||
|
listvar := pndk_common_dest_files
|
||||||
|
$(call define-tree-copy-rules,$(samplejni_src_dir),$(samplejni_dest_dir),$(listvar))
|
||||||
|
$(call define-tree-copy-rules,$(config_src_dir),$(config_dest_dir),$(listvar))
|
||||||
|
$(call define-tree-copy-rules,$(kernel_common_src_dir),$(kernel_dest_dir),$(listvar))
|
||||||
|
$(call define-tree-copy-rules,$(kernel_arch_src_dir),$(kernel_dest_dir),$(listvar))
|
||||||
|
$(call define-tree-copy-rules,$(jni_src_dir),$(jni_dest_dir),$(listvar), -name jni.h)
|
||||||
|
|
||||||
|
# Install files common to the full builds but not the JNI build
|
||||||
|
listvar := pndk_common_full_dest_files
|
||||||
|
$(call define-tree-copy-rules,$(sample_src_dir),$(sample_dest_dir),$(listvar))
|
||||||
|
|
||||||
|
# Install files without sources
|
||||||
|
listvar := pndk_no_src_dest_files
|
||||||
|
$(call define-tree-copy-rules,$(bionic_src_dir),$(bionic_no_src_dest_dir),$(listvar),-name '*.h')
|
||||||
|
|
||||||
|
# Install files including sources
|
||||||
|
listvar := pndk_with_src_dest_files
|
||||||
|
$(call define-tree-copy-rules,$(bionic_src_dir),$(bionic_src_dest_dir),$(listvar))
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Create the multiple versions of the pndk:
|
||||||
|
# pndk_no_src all files without source
|
||||||
|
# pndk_with_source all files with source
|
||||||
|
# pndk_jni_with_source just files for building JNI shared libraries with source.
|
||||||
|
|
||||||
|
# Name the tar files
|
||||||
|
name := android_pndk-$(TARGET_PRODUCT)
|
||||||
|
ifeq ($(TARGET_BUILD_TYPE),debug)
|
||||||
|
name := $(name)_debug
|
||||||
|
endif
|
||||||
|
name := $(name)-$(BUILD_NUMBER)
|
||||||
|
pndk_tarfile := $(pndk_intermediates)/$(name).tar
|
||||||
|
pndk_tarfile_zipped := $(pndk_tarfile).gz
|
||||||
|
pndk_with_src_tarfile := $(pndk_intermediates)/$(name)-src.tar
|
||||||
|
pndk_with_src_tarfile_zipped := $(pndk_with_src_tarfile).gz
|
||||||
|
pndk_jni_with_src_tarfile := $(pndk_intermediates)/$(name)-jni-src.tar
|
||||||
|
pndk_jni_with_src_tarfile_zipped := $(pndk_jni_with_src_tarfile).gz
|
||||||
|
|
||||||
|
.PHONY: pndk pndk_with_src pndk_no_src pndk_jni_with_src pndk_debug
|
||||||
|
|
||||||
|
pndk: pndk_no_src pndk_with_src pndk_jni_with_src
|
||||||
|
pndk_no_src: $(pndk_tarfile_zipped)
|
||||||
|
pndk_with_src: $(pndk_with_src_tarfile_zipped)
|
||||||
|
pndk_jni_with_src: $(pndk_jni_with_src_tarfile_zipped)
|
||||||
|
|
||||||
|
# Put the pndk zip files in the distribution directory
|
||||||
|
$(call dist-for-goals,pndk,$(pndk_tarfile_zipped))
|
||||||
|
$(call dist-for-goals,pndk,$(pndk_with_src_tarfile_zipped))
|
||||||
|
$(call dist-for-goals,pndk,$(pndk_jni_with_src_tarfile_zipped))
|
||||||
|
|
||||||
|
# zip up tar files
|
||||||
|
%.tar.gz: %.tar
|
||||||
|
@echo "pndk: zipped $<"
|
||||||
|
$(hide) gzip -cf $< > $@
|
||||||
|
|
||||||
|
# tar up the files without our sources to make the pndk.
|
||||||
|
$(pndk_tarfile): $(pndk_common_dest_files) $(pndk_common_full_dest_files) $(pndk_no_src_dest_files)
|
||||||
|
@echo "pndk: $@"
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
@rm -f $@
|
||||||
|
$(hide) tar rf $@ -C $(pndk_common_tree) pndk
|
||||||
|
$(hide) tar rf $@ -C $(pndk_common_full_tree) pndk
|
||||||
|
$(hide) tar rf $@ -C $(pndk_no_src_tree) pndk
|
||||||
|
|
||||||
|
# tar up the full sources to make the pndk with sources.
|
||||||
|
$(pndk_with_src_tarfile): $(pndk_common_dest_files) $(pndk_common_full_dest_files) $(pndk_with_src_dest_files) $(pndk_full_with_src_dest_files)
|
||||||
|
@echo "pndk: $@"
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
@rm -f $@
|
||||||
|
$(hide) tar rf $@ -C $(pndk_common_tree) pndk
|
||||||
|
$(hide) tar rf $@ -C $(pndk_common_full_tree) pndk
|
||||||
|
$(hide) tar rf $@ -C $(pndk_src_tree) pndk
|
||||||
|
|
||||||
|
# tar up the sources to make the pndk with JNI support.
|
||||||
|
$(pndk_jni_with_src_tarfile): $(pndk_common_dest_files) $(pndk_with_src_dest_files)
|
||||||
|
@echo "pndk: $@"
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
@rm -f $@
|
||||||
|
$(hide) tar rf $@ -C $(pndk_common_tree) pndk
|
||||||
|
$(hide) tar rf $@ -C $(pndk_src_tree) pndk
|
||||||
|
|
||||||
|
# Debugging reporting can go here, add it as a target to get output.
|
||||||
|
pndk_debug: pndk
|
||||||
|
@echo "You are here: $@"
|
||||||
|
@echo "pndk tar file: $(pndk_tarfile_zipped)"
|
||||||
|
@echo "pndk_with_src tar file: $(pndk_with_src_tarfile_zipped)"
|
||||||
|
@echo "pndk_jni_with_src tar file: $(pndk_jni_with_src_tarfile_zipped)"
|
||||||
|
@echo "pndk_files: $(pndk_no_src_dest_files)"
|
||||||
|
@echo "pndk_with_src files: $(pndk_with_src_dest_files)"
|
||||||
|
@echo "pndk_full_with_src files: $(pndk_full_with_src_dest_files)"
|
||||||
|
@echo "pndk_common_files: $(pndk_common_dest_files)"
|
||||||
|
@echo "pndk_common_full_dest_files: $(pndk_common_full_dest_files)"
|
||||||
|
|
||||||
@@ -10,9 +10,9 @@ Building an application.
|
|||||||
where you type in the actual path to the android source in place of <path_to_android_src>
|
where you type in the actual path to the android source in place of <path_to_android_src>
|
||||||
and the platform you are using instead of <platform>: either linux-x86 or darwin-x86
|
and the platform you are using instead of <platform>: either linux-x86 or darwin-x86
|
||||||
|
|
||||||
1) Test the ndk install by building the hello world sample application:
|
1) Test the pndk install by building the hello world sample application:
|
||||||
|
|
||||||
cd <your_ndk_base>/samples/sample
|
cd <your_pndk_base>/samples/sample
|
||||||
make clean
|
make clean
|
||||||
make
|
make
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ can load and run on the ARM device. To achieve proper runtime behavior, verify
|
|||||||
that:
|
that:
|
||||||
* crtbegin_dynamic.o is the first linked object file
|
* crtbegin_dynamic.o is the first linked object file
|
||||||
* crtend_android.o is last linked object.
|
* crtend_android.o is last linked object.
|
||||||
Both are set by the config.mk file in ndk/config.
|
Both are set by the config.mk file in pndk/config.
|
||||||
|
|
||||||
2) Test that this works correctly by attaching your ARM-based device to the USB
|
2) Test that this works correctly by attaching your ARM-based device to the USB
|
||||||
port and installing the application (hello) you just made by (in the commands
|
port and installing the application (hello) you just made by (in the commands
|
||||||
@@ -59,7 +59,7 @@ STEP 2
|
|||||||
Building and using a library
|
Building and using a library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Makefile.lib in ndk/sample shows how to make either a shared library or a
|
Makefile.lib in pndk/sample shows how to make either a shared library or a
|
||||||
static library from the hellolibrary.c source. The example makes the libraries
|
static library from the hellolibrary.c source. The example makes the libraries
|
||||||
libhello-shared.so and libhello-static.a .
|
libhello-shared.so and libhello-static.a .
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ Build Steps:
|
|||||||
Choose Next
|
Choose Next
|
||||||
Enter "JNIExample" into the Project name: field.
|
Enter "JNIExample" into the Project name: field.
|
||||||
Choose "Create project from existing source"
|
Choose "Create project from existing source"
|
||||||
Click the Browse button and browse to the ndk/samplejni directory
|
Click the Browse button and browse to the pndk/samplejni directory
|
||||||
|
|
||||||
Click Finish
|
Click Finish
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Reference in New Issue
Block a user