Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 14, 2016
0 parents commit c943c1d
Show file tree
Hide file tree
Showing 696 changed files with 141,253 additions and 0 deletions.
27 changes: 27 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Freeware License, some rights reserved

Copyright (c) 2009 Vladimir Silva

Permission is hereby granted, free of charge, to anyone obtaining a copy
of this software and associated documentation files (the "Software"),
to work with the Software within the limits of freeware distribution and fair use.
This includes the rights to use, copy, and modify the Software for personal use.
Users are also allowed and encouraged to submit corrections and modifications
to the Software for the benefit of other users.

It is not allowed to reuse, modify, or redistribute the Software for
commercial use in any way, or for a user�s educational materials such as books
or blog articles without prior permission from the copyright holder.

The above copyright notice and this permission notice need to be included
in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Apress Source Code

This repository accompanies [*Pro Android Games*](http://www.apress.com/9781430226475) by Vladimir Silva (Apress, 2009).

![Cover image](9781430226475.jpg)

Download the files as a zip using the green button, or clone the repository to your machine using Git.

##Releases

Release v1.0 corresponds to the code in the published book, without corrections or updates.

##Contributions

See the file Contributing.md for more information on how you can contribute to this repository.
14 changes: 14 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Contributing to Apress Source Code

Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers.

## How to Contribute

1. Make sure you have a GitHub account.
2. Fork the repository for the relevant book.
3. Create a new branch on which to make your change, e.g.
`git checkout -b my_code_contribution`
4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted.
5. Submit a pull request.

Thank you for your contribution!
67 changes: 67 additions & 0 deletions workspace/ch01/bin/agcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

#############################################
# Android Stuff
#############################################

HOME=/home/user
JAVA_HOME=/usr/lib/jvm/java-6-sun

SYS_ROOT=$HOME/tmp/android/system
SYS_DEV=$HOME/mydroid

#Tool chain
TOOLCHAIN_ROOT=$HOME/Desktop/android/arm-2008q3

# Includes
BASE=$SYS_DEV/frameworks/base
LIBC=$SYS_DEV/bionic/libc
LIBM=${SYS_DEV}/bionic/libm

TC=${SYS_DEV}/prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/lib/gcc/arm-eabi/4.3.1
KERNEL=${SYS_DEV}/kernel

LIBZ=${SYS_DEV}/external/zlib
EXPAT=${SYS_DEV}/external/expat/lib

AND_INC="-Iinclude -I$JAVA_HOME/include"
AND_INC+=" -I${JAVA_HOME}/include/linux"
AND_INC+=" -I${LIBC}/include "
AND_INC+=" -I${LIBC}/arch-arm/include"
AND_INC+=" -I${LIBC}/kernel/arch-arm/include "
AND_INC+=" -I${LIBM}/include"
AND_INC+=" -I${BASE}/include"
AND_INC+=" -I${TC}/include"
AND_INC+=" -I${KERNEL}/include"
AND_INC+=" -I${KERNEL}/arch/arm/include -I${KERNEL}/arch/arm/mach-ebsa110/include"
AND_INC+=" -I${SYS_DEV}/system/core/include"
AND_INC+=" -I${LIBZ}"
AND_INC+=" -I${EXPAT}"

#EXTRA_INC="${KERNEL}/include/linux/soundcard.h"
#AND_INC+=" -I${KERNEL}/include/linux"
#AND_INC+=" -I${LIBC}/kernel/common/linux"

LIBDIR=${TOOLCHAIN_ROOT}/lib/gcc/arm-none-linux-gnueabi/4.3.2
LIBRARIES=${LIBDIR}/libgcc.a

LIB_PATHS="-rpath /system/lib \
-rpath ${SYS_ROOT}/lib \
-L. -L${SYS_ROOT}/lib \
-L${JAVA_HOME}/jre/lib/i386"

#############################################
# End Android Stuff
#############################################

CROSS=arm-none-linux-gnueabi-
GCC=${CROSS}gcc


#echo ${GCC} -nostdinc $AND_INC $@

#${GCC} -nostdinc ${AND_INC} -DINLINE='static __inline__' $@
${GCC} -nostdinc ${AND_INC} "$@"



44 changes: 44 additions & 0 deletions workspace/ch01/bin/ald
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

#############################################
# Android Stuff
#############################################

HOME=/home/user
JAVA_HOME=/usr/lib/jvm/java-6-sun

SYS_ROOT=$HOME/tmp/android/system
SYS_DEV=$HOME/mydroid

# Tool chain Root
TOOLCHAIN_ROOT=$HOME/Desktop/android/arm-2008q3

# Android Toolchain
LIBGCC=${SYS_DEV}/prebuilt/darwin-x86/toolchain/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/libgcc.a

# Code Sourcery
#LIBGCC=${TOOLCHAIN_ROOT}/lib/gcc/arm-none-linux-gnueabi/4.3.2/libgcc.a

LIBRARIES="-lc -lm ${LIBGCC}"

LIB_PATHS="-rpath /system/lib \
-rpath ${SYS_ROOT}/lib \
-L${SYS_ROOT}/lib \
-L${JAVA_HOME}/jre/lib/i386 -L."

# When compiling statically remove -nostdlib
LD_FLAGS="--dynamic-linker=/system/bin/linker -nostdlib"

#############################################
# End Android Stuff
#############################################

CROSS=arm-none-linux-gnueabi-
GCC=${CROSS}ld

#echo "${GCC} $LD_FLAGS $LIB_PATHS $@ $LIBRARIES"

${GCC} $LD_FLAGS $LIB_PATHS $@ $LIBRARIES



Binary file added workspace/ch01/bin/strace
Binary file not shown.
7 changes: 7 additions & 0 deletions workspace/ch02.Project/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
</classpath>
33 changes: 33 additions & 0 deletions workspace/ch02.Project/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ch02.Project</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
16 changes: 16 additions & 0 deletions workspace/ch02.Project/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ch02.project"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>
Binary file added workspace/ch02.Project/assets/libch02.so
Binary file not shown.
Binary file added workspace/ch02.Project/bin/ch02.Project.apk
Binary file not shown.
Binary file not shown.
Binary file added workspace/ch02.Project/bin/ch02/project/R$attr.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added workspace/ch02.Project/bin/ch02/project/R.class
Binary file not shown.
Binary file added workspace/ch02.Project/bin/classes.dex
Binary file not shown.
Binary file added workspace/ch02.Project/bin/jni/Natives.class
Binary file not shown.
Binary file added workspace/ch02.Project/bin/resources.ap_
Binary file not shown.
11 changes: 11 additions & 0 deletions workspace/ch02.Project/default.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-3
23 changes: 23 additions & 0 deletions workspace/ch02.Project/gen/ch02/project/R.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/

package ch02.project;

public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
70 changes: 70 additions & 0 deletions workspace/ch02.Project/native/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#####################################
# Make file
#####################################

# Compiler and loader
CC = agcc
LD = ald

# flags
CFLAGS = -Werror
MACROS =
INCLUDES =

# static objects
OBJ = main.o

# shared library ob
LIBOBJ = lib.o

# test shared lib
TESTLIBOBJ = testlib.o

# default make target
all: testlib $(OBJ)
@echo
@echo "Linking..."
$(LD) -static -o a.out $(OBJ)

# Build lib
lib: $(LIBOBJ)
@echo
@echo "Linking Shared library..."
$(LD) -shared -o libch02.so $(LIBOBJ)
@echo
@echo "Copying Shared library to assest folder"
cp libch02.so ../assets

# Build test program for lib
testlib: lib $(TESTLIBOBJ)
@echo
@echo "Linking Test for Shared library"
$(LD) -o testlib $(TESTLIBOBJ) -L. -lch02

# Build JNI Headers (for lib)
jni:
@echo "Creating JNI C headers..."
javah -jni -classpath ../bin -d include jni.Natives

# compile
.c.o:
@echo
@echo "Compiling $<..."
$(CC) -c $(FLAGS) $(MACROS) $(INCLUDES) $<

# Cleanup
clean:
rm *.o

#
# Push binary into device
#
pushbin:
adb push a.out /data

# Push lib & test program to the device
pushlib:
adb push testlib /data
adb push libch02.so /data


21 changes: 21 additions & 0 deletions workspace/ch02.Project/native/include/jni_Natives.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c943c1d

Please sign in to comment.