Skip to content

Commit

Permalink
Make this usable
Browse files Browse the repository at this point in the history
Sync the version of GNUstep compiled to that shipped with Hopper,
and update the patches to track the changes upstream.

Rework the install location. The SDK now installs into the user's
`ApplicationSupport/Hopper` directory, and drops a symlink to the
`GNUstep.sh` environment setup script into `$HOME`
  • Loading branch information
ckuethe committed May 12, 2017
1 parent 2bfff5a commit b3fc5f6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 46 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Introduction

This is an update of the Hopper
[Linux SDK](https://www.hopperapp.com/blog/?p=150) to match the
versions of libraries shipped by more recent Hopper builds.

# Usage

```
git clone https://github.com/ckuethe/HopperSDK-Linux
cd HopperSDK-Linux
./install.sh
. ${HOME}/hopper-gnustep.sh
# go about your plugin development business.
```

When the build finishes, the SDK will be installed in
`${HOME}/GNUstep/Library/ApplicationSupport/Hopper` as
`HopperSDK-${SDKVER}` and `gnustep-$(arch)`. Additionally a symbolic
link to `GNUstep.sh` - required to set up some environment variables
to compile plugins - will be installed at `${HOME}/hopper-gnustep.sh`.
On a multiuser machine, each user will need to run this SDK installer.

# Notes
* On recent Ubuntu (17.04) `libxml2-dev` `libgnutls28-dev` `libxslt1-dev`
`libgcrypt20-dev` are to compile GNUstep base
67 changes: 37 additions & 30 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,86 +3,92 @@
set -e

## Variables
SUFFIX=$(uname)-$(arch)

SDKVER=4.1.5
GNUSTEP_REV=37819
GNUSTEP_BASE_GIT=3c4ff69d696e2b5d4afacf70352b5d483b18997b # close to svn-37819
GNUSTEP_MAKE_GIT=0b7a76a45e9f6d7dc4d982c226fff111465d1272 # close to svn-37819
LIBDISPATCH_REV=700a514955d6c86b29439c80f3bc0b69405b43f0
GNUSTEP_MAKE_GIT=a964f87bdecab5156ed24f224548680aa2555676 # svn-39575, probably close to what hopper was built with
GNUSTEP_BASE_GIT=03952f1e961931828a3eba62784c02205e8c0a65 # svn-39569, hopper ships libgnustep-base 1.24.9
LIBDISPATCH_REV=e63c3c130c5115b653beca04b7f245e20ba84a08 # hopper ships libdispatch 0.1.3.1

JOBS=$(nproc)
DEST=$(pwd)/gnustep-$SUFFIX
DEST="${HOME}/GNUstep/Library/ApplicationSupport/Hopper"
SDKDIR="${DEST}/HopperSDK-${SDKVER}"
GS_DIR="${DEST}/gnustep-$(arch)"
LAYOUT=fhs

CC=clang
CXX=clang++

## Cleanup
mkdir -p "${DEST}"
echo "Cleaning"
rm -rf "$DEST"
rm -rf sources HopperSDK
mkdir sources HopperSDK
rm -rf sources # comment this out to not remove downloaded sources (saves dowloads) while developing this script
rm -rf "${DEST}/HopperSDK" "${SDKDIR}" "${GS_DIR}"
mkdir -p "${SDKDIR}" "${GS_DIR}" sources

## Download latest Hopper SDK
echo "Downloading sources"
echo " Hopper SDK"
SDKZIP="sources/HopperSDK-${SDKVER}.zip"
curl -A SDK -L --progress-bar -o $SDKZIP "https://d2ap6ypl1xbe4k.cloudfront.net/HopperSDK-${SDKVER}.zip"
unzip -d HopperSDK $SDKZIP >/dev/null 2>&1
SDK_ZIP="HopperSDK-${SDKVER}.zip"
test -f sources/$SDK_ZIP || curl -A SDK -L --progress-bar -o sources/$SDK_ZIP "https://d2ap6ypl1xbe4k.cloudfront.net/${SDK_ZIP}"
unzip -qq -d "${SDKDIR}" sources/$SDK_ZIP >/dev/null 2>&1
ln -s "${SDKDIR}" "${DEST}/HopperSDK"

## Download sources
cd sources
echo " libobjc2..."
git clone -q https://github.com/gnustep/libobjc2 gnustep-libobjc2
D=gnustep-libobjc2
test -d $D || git clone -q https://github.com/gnustep/libobjc2 $D

echo " gnustep-make..."
git clone -q https://github.com/gnustep/make gnustep-make
git -C gnustep-make checkout -q $GNUSTEP_MAKE_GIT
D=gnustep-make
test -d $D || git clone -q https://github.com/gnustep/make $D
git -C $D checkout -qf $GNUSTEP_MAKE_GIT

echo " gnustep-base..."
git clone -q https://github.com/gnustep/base gnustep-base
git -C gnustep-base checkout -q $GNUSTEP_BASE_GIT
D=gnustep-base
test -d $D || git clone -q https://github.com/gnustep/base $D
git -C $D checkout -qf $GNUSTEP_BASE_GIT

echo " libdispatch..."
git clone -q https://github.com/nickhutchinson/libdispatch.git
git -C libdispatch checkout -q $LIBDISPATCH_REV
D=libdispatch
test -d $D || git clone -q https://github.com/nickhutchinson/libdispatch $D
git -C $D checkout -qf $LIBDISPATCH_REV

## Compilation
echo "Compilation"
SRC=$(pwd)
## Compile gnustep-make
echo " gnustep-make..."
cd gnustep-make
./configure CC=$CC CXX=$CXX --with-layout=$LAYOUT --prefix="$DEST"
./configure CC=$CC CXX=$CXX --with-layout=$LAYOUT --prefix="${GS_DIR}"
make
make install
cd "$DEST/bin"
ln -s "../share/GNUstep/Makefiles/GNUstep.sh"

cd $SRC
. "$DEST/share/GNUstep/Makefiles/GNUstep.sh"
. "${GS_DIR}/share/GNUstep/Makefiles/GNUstep.sh"

## Compile the Objective-C 2 runtime
echo " libobjc2..."
cd gnustep-libobjc2
rm -rf build ; mkdir build ; cd build
cmake .. -DCMAKE_INSTALL_PREFIX="$DEST" -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX
cmake .. -DCMAKE_INSTALL_PREFIX="${GS_DIR}" -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX
make -j$JOBS
make install
cd $SRC

cd gnustep-make
./configure CC=$CC CXX=$CXX --enable-objc-nonfragile-abi --with-layout=$LAYOUT --prefix="$DEST"
./configure CC=$CC CXX=$CXX --enable-objc-nonfragile-abi --with-layout=$LAYOUT --prefix="${GS_DIR}"
make
make install
cd $SRC

. "$DEST/share/GNUstep/Makefiles/GNUstep.sh"
. "${GS_DIR}/share/GNUstep/Makefiles/GNUstep.sh"

## Compile GNUstep base
# On recent Ubuntu (17.04...) you may need to do 'sudo apt install libxml2-dev libgnutls28-dev libxslt1-dev libgcrypt20-dev'
echo " gnustep-base..."
cd gnustep-base
patch -p0 <../../patches/gnustep-base.patch
./configure CC=$CC CXX=$CXX --prefix="$DEST"
./configure CC=$CC CXX=$CXX --prefix="${GS_DIR}"
make -j$JOBS 2>/dev/null
make install
cd $SRC
Expand All @@ -94,7 +100,7 @@ patch -p1 <../../patches/libdispatch.patch
sed -i"" "s/add_subdirectory(testing)/#add_subdirectory(testing)/" CMakeLists.txt
mkdir build
cd build
cmake .. -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_INSTALL_PREFIX="$DEST" -DCMAKE_BUILD_TYPE=Release
cmake .. -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_INSTALL_PREFIX="${GS_DIR}" -DCMAKE_BUILD_TYPE=Release
make
make install
cd $SRC
Expand Down Expand Up @@ -147,4 +153,5 @@ _EOF
clang test.m -o test $(gnustep-config --objc-flags) $(gnustep-config --base-libs) -fobjc-arc -fobjc-nonfragile-abi -O0 -g -ldispatch
./test
echo "GNUstep for Hopper SDK ready."
echo "source '$DEST/bin/GNUstep.sh' to use it"
echo "source '${HOME}/hopper-gnustep.sh' to use it"
ln -fs "${GS_DIR}/share/GNUstep/Makefiles/GNUstep.sh" "${HOME}/hopper-gnustep.sh"
16 changes: 0 additions & 16 deletions patches/gnustep-base.patch
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,3 @@ Index: Source/NSArray.m
return (NSOrderedSame == CALL_BLOCK(comparator,
key, [self objectAtIndex: index]) ? index : NSNotFound);
}
@@ -2025,7 +2033,14 @@

- (void) setObject: (id)anObject atIndexedSubscript: (size_t)anIndex
{
- [self replaceObjectAtIndex: (NSUInteger)anIndex withObject: anObject];
+ if (anIndex == [self count]) {
+ // From Apple documentation of -[NSMutableArray setObject:atIndexedSubscript:]
+ // "If the index is equal to count the element is added to the end of the array, growing the array."
+ [self addObject:anObject];
+ }
+ else {
+ [self replaceObjectAtIndex: (NSUInteger)anIndex withObject: anObject];
+ }
}

/** Replaces the values in the receiver at the locations given by the

0 comments on commit b3fc5f6

Please sign in to comment.