File: setup_anddev.sh

package info (click to toggle)
openmsx 0.10.1-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 16,628 kB
  • ctags: 19,723
  • sloc: cpp: 131,938; xml: 25,418; tcl: 15,394; python: 4,012; sh: 365; makefile: 26
file content (169 lines) | stat: -rwxr-xr-x 5,600 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash

function explain_usage()
{
  echo "This script configures the \"commandergenius\" SDL Android port"
  echo "for the build of openMSX."
  echo ""
  echo "The script depends on the Android SDK and NDK and on the"
  echo "\"commandergenius\" SDL Android port."
  echo ""
  echo "First download and install the Android SDK and NDK"
  echo "as per the instructions on the Android website."
  echo ""
  echo "Please make sure to add the Android SDK and NDK tools locations"
  echo "to your PATH variable, as per the instructions on the Android"
  echo "website. Otherwise the setup will fail."
  echo ""
  echo "Subsequently download the \"commandergenius\" SDL Android port"
  echo "into your favorite location."
  echo ""
  echo "Example:"
  echo "> cd /opt"
  echo "> git clone https://github.com/pelya/commandergenius.git"
  echo ""
  echo "Once that is done, you can launch this script."
  echo "You must specify the path to the \"commandergenius\" SDL Android port"
  echo "on the command line or in environment parameter SDL_ANDROID_PORT_PATH."
  echo ""
  echo "Example 1:"
  echo "> export SDL_ANDROID_PORT_PATH=/opt/commandergenius"
  echo "> ./setup_anddev.sh"
  echo ""
  echo "Example 2:"
  echo "> ./setup_anddev.sh /opt/commandergenius"
  echo ""
}

if [ $# -eq 0 -a -z "$SDL_ANDROID_PORT_PATH" ]; then
  explain_usage
  exit 1
fi

if [ $# -eq 1 ]; then
    sdl_android_port_path="$1"
else
    sdl_android_port_path="$SDL_ANDROID_PORT_PATH"
fi

if [ ! -d "${sdl_android_port_path}" ]; then
  echo "Can not find directory ${sdl_android_port_path}"
  exit 1
fi
sdl_port_app_dir="${sdl_android_port_path}/project/jni/application"
if [ ! -d "${sdl_port_app_dir}" ]; then
    echo "Can not find expected sub-directory project/jni/application"
    echo "in specified directory ${sdl_android_port_path}"
    exit 1
fi

this_script_dir=$(dirname $0)
this_script_dir=$(cd ${this_script_dir}; pwd)
my_home_dir=${this_script_dir%/*}
my_home_dir=${my_home_dir%/*}
my_android_dir="${my_home_dir}/build/android/openmsx"
my_relative_dir="${my_android_dir##*/}"

tcl_build=8.5.11
tcl_version=${tcl_build%.*}
tcl_archive="${my_home_dir}/derived/3rdparty/download/tcl${tcl_build}-src.tar.gz"
tcl_sdl_dir="${sdl_android_port_path}/project/jni/tcl${tcl_version}"
if [ -d "${tcl_sdl_dir}" ]; then
	if [ ! -f "${tcl_sdl_dir}/${tcl_build}.txt" ]; then
		echo "ERROR: expecting TCL build ${tcl_build} in ${tcl_sdl_dir}"
		exit 1
	fi
fi
if [ ! -d "${tcl_sdl_dir}" ]; then
    if [ ! -f "${tcl_archive}" ]; then
		cd "${my_home_dir}"
		echo "Downloading TCL"
		python build/android_download.py
		if [ $? -ne 0 ]; then
			echo "ERROR: Failed to download TCL"
			exit 1
		fi
		if [ ! -f "${tcl_archive}" ]; then
			echo "ERROR: Failed to download TCL ${tcl_build}"
			exit 1
		fi
    fi
    cd "${sdl_android_port_path}/project/jni"
    tar xzf "${tcl_archive}"
	tcl_relative_dir=tcl${tcl_version}
    mv tcl${tcl_build} ${tcl_relative_dir}
	touch ${tcl_relative_dir}/${tcl_build}.txt
    cp -p "${my_home_dir}/build/android/tcl${tcl_build}_Android.mk" ${tcl_relative_dir}/Android.mk
    cd ${tcl_relative_dir}
    mkdir -p lib/armeabi
    mkdir -p lib/armeabi-v7a
    mkdir -p include
    cp -p generic/*.h include
    cd unix
    if [ ! -f Makefile.in.original ]; then
        cp -p Makefile.in Makefile.in.original
        patch -i "${my_home_dir}/build/android/tcl${tcl_build}_unix_Makefile.in.patch"
    fi
    export BUILD_EXECUTABLE=yes
    ../../setCrossEnvironment.sh ./configure --host=arm-eabi
    make clean
    ../../setCrossEnvironment.sh make
    mv libtcl8.5.so ../lib/armeabi
    ../../setCrossEnvironment.sh ./configure --host=arm-eabi-v7a
    make clean
    ../../setCrossEnvironment.sh make
    mv libtcl8.5.so ../lib/armeabi-v7a
fi

echo "Setting-up softlink to this application in the SDL android port."
if [ -h "${sdl_port_app_dir}/${my_relative_dir}" ]; then
    rm "${sdl_port_app_dir}/${my_relative_dir}"
fi
if [ -d "${sdl_port_app_dir}/${my_relative_dir}" ]; then
    echo "ERROR: found directory ${my_relative_dir} in ${sdl_port_app_dir}"
    echo "This seems to be another app with the same name."
    echo "Please resolve the conflict and then re-run this script."
    exit 1
fi
ln -s "${my_android_dir}" "${sdl_port_app_dir}/${my_relative_dir}"
rm -f "${sdl_port_app_dir}/src"
ln -s "${my_relative_dir}" "${sdl_port_app_dir}/src"

echo "Making environment.props file for the build script"
cat > "${my_android_dir}/environment.props" << @EOT
# Do not edit this file. It is generated by setup_anddev.sh
sdl_android_port_path="${sdl_android_port_path}"
my_home_dir="${my_home_dir}"
@EOT

cd "${my_android_dir}"
./generate_AndroidAppSettings.sh
if [ $? -ne 0 ]; then
	exit 1
fi

echo "Configuring SDL android port to build this application"
cd "${sdl_android_port_path}"
./changeAppSettings.sh -a
if [ $? -ne 0 ]; then
    echo "ERROR: an unexpected problem occurred while running changeAppSettings.sh -a"
    echo "       in ${sdl_android_port_path}"
    exit 1
fi

android update project -p project -t android-19
if [ $? -ne 0 ]; then
    echo "ERROR: an unexpected problem occurred while running \"android update ...\""
    exit 1
fi

echo ""
echo "You can now build the application from the openMSX android build directory"
echo ""
echo "Example"
echo "> cd ${my_android_dir}"
echo "> ./launch_anddev_build.sh"
echo ""
echo "Note: the first time that you run the launch_anddev_build.sh script, you may get some error"
echo "      message. It is due to a subtle bug in the SDL android port."
echo "      Simply re-run the build.sh script a second time and it will work fine."