Skip to content

Commit

Permalink
Link the sources in build.properties instead of copying with ant-tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi authored and HannesWell committed Feb 7, 2024
1 parent 8dc46be commit 623c8ce
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 78 deletions.
26 changes: 25 additions & 1 deletion binaries/org.eclipse.swt.cocoa.macosx.aarch64/build.properties
Expand Up @@ -13,7 +13,31 @@
custom = true
bin.includes = .,*.jnilib,about_files/,about.html,fragment.properties
bin.excludes = library/
source.. = src/
source.. = \
../../bundles/org.eclipse.swt/Eclipse SWT/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/expand,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/tooltip,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/common,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT WebKit/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/common
src.includes = about.html,about_files/

pom.model.property.os=macosx
Expand Down
26 changes: 25 additions & 1 deletion binaries/org.eclipse.swt.cocoa.macosx.x86_64/build.properties
Expand Up @@ -13,7 +13,31 @@
custom = true
bin.includes = .,*.jnilib,about_files/,about.html,fragment.properties
bin.excludes = library/
source.. = src/
source.. = \
../../bundles/org.eclipse.swt/Eclipse SWT/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/expand,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/tooltip,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/common,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT WebKit/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/common
src.includes = about.html,about_files/

pom.model.property.os=macosx
Expand Down
28 changes: 27 additions & 1 deletion binaries/org.eclipse.swt.gtk.linux.aarch64/build.properties
Expand Up @@ -12,7 +12,33 @@
custom = true
bin.includes = .,*.so,about_files/,about.html,fragment.properties
bin.excludes = library/
source.. = src/
source.. = \
../../bundles/org.eclipse.swt/Eclipse SWT/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT/cairo,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/taskbar,\
../../bundles/org.eclipse.swt/Eclipse SWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/cairo,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/common,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/common,\
../../bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk
src.includes = about.html,about_files/

pom.model.property.os=linux
Expand Down
28 changes: 27 additions & 1 deletion binaries/org.eclipse.swt.gtk.linux.loongarch64/build.properties
Expand Up @@ -12,7 +12,33 @@
custom = true
bin.includes = .,*.so,about_files/,about.html,fragment.properties
bin.excludes = library/
source.. = src/
source.. = \
../../bundles/org.eclipse.swt/Eclipse SWT/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT/cairo,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/taskbar,\
../../bundles/org.eclipse.swt/Eclipse SWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/cairo,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/common,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/common,\
../../bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk
src.includes = about.html,about_files/

pom.model.property.os=linux
Expand Down
28 changes: 27 additions & 1 deletion binaries/org.eclipse.swt.gtk.linux.ppc64le/build.properties
Expand Up @@ -12,7 +12,33 @@
custom = true
bin.includes = .,*.so,about_files/,about.html,fragment.properties
bin.excludes = library/
source.. = src/
source.. = \
../../bundles/org.eclipse.swt/Eclipse SWT/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT/cairo,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/taskbar,\
../../bundles/org.eclipse.swt/Eclipse SWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/cairo,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/common,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/common,\
../../bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk
src.includes = about.html,about_files/

pom.model.property.os=linux
Expand Down
29 changes: 28 additions & 1 deletion binaries/org.eclipse.swt.gtk.linux.x86_64/build.properties
Expand Up @@ -13,7 +13,34 @@
custom = true
bin.includes = .,*.so,about_files/,about.html,fragment.properties
bin.excludes = library/
source.. = src/
source.. = \
../../bundles/org.eclipse.swt/Eclipse SWT/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT/cairo,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/bidi,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar,\
../../bundles/org.eclipse.swt/Eclipse SWT/emulated/taskbar,\
../../bundles/org.eclipse.swt/Eclipse SWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/cairo,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/common,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/glx,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/common,\
../../bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk

src.includes = about.html,about_files/

pom.model.property.os=linux
Expand Down
22 changes: 21 additions & 1 deletion binaries/org.eclipse.swt.win32.win32.x86_64/build.properties
Expand Up @@ -13,7 +13,27 @@
custom = true
bin.includes = .,*.dll,about_files/,about.html,fragment.properties
bin.excludes = library/
source.. = src/
source.. = \
../../bundles/org.eclipse.swt/Eclipse SWT/win32,\
../../bundles/org.eclipse.swt/Eclipse SWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/common,\
../../bundles/org.eclipse.swt/Eclipse SWT PI/win32,\
../../bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32,\
../../bundles/org.eclipse.swt/Eclipse SWT Accessibility/common,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/win32,\
../../bundles/org.eclipse.swt/Eclipse SWT AWT/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32,\
../../bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/win32,\
../../bundles/org.eclipse.swt/Eclipse SWT Printing/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/win32,\
../../bundles/org.eclipse.swt/Eclipse SWT Program/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/common,\
../../bundles/org.eclipse.swt/Eclipse SWT Browser/win32,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/win32,\
../../bundles/org.eclipse.swt/Eclipse SWT OpenGL/common
src.includes = about.html,about_files/

pom.model.property.os=win32
Expand Down
14 changes: 0 additions & 14 deletions binaries/pom.xml
Expand Up @@ -112,20 +112,6 @@
<exportAntProperties>true</exportAntProperties>
</configuration>
</execution>
<execution>
<id>collect-java-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<exec executable="${java.home}/bin/java" dir="${swtMainProject}" failonerror="true">
<arg line="-Dws=${ws} -Darch=${arch} build-scripts/CollectSources.java -javaSources '${project.basedir}/src' "/>
</exec>
</target>
</configuration>
</execution>
<execution>
<id>build-native-binaries</id>
<phase>process-resources</phase>
Expand Down
69 changes: 12 additions & 57 deletions bundles/org.eclipse.swt/build-scripts/CollectSources.java
Expand Up @@ -11,16 +11,17 @@
* Contributors:
* Hannes Wellmann - initial API and implementation
*******************************************************************************/
import java.io.*;
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;

import javax.xml.parsers.*;

import org.w3c.dom.*;
import org.w3c.dom.Node;
import org.xml.sax.*;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
* Script to collect the SWT sources for the specified native fragment.
Expand All @@ -38,7 +39,7 @@ private static ScriptEnvironment read(String[] args) {
}
Path swtProjectRoot = Path.of("").toAbsolutePath();
if (!swtProjectRoot.endsWith(Path.of("bundles/org.eclipse.swt"))) { // Consistency check
throw new IllegalStateException("Sript must be excuted from org.eclipse.swt project");
throw new IllegalStateException("Script must be executed from org.eclipse.swt project");
}
Path binariesRoot = swtProjectRoot.getParent().getParent().resolve("binaries").toAbsolutePath();
Path targetDirectory = Path.of(args[1]);
Expand All @@ -53,9 +54,6 @@ public static void main(String[] args) throws Exception {
case "-nativeSources":
collectNativeSources(env);
break;
case "-javaSources":
collectJavaSources(env);
break;
default:
throw new IllegalArgumentException("Unexpected value: " + args[0]);
}
Expand All @@ -81,49 +79,6 @@ private static Map<String, String> loadProperties(Path path) throws IOException
}
}

private static void collectJavaSources(ScriptEnvironment env) throws Exception {
Path classpathFile = env.binariesRoot.resolve(".classpath_" + env.ws);
Set<String> srcClassPaths = readNativeJavaSourcesFromClasspath(classpathFile);
Set<String> excludedExtensions = Set.of("_properties", "extras", "bridgesupport");
System.out.println("Copy " + srcClassPaths.size() + " java source folders for " + env.ws);
copySubDirectories(env.swtProjectRoot, srcClassPaths, env.targetDirectory, excludedExtensions);
}

private static Set<String> readNativeJavaSourcesFromClasspath(Path classpathFile)
throws IOException, SAXException, ParserConfigurationException {
Element root = parseXMLFile(classpathFile);
Set<String> srcPaths = new HashSet<>();
if ("classpath".equals(root.getTagName())) {
for (Node child : children(root)) {
if (child instanceof Element classpathentry && "classpathentry".equals(classpathentry.getTagName())
&& getAttributeValue(classpathentry, "kind").equals("src")
&& getAttributeValue(classpathentry, "output").isBlank()) {
srcPaths.add(getAttributeValue(classpathentry, "path"));
}
}
}
return srcPaths;
}

private static Element parseXMLFile(Path classpathFile)
throws IOException, SAXException, ParserConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
try (InputStream in = Files.newInputStream(classpathFile)) {
return factory.newDocumentBuilder().parse(in).getDocumentElement();
}
}

private static Iterable<Node> children(Node node) {
NodeList children = node.getChildNodes();
return () -> IntStream.range(0, children.getLength()).mapToObj(children::item).iterator();
}

private static String getAttributeValue(Element classpathentry, String attributeName) {
Attr attribute = classpathentry.getAttributeNode(attributeName);
return attribute != null ? attribute.getValue() : "";
}

private static void copySubDirectories(Path root, Collection<String> allSources, Path target,
Set<String> excludedExtensions) throws IOException {
System.out.println("from " + root + "\nto " + target);
Expand Down

0 comments on commit 623c8ce

Please sign in to comment.