summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2018-12-18 12:51:38 +0100
committerJani Heikkinen <jani.heikkinen@qt.io>2019-01-08 10:03:12 +0000
commit4f101ffed20065cf7ad307a584f00ae719982110 (patch)
tree42e3c916fa2d16c407d257ebc8007a0c6d15772f
parent9f1f265c6d3da31f8990240ae48cc66f373aee22 (diff)
Bring the qcollectiongenerator tool back
Deprecate it now and redirect it to qhelpgenerator. Change-Id: Iffda5c34c3d6833859c0fb155b52e8b42af02b1c Reviewed-by: Kai Koehne <kai.koehne@qt.io>
-rw-r--r--.gitignore1
-rw-r--r--src/assistant/assistant.pro4
-rw-r--r--src/assistant/help/Qt5HelpConfigExtras.cmake.in15
-rw-r--r--src/assistant/qcollectiongenerator/main.c112
-rw-r--r--src/assistant/qcollectiongenerator/qcollectiongenerator.pro7
5 files changed, 138 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index b3fc428a9..2fd837c97 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,6 +74,7 @@ bin/rcc*
bin/uic*
bin/patternist*
bin/phonon*
+bin/qcollectiongenerator*
bin/qdbus*
bin/qhelpgenerator*
bin/xmlpatterns*
diff --git a/src/assistant/assistant.pro b/src/assistant/assistant.pro
index 2d3ca5690..1529167c0 100644
--- a/src/assistant/assistant.pro
+++ b/src/assistant/assistant.pro
@@ -4,7 +4,8 @@ TEMPLATE = subdirs
SUBDIRS += \
help \
assistant \
- qhelpgenerator
+ qhelpgenerator \
+ qcollectiongenerator
assistant.depends = help
qhelpgenerator.depends = help
@@ -12,4 +13,5 @@ qhelpgenerator.depends = help
qtNomakeTools( \
assistant \
qhelpgenerator \
+ qcollectiongenerator \
)
diff --git a/src/assistant/help/Qt5HelpConfigExtras.cmake.in b/src/assistant/help/Qt5HelpConfigExtras.cmake.in
index b8ce04427..3b97923a9 100644
--- a/src/assistant/help/Qt5HelpConfigExtras.cmake.in
+++ b/src/assistant/help/Qt5HelpConfigExtras.cmake.in
@@ -1,4 +1,19 @@
+if (NOT TARGET Qt5::qcollectiongenerator)
+ add_executable(Qt5::qcollectiongenerator IMPORTED)
+
+!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+ set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
+!!ELSE
+ set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\")
+!!ENDIF
+ _qt5_Help_check_file_exists(${imported_location})
+
+ set_target_properties(Qt5::qcollectiongenerator PROPERTIES
+ IMPORTED_LOCATION ${imported_location}
+ )
+endif()
+
if (NOT TARGET Qt5::qhelpgenerator)
add_executable(Qt5::qhelpgenerator IMPORTED)
diff --git a/src/assistant/qcollectiongenerator/main.c b/src/assistant/qcollectiongenerator/main.c
new file mode 100644
index 000000000..5e4e02630
--- /dev/null
+++ b/src/assistant/qcollectiongenerator/main.c
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Assistant of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef _WIN32
+#include <process.h>
+#else
+#include <unistd.h>
+#endif
+
+static const char collectionGeneratorName[] = "qcollectiongenerator";
+static const char helpGeneratorName[] = "qhelpgenerator";
+
+#ifdef _WIN32
+static const char separator = '\\';
+#else
+static const char separator = '/';
+#endif
+
+int main(int argc, char *argv[])
+{
+ printf("The \"%s\" tool is deprecated, use \"%s\" instead.\n\n",
+ collectionGeneratorName, helpGeneratorName);
+
+ // Replace the "qcollectiongenerator" with "qhelpgenerator"
+ // in passed argv[0], keeping the path.
+
+ const size_t currentNameSize = strlen(argv[0]);
+ const size_t collectionGeneratorNameSize = strlen(collectionGeneratorName);
+ const ptrdiff_t maxPathOffset = currentNameSize - collectionGeneratorNameSize;
+ ptrdiff_t pathOffset = maxPathOffset;
+
+ if (maxPathOffset >= 0 && strchr(argv[0] + maxPathOffset, separator))
+ pathOffset = -1; // Separator detected. Wrong filename.
+
+ while (pathOffset >= 0) {
+ const char *fileName = argv[0] + pathOffset;
+
+ if (fileName[0] == separator) { // Separator detected. Wrong filename.
+ pathOffset = -1;
+ break;
+ }
+
+ if (!strncmp(fileName, collectionGeneratorName, collectionGeneratorNameSize))
+ break;
+
+ --pathOffset;
+ }
+
+ if (pathOffset < 0) {
+ fprintf(stderr, "Wrong tool name. "
+ "The tool name is expected to contain: \"%s\", got: \"%s\" instead.\n",
+ collectionGeneratorName, argv[0]);
+ return 3;
+ }
+
+ const size_t helpGeneratorNameSize = strlen(helpGeneratorName);
+ // Allocate a buffer for the new full path, consisting of the pathSize + new name
+ char *newPath = (char *) malloc((maxPathOffset + helpGeneratorNameSize + 1) * sizeof(char));
+ // Copy the path
+ memcpy(newPath, argv[0], pathOffset);
+ // Copy the new name
+ memcpy(newPath + pathOffset, helpGeneratorName, helpGeneratorNameSize);
+ // Copy the remaining part
+ memcpy(newPath + pathOffset + helpGeneratorNameSize,
+ argv[0] + pathOffset + collectionGeneratorNameSize,
+ currentNameSize - pathOffset - collectionGeneratorNameSize + 1);
+
+ argv[0] = newPath;
+#ifdef _WIN32
+ const intptr_t ret = _spawnvp(_P_WAIT, newPath, argv);
+ if (ret == -1) {
+ fprintf(stderr, "Error while executing \"%s\" tool.\n", newPath);
+ return 3;
+ }
+ return ret;
+#else
+ execvp(newPath, argv);
+ fprintf(stderr, "Error while executing \"%s\" tool.\n", newPath);
+ return 3;
+#endif
+}
+
diff --git a/src/assistant/qcollectiongenerator/qcollectiongenerator.pro b/src/assistant/qcollectiongenerator/qcollectiongenerator.pro
new file mode 100644
index 000000000..491c8f927
--- /dev/null
+++ b/src/assistant/qcollectiongenerator/qcollectiongenerator.pro
@@ -0,0 +1,7 @@
+CONFIG += console
+CONFIG -= qt app_bundle
+SOURCES += main.c
+
+QMAKE_TARGET_DESCRIPTION = "Qt Help Collection File Generator"
+load(qt_tool)
+