Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading of the Foundation framework under GNUstep #122

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 47 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
branches:
only:
- master
os: osx
matrix:
include:
# Note: The ordering of the environments is optimized so that the complete matrix runs as quickly as possible,
Expand All @@ -18,14 +17,32 @@ matrix:
# With the following order, xcode6.4 will take up the first slot, and at the same time the three other
# environments use the second slot in sequence. xcode9.2 will finish first and provide some early results - most
# test failures happen in all environments and will be quickly reported this way.
# Linux builds have a higher limit than Mac builds, so the Linux environment will run in parallel with the Mac
# environments.

# OSX 10.10 Yosemite
- osx_image: xcode6.4
- os: osx
osx_image: xcode6.4
# macOS 10.12 Sierra
- osx_image: xcode9.2
- osx_image: xcode8.3
- os: osx
osx_image: xcode9.2
- os: osx
osx_image: xcode8.3
# OSX 10.11 El Capitan
- osx_image: xcode7.3
- os: osx
osx_image: xcode7.3
# Linux with GNUstep
- os: linux
dist: xenial
addons:
apt:
packages:
- gnustep-devel
# Linux for flake8 only
- os: linux
dist: xenial
env:
- FLAKE8_ONLY=1
language: generic
cache:
directories:
Expand All @@ -37,25 +54,40 @@ env:
- PY36="3.6.5"
- PY37="3.7.0"
install:
# The different Travis environments have different pyenv versions, and not all have the Python versions we need,
# so we upgrade pyenv to get a consistent setup in all environments.
- brew update
- brew outdated pyenv || brew upgrade pyenv
- |
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
# The different Travis environments have different pyenv versions, and not all have the Python versions we need,
# so we upgrade pyenv to get a consistent setup in all environments.
brew update
brew outdated pyenv || brew upgrade pyenv
else
pushd "$(pyenv root)"
git checkout master
git pull
popd
fi
# The existing pyenv shims from the build cache may no longer be valid, for example if pyenv was upgraded
# (in which case the paths used in the shims point to an older, no longer installed pyenv version).
# By rehashing the shims we can be sure that they are always valid again.
- pyenv rehash
# pyenv's shims directory is not in the PATH by default.
- export PATH="$(pyenv root)/shims:${PATH}"
# These are the Python versions that we want to test on.
- pyenv install --skip-existing ${PY34}
- pyenv install --skip-existing ${PY35}
- pyenv install --skip-existing ${PY36}
- pyenv install --skip-existing ${PY37}
- pyenv install --skip-existing ${PY36}
- pyenv install --skip-existing ${PY35}
- pyenv install --skip-existing ${PY34}
- pyenv global ${PY37} ${PY36} ${PY35} ${PY34} system
# tox is not installed by default in some older Travis environments.
- python3.6 -m pip install tox
- make -f Makefile
script:
- export DYLD_LIBRARY_PATH=`pwd`/tests/objc
- python3.6 -m tox -e "py{34,35,36,37}-default,flake8"
- |
if [[ "${FLAKE8_ONLY}" == "1" ]]; then
python3.6 -m tox -e "flake8"
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
make -f Makefile
DYLD_LIBRARY_PATH="$(pwd)/tests/objc" python3.6 -m tox -e "py{34,35,36,37}-default"
else
make -f Makefile
LD_LIBRARY_PATH="$(pwd)/tests/objc" python3.6 -m tox -e "py{34,35,36,37}-default"
fi
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
OBJ_FILES=tests/objc/Thing.o tests/objc/Example.o tests/objc/BaseExample.o tests/objc/Blocks.o

# By default, build a universal i386/x86_64 binary.
# Modify here (or on the command line) to build for other architecture(s).
EXTRA_FLAGS=-arch i386 -arch x86_64
OS := $(shell uname)
CC = clang
ifeq ($(OS),Darwin)
# By default, build a universal i386/x86_64 binary.
# Modify here (or on the command line) to build for other architecture(s).
CFLAGS = -arch i386 -arch x86_64
LDFLAGS = -dynamiclib -arch i386 -arch x86_64
LDLIBS = -fobjc-link-runtime
LIB_EXT = dylib
else
CFLAGS = `gnustep-config --objc-flags`
LDFLAGS =
LDLIBS = `gnustep-config --objc-libs`
LIB_EXT = so
endif

all: tests/objc/librubiconharness.dylib
all: tests/objc/librubiconharness.$(LIB_EXT)

tests/objc/librubiconharness.dylib: $(OBJ_FILES)
clang -dynamiclib -fobjc-link-runtime $(EXTRA_FLAGS) $(OBJ_FILES) -o tests/objc/librubiconharness.dylib
tests/objc/librubiconharness.$(LIB_EXT): $(OBJ_FILES)
$(CC) $(LDFLAGS) $(OBJ_FILES) -o tests/objc/librubiconharness.$(LIB_EXT) $(LDLIBS)

clean:
rm -rf tests/objc/*.o tests/objc/*.d tests/objc/librubiconharness.dylib
rm -rf tests/objc/*.o tests/objc/*.d tests/objc/librubiconharness.$(LIB_EXT)

%.o: %.m tests/objc/*.h
clang -x objective-c -I./tests/objc -c $(EXTRA_FLAGS) $< -o $@
$(CC) -c $(CFLAGS) $< -o $@

8 changes: 7 additions & 1 deletion rubicon/objc/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ def load_library(name):

libc = load_library('c')
libobjc = load_library('objc')
Foundation = load_library('Foundation')
try:
Foundation = load_library('Foundation')
except ValueError:
# The Foundation framework was not found. This means we're on a non-Apple system, so try to use GNUstep instead.
# Because GNUstep uses the traditional Unix library structure instead of frameworks, it provides the Foundation
# classes in a library called gnustep-base rather than Foundation.
Foundation = load_library('gnustep-base')


@with_encoding(b'@')
Expand Down
2 changes: 1 addition & 1 deletion tests/objc/Example.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ extern NSString *const SomeGlobalStringConstant;
+(int) classAmbiguous;

-(NSString *) toString;
-(NSString *) duplicateString:(NSString *) in;
-(NSString *) duplicateString:(NSString *) inStr;
-(NSString *) smiley;

-(NSNumber *) theAnswer;
Expand Down
4 changes: 2 additions & 2 deletions tests/objc/Example.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ -(NSString *) toString
return [NSString stringWithFormat:@"This is an ObjC Example object"];
}

-(NSString *) duplicateString:(NSString *) in
-(NSString *) duplicateString:(NSString *) inStr
{
return [NSString stringWithFormat:@"%@%@", in, in];
return [NSString stringWithFormat:@"%@%@", inStr, inStr];
}

-(NSString *) smiley
Expand Down