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
17namespace toolchains {
18const QString K_SCIRPTNAME{"toolchain.sh"};
19const QString K_TOOLCHAINFILE{"toolchains_cxx.support"};
20const QString K_VERSION{"version"};
21const QString K_HOSTK_TOOLCHAINFILEK_TOOLCHAINFILEK_TOOLCHAINFILE_OS{"host_os"};
22const QString K_HOST_ARCH{"host_arch"};
23const QString K_HOST_KERNEL{"host_kernel"};
24const QString K_TOOLCHAINS{"toolchains"};
25const QString K_TOOLCHAIN_NAME{"toolchain_name"};
26const QString K_TOOLCHAIN_ABI{"toolchain_abi"};
27const QString K_TOOLCHAIN_PREFIX{"toolchain_prefix"};
28const QString K_TOOLCHAIN_PATH{"toolchain_path"};
29const QString K_TOOLCHAIN_C_COMPILER{"toolchain_c_compiler"};
30const QString K_TOOLCHAIN_CXX_COMPILER{"toolchain_cxx_compiler"};
31const QString K_TOOLCHAIN_DEBUGGER{"toolchain_debugger"};
32} // namespace toolchain
33
34bool 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