From 429fbd82d82c5e278a546de226c193138a9a2669 Mon Sep 17 00:00:00 2001 From: Mike Ritter Date: Tue, 19 May 2009 11:28:10 -0700 Subject: [PATCH] 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 --- pdk/Pdk.mk | 12 +- pdk/README | 12 +- pdk/ndk/Ndk.mk | 232 -------- .../Android_PNDK_README.html} | 562 +++++++++--------- pdk/pndk/Pndk.mk | 232 ++++++++ pdk/{ndk => pndk}/config/config.mk | 0 pdk/{ndk => pndk}/samples/sample/Makefile | 0 .../samples/sample/Makefile.hello_cpp | 0 pdk/{ndk => pndk}/samples/sample/Makefile.lib | 0 .../samples/sample/Makefile.uselib | 0 pdk/{ndk => pndk}/samples/sample/README | 8 +- pdk/{ndk => pndk}/samples/sample/hello.c | 0 .../samples/sample/hello_cpp.cpp | 0 pdk/{ndk => pndk}/samples/sample/hello_cpp.h | 0 .../samples/sample/hellolibrary.c | 0 .../samples/sample/use_hellolibrary.c | 0 .../samples/samplejni/AndroidManifest.xml | 0 pdk/{ndk => pndk}/samples/samplejni/Makefile | 0 pdk/{ndk => pndk}/samples/samplejni/README | 2 +- .../samples/samplejni/native.cpp | 0 .../samples/samplejni/res/drawable/icon.png | Bin .../samples/samplejni/res/values/strings.xml | 0 .../com/example/jniexample/JNIExample.java | 0 23 files changed, 530 insertions(+), 530 deletions(-) delete mode 100644 pdk/ndk/Ndk.mk rename pdk/{ndk/Android_NDK_README.html => pndk/Android_PNDK_README.html} (97%) create mode 100644 pdk/pndk/Pndk.mk rename pdk/{ndk => pndk}/config/config.mk (100%) rename pdk/{ndk => pndk}/samples/sample/Makefile (100%) rename pdk/{ndk => pndk}/samples/sample/Makefile.hello_cpp (100%) rename pdk/{ndk => pndk}/samples/sample/Makefile.lib (100%) rename pdk/{ndk => pndk}/samples/sample/Makefile.uselib (100%) rename pdk/{ndk => pndk}/samples/sample/README (94%) rename pdk/{ndk => pndk}/samples/sample/hello.c (100%) rename pdk/{ndk => pndk}/samples/sample/hello_cpp.cpp (100%) rename pdk/{ndk => pndk}/samples/sample/hello_cpp.h (100%) rename pdk/{ndk => pndk}/samples/sample/hellolibrary.c (100%) rename pdk/{ndk => pndk}/samples/sample/use_hellolibrary.c (100%) rename pdk/{ndk => pndk}/samples/samplejni/AndroidManifest.xml (100%) rename pdk/{ndk => pndk}/samples/samplejni/Makefile (100%) rename pdk/{ndk => pndk}/samples/samplejni/README (94%) rename pdk/{ndk => pndk}/samples/samplejni/native.cpp (100%) rename pdk/{ndk => pndk}/samples/samplejni/res/drawable/icon.png (100%) rename pdk/{ndk => pndk}/samples/samplejni/res/values/strings.xml (100%) rename pdk/{ndk => pndk}/samples/samplejni/src/com/example/jniexample/JNIExample.java (100%) diff --git a/pdk/Pdk.mk b/pdk/Pdk.mk index 0a2b1fd8a..c824037eb 100644 --- a/pdk/Pdk.mk +++ b/pdk/Pdk.mk @@ -15,12 +15,12 @@ # # 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: - @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: $^" LOCAL_PATH := $(call my-dir) @@ -28,8 +28,8 @@ LOCAL_PATH := $(call my-dir) #------------------------------------------------------------------------------- # Make the Native Development Kit (Code examples) # Allows vendors to build shared libraries without entire source tree. -# This include adds /ndk to LOCAL_PATH, so can't use it afterwards... -include $(LOCAL_PATH)/ndk/Ndk.mk +# This include adds /pndk to LOCAL_PATH, so can't use it afterwards... +include $(LOCAL_PATH)/pndk/Pndk.mk #------------------------------------------------------------------------------- @@ -180,7 +180,7 @@ $(LOCAL_PATH)/pdk-timestamp: $(pdk_docs_intermediates)/pdk-timestamp include $(CLEAR_VARS) 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_HTML_DIR := ../../../$(pdk_app_eng_root) diff --git a/pdk/README b/pdk/README index 99598b1d2..036912df3 100644 --- a/pdk/README +++ b/pdk/README @@ -28,7 +28,7 @@ then build everything: 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 @@ -38,10 +38,10 @@ so you can have a record of the build commands in the logs directory. -------------------------------------------------------------------------------- # 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: 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 To change which version of doxygen runs you can pass in the variable: @@ -90,13 +90,13 @@ To add port forwarding -------------------------------------------------------------------------------- # Deployment -To host the pdk docs on the interanl appengine run: -/home/build/static/projects/apphosting/devtools/appcfg.py update /out/common/docs +To host the pdk docs on the internal appengine run: +/home/build/static/projects/apphosting/devtools/appcfg.py update /out/target/common/docs 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. To host the pdk docs on the external appengine run: -/home/build/static/projects/apphosting/devtools/appcfg.py -s pdk-docs.appspot.com update /out/common/docs +/home/build/static/projects/apphosting/devtools/appcfg.py -s pdk-docs.appspot.com update /out/target/common/docs 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. diff --git a/pdk/ndk/Ndk.mk b/pdk/ndk/Ndk.mk deleted file mode 100644 index 0ec3b943d..000000000 --- a/pdk/ndk/Ndk.mk +++ /dev/null @@ -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)" - diff --git a/pdk/ndk/Android_NDK_README.html b/pdk/pndk/Android_PNDK_README.html similarity index 97% rename from pdk/ndk/Android_NDK_README.html rename to pdk/pndk/Android_PNDK_README.html index d4c307bdb..40b7a72c8 100644 --- a/pdk/ndk/Android_NDK_README.html +++ b/pdk/pndk/Android_PNDK_README.html @@ -456,286 +456,286 @@ ol.writely-toc-subheading { -

- Using the Android Native Development Kit (NDK) -

-version 1.3
-
-

- Introduction -

-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 -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 -Android phone.
-
-The Native Development Kit consists of:
-
    -
  • - C/C++ headers for native APIs
    -
  • -
  • - C/C++ libraries for native APIs
    -
  • -
  • - Documentation -
  • -
  • - Sample Code -
  • -
-
-The Native Development Kit is designed to be used with the Android SDK:
-
    -
  • - The NDK is used to create a shared library containing native code. -
  • -
  • - The SDK is used to create an Android application written in Java that calls - into the native code shared library. -
  • -
-

-

-

- Setting up your machine
-

-The Native Development Kit may be installed on either Linux or OS X. Developing -under Windows is not yet supported.
-
-

- Linux Installation -

- The - Android build is routinely tested on recent versions of Ubuntu (6.06 and later), but - may work on other distributions as well.
-

- Ubuntu - Linux (i386) -

-
- To set up your Linux development environment, make sure you have the - following: - -
-
-
-
-
    -
  • - Git 1.5.4 or - newer -
  • -
-
-
-
-
- $ - sudo apt-get - install git-core
-
-
-
-
-
-
-

- Ubuntu - Linux (amd64) -

- This has not been as well - tested. -
-
-
-
-
- The Android build requires a 32-bit build environment: -
-
-
    -
  • - Get the packages as listed above in the i386 - instructions:    -
  • -
-
-
-
-
-
- sudo - apt-get install git-core
-
-
-

- Other Linux -

-

- There's - no reason why Android cannot be built on non-Ubuntu systems. In general you will need: -

- -
-

- Mac OS Installation -

-
    -
  • - To build the Android files in a - Mac OS environment, you need an Intel/x86 machine. The Android build - system and tools do not support the older PowerPC architecture. -
  • -
  • - Android must be built on a - case-sensitive file system.
    -
    -
  • -
      -
    • - We recommend that you build Android on a partition that has been - formatted with the "Case-sensitive Journaled HFS+" file system: -
    • -
        -
      • - A case-sensitive file system is required because the sources contain - files that differ only in case. -
      • -
      • - Journaled systems are more robust. (This is optional, but - recommended.) -
      • -
      • - HFS+ is required to successfully build Mac OS applications such as - the Android Emulator for OS X. -
      • -
      -
    • - If you want to avoid partitioning/formatting your hard drive, you can - use a case-sensitive disk image instead. -
    • -
        -
      • - To create the image:
        -
          -
        • - launch /Applications/Utilities/Disk Utility -
        • -
        • - select "New Image" -
        • -
        • - size: 8 GB (this will work, but you can choose more if you want - to) -
        • -
        • - volume format: case sensitive, journaled -
        • -
        -
      • -
      • - This will create a .dmg file which, once mounted, acts as a drive - with the required formatting for Android development. For a disk - image named "android.dmg" stored in your home directory, you can add - the following to your ~/.bash_profile to mount the image when you - execute "mountAndroid":
        -
        -
        - # command to mount - the android file - image
        - function - mountAndroid  { hdiutil attach ~/android.dmg  - -mountpoint /Volumes/android; }
        -
        -
        - 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 - drive. -
      • -
      -
    -
-
-
- -

- Installing the Android SDK -

- The Android NDK uses the Android SDK. You can find the Android SDK at - http://code.google.com/android/download.html
- This version of the Android NDK requires the Cupcake version of the - Android SDK.
-
-

- Installing the Prebuilt Native Toolchain
-

- The NDK uses the prebuilt native toolchain from the Android Open Source - git repository.
-
- To download the prebuilt native toolchain to your working directory, - execute the following commands:
-
- -
- git clone - git://android.git.kernel.org/platform/prebuilt.git
- cd prebuilt
- git checkout -b cupcake -t - origin/cupcake
-
-
- -
-
-

- Setting Environment Variables -

- The NDK requires that you set two environment variables:
-
    -
  • - PREBUILT must be set to the directory that contains the prebuilt - toolchain. Include the "prebuilt" directory in the path. Example: - /Volumes/android/prebuilt
    -
  • -
  • - ANDROID_SDK_BASE must be set to the directory that contains the - Android SDK. Example: ~/AndroidSDK
    -
  • -
-
-

- Unpacking the NDK -

- Unpack the android_ndk.tar.gz into your working directory
-
-
- tar -zxvf - android_ndk.tar.gz
-
-
- This will create a directory called ndk. It should contain a README.html - file (this file) and the following directories: config, include, lib, and - sample.
-
- Look in the "samples" directory for samples showing how to use the NDK.
-
-
-
-
-
-
-
+

+ Using the Android Native Development Kit (NDK) +

+version 1.3
+
+

+ Introduction +

+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 +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 +Android phone.
+
+The Native Development Kit consists of:
+
    +
  • + C/C++ headers for native APIs
    +
  • +
  • + C/C++ libraries for native APIs
    +
  • +
  • + Documentation +
  • +
  • + Sample Code +
  • +
+
+The Native Development Kit is designed to be used with the Android SDK:
+
    +
  • + The NDK is used to create a shared library containing native code. +
  • +
  • + The SDK is used to create an Android application written in Java that calls + into the native code shared library. +
  • +
+

+

+

+ Setting up your machine
+

+The Native Development Kit may be installed on either Linux or OS X. Developing +under Windows is not yet supported.
+
+

+ Linux Installation +

+ The + Android build is routinely tested on recent versions of Ubuntu (6.06 and later), but + may work on other distributions as well.
+

+ Ubuntu + Linux (i386) +

+
+ To set up your Linux development environment, make sure you have the + following: + +
+
+
+
+
    +
  • + Git 1.5.4 or + newer +
  • +
+
+
+
+
+ $ + sudo apt-get + install git-core
+
+
+
+
+
+
+

+ Ubuntu + Linux (amd64) +

+ This has not been as well + tested. +
+
+
+
+
+ The Android build requires a 32-bit build environment: +
+
+
    +
  • + Get the packages as listed above in the i386 + instructions:    +
  • +
+
+
+
+
+
+ sudo + apt-get install git-core
+
+
+

+ Other Linux +

+

+ There's + no reason why Android cannot be built on non-Ubuntu systems. In general you will need: +

+ +
+

+ Mac OS Installation +

+
    +
  • + To build the Android files in a + Mac OS environment, you need an Intel/x86 machine. The Android build + system and tools do not support the older PowerPC architecture. +
  • +
  • + Android must be built on a + case-sensitive file system.
    +
    +
  • +
      +
    • + We recommend that you build Android on a partition that has been + formatted with the "Case-sensitive Journaled HFS+" file system: +
    • +
        +
      • + A case-sensitive file system is required because the sources contain + files that differ only in case. +
      • +
      • + Journaled systems are more robust. (This is optional, but + recommended.) +
      • +
      • + HFS+ is required to successfully build Mac OS applications such as + the Android Emulator for OS X. +
      • +
      +
    • + If you want to avoid partitioning/formatting your hard drive, you can + use a case-sensitive disk image instead. +
    • +
        +
      • + To create the image:
        +
          +
        • + launch /Applications/Utilities/Disk Utility +
        • +
        • + select "New Image" +
        • +
        • + size: 8 GB (this will work, but you can choose more if you want + to) +
        • +
        • + volume format: case sensitive, journaled +
        • +
        +
      • +
      • + This will create a .dmg file which, once mounted, acts as a drive + with the required formatting for Android development. For a disk + image named "android.dmg" stored in your home directory, you can add + the following to your ~/.bash_profile to mount the image when you + execute "mountAndroid":
        +
        +
        + # command to mount + the android file + image
        + function + mountAndroid  { hdiutil attach ~/android.dmg  + -mountpoint /Volumes/android; }
        +
        +
        + 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 + drive. +
      • +
      +
    +
+
+
+ +

+ Installing the Android SDK +

+ The Android NDK uses the Android SDK. You can find the Android SDK at + http://code.google.com/android/download.html
+ This version of the Android NDK requires the Cupcake version of the + Android SDK.
+
+

+ Installing the Prebuilt Native Toolchain
+

+ The NDK uses the prebuilt native toolchain from the Android Open Source + git repository.
+
+ To download the prebuilt native toolchain to your working directory, + execute the following commands:
+
+ +
+ git clone + git://android.git.kernel.org/platform/prebuilt.git
+ cd prebuilt
+ git checkout -b cupcake -t + origin/cupcake
+
+
+ +
+
+

+ Setting Environment Variables +

+ The NDK requires that you set two environment variables:
+
    +
  • + PREBUILT must be set to the directory that contains the prebuilt + toolchain. Include the "prebuilt" directory in the path. Example: + /Volumes/android/prebuilt
    +
  • +
  • + ANDROID_SDK_BASE must be set to the directory that contains the + Android SDK. Example: ~/AndroidSDK
    +
  • +
+
+

+ Unpacking the NDK +

+ Unpack the android_pndk.tar.gz into your working directory
+
+
+ tar -zxvf + android_pndk.tar.gz
+
+
+ This will create a directory called pndk. It should contain a README.html + file (this file) and the following directories: config, include, lib, and + sample.
+
+ Look in the "samples" directory for samples showing how to use the NDK.
+
+
+
+
+
+
+

\ No newline at end of file diff --git a/pdk/pndk/Pndk.mk b/pdk/pndk/Pndk.mk new file mode 100644 index 000000000..ce9e3b09d --- /dev/null +++ b/pdk/pndk/Pndk.mk @@ -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)" + diff --git a/pdk/ndk/config/config.mk b/pdk/pndk/config/config.mk similarity index 100% rename from pdk/ndk/config/config.mk rename to pdk/pndk/config/config.mk diff --git a/pdk/ndk/samples/sample/Makefile b/pdk/pndk/samples/sample/Makefile similarity index 100% rename from pdk/ndk/samples/sample/Makefile rename to pdk/pndk/samples/sample/Makefile diff --git a/pdk/ndk/samples/sample/Makefile.hello_cpp b/pdk/pndk/samples/sample/Makefile.hello_cpp similarity index 100% rename from pdk/ndk/samples/sample/Makefile.hello_cpp rename to pdk/pndk/samples/sample/Makefile.hello_cpp diff --git a/pdk/ndk/samples/sample/Makefile.lib b/pdk/pndk/samples/sample/Makefile.lib similarity index 100% rename from pdk/ndk/samples/sample/Makefile.lib rename to pdk/pndk/samples/sample/Makefile.lib diff --git a/pdk/ndk/samples/sample/Makefile.uselib b/pdk/pndk/samples/sample/Makefile.uselib similarity index 100% rename from pdk/ndk/samples/sample/Makefile.uselib rename to pdk/pndk/samples/sample/Makefile.uselib diff --git a/pdk/ndk/samples/sample/README b/pdk/pndk/samples/sample/README similarity index 94% rename from pdk/ndk/samples/sample/README rename to pdk/pndk/samples/sample/README index 64e99de46..ecc751fe3 100644 --- a/pdk/ndk/samples/sample/README +++ b/pdk/pndk/samples/sample/README @@ -10,9 +10,9 @@ Building an application. where you type in the actual path to the android source in place of and the platform you are using instead of : 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 /samples/sample + cd /samples/sample make clean make @@ -21,7 +21,7 @@ can load and run on the ARM device. To achieve proper runtime behavior, verify that: * crtbegin_dynamic.o is the first linked object file * 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 port and installing the application (hello) you just made by (in the commands @@ -59,7 +59,7 @@ STEP 2 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 libhello-shared.so and libhello-static.a . diff --git a/pdk/ndk/samples/sample/hello.c b/pdk/pndk/samples/sample/hello.c similarity index 100% rename from pdk/ndk/samples/sample/hello.c rename to pdk/pndk/samples/sample/hello.c diff --git a/pdk/ndk/samples/sample/hello_cpp.cpp b/pdk/pndk/samples/sample/hello_cpp.cpp similarity index 100% rename from pdk/ndk/samples/sample/hello_cpp.cpp rename to pdk/pndk/samples/sample/hello_cpp.cpp diff --git a/pdk/ndk/samples/sample/hello_cpp.h b/pdk/pndk/samples/sample/hello_cpp.h similarity index 100% rename from pdk/ndk/samples/sample/hello_cpp.h rename to pdk/pndk/samples/sample/hello_cpp.h diff --git a/pdk/ndk/samples/sample/hellolibrary.c b/pdk/pndk/samples/sample/hellolibrary.c similarity index 100% rename from pdk/ndk/samples/sample/hellolibrary.c rename to pdk/pndk/samples/sample/hellolibrary.c diff --git a/pdk/ndk/samples/sample/use_hellolibrary.c b/pdk/pndk/samples/sample/use_hellolibrary.c similarity index 100% rename from pdk/ndk/samples/sample/use_hellolibrary.c rename to pdk/pndk/samples/sample/use_hellolibrary.c diff --git a/pdk/ndk/samples/samplejni/AndroidManifest.xml b/pdk/pndk/samples/samplejni/AndroidManifest.xml similarity index 100% rename from pdk/ndk/samples/samplejni/AndroidManifest.xml rename to pdk/pndk/samples/samplejni/AndroidManifest.xml diff --git a/pdk/ndk/samples/samplejni/Makefile b/pdk/pndk/samples/samplejni/Makefile similarity index 100% rename from pdk/ndk/samples/samplejni/Makefile rename to pdk/pndk/samples/samplejni/Makefile diff --git a/pdk/ndk/samples/samplejni/README b/pdk/pndk/samples/samplejni/README similarity index 94% rename from pdk/ndk/samples/samplejni/README rename to pdk/pndk/samples/samplejni/README index a821b7b8e..c5ed772ed 100644 --- a/pdk/ndk/samples/samplejni/README +++ b/pdk/pndk/samples/samplejni/README @@ -19,7 +19,7 @@ Build Steps: Choose Next Enter "JNIExample" into the Project name: field. 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 diff --git a/pdk/ndk/samples/samplejni/native.cpp b/pdk/pndk/samples/samplejni/native.cpp similarity index 100% rename from pdk/ndk/samples/samplejni/native.cpp rename to pdk/pndk/samples/samplejni/native.cpp diff --git a/pdk/ndk/samples/samplejni/res/drawable/icon.png b/pdk/pndk/samples/samplejni/res/drawable/icon.png similarity index 100% rename from pdk/ndk/samples/samplejni/res/drawable/icon.png rename to pdk/pndk/samples/samplejni/res/drawable/icon.png diff --git a/pdk/ndk/samples/samplejni/res/values/strings.xml b/pdk/pndk/samples/samplejni/res/values/strings.xml similarity index 100% rename from pdk/ndk/samples/samplejni/res/values/strings.xml rename to pdk/pndk/samples/samplejni/res/values/strings.xml diff --git a/pdk/ndk/samples/samplejni/src/com/example/jniexample/JNIExample.java b/pdk/pndk/samples/samplejni/src/com/example/jniexample/JNIExample.java similarity index 100% rename from pdk/ndk/samples/samplejni/src/com/example/jniexample/JNIExample.java rename to pdk/pndk/samples/samplejni/src/com/example/jniexample/JNIExample.java