Skip to content

Commit 1ffe595

Browse files
committed
Revamp installation/setup guide based on https://github.com/gnustep/documentation
1 parent 47b5b52 commit 1ffe595

File tree

13 files changed

+553
-20
lines changed

13 files changed

+553
-20
lines changed

source/Guides/Install/Linux.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

source/Guides/Install/Windows.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Building on Linux
2+
3+
We first need to install some prequisits including
4+
clang for Objective-C 2.0 support, and set some
5+
enviroment variables.
6+
7+
Debian-based:
8+
```sh
9+
sudo apt install clang lld git cmake make pkg-config
10+
```
11+
12+
Environment:
13+
```sh
14+
export CC=/usr/bin/clang
15+
export CXX=/usr/bin/clang++
16+
export PATH=/usr/local/bin:$PATH
17+
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
18+
export LD=/usr/bin/ld.lld
19+
export LDFLAGS=-fuse-ld=/usr/bin/ld.lld
20+
```
21+
22+
## 1.1 libobjc2
23+
24+
We can now build and install the Objective-C runtime libobjc2.
25+
```sh
26+
git clone --recurse-submodules --branch <REPLACE_WITH_LATEST_TAG> "https://github.com/gnustep/libobjc2"
27+
cd libobjc2
28+
mkdir build && cd build
29+
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
30+
sudo make install
31+
```
32+
33+
## 1.2 libdispatch
34+
35+
Grand Central Dispatch (GCD) is a library that provides a
36+
low-level and efficient API for managing work across threads.
37+
38+
```sh
39+
git clone --branch <REPLACE_WITH_LATEST_TAG> https://github.com/apple/swift-corelibs-libdispatch
40+
cd swift-corelibs-libdispatch/
41+
mkdir build && cd build
42+
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DINSTALL_PRIVATE_HEADERS=YES
43+
sudo make install
44+
```
45+
46+
## 1.3 GNUstep Make
47+
48+
GNUstep make is a collection of makefiles and scripts to
49+
build GNUstep frameworks, libraries and applications.
50+
51+
```sh
52+
git clone --branch <REPLACE_WITH_LATEST_TAG> https://github.com/gnustep/tools-make
53+
cd tools-make
54+
./configure \
55+
--with-layout=fhs \
56+
--enable-native-objc-exceptions \
57+
--enable-objc-arc \
58+
--enable-install-ld-so-conf \
59+
--enable-debug-by-default
60+
sudo make install
61+
```
62+
63+
## 1.4 GNUstep Base
64+
65+
GNUstep Base features the Foundation framework, a collection of non-graphical Objective-C objects.
66+
Different from the Foundation framework on macOS, GNUstep Base is not based on CoreFoundation.
67+
You can still use CoreFoundation (a.k.a CoreBase) on GNUstep, but it is not required.
68+
69+
### 1.4.1 Dependencies
70+
You will need to install the following dependencies before building GNUstep Base:
71+
- GNUstep Make (see above)
72+
- gnutls or openssl
73+
- libffi
74+
- libxml2
75+
- libxslt
76+
- zlib
77+
- libavahi
78+
- libicu
79+
- tzdata
80+
- libcurl
81+
82+
Debian-based:
83+
```sh
84+
sudo apt install gnutls-bin, libffi-dev, libxml2-dev, libxslt1-dev, libgnutls28-dev, zlib1g-dev, libavahi-client-dev, libicu-dev, tzdata, libcurl4-openssl-dev
85+
```
86+
87+
### 1.4.2 Building
88+
89+
```sh
90+
# Source the GNUstep environment
91+
source /usr/local/share/GNUstep/Makefiles/GNUstep.sh
92+
93+
# Clone the repository
94+
git clone --branch <REPLACE_WITH_LATEST_TAG> https://github.com/gnustep/libs-base
95+
96+
cd libs-base
97+
./configure
98+
```
99+
100+
## 1.5 GNUstep CoreBase
101+
If you are interested in using the C-based CoreFoundation
102+
API you can build and install GNUstep CoreBase.
103+
104+
Please note that CoreBase is not that mature yet and you can run into
105+
issues when using it. For more information about the current state
106+
of CoreBase please see [TODO]().
107+
108+
### 1.5.1 Dependencies
109+
- GNUstep Make (see above)
110+
- GNUstep Base (see above)
111+
- libicu
112+
113+
Debian-based:
114+
```sh
115+
sudo apt install libicu-dev
116+
```
117+
118+
### 1.5.2 Building
119+
120+
```sh
121+
# Source the GNUstep environment
122+
source /usr/local/share/GNUstep/Makefiles/GNUstep.sh
123+
124+
# Clone the repository
125+
git clone --branch <REPLACE_WITH_LATEST_TAG> https://github.com/gnustep/libs-corebase
126+
127+
cd libs-corebase
128+
./configure
129+
```
130+
131+
If you are only interested in using non-graphical frameworks you can stop here.

source/Guides/Setup/Linux/index.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Linux
2+
3+
```{toctree}
4+
:maxdepth: 2
5+
:caption: Contents
6+
:titlesonly: true
7+
8+
building-linux
9+
```
10+
11+
## Installation (simple)
12+
13+
Ensure you have `bash`, `curl`, and `sudo` installed and working. Then run the following command in your terminal:
14+
15+
```bash
16+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/gnustep/tools-scripts/master/gnustep-web-install)"
17+
```
18+
19+
This will install GNUstep with most modern features enabled, including a recent version of Clang, support for ARC and other modern Objective-C features, typed selectors, ICU support in NSString, NSLocale, and similar classes, and Grand Central Dispatch. It installs from the `master` or `main` branch of most repositories.
20+
21+
Avoid your distribution packages -- it is often outdated and sometimes is compiled using GCC, which disables ARC and modern Objective-C features.
22+
23+
## Code completion, navigation, and linting
24+
25+
### VSCode or VSCodium
26+
27+
We use the clangd extension, which provides support for code completion and navigation, along with Clang-style warnings and error messages, based on the Clang compiler's code. If you have the Microsoft C/C++ extension, make sure to disable IntelliSense when prompted, as IntelliSense does not support Objective-C and Objective-C++ code.
28+
29+
Here is the list of extensions:
30+
- [clangd](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) - The official clang language server for Visual Studio Code
31+
32+
You need to explicitly set the clangd executable path in the clangd extension settings if you want to use the system version of LLVM. You can find the clangd executable in the LLVM installation directory (e.g. `C:\Program Files\LLVM\bin\clangd.exe`).
33+
34+
You can now open a folder in Visual Studio Code, and start coding. The clangd extension will search for the file `compile_commands.json` to get the compiler flags.
35+
36+
To build your project, simply use the integrated terminal.
37+
38+
Behaviour with different build systems:
39+
- Meson: Generates `compile_commands.json` by default
40+
- CMake: Generates `compile_commands.json` with the `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` flag
41+
- Make: Intercept and generate `compile_commands.json` with the [bear](https://github.com/rizsotto/Bear) tool
42+
- Run Make using `bear -- make` in order to generate a `compile_commands.json` file
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Building on Windows
2+
3+
As building the GNUstep toolchain on Windows is a bit more involved than on other platforms, we have a dedicated build script for it.
4+
5+
The toolchain is used commercially as well, and can be used to integrate Objective-C into your existing Windows projects.
6+
7+
## 1 Prerequisites
8+
9+
Before we can start building, we need to install some dependencies. We will be using [Chocolatey](https://chocolatey.org/) to install them.
10+
11+
Follow the guide on installing Visual Studio, and the Windows SDK from the [Windows Development Workflow](./windows-dev-workflow.md) guide.
12+
13+
### 1.1 Installing other dependencies
14+
15+
Now install the following dependencies using chocolatey:
16+
17+
```sh
18+
choco install llvm git msys2 nasm
19+
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
20+
```
21+
22+
We use LLVM and the clang frontend to compile Objective-C code, and lld as a linker.
23+
24+
MSYS2 is a software distribution and a development platform for Windows, providing a
25+
Unix-like environment, a package management system (based on pacman), and tools
26+
for bridging Windows idiosyncrasies with the Unix world.
27+
28+
### 1.2 Installing msys2 packages
29+
30+
Now we need to install some packages using pacman, the package manager of MSYS2.
31+
Open a MSYS2 shell (Windows + R -> msys2.exe), and run the following commands:
32+
33+
```sh
34+
pacman -S --needed make autoconf automake libtool pkg-config
35+
```
36+
37+
### 2 Building
38+
39+
We can start building the toolchain. Open a MSYS2 shell, and clone the tools-windows-msvc repository:
40+
41+
```sh
42+
# Export the path to the LLVM and Git binaries
43+
export PATH=$PATH:/c/Program\ Files/Git/cmd:/c/Program\ Files/LLVM/bin
44+
45+
# Clone the repository (you can change the installation directory)
46+
cd /c
47+
git clone https://github.com/gnustep/tools-windows-msvc
48+
```
49+
50+
Open a x64 Native Tools Command Prompt (search for it in the start menu) and run the build.bat script:
51+
52+
```sh
53+
cd C:\tools-windows-msvc
54+
55+
# You can omit the type to build debug, and release, or change it to Debug
56+
# We only build non-gui libraries (libobjc2, libdispatch, base, corebase)
57+
# If you want to build the gui libraries, you can remove the --no-gui flag
58+
build.bat --type Release --no-gui
59+
```
60+
61+
If no error occured during the build, you can now find the toolchain in `C:\GNUstep\x64\{Debug, Release}`.
62+
To learn more about the toolchain directory structure and how to use it, see [Using the MSVC toolchain](./using-windows-msvc.md).
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# IDE setup
2+
3+
## 3 Code completion, navigation, and linting
4+
5+
### 3.1 Using Visual Studio Code
6+
7+
We use a combination of the Microsoft C/C++ extension, and the clangd extension. Make sure to disable IntelliSense when prompted, as IntelliSense does not support Objective-C and Objective-C++ code.
8+
9+
Here is the list of extensions:
10+
- [C/C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) - IntelliSense, debugging, and code browsing for C and C++
11+
- [clangd](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd) - The official clang language server for Visual Studio Code
12+
13+
You need to explicitly set the clangd executable path in the clangd extension settings if you want to use the system version of LLVM. You can find the clangd executable in the LLVM installation directory (e.g. `C:\Program Files\LLVM\bin\clangd.exe`).
14+
15+
You can now open a folder in Visual Studio Code, and start coding The clangd extension will search for the file `compile_commands.json` to get the compiler flags.
16+
17+
Behaviour with different build systems:
18+
- Meson: Generates `compile_commands.json` by default
19+
- CMake: Generates `compile_commands.json` with the `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` flag
20+
- Make: Intercept and generate `compile_commands.json` with the [bear](https://github.com/rizsotto/Bear) tool
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Windows
2+
3+
```{toctree}
4+
:maxdepth: 2
5+
:caption: Contents
6+
:titlesonly: true
7+
8+
sdk-setup
9+
installing-windows-msvc
10+
using-windows-msvc-msys2
11+
building-windows-msvc
12+
ide-setup
13+
```
14+
15+
First, you should set up a development environment following [the SDK setup guide](sdk-setup). Then you can either [build GNUstep](building-windows-msvc) or [install GNUstep from the prebuilt binaries](installing-windows-msvc). Then, [set up and use GNUstep in MSYS2](using-windows-msvc-msys2) and [set up VS Code](ide-setup).
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Installing the GNUstep MSVC toolchain on Windows
2+
3+
We call the native GNUstep toolchain for Windows the MSVC (Microsoft Visual C++) toolchain, as it uses the MSVC compiler for some projects,
4+
and uses native Windows APIs, instead of a POSIX compatibility layer like MinGW. It also produces native Windows binaries.
5+
6+
Clang is used for compiling Objective-C code.
7+
8+
## 1 Prerequisites
9+
10+
First we need to install LLVM, to get the clang frontend, and lld. We will be using [Chocolatey](https://chocolatey.org/) to install it, but you can also install it manually using the official installer.
11+
12+
In a Administrator Shell (either CMD or Powershell), run the following command:
13+
```sh
14+
choco install llvm
15+
```
16+
17+
## 2 Installing from a prebuilt release
18+
19+
We provide prebuilt releases of the toolchain, which you can download from the [releases page](https://github.com/gnustep/tools-windows-msvc/releases) on GitHub. Select the latest release, and download `GNUstep-Windows-MSVC-x64.zip` artefact
20+
if you are on a x86_64 system.
21+
22+
Extract the zip file to a directory of your choice. We will use `C:\GNUstep` in this guide, as it is also the default installation directory of the build script.
23+
24+
You can now use the toolchain, and start building your own projects.
25+
26+
## 3 Structure of the toolchain directory
27+
28+
If you are familiar with the standard filesystem structure on UNIX-based system, you will find some similarities here.
29+
`C:\GNUstep\x64` contains two directories: Debug and Release. The debug build contains debug symbols (.pdb files for dlls).
30+
31+
```sh
32+
$ ls GNUstep/x64/Debug
33+
bin etc include lib share
34+
```
35+
36+
The `bin` directory contains binaries, and dlls (objc.dll, gnustep-base-1_28.dll, etc).
37+
```sh
38+
$ ls GNUstep/x64/Debug/bin
39+
HTMLLinker.exe defaults.exe gnustep-base-1_28.dll gnustep-corebase-0.pdb icuin72.dll libffi-8.dll make_strings.exe opentool plget.exe plutil.exe
40+
autogsdoc.exe dispatch.dll gnustep-base-1_28.pdb gnustep-tests icuio72.dll libffi-8.pdb objc.dll pl.exe plmerge.exe sfparse.exe
41+
cvtenc.exe dispatch.pdb gnustep-config gspath.exe icutu72.dll libiconv.dll objc.pdb pl2link.exe plparse.exe xmlparse.exe
42+
debugapp gdnc.exe gnustep-corebase-0.dll icudt72.dll icuuc72.dll libiconv.pdb openapp pldes.exe plser.exe
43+
```
44+
45+
The `lib` directory contains static libraries (.lib files).
46+
```
47+
$ ls GNUstep/x64/Debug/lib
48+
GNUstep dispatch.lib exslt.lib ffi.lib gnustep-base.lib gnustep-corebase.lib iconv.lib icudt.lib icuin.lib icuio.lib icutest.lib icutu.lib icuuc.lib objc.lib pkgconfig xml2.lib xslt.lib
49+
```
50+
51+
The `include` directory contains the headers for the libraries (you will recognise the `Foundation` subdirectory containing the header files). The `share` directory contains the GNUstep configuration files.
52+

0 commit comments

Comments
 (0)