Skip to content

Commit aed953c

Browse files
committed
Further improve general and native binaries build instructions
1 parent 596bef6 commit aed953c

File tree

6 files changed

+61
-64
lines changed

6 files changed

+61
-64
lines changed

AGENTS.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,15 @@ SWT consists of two main parts:
3333
### Build Commands
3434
```bash
3535
# Build the entire project
36-
mvn clean install
37-
38-
# Build (and include) specific platform native binaries
39-
mvn clean install '-Dnative=<ws>.<os>.<arch>'
36+
mvn clean verify
4037

4138
# Skip tests
42-
mvn clean install -DskipTests
39+
mvn clean verify -DskipTests
4340
```
4441

4542
### Building native binaries
4643

47-
Run from the repository root, specifying the target platform:
48-
49-
```bash
50-
# Windows (x86_64)
51-
mvn clean install '-Dnative=win32.win32.x86_64' -DskipTests
52-
53-
# Linux (x86_64)
54-
mvn clean install '-Dnative=gtk.linux.x86_64' -DskipTests
55-
56-
# macOS (x86_64 / aarch64)
57-
mvn clean install '-Dnative=cocoa.macosx.x86_64' -DskipTests
58-
mvn clean install '-Dnative=cocoa.macosx.aarch64' -DskipTests
59-
```
60-
61-
For Linux GTK3-only or GTK4-only builds, set `GTK_VERSION=3.0` or `GTK_VERSION=4.0` in the environment before running.
44+
See `bundles/org.eclipse.swt/Readme.md#building-native-binaries` for instructions how to build the SWT native binaries.
6245

6346
**CRITICAL**: Files like `os.c`, `os_stats.c`, `os_stats.h` are **auto-generated**. Never edit them directly!
6447
Instead: modify Java source (e.g., `OS.java`), clean/rebuild the project, then run the native build command above.

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,19 @@ The `while`-loop processes all GUI related events until the shell is disposed wh
8181
Before exiting, any claimed GUI resources needs to be freed.
8282

8383

84-
## Building Native Binaries
85-
86-
Run from the repository root:
84+
## Building
8785

86+
To build all SWT artifacts and to run all tests,
87+
execute at the CLI from the repository root:
8888
```bash
89-
# Windows (x86_64)
90-
mvn clean install '-Dnative=win32.win32.x86_64' -DskipTests
91-
92-
# Linux (x86_64)
93-
mvn clean install '-Dnative=gtk.linux.x86_64' -DskipTests
94-
95-
# macOS (x86_64 / aarch64)
96-
mvn clean install '-Dnative=cocoa.macosx.x86_64' -DskipTests
97-
mvn clean install '-Dnative=cocoa.macosx.aarch64' -DskipTests
89+
mvn clean verify
9890
```
91+
To build only the artifacts, without testing, run
92+
```bash
93+
mvn clean verify -DskipTests
94+
```
95+
96+
For instructions on building the native binaries of SWT see the section [Building native binaries](bundles/org.eclipse.swt/Readme.md#building-native-binaries).
9997

10098
# Contributing to SWT
10199

bundles/org.eclipse.swt/Readme.Linux.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ You need to install the following on your system:
1616
* Java 21 JDK (https://adoptium.net/marketplace/?version=21)
1717
* (optional) Webkit for GTK development files (webkit2gtk3-devel)
1818

19-
### Building and Testing locally
20-
21-
Import and build the SWT project `bundles/org.eclipse.swt` and `binaries/org.eclipse.swt.gtk.linux.${arch}` in Eclipse.
22-
23-
See **Building and Testing locally** in [Readme.md](Readme.md) for further instructions.
24-
2519
Additional information on GTK SWT development can be found in Eclipse Wiki:
2620

2721
https://wiki.eclipse.org/SWT/Devel/Gtk/Dev_guide

bundles/org.eclipse.swt/Readme.Win32.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,3 @@ You need to install the following on your system:
1818
Either select the components "MSVC C++-x64/x86-Buildtools" and "Windows 10 SDK"
1919
or the workload "Desktop development with C++" which includes the required components and some more.
2020
* Java 17 JDK (https://adoptium.net/marketplace/?version=17)
21-
22-
### Building and Testing locally
23-
24-
Import and build the SWT project `bundles/org.eclipse.swt` and `binaries/org.eclipse.swt.win32.win32.${arch}` in Eclipse.
25-
26-
See **Building and Testing locally** in [Readme.md](Readme.md) for further instructions.

bundles/org.eclipse.swt/Readme.macOS.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,3 @@ You need to install the following on your system:
9090

9191
* XCode Command Line Tools (already present in XCode)
9292
* Java 21 JDK (https://adoptium.net/marketplace/?version=21)
93-
94-
### Building and Testing locally
95-
96-
Import and build the SWT project `bundles/org.eclipse.swt` and `binaries/org.eclipse.swt.cocoa.macosx.${arch}` in Eclipse.
97-
98-
See **Building and Testing locally** in [Readme.md](Readme.md) for further instructions.
99-
100-
Happy development!

bundles/org.eclipse.swt/Readme.md

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,20 @@ _for example_
2323
* `binaries/org.eclipse.swt.cocoa.macosx.x86_64` for Mac
2424

2525
These examples refer to the architecture `x86_64` but there are other projects for
26-
other architectures, like `aarch64` (or `loongarch64` / `ppc64le` for Linux)
26+
other architectures, like `aarch64` (or `loongarch64` / `ppc64le` for Linux).
27+
28+
For details about the operating system specific SWT implementations and their (build) requirements, see
29+
- [Linux](Readme.Linux.md)
30+
- [macOS](Readme.macOS.md)
31+
- [Windows](Readme.Win32.md)
2732

2833
Dependencies:
2934
-------------
3035

31-
* **SWT Binaries**
36+
* **SWT native binaries**
3237

33-
Ensure that the fragment matching your _windowingSystem.operatingSystem.cpuArchitecture_
34-
(e.g. org.eclipse.swt.gtk.linux.x86_64) is open in your workspace.
38+
Ensure that the fragment matching your <windowingSystem>.<operatingSystem>.<cpuArchitecture>
39+
(e.g. `org.eclipse.swt.gtk.linux.x86_64`) is open in your workspace.
3540
The fragments provide the platform-specific native libraries and compile the java source code.
3641

3742
Using Assertions:
@@ -56,20 +61,51 @@ Running the snippets:
5661
* (Optionally) install CDT from marketplace if you want to work on C/Native parts of SWT.
5762
* You should be able to run snippets now. (_e.g._ `Snippet1`).
5863

59-
Building and Testing locally:
60-
-----------------------------
64+
## Building native binaries
65+
66+
To build only SWT's native binaries, run from the CLI (at the repository root):
67+
```bash
68+
cd binaries/org.eclipse.swt.<ws>.<os>.<arch>
69+
mvn clean antrun:run@build-native-binaries -Dnative=<ws>.<os>.<arch>
70+
```
71+
With the placeholder
72+
- `<os>` replaced by one of the supported values `macosx`, `linux` or `win32`,
73+
- `<ws>` replaced by `cocoa` (for Mac), `gtk` (for Linux) or `win32` (for Windows),
74+
- `<arch>` replaced by `x86_64`, `aarch64`, `ppc64le` or `riscv64`,
75+
76+
according to the targeted platform.
77+
78+
For example to build the native binaries for Linux (GTK) running on x86 64bit CPUs, execute
79+
```bash
80+
cd binaries/org.eclipse.swt.gtk.linux.x86_64
81+
mvn clean antrun:run@build-native-binaries -Dnative=gtk.linux.x86_64
82+
```
6183

62-
From Eclipse:
84+
For Linux, to build only the GTK3 binaries, set the environment variable `GTK_VERSION` to value `3.0`,
85+
to build only GTK4 binaries, set `GTK_VERSION` to `4.0`.
6386

64-
* If necessary, install the **M2E - Maven integration for Eclipse** (see [m2e](https://eclipse.dev/m2e/))
87+
The Maven build will perform a `clean` and then calls [`build-native-libraries`](https://github.com/eclipse-platform/eclipse.platform.swt/blob/a589ee9fedcfdab60f90902da87f5058faf94be9/binaries/pom.xml#L133-L173),
88+
which sets the required environment variables and runs the appropriated build script for the current platform (`build.sh`/`build.bat`).
89+
The script is located in the source folder `Eclipse SWT PI\<current-ws>\library` of the corresponding SWT native fragment.
90+
91+
To build the native binaries as part of a complete build of all SWT artifacts, run:
92+
```bash
93+
mvn clean verify -Dnative=<ws>.<os>.<arch>
94+
```
95+
using the placeholder from above.
96+
97+
#### Building native binaries from within the Eclipse IDE
98+
99+
* Ensure the **M2E - Maven integration for Eclipse** is installed (see [m2e](https://eclipse.dev/m2e/))
65100
* Open the **Launch Configurations** dialog.
66101
* Run the **Maven** configuration called: `Build-SWT-native-binaries-for-running-platform`.
102+
* This will build the native binaries for the current target platform.
67103
* If compile fails, inspect build log for warnings, they can point out issues in your configuration.
68104

69-
The Maven configuration will perform a `clean` and then call [`build-native-libraries`](https://github.com/eclipse-platform/eclipse.platform.swt/blob/979d3f1580b4786aee1efe046da8a6f836300804/binaries/pom.xml#L92-L134),
70-
which sets the required environment variables and then runs the appropriate
71-
build script for the current platform (`build.sh`/`build.bat`). The script is located in the
72-
source folder `Eclipse SWT PI\<current-ws>\library` in the appropriate fragment.
105+
Testing the native binaries
106+
----------------------------
107+
108+
Import and build the SWT project `bundles/org.eclipse.swt` and `binaries/org.eclipse.swt.<ws>.<os>.<arch>` in Eclipse.
73109

74110
To test if you binaries actually get used, you could try to revert back to some older version and
75111
run a snippet, you should get the 'missing natives' error. Then if you build the natives

0 commit comments

Comments
 (0)