Skip to content

Commit

Permalink
Merge pull request #7 from Tightdb/ks-config-step2
Browse files Browse the repository at this point in the history
A 'config' step has been introduced into the build procedure.
  • Loading branch information
kspangsege committed Jun 21, 2013
2 parents 55f8784 + 1b6e916 commit e6f5a1a
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 70 deletions.
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
*~
.DS_Store
# Test output
/employees.tightdb
/table_test.tbl

# sh build.sh config
/config

# sh build.sh test
/employees.tightdb
/table_test.tightdb

/doc/ref/*.html
41 changes: 34 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
Objective-C
===========

This is the TightDB language binding for Objective-C.
This README file explains how to build and install the TightDB
language binding for Objective-C. It assumes that the TightDB core
library has already been installed.


Dependencies
------------
Prerequisites
-------------

You need the standard set of build tools. This includes an
Objective-C/C++ compiler and GNU make. The Objective-C language
binding is thoroughly tested with Clang. It is known to work with
Clang 3.0 and newer.

The TightDB core library must have been installed.
Currently, the Objective-C binding is availble only on Mac OS X (and
iPhone). The following is a suggestion of how to install the
prerequisites on Mac OS X 10.7 and 10.8:

### OS X 10.8
Clang comes with Xcode, so install Xcode if it is not already
installed. If you have a version that preceeds 4.2, we recommend that
you upgrade. This will ensure that the Clang version is at least
3.0. Run the following command in the command prompt to see if you
have Xcode installed, and, if so, what version it is:

Install Xcode
Install command line tools (via Xcode)
xcodebuild -version

Make sure you also install "Command line tools" found under the
preferences pane "Downloads" in Xcode.


Building, testing, and installing
---------------------------------

export CPATH="$TIGHTDB_HOME/src"
export LIBRARY_PATH="$TIGHTDB_HOME/src/tightdb"

sh build.sh config
sh build.sh clean
sh build.sh build
sh build.sh test
sh build.sh test-debug
sh build.sh test-gdb
sudo sh build.sh install
sh build.sh test-intalled

Expand All @@ -48,6 +67,14 @@ The iPhone libraries can be tested via the Xcode project in:
Configuration
-------------

It is possible to install into a non-default location by running the
following command before building and installing:

sh build.sh config [PREFIX]

Here, `PREFIX` is the installation prefix. If it is not specified, it
defaults to `/usr/local`.

To use a nondefault compiler, or a compiler in a nondefault location,
set the environment variable `CC` before calling `sh build.sh build`,
as in the following example:
Expand Down
154 changes: 117 additions & 37 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,80 @@ export MAKEFLAGS



require_config()
{
cd "$TIGHTDB_OBJC_HOME" || return 1
if ! [ -e "config" ]; then
cat 1>&2 <<EOF
ERROR: Found no configuration!
You need to run 'sh build.sh config [PREFIX]'.
EOF
return 1
fi
echo "Using existing configuration:"
cat "config" | sed 's/^/ /' || return 1
}

auto_configure()
{
cd "$TIGHTDB_OBJC_HOME" || return 1
if [ -e "config" ]; then
require_config || return 1
else
echo "No configuration found. Running 'sh build.sh config'"
sh build.sh config || return 1
fi
}

get_config_param()
{
local name line value
cd "$TIGHTDB_OBJC_HOME" || return 1
name="$1"
if ! [ -e "config" ]; then
cat 1>&2 <<EOF
ERROR: Found no configuration!
You need to run 'sh build.sh config [PREFIX]'.
EOF
return 1
fi
if ! line="$(grep "^$name:" "config")"; then
echo "ERROR: Failed to read configuration parameter '$name'" 1>&2
return 1
fi
value="$(printf "%s\n" "$line" | cut -d: -f2)" || return 1
value="$(printf "%s\n" "$value" | sed 's/^ *//')" || return 1
printf "%s\n" "$value"
}



case "$MODE" in

"config")
install_prefix="$1"
if [ -z "$install_prefix" ]; then
install_prefix="/usr/local"
fi
install_libdir="$(make prefix="$install_prefix" get-libdir)" || exit 1

if [ "$OS" != "Darwin" ]; then
echo "ERROR: Currently, the Objective-C extension is only available on Mac OS X" 1>&2
exit 1
fi

cat >"config" <<EOF
install-prefix: $install_prefix
install-libdir: $install_libdir
EOF
echo "New configuration:"
cat "config" | sed 's/^/ /' || exit 1
echo "Done configuring"
exit 0
;;

"clean")
auto_configure || exit 1
make clean || exit 1
if [ "$OS" = "Darwin" ]; then
PLATFORMS="iPhoneOS iPhoneSimulator"
Expand All @@ -71,6 +142,7 @@ case "$MODE" in
;;

"build")
auto_configure || exit 1
# FIXME: Our language binding requires that Objective-C ARC is enabled, which, in turn, is only available on a 64-bit architecture, so for now we cannot build a "fat" version.
# TIGHTDB_ENABLE_FAT_BINARIES="1" make || exit 1
make || exit 1
Expand Down Expand Up @@ -150,6 +222,7 @@ case "$MODE" in
;;

"test")
require_config || exit 1
make test-norun || exit 1
TEMP_DIR="$(mktemp -d /tmp/tightdb.objc.test.XXXX)" || exit 1
mkdir -p "$TEMP_DIR/unit-tests.octest/Contents/MacOS" || exit 1
Expand All @@ -160,73 +233,80 @@ case "$MODE" in
exit 0
;;

"test-debug")
require_config || exit 1
make test-debug-norun || exit 1
TEMP_DIR="$(mktemp -d /tmp/tightdb.objc.test-debug.XXXX)" || exit 1
mkdir -p "$TEMP_DIR/unit-tests-dbg.octest/Contents/MacOS" || exit 1
cp "src/tightdb/objc/test/unit-tests-dbg" "$TEMP_DIR/unit-tests-dbg.octest/Contents/MacOS/" || exit 1
XCODE_HOME="$(xcode-select --print-path)" || exit 1
OBJC_DISABLE_GC=YES "$XCODE_HOME/Tools/otest" "$TEMP_DIR/unit-tests-dbg.octest" || exit 1
echo "Test passed"
exit 0
;;

"test-gdb")
require_config || exit 1
make test-debug-norun || exit 1
TEMP_DIR="$(mktemp -d /tmp/tightdb.objc.test-gdb.XXXX)" || exit 1
mkdir -p "$TEMP_DIR/unit-tests-dbg.octest/Contents/MacOS" || exit 1
cp "src/tightdb/objc/test/unit-tests-dbg" "$TEMP_DIR/unit-tests-dbg.octest/Contents/MacOS/" || exit 1
XCODE_HOME="$(xcode-select --print-path)" || exit 1
OBJC_DISABLE_GC=YES gdb --args "$XCODE_HOME/Tools/otest" "$TEMP_DIR/unit-tests-dbg.octest"
;;

"install")
PREFIX="$1"
if [ -z "$PREFIX" ]; then
PREFIX="/usr/local"
fi
make install DESTDIR="$DESTDIR" prefix="$PREFIX" || exit 1
require_config || exit 1
install_prefix="$(get_config_param "install-prefix")" || exit 1
make install DESTDIR="$DESTDIR" prefix="$install_prefix" || exit 1
echo "Done installing"
exit 0
;;

"install-shared")
PREFIX="$1"
if ! [ "$PREFIX" ]; then
PREFIX="/usr/local"
fi
make install DESTDIR="$DESTDIR" prefix="$PREFIX" INSTALL_FILTER=shared-libs || exit 1
require_config || exit 1
install_prefix="$(get_config_param "install-prefix")" || exit 1
make install DESTDIR="$DESTDIR" prefix="$install_prefix" INSTALL_FILTER=shared-libs || exit 1
echo "Done installing"
exit 0
;;

"install-devel")
PREFIX="$1"
if ! [ "$PREFIX" ]; then
PREFIX="/usr/local"
fi
make install DESTDIR="$DESTDIR" prefix="$PREFIX" INSTALL_FILTER=static-libs,progs,headers || exit 1
require_config || exit 1
install_prefix="$(get_config_param "install-prefix")" || exit 1
make install DESTDIR="$DESTDIR" prefix="$install_prefix" INSTALL_FILTER=static-libs,progs,headers || exit 1
echo "Done installing"
exit 0
;;

"uninstall")
PREFIX="$1"
if [ -z "$PREFIX" ]; then
PREFIX="/usr/local"
fi
make uninstall prefix="$PREFIX" || exit 1
require_config || exit 1
install_prefix="$(get_config_param "install-prefix")" || exit 1
make uninstall prefix="$install_prefix" || exit 1
echo "Done uninstalling"
exit 0
;;

"uninstall-shared")
PREFIX="$1"
if ! [ "$PREFIX" ]; then
PREFIX="/usr/local"
fi
make uninstall prefix="$PREFIX" INSTALL_FILTER=shared-libs || exit 1
require_config || exit 1
install_prefix="$(get_config_param "install-prefix")" || exit 1
make uninstall prefix="$install_prefix" INSTALL_FILTER=shared-libs || exit 1
echo "Done uninstalling"
exit 0
;;

"uninstall-devel")
PREFIX="$1"
if ! [ "$PREFIX" ]; then
PREFIX="/usr/local"
fi
make uninstall prefix="$PREFIX" INSTALL_FILTER=static-libs,progs,extra || exit 1
require_config || exit 1
install_prefix="$(get_config_param "install-prefix")" || exit 1
make uninstall prefix="$install_prefix" INSTALL_FILTER=static-libs,progs,extra || exit 1
echo "Done uninstalling"
exit 0
;;

"test-installed")
PREFIX="$1"
if [ -z "$PREFIX" ]; then
PREFIX="/usr/local"
fi
LIBDIR="$(make prefix="$PREFIX" get-libdir)" || exit 1
export LD_RUN_PATH="$LIBDIR"
require_config || exit 1
install_libdir="$(get_config_param "install-libdir")" || exit 1
export LD_RUN_PATH="$install_libdir"
make -C "test-installed" clean || exit 1
make -C "test-installed" test || exit 1
echo "Test passed"
Expand Down Expand Up @@ -269,7 +349,7 @@ EOF

*)
echo "Unspecified or bad mode '$MODE'" 1>&2
echo "Available modes are: clean build test install uninstall test-installed" 1>&2
echo "Available modes are: config clean build test test-debug test-gdb install uninstall test-installed" 1>&2
echo "As well as: install-shared install-devel uninstall-shared uninstall-devel dist-copy" 1>&2
exit 1
;;
Expand Down
4 changes: 4 additions & 0 deletions src/tightdb/objc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ libtightdb_objc_a_VERSION = 1:0:0
include ../../../generic.mk

# Code generation
ifeq ($(DISABLE_CHEETAH_CODE_GEN),)
$(TIGHTDB_H): tightdb.h.sh tightdb.h.py
$(SHELL) tightdb.h.sh $(TIGHTDB_H)
endif

# Code generation

uninstall/extra:
$(RM) $(DESTDIR)$(includedir)/tightdb/objc/*.h
Expand Down
1 change: 1 addition & 0 deletions src/tightdb/objc/group_objc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ @interface TightdbGroup()
@property(nonatomic) tightdb::Group *group;
@property(nonatomic) BOOL readOnly;
@end

@implementation TightdbGroup
@synthesize group = _group;
@synthesize readOnly = _readOnly;
Expand Down
7 changes: 0 additions & 7 deletions src/tightdb/objc/group_shared_objc.mm
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
//
// group_shared.mm
// Tightdb_objc
//
// Created by Tightdb on 11/14/12.
// Copyright (c) 2012 Tightdb. All rights reserved.
//
#include <tightdb/group_shared.hpp>

#import <tightdb/objc/group_shared.h>
Expand Down
Loading

0 comments on commit e6f5a1a

Please sign in to comment.