Link Here
|
1 |
|
1 |
|
|
|
2 |
if (NOT TARGET Qt5::qcollectiongenerator) |
3 |
add_executable(Qt5::qcollectiongenerator IMPORTED) |
4 |
|
5 |
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) |
6 |
set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\") |
7 |
!!ELSE |
8 |
set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\") |
9 |
!!ENDIF |
10 |
_qt5_Help_check_file_exists(${imported_location}) |
11 |
|
12 |
set_target_properties(Qt5::qcollectiongenerator PROPERTIES |
13 |
IMPORTED_LOCATION ${imported_location} |
14 |
) |
15 |
endif() |
16 |
|
2 |
if (NOT TARGET Qt5::qhelpgenerator) |
17 |
if (NOT TARGET Qt5::qhelpgenerator) |
3 |
add_executable(Qt5::qhelpgenerator IMPORTED) |
18 |
add_executable(Qt5::qhelpgenerator IMPORTED) |
4 |
|
19 |
|
5 |
-- /dev/null |
20 |
++ b/src/assistant/qcollectiongenerator/main.c |
Link Here
|
0 |
-- /dev/null |
1 |
/**************************************************************************** |
|
|
2 |
** |
3 |
** Copyright (C) 2018 The Qt Company Ltd. |
4 |
** Contact: https://www.qt.io/licensing/ |
5 |
** |
6 |
** This file is part of the Qt Assistant of the Qt Toolkit. |
7 |
** |
8 |
** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 |
** Commercial License Usage |
10 |
** Licensees holding valid commercial Qt licenses may use this file in |
11 |
** accordance with the commercial license agreement provided with the |
12 |
** Software or, alternatively, in accordance with the terms contained in |
13 |
** a written agreement between you and The Qt Company. For licensing terms |
14 |
** and conditions see https://www.qt.io/terms-conditions. For further |
15 |
** information use the contact form at https://www.qt.io/contact-us. |
16 |
** |
17 |
** GNU General Public License Usage |
18 |
** Alternatively, this file may be used under the terms of the GNU |
19 |
** General Public License version 3 as published by the Free Software |
20 |
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 |
** included in the packaging of this file. Please review the following |
22 |
** information to ensure the GNU General Public License requirements will |
23 |
** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 |
** |
25 |
** $QT_END_LICENSE$ |
26 |
** |
27 |
****************************************************************************/ |
28 |
|
29 |
#include <stddef.h> |
30 |
#include <stdio.h> |
31 |
#include <stdlib.h> |
32 |
#include <string.h> |
33 |
|
34 |
#ifdef _WIN32 |
35 |
#include <process.h> |
36 |
#else |
37 |
#include <unistd.h> |
38 |
#endif |
39 |
|
40 |
static const char collectionGeneratorName[] = "qcollectiongenerator"; |
41 |
static const char helpGeneratorName[] = "qhelpgenerator"; |
42 |
|
43 |
#ifdef _WIN32 |
44 |
static const char separator = '\\'; |
45 |
#else |
46 |
static const char separator = '/'; |
47 |
#endif |
48 |
|
49 |
int main(int argc, char *argv[]) |
50 |
{ |
51 |
printf("The \"%s\" tool is deprecated, use \"%s\" instead.\n\n", |
52 |
collectionGeneratorName, helpGeneratorName); |
53 |
|
54 |
// Replace the "qcollectiongenerator" with "qhelpgenerator" |
55 |
// in passed argv[0], keeping the path. |
56 |
|
57 |
const size_t currentNameSize = strlen(argv[0]); |
58 |
const size_t collectionGeneratorNameSize = strlen(collectionGeneratorName); |
59 |
const ptrdiff_t maxPathOffset = currentNameSize - collectionGeneratorNameSize; |
60 |
ptrdiff_t pathOffset = maxPathOffset; |
61 |
|
62 |
if (maxPathOffset >= 0 && strchr(argv[0] + maxPathOffset, separator)) |
63 |
pathOffset = -1; // Separator detected. Wrong filename. |
64 |
|
65 |
while (pathOffset >= 0) { |
66 |
const char *fileName = argv[0] + pathOffset; |
67 |
|
68 |
if (fileName[0] == separator) { // Separator detected. Wrong filename. |
69 |
pathOffset = -1; |
70 |
break; |
71 |
} |
72 |
|
73 |
if (!strncmp(fileName, collectionGeneratorName, collectionGeneratorNameSize)) |
74 |
break; |
75 |
|
76 |
--pathOffset; |
77 |
} |
78 |
|
79 |
if (pathOffset < 0) { |
80 |
fprintf(stderr, "Wrong tool name. " |
81 |
"The tool name is expected to contain: \"%s\", got: \"%s\" instead.\n", |
82 |
collectionGeneratorName, argv[0]); |
83 |
return 3; |
84 |
} |
85 |
|
86 |
const size_t helpGeneratorNameSize = strlen(helpGeneratorName); |
87 |
// Allocate a buffer for the new full path, consisting of the pathSize + new name |
88 |
char *newPath = (char *) malloc((maxPathOffset + helpGeneratorNameSize + 1) * sizeof(char)); |
89 |
// Copy the path |
90 |
memcpy(newPath, argv[0], pathOffset); |
91 |
// Copy the new name |
92 |
memcpy(newPath + pathOffset, helpGeneratorName, helpGeneratorNameSize); |
93 |
// Copy the remaining part |
94 |
memcpy(newPath + pathOffset + helpGeneratorNameSize, |
95 |
argv[0] + pathOffset + collectionGeneratorNameSize, |
96 |
currentNameSize - pathOffset - collectionGeneratorNameSize + 1); |
97 |
|
98 |
argv[0] = newPath; |
99 |
#ifdef _WIN32 |
100 |
const intptr_t ret = _spawnvp(_P_WAIT, newPath, argv); |
101 |
if (ret == -1) { |
102 |
fprintf(stderr, "Error while executing \"%s\" tool.\n", newPath); |
103 |
return 3; |
104 |
} |
105 |
return ret; |
106 |
#else |
107 |
execvp(newPath, argv); |
108 |
fprintf(stderr, "Error while executing \"%s\" tool.\n", newPath); |
109 |
return 3; |
110 |
#endif |
111 |
} |
112 |
|
|
|
113 |
++ b/src/assistant/qcollectiongenerator/qcollectiongenerator.pro |
Link Here
|
|
|
1 |
CONFIG += console |
2 |
CONFIG -= qt app_bundle |
3 |
SOURCES += main.c |
4 |
|
5 |
QMAKE_TARGET_DESCRIPTION = "Qt Help Collection File Generator" |
6 |
load(qt_tool) |
7 |
|