From c676f439dc8524833f10259ae9a74b6961cf501d Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 1 Jul 2018 00:37:07 +0200 Subject: [PATCH 01/14] Fix loading of the Foundation framework under GNUstep Fixes #113. --- rubicon/objc/runtime.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rubicon/objc/runtime.py b/rubicon/objc/runtime.py index ccc27875..3eebc199 100644 --- a/rubicon/objc/runtime.py +++ b/rubicon/objc/runtime.py @@ -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'@') From 1f3a0f1f9cc7369e511c98e0a41a19f3ade4106f Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 1 Jul 2018 14:49:54 +0200 Subject: [PATCH 02/14] Add a Travis environment with Linux and GNUstep --- .travis.yml | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9479dea..c08fd8c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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, @@ -17,16 +16,28 @@ matrix: # https://blog.travis-ci.com/2017-09-22-macos-update # 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. + # 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 language: generic +addons: + apt: + packages: + - gnustep cache: directories: ~/.pyenv @@ -36,10 +47,14 @@ env: - PY35="3.5.5" - PY36="3.6.4" 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 + 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. From 96cad205d8e4b1b3d9d853828eb5113f4fda644a Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 1 Jul 2018 15:04:01 +0200 Subject: [PATCH 03/14] Move flake8 check into a separate environment This way a style error won't cause all environments to fail anymore. --- .travis.yml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index c08fd8c3..a4b8ecff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,11 +33,15 @@ matrix: osx_image: xcode7.3 # Linux with GNUstep - os: linux + addons: + apt: + packages: + - gnustep + # Linux for flake8 only + - os: linux + env: + - FLAKE8_ONLY=1 language: generic -addons: - apt: - packages: - - gnustep cache: directories: ~/.pyenv @@ -68,7 +72,12 @@ install: - pyenv global ${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}-default,flake8" + - | + if [[ "${FLAKE8_ONLY}" == "1" ]] + then + python3.6 -m tox -e "flake8" + else + make -f Makefile + DYLD_LIBRARY_PATH="$(pwd)/tests/objc" python3.6 -m tox -e "py{34,35,36}-default" + fi From f8b48d52f0ebc7636b9abfbb0b999acc3f24fe95 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 1 Jul 2018 15:11:12 +0200 Subject: [PATCH 04/14] Fix pyenv not being updated on Linux Travis builds --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a4b8ecff..e842fca6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,6 +58,8 @@ install: # so we upgrade pyenv to get a consistent setup in all environments. brew update brew outdated pyenv || brew upgrade pyenv + else + pyenv update 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). From f5bc4afcd1efe9f32821ee7d43fb459e8099e7a6 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 1 Jul 2018 15:32:58 +0200 Subject: [PATCH 05/14] Fix updating of pyenv on Linux --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e842fca6..07ff5bf9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,7 @@ install: brew update brew outdated pyenv || brew upgrade pyenv else - pyenv update + git pull "$(pyenv root)" 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). From 654b96a90f73a89ab6045601c7c05f584fee054c Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 1 Jul 2018 15:42:20 +0200 Subject: [PATCH 06/14] Try to fix updating of pyenv on Linux, again --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 07ff5bf9..b4cb0401 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,10 @@ install: brew update brew outdated pyenv || brew upgrade pyenv else - git pull "$(pyenv root)" + pushd "$(pyenv root)" + git fetch + git checkout master + 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). From 11e92d12124e835dbad7d24418aa7348e9e14bfb Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 1 Jul 2018 15:44:35 +0200 Subject: [PATCH 07/14] Fix updating of pyenv on Linux, for real this time --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b4cb0401..f66c7cb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,8 +60,8 @@ install: brew outdated pyenv || brew upgrade pyenv else pushd "$(pyenv root)" - git fetch 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 From 67768866b4add11dd28db8b50991edcfb5dbe382 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 1 Jul 2018 15:55:10 +0200 Subject: [PATCH 08/14] Install development version of GNUstep on Linux Travis Otherwise we can't build the test harness, due to missing headers. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f66c7cb6..93b3090d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ matrix: addons: apt: packages: - - gnustep + - gnustep-devel # Linux for flake8 only - os: linux env: From cc064bd2549614553b8ced9f7b66d0e98620ff1f Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 1 Jul 2018 16:25:33 +0200 Subject: [PATCH 09/14] Make the test harness build on Linux --- Makefile | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f268cf24..19e1e25b 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,30 @@ 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) +ifeq ($(OS),Darwin) + CC = clang + # 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 + CC = gcc + CFLAGS = + LDFLAGS = + LDLIBS = -lobjc -lgnustep-base + 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) -x objective-c -I./tests/objc -c $(CFLAGS) $< -o $@ From e5c005210ddc0c212dcbe1b26fd1fc216aa1cc68 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 1 Jul 2018 16:27:49 +0200 Subject: [PATCH 10/14] Remove unneeded compiler flags from Makefile The language doesn't need to be specified explicitly, the compiler can infer it from the source file extensions. There's no need to add tests/objc to the include path manually, since the source files are already in the same directory as the headers. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 19e1e25b..2f8a3b07 100644 --- a/Makefile +++ b/Makefile @@ -26,5 +26,5 @@ clean: rm -rf tests/objc/*.o tests/objc/*.d tests/objc/librubiconharness.$(LIB_EXT) %.o: %.m tests/objc/*.h - $(CC) -x objective-c -I./tests/objc -c $(CFLAGS) $< -o $@ + $(CC) -c $(CFLAGS) $< -o $@ From 86bb74b03b5d0b0dd38624f8bbf303ed5ae99c79 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 7 Jul 2018 08:24:53 +0800 Subject: [PATCH 11/14] Added GNUStep include paths to Makefile. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2f8a3b07..dba083d7 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ ifeq ($(OS),Darwin) LIB_EXT = dylib else CC = gcc - CFLAGS = + CFLAGS = -I/usr/include/GNUstep -fconstant-string-class=NSConstantString LDFLAGS = LDLIBS = -lobjc -lgnustep-base LIB_EXT = so From a8b64f309f53f3c4ea2941a9ea9fef80a891698d Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 7 Jul 2018 10:59:19 +0800 Subject: [PATCH 12/14] Use Xenial as the base for Linux builds. --- .travis.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index c3d0b0a4..ee87484b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,12 +33,14 @@ matrix: 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 @@ -53,8 +55,7 @@ env: - PY37="3.7.0" install: - | - if [[ "${TRAVIS_OS_NAME}" == "osx" ]] - then + 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 @@ -72,19 +73,21 @@ install: # 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 script: - | - if [[ "${FLAKE8_ONLY}" == "1" ]] - then + if [[ "${FLAKE8_ONLY}" == "1" ]]; then python3.6 -m tox -e "flake8" - else + 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 From fc61fa8585fae8b8d65ee82750712166d3b1b54e Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 7 Jul 2018 13:11:44 +0800 Subject: [PATCH 13/14] Modified build instructions for GNUstep. --- Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index dba083d7..268f0d1f 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ OBJ_FILES=tests/objc/Thing.o tests/objc/Example.o tests/objc/BaseExample.o tests/objc/Blocks.o OS := $(shell uname) +CC = clang ifeq ($(OS),Darwin) - CC = clang # 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 @@ -10,10 +10,9 @@ ifeq ($(OS),Darwin) LDLIBS = -fobjc-link-runtime LIB_EXT = dylib else - CC = gcc - CFLAGS = -I/usr/include/GNUstep -fconstant-string-class=NSConstantString + CFLAGS = `gnustep-config --objc-flags` LDFLAGS = - LDLIBS = -lobjc -lgnustep-base + LDLIBS = `gnustep-config --objc-libs` LIB_EXT = so endif From c26427b7d213ae5606b583f3d503e659fe6ba389 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 7 Jul 2018 13:12:09 +0800 Subject: [PATCH 14/14] Changed a variable name that caused problems on GNUstep. --- tests/objc/Example.h | 2 +- tests/objc/Example.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/objc/Example.h b/tests/objc/Example.h index 5e17a0f5..16b77a30 100644 --- a/tests/objc/Example.h +++ b/tests/objc/Example.h @@ -83,7 +83,7 @@ extern NSString *const SomeGlobalStringConstant; +(int) classAmbiguous; -(NSString *) toString; --(NSString *) duplicateString:(NSString *) in; +-(NSString *) duplicateString:(NSString *) inStr; -(NSString *) smiley; -(NSNumber *) theAnswer; diff --git a/tests/objc/Example.m b/tests/objc/Example.m index cbefd7a3..681c0973 100644 --- a/tests/objc/Example.m +++ b/tests/objc/Example.m @@ -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