aboutsummaryrefslogtreecommitdiffstats
path: root/src/libexec
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2015-07-03 05:12:29 -0700
committerJake Petroules <jake.petroules@petroules.com>2015-07-09 08:45:30 +0000
commitb5573c479f361ea280f0607ef0d042d9285df9e0 (patch)
tree6c3c4c793ac3f1bea08c7d8ceba2d26ad9c5577c /src/libexec
parent377c398cc2a1e6b2c95ad7580f0cdace7ddf3c43 (diff)
Solve the Java dependency tracking issue once and for all.
This approach relies on the newly introduced ability of Modules to contain Groups, which may add additional source files to a Product. In the case of the Java module, the module includes a group which adds some sources to build a helper tool on-demand for each product that builds Java source code. This deviates from the previous approach of supplying a single jar for the entire qbs distribution and is thus somewhat less efficient, but is not expected to be a critical issue in the short term. To start, it solves two critical issues: the build-time dependency on javac, which complicates the qbs build process unnecessarily, and the bootstrap class path warning due to targeting Java 1.6 with newer JDKs. Change-Id: I533214a5d37fd69a4d8bfcf0db36bc7dae821d5f Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Diffstat (limited to 'src/libexec')
-rw-r--r--src/libexec/libexec.pro5
-rw-r--r--src/libexec/libexec.qbs1
-rw-r--r--src/libexec/qbs-javac-scan/io/qt/qbs/Artifact.java75
-rw-r--r--src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListJsonWriter.java153
-rw-r--r--src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListTextWriter.java60
-rw-r--r--src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListWriter.java40
-rw-r--r--src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListXmlWriter.java98
-rw-r--r--src/libexec/qbs-javac-scan/io/qt/qbs/tools/JavaCompilerScannerTool.java66
-rw-r--r--src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/JavaCompilerOptions.java100
-rw-r--r--src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/JavaCompilerScanner.java139
-rw-r--r--src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/NullFileObject.java166
-rw-r--r--src/libexec/qbs-javac-scan/qbs-javac-scan.pro82
-rw-r--r--src/libexec/qbs-javac-scan/qbs-javac-scan.qbs19
13 files changed, 0 insertions, 1004 deletions
diff --git a/src/libexec/libexec.pro b/src/libexec/libexec.pro
index f1044a609..967108504 100644
--- a/src/libexec/libexec.pro
+++ b/src/libexec/libexec.pro
@@ -1,6 +1 @@
TEMPLATE = subdirs
-
-qbs_enable_java {
- SUBDIRS += \
- qbs-javac-scan
-}
diff --git a/src/libexec/libexec.qbs b/src/libexec/libexec.qbs
index f132925e2..489864a26 100644
--- a/src/libexec/libexec.qbs
+++ b/src/libexec/libexec.qbs
@@ -2,6 +2,5 @@ import qbs
Project {
references: [
- "qbs-javac-scan/qbs-javac-scan.qbs"
]
}
diff --git a/src/libexec/qbs-javac-scan/io/qt/qbs/Artifact.java b/src/libexec/qbs-javac-scan/io/qt/qbs/Artifact.java
deleted file mode 100644
index 6d250043e..000000000
--- a/src/libexec/qbs-javac-scan/io/qt/qbs/Artifact.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 Jake Petroules.
- ** Contact: http://www.qt.io/licensing
- **
- ** This file is part of the Qt Build Suite.
- **
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms and
- ** conditions see http://www.qt.io/terms-conditions. For further information
- ** use the contact form at http://www.qt.io/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 2.1 or version 3 as published by the Free
- ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
- ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
- ** following information to ensure the GNU Lesser General Public License
- ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
- ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, The Qt Company gives you certain additional
- ** rights. These rights are described in The Qt Company LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ****************************************************************************/
-
-package io.qt.qbs;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Artifact {
- private String filePath;
- private List<String> fileTags;
-
- public Artifact(String filePath) {
- if (filePath == null)
- throw new IllegalArgumentException("filePath");
-
- this.filePath = filePath;
- this.fileTags = new ArrayList<String>();
- }
-
- public String getFilePath() {
- return filePath;
- }
-
- public void setFilePath(String filePath) {
- this.filePath = filePath;
- }
-
- public List<String> getFileTags() {
- return fileTags;
- }
-
- public void setFileTags(List<String> fileTags) {
- this.fileTags = fileTags;
- }
-
- public void addFileTag(String fileTag) {
- this.fileTags.add(fileTag);
- }
-
- public void removeFileTag(String fileTag) {
- this.fileTags.remove(fileTag);
- }
-
- public void clearFileTags() {
- this.fileTags.clear();
- }
-}
diff --git a/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListJsonWriter.java b/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListJsonWriter.java
deleted file mode 100644
index 02198d0f4..000000000
--- a/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListJsonWriter.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 Jake Petroules.
- ** Contact: http://www.qt.io/licensing
- **
- ** This file is part of the Qt Build Suite.
- **
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms and
- ** conditions see http://www.qt.io/terms-conditions. For further information
- ** use the contact form at http://www.qt.io/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 2.1 or version 3 as published by the Free
- ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
- ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
- ** following information to ensure the GNU Lesser General Public License
- ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
- ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, The Qt Company gives you certain additional
- ** rights. These rights are described in The Qt Company LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ****************************************************************************/
-
-package io.qt.qbs;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.List;
-
-/**
- * This uses a custom JSON implementation because the Java Standard Library does
- * not yet have native support for JSON, and only minimal support is required
- * here.
- */
-public class ArtifactListJsonWriter implements ArtifactListWriter {
- private static final int TAB_WIDTH = 4;
-
- // based on escapeString from qtbase/qjsonwriter.cpp
- private static String escapeString(String s) {
- String out = "";
- for (int i = 0; i < s.length();) {
- int u = s.codePointAt(i);
-
- // unpaired surrogate
- if (u >= Character.MIN_SURROGATE && u <= Character.MAX_SURROGATE) {
- out += "\ufffd";
- i += Character.charCount(u);
- continue;
- }
-
- if (u < 0x80) {
- if (u < 0x20 || u == 0x22 || u == 0x5c) {
- out += "\\";
- switch (u) {
- case 0x22:
- out += "\"";
- break;
- case 0x5c:
- out += "\\";
- break;
- case 0x8:
- out += "b";
- break;
- case 0xc:
- out += "f";
- break;
- case 0xa:
- out += "n";
- break;
- case 0xd:
- out += "r";
- break;
- case 0x9:
- out += "t";
- break;
- default:
- out += "u";
- out += "0";
- out += "0";
- String hex = Integer.toHexString(u);
- if (hex.length() == 1)
- out += "0";
- out += hex;
- break;
- }
- } else {
- out += s.substring(i, i + Character.charCount(u));
- }
- } else {
- out += s.substring(i, i + Character.charCount(u));
- }
-
- i += Character.charCount(u);
- }
-
- return out;
- }
-
- private static void writeString(PrintStream printWriter, String s) {
- printWriter.print("\"");
- printWriter.print(escapeString(s));
- printWriter.print("\"");
- }
-
- private static void writeIndent(PrintStream printWriter, int level) {
- for (int i = 0; i < level * TAB_WIDTH; ++i) {
- printWriter.print(" ");
- }
- }
-
- private static void writeArtifact(Artifact artifact,
- PrintStream printWriter, int indentLevel, Boolean comma) {
- writeIndent(printWriter, indentLevel++);
- printWriter.print("{\n");
- writeIndent(printWriter, indentLevel);
- writeString(printWriter, "filePath");
- printWriter.print(": ");
- writeString(printWriter, artifact.getFilePath());
- printWriter.println(",");
- writeIndent(printWriter, indentLevel);
- writeString(printWriter, "fileTags");
- printWriter.print(": [");
- for (int i = 0; i < artifact.getFileTags().size(); ++i) {
- writeString(printWriter, artifact.getFileTags().get(i));
- if (i != artifact.getFileTags().size() - 1)
- printWriter.print(", ");
- }
- printWriter.println("]");
- writeIndent(printWriter, --indentLevel);
- printWriter.println("}" + (comma ? "," : ""));
- }
-
- @Override
- public void write(List<Artifact> artifacts, OutputStream outputStream)
- throws IOException {
- PrintStream printWriter = new PrintStream(outputStream);
- printWriter.print("[\n");
- for (int i = 0; i < artifacts.size(); ++i) {
- writeArtifact(artifacts.get(i), printWriter, 1,
- i != artifacts.size() - 1);
- }
-
- printWriter.println("]");
- }
-}
diff --git a/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListTextWriter.java b/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListTextWriter.java
deleted file mode 100644
index 2b32bdd2a..000000000
--- a/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListTextWriter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 Jake Petroules.
- ** Contact: http://www.qt.io/licensing
- **
- ** This file is part of the Qt Build Suite.
- **
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms and
- ** conditions see http://www.qt.io/terms-conditions. For further information
- ** use the contact form at http://www.qt.io/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 2.1 or version 3 as published by the Free
- ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
- ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
- ** following information to ensure the GNU Lesser General Public License
- ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
- ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, The Qt Company gives you certain additional
- ** rights. These rights are described in The Qt Company LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ****************************************************************************/
-
-package io.qt.qbs;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.List;
-
-public class ArtifactListTextWriter implements ArtifactListWriter {
- private String join(List<String> list, String separator) {
- String string = "";
- if (!list.isEmpty()) {
- string += list.get(0);
- for (int i = 1; i < list.size(); ++i) {
- string += separator + list;
- }
- }
-
- return string;
- }
-
- @Override
- public void write(List<Artifact> artifacts, OutputStream outputStream)
- throws IOException {
- PrintStream stream = new PrintStream(outputStream);
- for (Artifact artifact : artifacts) {
- stream.format("%s [%s]\n", artifact.getFilePath(),
- join(artifact.getFileTags(), ", "));
- }
- }
-}
diff --git a/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListWriter.java b/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListWriter.java
deleted file mode 100644
index 30a5b816f..000000000
--- a/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListWriter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 Jake Petroules.
- ** Contact: http://www.qt.io/licensing
- **
- ** This file is part of the Qt Build Suite.
- **
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms and
- ** conditions see http://www.qt.io/terms-conditions. For further information
- ** use the contact form at http://www.qt.io/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 2.1 or version 3 as published by the Free
- ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
- ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
- ** following information to ensure the GNU Lesser General Public License
- ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
- ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, The Qt Company gives you certain additional
- ** rights. These rights are described in The Qt Company LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ****************************************************************************/
-
-package io.qt.qbs;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.List;
-
-public interface ArtifactListWriter {
- public abstract void write(List<Artifact> artifacts,
- OutputStream outputStream) throws IOException;
-}
diff --git a/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListXmlWriter.java b/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListXmlWriter.java
deleted file mode 100644
index 9fbf09ed1..000000000
--- a/src/libexec/qbs-javac-scan/io/qt/qbs/ArtifactListXmlWriter.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 Jake Petroules.
- ** Contact: http://www.qt.io/licensing
- **
- ** This file is part of the Qt Build Suite.
- **
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms and
- ** conditions see http://www.qt.io/terms-conditions. For further information
- ** use the contact form at http://www.qt.io/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 2.1 or version 3 as published by the Free
- ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
- ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
- ** following information to ensure the GNU Lesser General Public License
- ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
- ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, The Qt Company gives you certain additional
- ** rights. These rights are described in The Qt Company LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ****************************************************************************/
-
-package io.qt.qbs;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class ArtifactListXmlWriter implements ArtifactListWriter {
- @Override
- public void write(List<Artifact> artifacts, OutputStream outputStream)
- throws IOException {
- try {
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder documentBuilder = documentBuilderFactory
- .newDocumentBuilder();
-
- Document document = documentBuilder.newDocument();
- Element rootElement = document.createElement("artifacts");
- document.appendChild(rootElement);
-
- for (Artifact artifact : artifacts) {
- Element artifactElement = document.createElement("artifact");
- rootElement.appendChild(artifactElement);
-
- Element filePathElement = document.createElement("filePath");
- artifactElement.appendChild(filePathElement);
- filePathElement.appendChild(document.createTextNode(artifact
- .getFilePath()));
-
- Element fileTagsElement = document.createElement("fileTags");
- artifactElement.appendChild(fileTagsElement);
-
- for (String fileTag : artifact.getFileTags()) {
- Element fileTagElement = document.createElement("fileTag");
- fileTagsElement.appendChild(fileTagElement);
- fileTagElement
- .appendChild(document.createTextNode(fileTag));
- }
- }
-
- TransformerFactory transformerFactory = TransformerFactory
- .newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- DOMSource source = new DOMSource(document);
- StreamResult result = new StreamResult(outputStream);
-
- transformer.transform(source, result);
- new PrintStream(outputStream).println();
- } catch (ParserConfigurationException pce) {
- throw new IOException(pce);
- } catch (TransformerException tfe) {
- throw new IOException(tfe);
- }
- }
-}
diff --git a/src/libexec/qbs-javac-scan/io/qt/qbs/tools/JavaCompilerScannerTool.java b/src/libexec/qbs-javac-scan/io/qt/qbs/tools/JavaCompilerScannerTool.java
deleted file mode 100644
index 5bef0c90f..000000000
--- a/src/libexec/qbs-javac-scan/io/qt/qbs/tools/JavaCompilerScannerTool.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 Jake Petroules.
- ** Contact: http://www.qt.io/licensing
- **
- ** This file is part of the Qt Build Suite.
- **
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms and
- ** conditions see http://www.qt.io/terms-conditions. For further information
- ** use the contact form at http://www.qt.io/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 2.1 or version 3 as published by the Free
- ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
- ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
- ** following information to ensure the GNU Lesser General Public License
- ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
- ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, The Qt Company gives you certain additional
- ** rights. These rights are described in The Qt Company LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ****************************************************************************/
-
-package io.qt.qbs.tools;
-
-import io.qt.qbs.tools.utils.JavaCompilerScanner;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class JavaCompilerScannerTool {
- public static void main(String[] args) {
- JavaCompilerScanner scanner = new JavaCompilerScanner();
-
- List<String> compilerArguments = new ArrayList<String>(
- Arrays.asList(args));
- if (args.length >= 1 && args[0].equals("--output-format")) {
- compilerArguments.remove(0);
- if (args.length < 2) {
- throw new IllegalArgumentException(
- "--output-format requires an argument");
- }
-
- scanner.setOutputFormat(args[1]);
- compilerArguments.remove(0);
- }
-
- try {
- int result = scanner.run(compilerArguments);
- scanner.write(System.out);
- System.exit(result);
- } catch (IOException e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
-}
diff --git a/src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/JavaCompilerOptions.java b/src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/JavaCompilerOptions.java
deleted file mode 100644
index 53cf71033..000000000
--- a/src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/JavaCompilerOptions.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 Jake Petroules.
- ** Contact: http://www.qt.io/licensing
- **
- ** This file is part of the Qt Build Suite.
- **
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms and
- ** conditions see http://www.qt.io/terms-conditions. For further information
- ** use the contact form at http://www.qt.io/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 2.1 or version 3 as published by the Free
- ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
- ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
- ** following information to ensure the GNU Lesser General Public License
- ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
- ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, The Qt Company gives you certain additional
- ** rights. These rights are described in The Qt Company LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ****************************************************************************/
-
-package io.qt.qbs.tools.utils;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.lang.model.SourceVersion;
-import javax.tools.JavaCompiler;
-import javax.tools.StandardJavaFileManager;
-
-public class JavaCompilerOptions {
- private final List<String> recognizedOptions;
- private final List<String> classNames;
- private final List<File> files;
-
- private JavaCompilerOptions(List<String> recognizedOptions,
- List<String> classNames, List<File> files) {
- this.recognizedOptions = recognizedOptions;
- this.classNames = classNames;
- this.files = files;
- }
-
- public static JavaCompilerOptions parse(JavaCompiler compiler,
- StandardJavaFileManager fileManager, String... arguments) {
- List<String> recognizedOptions = new ArrayList<String>();
- List<String> classNames = new ArrayList<String>();
- List<File> files = new ArrayList<File>();
-
- for (int i = 0; i < arguments.length; ++i) {
- int argumentCount = compiler.isSupportedOption(arguments[i]);
- if (argumentCount < 0)
- argumentCount = fileManager.isSupportedOption(arguments[i]);
-
- if (argumentCount >= 0) {
- for (int j = 0; j < argumentCount + 1; ++j) {
- if (i + j >= arguments.length) {
- throw new IllegalArgumentException(arguments[i]);
- }
-
- recognizedOptions.add(arguments[i + j]);
- }
-
- i += argumentCount;
- } else {
- File file = new File(arguments[i]);
- if (file.exists())
- files.add(file);
- else if (SourceVersion.isName(arguments[i]))
- classNames.add(arguments[i]);
- else
- throw new IllegalArgumentException(arguments[i]);
- }
- }
-
- return new JavaCompilerOptions(recognizedOptions, classNames, files);
- }
-
- public List<String> getRecognizedOptions() {
- return Collections.unmodifiableList(recognizedOptions);
- }
-
- public List<File> getFiles() {
- return Collections.unmodifiableList(files);
- }
-
- public List<String> getClassNames() {
- return Collections.unmodifiableList(classNames);
- }
-}
diff --git a/src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/JavaCompilerScanner.java b/src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/JavaCompilerScanner.java
deleted file mode 100644
index db5653e5d..000000000
--- a/src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/JavaCompilerScanner.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 Jake Petroules.
- ** Contact: http://www.qt.io/licensing
- **
- ** This file is part of the Qt Build Suite.
- **
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms and
- ** conditions see http://www.qt.io/terms-conditions. For further information
- ** use the contact form at http://www.qt.io/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 2.1 or version 3 as published by the Free
- ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
- ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
- ** following information to ensure the GNU Lesser General Public License
- ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
- ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, The Qt Company gives you certain additional
- ** rights. These rights are described in The Qt Company LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ****************************************************************************/
-
-package io.qt.qbs.tools.utils;
-
-import io.qt.qbs.Artifact;
-import io.qt.qbs.ArtifactListJsonWriter;
-import io.qt.qbs.ArtifactListTextWriter;
-import io.qt.qbs.ArtifactListWriter;
-import io.qt.qbs.ArtifactListXmlWriter;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.tools.FileObject;
-import javax.tools.ForwardingJavaFileManager;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-
-public class JavaCompilerScanner {
- private static final String humanReadableTextFormat = "human-readable-text";
- private static final String jsonFormat = "json";
- private static final String xmlFormat = "xml1";
-
- private List<Artifact> artifacts = new ArrayList<Artifact>();
- private String outputFormat = humanReadableTextFormat;
-
- private static Map<String, ArtifactListWriter> getOutputFormatters() {
- Map<String, ArtifactListWriter> outputFormatters = new HashMap<String, ArtifactListWriter>();
- outputFormatters.put(humanReadableTextFormat,
- new ArtifactListTextWriter());
- outputFormatters.put(jsonFormat, new ArtifactListJsonWriter());
- outputFormatters.put(xmlFormat, new ArtifactListXmlWriter());
- return outputFormatters;
- }
-
- public String getOutputFormat() {
- return this.outputFormat;
- }
-
- public void setOutputFormat(String outputFormat) {
- this.outputFormat = outputFormat;
- }
-
- public List<Artifact> getArtifacts() {
- return this.artifacts;
- }
-
- public int run(List<String> compilerArguments) {
- artifacts.clear();
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- StandardJavaFileManager standardFileManager = compiler
- .getStandardFileManager(null, null, null);
- JavaFileManager fileManager = new ForwardingJavaFileManager<StandardJavaFileManager>(
- standardFileManager) {
- public JavaFileObject getJavaFileForOutput(
- JavaFileManager.Location location, String className,
- JavaFileObject.Kind kind, FileObject sibling)
- throws IOException {
- JavaFileObject o = super.getJavaFileForOutput(location,
- className, kind, sibling);
- Artifact artifact = new Artifact(new File(o.toUri()
- .getSchemeSpecificPart()).toString());
- if (kind.equals(JavaFileObject.Kind.CLASS)) {
- artifact.addFileTag("java.class");
- } else if (kind.equals(JavaFileObject.Kind.SOURCE)) {
- artifact.addFileTag("java.java");
- }
- artifacts.add(artifact);
- return new NullFileObject(o);
- }
-
- public FileObject getFileForOutput(
- JavaFileManager.Location location, String packageName,
- String relativeName, FileObject sibling) throws IOException {
- FileObject o = super.getFileForOutput(location, packageName,
- relativeName, sibling);
- Artifact artifact = new Artifact(new File(o.toUri()
- .getSchemeSpecificPart()).toString());
- if (o.getName().endsWith(".h")) {
- artifact.addFileTag("hpp");
- }
- artifacts.add(artifact);
- return new NullFileObject(o);
- }
- };
-
- final JavaCompilerOptions options = JavaCompilerOptions
- .parse(compiler, standardFileManager, compilerArguments
- .toArray(new String[compilerArguments.size()]));
- return compiler.getTask(
- null,
- fileManager,
- null,
- options.getRecognizedOptions(),
- options.getClassNames(),
- standardFileManager.getJavaFileObjectsFromFiles(options
- .getFiles())).call() ? 0 : 1;
- }
-
- public void write(OutputStream outputStream) throws IOException {
- getOutputFormatters().get(outputFormat).write(artifacts, outputStream);
- }
-}
diff --git a/src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/NullFileObject.java b/src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/NullFileObject.java
deleted file mode 100644
index e5a4fc4a3..000000000
--- a/src/libexec/qbs-javac-scan/io/qt/qbs/tools/utils/NullFileObject.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2015 Jake Petroules.
- ** Contact: http://www.qt.io/licensing
- **
- ** This file is part of the Qt Build Suite.
- **
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms and
- ** conditions see http://www.qt.io/terms-conditions. For further information
- ** use the contact form at http://www.qt.io/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 2.1 or version 3 as published by the Free
- ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
- ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
- ** following information to ensure the GNU Lesser General Public License
- ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
- ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, The Qt Company gives you certain additional
- ** rights. These rights are described in The Qt Company LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ****************************************************************************/
-
-package io.qt.qbs.tools.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.URI;
-
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.NestingKind;
-import javax.tools.FileObject;
-import javax.tools.JavaFileObject;
-
-/**
- * Represents a FileObject that discards its output when written.
- */
-public class NullFileObject implements FileObject, JavaFileObject {
- FileObject obj;
-
- public NullFileObject(FileObject obj) {
- this.obj = obj;
- }
-
- @Override
- public URI toUri() {
- return obj.toUri();
- }
-
- @Override
- public String getName() {
- return obj.getName();
- }
-
- @Override
- public InputStream openInputStream() throws IOException {
- return new InputStream() {
- @Override
- public int read() throws IOException {
- return -1;
- }
- };
- }
-
- @Override
- public OutputStream openOutputStream() throws IOException {
- return new OutputStream() {
- @Override
- public void write(int b) throws IOException {
- }
- };
- }
-
- @Override
- public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
- return new Reader() {
- @Override
- public int read(char[] cbuf, int off, int len) throws IOException {
- return -1;
- }
-
- @Override
- public void close() throws IOException {
- }
- };
- }
-
- @Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors)
- throws IOException {
- return obj.getCharContent(ignoreEncodingErrors);
- }
-
- @Override
- public Writer openWriter() throws IOException {
- return new Writer() {
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- }
-
- @Override
- public void flush() throws IOException {
- }
-
- @Override
- public void close() throws IOException {
- }
- };
- }
-
- @Override
- public long getLastModified() {
- return obj.getLastModified();
- }
-
- @Override
- public boolean delete() {
- return obj.delete();
- }
-
- @Override
- public Kind getKind() {
- if (obj instanceof JavaFileObject) {
- return ((JavaFileObject) obj).getKind();
- }
-
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isNameCompatible(String simpleName, Kind kind) {
- if (obj instanceof JavaFileObject) {
- return ((JavaFileObject) obj).isNameCompatible(simpleName, kind);
- }
-
- throw new UnsupportedOperationException();
- }
-
- @Override
- public NestingKind getNestingKind() {
- if (obj instanceof JavaFileObject) {
- return ((JavaFileObject) obj).getNestingKind();
- }
-
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Modifier getAccessLevel() {
- if (obj instanceof JavaFileObject) {
- return ((JavaFileObject) obj).getAccessLevel();
- }
-
- throw new UnsupportedOperationException();
- }
-}
diff --git a/src/libexec/qbs-javac-scan/qbs-javac-scan.pro b/src/libexec/qbs-javac-scan/qbs-javac-scan.pro
deleted file mode 100644
index 7c9283776..000000000
--- a/src/libexec/qbs-javac-scan/qbs-javac-scan.pro
+++ /dev/null
@@ -1,82 +0,0 @@
-include(../libexec.pri)
-
-TARGET = qbs-javac-scan
-
-PATHPREFIX = $$PWD/io/qt/qbs/
-
-JAVACLASSPATH += $$PWD
-JAVASOURCES += \
- $$PATHPREFIX/Artifact.java \
- $$PATHPREFIX/ArtifactListJsonWriter.java \
- $$PATHPREFIX/ArtifactListTextWriter.java \
- $$PATHPREFIX/ArtifactListWriter.java \
- $$PATHPREFIX/ArtifactListXmlWriter.java \
- $$PATHPREFIX/tools/JavaCompilerScannerTool.java \
- $$PATHPREFIX/tools/utils/JavaCompilerOptions.java \
- $$PATHPREFIX/tools/utils/JavaCompilerScanner.java \
- $$PATHPREFIX/tools/utils/NullFileObject.java
-
-JAVAMAINCLASS = io.qt.qbs.tools.JavaCompilerScannerTool
-
-# from mkspecs/features/java.prf
-TEMPLATE = lib
-
-CLASS_DIR = classes
-CLASS_DIR_MARKER = classes.marker
-CLASS_DIR_PREFIX = $$CLASS_DIR/io/qt/qbs
-
-CONFIG -= qt
-
-# Without these, qmake adds a name prefix and versioning postfixes (as well as file
-# links) to the target. This is hardcoded in the qmake code, so for now we use
-# the plugin configs to get what we want.
-CONFIG += plugin no_plugin_name_prefix
-
-javac.input = JAVASOURCES
-javac.output = $$CLASS_DIR_MARKER
-javac.clean = \
- $$shell_path($$CLASS_DIR_PREFIX/Artifact.class) \
- $$shell_path($$CLASS_DIR_PREFIX/ArtifactListJsonWriter.class) \
- $$shell_path($$CLASS_DIR_PREFIX/ArtifactListWriter.class) \
- $$shell_path($$CLASS_DIR_PREFIX/ArtifactListTextWriter.class) \
- $$shell_path($$CLASS_DIR_PREFIX/ArtifactListXmlWriter.class) \
- $$shell_path($$CLASS_DIR_PREFIX/tools/JavaCompilerScannerTool.class) \
- $$shell_path($$CLASS_DIR_PREFIX/tools/utils/JavaCompilerOptions.class) \
- $$shell_path($$CLASS_DIR_PREFIX/tools/utils/JavaCompilerScanner$1.class) \
- $$shell_path($$CLASS_DIR_PREFIX/tools/utils/JavaCompilerScanner.class) \
- $$shell_path($$CLASS_DIR_PREFIX/tools/utils/NullFileObject$1.class) \
- $$shell_path($$CLASS_DIR_PREFIX/tools/utils/NullFileObject$2.class) \
- $$shell_path($$CLASS_DIR_PREFIX/tools/utils/NullFileObject$3.class) \
- $$shell_path($$CLASS_DIR_PREFIX/tools/utils/NullFileObject$4.class) \
- $$shell_path($$CLASS_DIR_PREFIX/tools/utils/NullFileObject.class)
-javac.CONFIG += combine
-javac.commands = javac -source 1.6 -target 1.6 -Xlint:unchecked -cp $$shell_quote($$system_path($$join(JAVACLASSPATH, $$DIRLIST_SEPARATOR))) -d $$shell_quote($$CLASS_DIR) ${QMAKE_FILE_IN} $$escape_expand(\\n\\t) \
- @echo Nothing to see here. Move along. > $$CLASS_DIR_MARKER
-QMAKE_EXTRA_COMPILERS += javac
-
-mkpath($$absolute_path($$CLASS_DIR, $$OUT_PWD)) | error("Aborting.")
-
-# Disable all linker flags since we are overriding the regular linker
-QMAKE_LFLAGS =
-QMAKE_CFLAGS =
-QMAKE_LFLAGS_CONSOLE =
-QMAKE_LFLAGS_WINDOWS =
-QMAKE_LFLAGS_DLL =
-QMAKE_LFLAGS_DEBUG =
-QMAKE_LFLAGS_RELEASE =
-QMAKE_LFLAGS_RPATH =
-QMAKE_LFLAGS_PLUGIN =
-QMAKE_LIBS =
-QMAKE_LIBS_OPENGL_ES2 =
-QMAKE_LIBDIR =
-QMAKE_EXTENSION_SHLIB = jar
-
-# nmake
-QMAKE_LINK = jar
-QMAKE_LFLAGS = cfe $(DESTDIR_TARGET) $$JAVAMAINCLASS -C $$CLASS_DIR . && "echo "
-
-# Demonstrate an excellent reason why qbs exists
-QMAKE_LINK_O_FLAG = && "echo "
-
-# make
-QMAKE_LINK_SHLIB_CMD = jar cfe $(TARGET) $$JAVAMAINCLASS -C $$CLASS_DIR .
diff --git a/src/libexec/qbs-javac-scan/qbs-javac-scan.qbs b/src/libexec/qbs-javac-scan/qbs-javac-scan.qbs
deleted file mode 100644
index dc9aab8f4..000000000
--- a/src/libexec/qbs-javac-scan/qbs-javac-scan.qbs
+++ /dev/null
@@ -1,19 +0,0 @@
-import qbs
-
-JavaJarFile {
- condition: project.enableJava
-
- property string entryPoint: "io.qt.qbs.tools.JavaCompilerScannerTool"
-
- destinationDirectory: project.libexecInstallDir
-
- Group {
- fileTagsFilter: ["java.jar"]
- qbs.install: true
- qbs.installDir: project.libexecInstallDir
- }
-
- files: [
- "io/qt/qbs/**/*.java"
- ]
-}