Skip to content
This repository was archived by the owner on Mar 25, 2019. It is now read-only.

Commit d338d9a

Browse files
author
Eric Lange
committed
Updated documentation
Replaced --enable-jit with --disable-jit Added --force-jit Allow ffi to build on 64-bit arches
1 parent a330404 commit d338d9a

5 files changed

Lines changed: 67 additions & 82 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ obj
1010
project.properties
1111
build/
1212
lib/
13+
*~

README.md

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Design Goals
1919

2020
Version
2121
-------
22-
2.0 (not yet released, but HEAD works)
22+
2.0
2323

2424
Working With AndroidJSCore
2525
--------------------------
@@ -106,9 +106,40 @@ Objective-C.
106106
The [Javadocs] and included example app have detailed descriptions of how to do
107107
just about everything.
108108

109+
Use AndroidJSCore in your project
110+
---------------------------------
111+
The easy way is to simply download the file `AndroidJSCore-2.0-release.aar` from
112+
the [latest release] and drop it somewhere in your project (`libs/` is meant just for this). Then
113+
add the following to your app-level `build.gradle`:
114+
115+
repositories {
116+
flatDir {
117+
dirs 'libs'
118+
}
119+
}
120+
121+
dependencies {
122+
compile(name:'AndroidJSCore-2.0-release', ext:'aar')
123+
}
124+
125+
Building the AndroidJSCoreExample app
126+
---------------------------------
127+
128+
If you want to see AndroidJSCore in action, you can run the example app:
129+
130+
git clone https://github.com/ericwlange/AndroidJSCore.git ~/AndroidJSCore
131+
mkdir ~/AndroidJSCore/lib
132+
133+
Then download `AndroidJSCore-2.0-release.aar` from the [latest release] and
134+
copy it into `~/AndroidJSCore/lib`. Now you can open `~/AndroidJSCore/examples/AndroidJSCoreExample`
135+
in Android Studio and run it.
136+
109137
Building AndroidJSCore-2.0 library
110138
-------------------------------
111139

140+
If you are interested in building the library directly and possibly contributing, you must
141+
do the following:
142+
112143
#### TL;DR - do this
113144

114145
Set `ANDROID_HOME` and `ANDROID_NDK_ROOT` environment variables
@@ -118,6 +149,8 @@ Set `ANDROID_HOME` and `ANDROID_NDK_ROOT` environment variables
118149
% cd build
119150
% ../AndroidJSCore/scripts/build
120151

152+
Note the `--recursive` option in `git clone`. This is required for building the
153+
library, but not if you are just downloading the released library as with the example app above.
121154
Your library now sits in `lib/AndroidJSCore-2.0-release.aar`. To use it, simply
122155
add the following to your app's `build.gradle`:
123156

@@ -135,16 +168,18 @@ If something goes wrong or you want to understand what's going on, read on.
135168

136169
#### Step 1 - Set up required tools
137170

138-
At the moment, this has all been verified to work on Mac OSX. Once I can verify
139-
that it builds on Linux, as well, I will tag and release 2.0. If anyone else is
140-
married to that OS from Seattle, please feel free to get it working and contribute!
171+
This has all been verified to work on Mac OSX (specifically 10.11.2 El Capitan)
172+
and Linux (Ubuntu 14.04 LTS). If anyone else is married to that OS from Seattle,
173+
please feel free to get it working and contribute!
141174

142175
1. Download and install the latest version of [Android Studio], including the [NDK]
143176
2. Set two environment variables: `ANDROID_HOME` and `ANDROID_NDK_ROOT` to point to the SDK and NDK directories, respectively
144177
3. Clone the repo: `git clone --recursive https://github.com/ericwlange/AndroidJSCore.git`
145178

146179
This last step will grab both the AndroidJSCore repo, as well as my fork of the
147-
[webkit] repo. The latter part is huge, like 6 GBs or something, so settle in.
180+
[webkit] repo. The latter part is huge, like 6 GBs or something, so settle in. Not that
181+
the recursive clone is required for building the lib, but is not if you just want to
182+
build the example app.
148183

149184
The build process requires a bunch of other standard UNIX tools, too. The below script will
150185
complain if it can't find something, but you should expect to have the command-line
@@ -192,10 +227,16 @@ WebKit as a whole, but it doesn't seem to impact JavaScript to leave it out. If
192227
reason your project isn't working because of this, you can link the lib back in with this
193228
option.
194229

195-
`--enable-jit` will allow architectures that build with just-in-time compilation to use
196-
it. This should theoretically significantly improve the speed of JavaScript execution,
197-
however as of the release of AndroidJSCore 2.0, enabling this flag on arm, at least,
198-
causes the app to crash on load. In subsequent releases, I will try to get this to work.
230+
`--disable-jit` will disable just-in-time compilation for all architectures. Currently, it
231+
is disabled by default for `armeabi` and `mips` because they will not even compile, and it
232+
is turned off for `armeabi-v7a` because it causes the app to crash on load. In subsequent
233+
releases, I will try to get this to work. This should theoretically significantly improve
234+
the speed of JavaScript execution, and is currently enabled by default for `x86` and the
235+
64-bit arches.
236+
237+
`--force-jit` will force enable just-in-time compilation even for arches that don't work.
238+
Don't use this option unless you are trying to debug JIT. This option overrides `--disable-jit`
239+
if used together.
199240

200241
You may also specify target architectures explicitly. Currently, `armeabi`, `armeabi-v7a`,
201242
`x86` and `mips` build by default, but if you just want to build for a subset of these ABIs,
@@ -205,28 +246,6 @@ they crap out due to what appears to be a compiler bug in GCC 4.9. The `mips64`
205246
won't even get off the ground. Future versions will include the 64-bit targets as the
206247
tools mature.
207248

208-
#### Step 4 - Use AndroidJSCore in your project
209-
210-
You can now take `AndroidJSCore-2.0-release.aar` and drop it into your Android Studio
211-
project. Just drop the file somewhere in your project (`libs/` is meant just for this) and
212-
add the following to the app-level `build.gradle`:
213-
214-
repositories {
215-
flatDir {
216-
dirs 'libs'
217-
}
218-
}
219-
220-
dependencies {
221-
compile(name:'AndroidJSCore-2.0-release', ext:'aar')
222-
}
223-
224-
Building the AndroidJSCoreExample app
225-
---------------------------------
226-
227-
If you just want to see AndroidJSCore in action, once you've successfully built the library,
228-
you can load the `AndroidJSCoreExample` project in `examples/` and run it. That's it.
229-
230249
Work in Progress
231250
----------------
232251

@@ -260,7 +279,6 @@ I am just sticking with Webkit's license, since this thing depends on it.
260279
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261280
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262281

263-
[blog post]:http://www.bignerdranch.com/blog/javascriptcore-and-ios-7/
264282
[NDK]:http://developer.android.com/ndk/index.html
265283
[latest release]:https://github.com/ericwlange/AndroidJSCore/releases
266284
[Android Studio]:http://developer.android.com/sdk/index.html

examples/AndroidJSCoreExample/.idea/misc.xml

Lines changed: 0 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ PREFIXES = {
6060
ANDROID_APIS = {
6161
'armeabi' : '19',
6262
'armeabi-v7a' : '19',
63-
'arm64-v8a' : '19',
63+
'arm64-v8a' : '21',
6464
'x86' : '19',
6565
'x86_64' : '21',
6666
'mips' : '19',
@@ -145,12 +145,14 @@ def build_icu(abi):
145145
print "ERROR: Can't build GLIB library for " + abi
146146
return output
147147

148-
def build_JavaScriptCore(abi,link_icu,disable_jit):
148+
def build_JavaScriptCore(abi,link_icu,disable_jit,force_jit):
149149
os.environ['EXTRA_FLAGS'] = ''
150150
if link_icu:
151151
os.environ['EXTRA_FLAGS'] = os.environ['EXTRA_FLAGS'] + '-DLINK_ICU_DATA=1 '
152-
if disable_jit:
152+
if disable_jit:
153153
os.environ['EXTRA_FLAGS'] = os.environ['EXTRA_FLAGS'] + '-DDISABLE_JIT=1 '
154+
if force_jit:
155+
os.environ['EXTRA_FLAGS'] = os.environ['EXTRA_FLAGS'] + '-DFORCE_JIT=1 '
154156

155157
output = call([SH, config_common.SCRIPTS + '/build_JavaScriptCore.sh'])
156158
if output != 0:
@@ -165,13 +167,17 @@ def build_aar():
165167

166168
def main(argv):
167169
link_icu = False
168-
disable_jit = True
170+
disable_jit = False
171+
force_jit = False
169172
if '--link-icu-data' in argv:
170173
link_icu = True
171174
argv.remove('--link-icu-data')
172-
if '--enable-jit' in argv:
173-
disable_jit = False
174-
argv.remove('--enable-jit')
175+
if '--disable-jit' in argv:
176+
disable_jit = True
177+
argv.remove('--disable-jit')
178+
if '--force-jit' in argv:
179+
force_jit = True
180+
argv.remove('--force-jit')
175181

176182
if len(argv) == 0:
177183
argv = DEFAULT_ABIS
@@ -195,7 +201,7 @@ def main(argv):
195201
output = build_icu(abi)
196202
if output!=0: return output
197203

198-
output = build_JavaScriptCore(abi,link_icu,disable_jit)
204+
output = build_JavaScriptCore(abi,link_icu,disable_jit,force_jit)
199205
if output!=0: return output
200206

201207
output = build_aar()
@@ -204,4 +210,4 @@ def main(argv):
204210
print 'AndroidJSCore library successfully built and installed in ' + os.path.abspath(config_common.SRC_ROOT + '/../lib')
205211

206212
if __name__ == "__main__":
207-
main(sys.argv[1:])
213+
main(sys.argv[1:])

webkit

0 commit comments

Comments
 (0)