4632N/A#title JObjC
4632N/A#
4632N/A# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4632N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4632N/A#
4632N/A# This code is free software; you can redistribute it and/or modify it
4632N/A# under the terms of the GNU General Public License version 2 only, as
4632N/A# published by the Free Software Foundation. Oracle designates this
4632N/A# particular file as subject to the "Classpath" exception as provided
4632N/A# by Oracle in the LICENSE file that accompanied this code.
4632N/A#
4632N/A# This code is distributed in the hope that it will be useful, but WITHOUT
4632N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4632N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4632N/A# version 2 for more details (a copy is included in the LICENSE file that
4632N/A# accompanied this code).
4632N/A#
4632N/A# You should have received a copy of the GNU General Public License version
4632N/A# 2 along with this work; if not, write to the Free Software Foundation,
4632N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4632N/A#
4632N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4632N/A# or visit www.oracle.com if you need additional information or have any
4632N/A# questions.
4632N/A#
4632N/A
4632N/AJObjC core provides a pure Java interface for calling C functions and
4632N/Asending ObjC messages. Given some information, it can marshal types
4632N/Aautomatically.
4632N/A
4632N/AIt also parses BridgeSupport to generate Java wrappers around
4632N/AFramework bundles. These wrappers rely on the core to provide access
4632N/Ato the C constants, enums, structs, functions, ObjC classes, etc of a
4632N/Aframework.
4632N/A
4632N/A* How to build it
4632N/A
4632N/AYour best option is `ant all`. There's an Xcode "B&I" target that
4632N/Aworks for buildit.
4632N/A
4632N/AYou'll need a recent JavaNativeFoundation, and perhaps some other
4632N/Athings. Everything is usually there on SnowLeopard (or Leopard after
4632N/Athe common ~javabuild/bin/update runs).
4632N/A
4632N/AThe build process is quite involved. Xcode takes care of the native
4632N/Aparts, ant takes care of the Java parts, and there's an unholy mix of
4632N/Aexternal targets and hidden dependencies that keep Xcode and ant (and
4632N/Abuildit on top of that) from stepping on each other. So a warning: the
4632N/Aant and Xcode targets don't have proper dependencies set up because of
4632N/Athis. They have some dependencies configured, but not the entire
4632N/Achain. This is because of the jumping back and forth between
4632N/Aexternals. If you run the aggregate targets (Xcode B&I, ant all, ant
4632N/Atest, ant bench), everything's is good. But if you manually invoke
4632N/Aindividual targets, chances are you'll miss something. Let's go over
4632N/Ait all step by step:
4632N/A
4632N/A** ant gen-pcoder
4632N/A
4632N/AThe PrimitiveCoder subclasses have a lot of boiler plate which
4632N/Asimplifies the generated MixedPrimitiveCoder classes. So instead of
4632N/Amaintaining it, I maintain a tiny Haskell script that spits out the
4632N/AJava code. This ant target runs that script if Haskell is available on
4632N/Athe system. If it isn't available, this will silently fail. That's
4632N/Aokay, because chances are the PrimitiveCoder.java that you got from
4632N/Asvn is current and does not need to be updated.
4632N/A
4632N/A** ant build-core / Xcode build-core-java
4632N/A
4632N/ABuild core simply builds the JObjC core java classes, and also
4632N/Agenerates headers for the JNI for Xcode.
4632N/A
4632N/A** ant build-core-native / Xcode build-core-native
4632N/A
4632N/AXcode builds the native core, using the headers from the Java core. It
4632N/Agenerates libJObjC.dylib.
4632N/A
4632N/A** ant build-generator / Xcode build-generator-java
4632N/A
4632N/Aant builds the generator.
4632N/A
4632N/A** ant run-generator / Xcode run-generator
4632N/A
4632N/Aant runs the generator, using the core Java and native classes.
4632N/A
4632N/AWhat is rungen? And what's run-generator-old? run-generator-old is the
4632N/Apreferred way to run the generator from ant, but there's a strange bug
4632N/Awhen running from buildit that causes run-generator-old to
4632N/Afreeze. Pratik was helping me debug it, inspecting the stack and
4632N/Asnooping dtrace probes, but we never found the reason for the
4632N/Ablock. So I figured that maybe if I just add a layer of indirection
4632N/Amaybe it'll work around that. And it did. Sad but true.
4632N/A
4632N/A** ant build-generated / Xcode build-generated-java
4632N/A
4632N/ABuild the generator output.
4632N/A
4632N/A** ant build-additions / Xcode build-additions-java
4632N/A
4632N/ABuilds java additions.
4632N/A
4632N/A** ant build-additions-native / Xcode build-additions-native
4632N/A
4632N/AThis builds a new version of libJObjC.dylib. It will rebuild
4632N/Aeverything from the core, and include everything from additions.
4632N/A
4632N/A** ant assemble-product / Xcode assemble-product-java
4632N/A
4632N/ACreate a jar, copy products to destination, etc.
4632N/A
4632N/A* How to test it
4632N/A
4632N/AThe test cases also contain a Java component and a native component,
4632N/Aand are built similarly to the above. The benchmarks are built
4632N/Atogether with the tests. So "ant build-test" and "ant
4632N/Abuild-test-native" will build both the benchmarks and the test. "ant
4632N/Atest" will run the test. "ant bench" will run benchmarks. If you only
4632N/Awant to run a specific benchmark, you can pass a regexp in the
4632N/Aenvironment variable BENCH_MATCH.
4632N/A
4632N/A<src>
4632N/Aant test
4632N/Aant bench
4632N/ABENCH_MATCH=Foo ant bench
4632N/A</src>
4632N/A
4632N/ATest and bench reports will end up in
4632N/Abuild/JObjC.build/Debug/test-reports/
4632N/A
4632N/A* How to use it
4632N/A
4632N/AInclude the jar in your classpath and set your java.library.path to
4632N/Athe directory that contains the dylib. Same thing for app bundles.