1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "toolchain.h" |
6 | #include "util/processutil.h" |
7 | #include "util/custompaths.h" |
8 | |
9 | #include <QFile> |
10 | #include <QDir> |
11 | #include <QDebug> |
12 | #include <QJsonArray> |
13 | #include <QJsonValue> |
14 | #include <QJsonObject> |
15 | #include <QJsonDocument> |
16 | |
17 | namespace toolchains { |
18 | const QString K_SCIRPTNAME{"toolchain.sh"}; |
19 | const QString K_TOOLCHAINFILE{"toolchains_cxx.support"}; |
20 | const QString K_VERSION{"version"}; |
21 | const QString K_HOSTK_TOOLCHAINFILEK_TOOLCHAINFILEK_TOOLCHAINFILE_OS{"host_os"}; |
22 | const QString K_HOST_ARCH{"host_arch"}; |
23 | const QString K_HOST_KERNEL{"host_kernel"}; |
24 | const QString K_TOOLCHAINS{"toolchains"}; |
25 | const QString K_TOOLCHAIN_NAME{"toolchain_name"}; |
26 | const QString K_TOOLCHAIN_ABI{"toolchain_abi"}; |
27 | const QString K_TOOLCHAIN_PREFIX{"toolchain_prefix"}; |
28 | const QString K_TOOLCHAIN_PATH{"toolchain_path"}; |
29 | const QString K_TOOLCHAIN_C_COMPILER{"toolchain_c_compiler"}; |
30 | const QString K_TOOLCHAIN_CXX_COMPILER{"toolchain_cxx_compiler"}; |
31 | const QString K_TOOLCHAIN_DEBUGGER{"toolchain_debugger"}; |
32 | } // namespace toolchain |
33 | |
34 | bool toolchains::generatGlobalFile() |
35 | { |
36 | auto script = CustomPaths::global(CustomPaths::Scripts) + QDir::separator() + toolchains::K_SCIRPTNAME; |
37 | if (!QFileInfo(script).isFile()) |
38 | return false; |
39 | |
40 | QString result = CustomPaths::user(CustomPaths::Configures) + QDir::separator() + toolchains::K_TOOLCHAINFILE; |
41 | ProcessUtil::execute(script, {result}, [=](const QByteArray &out){ |
42 | qInfo() << out; |
43 | }); |
44 | |
45 | if (QFile(result).exists()) |
46 | return true; |
47 | |
48 | return false; |
49 | } |
50 | |
51 |