1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "pythonplugin.h"
6#include "python/pythongenerator.h"
7#include "python/project/pythonprojectgenerator.h"
8#include "python/option/optionpythongenerator.h"
9
10#include "services/language/languageservice.h"
11#include "services/project/projectservice.h"
12#include "services/option/optionservice.h"
13
14using namespace dpfservice;
15
16void PythonPlugin::initialize()
17{
18 qInfo() << __FUNCTION__;
19}
20
21bool PythonPlugin::start()
22{
23 qInfo() << __FUNCTION__;
24 auto &ctx = dpfInstance.serviceContext();
25 LanguageService *languageService = ctx.service<LanguageService>(LanguageService::name());
26 if (languageService) {
27 QString errorString;
28 bool ret = languageService->regClass<PythonGenerator>(PythonGenerator::toolKitName(), &errorString);
29 if (!ret) {
30 qCritical() << errorString;
31 } else {
32 ret = languageService->create<PythonGenerator>(PythonGenerator::toolKitName(), &errorString);
33 if (!ret) {
34 qCritical() << errorString;
35 }
36 }
37 }
38
39 ProjectService *projectService = ctx.service<ProjectService>(ProjectService::name());
40 if (projectService) {
41 QString errorString;
42 projectService->implGenerator<PythonProjectGenerator>(PythonProjectGenerator::toolKitName(), &errorString);
43 }
44
45 OptionService *optionService = ctx.service<OptionService>(OptionService::name());
46 if (!optionService) {
47 qCritical() << "Failed, not found OptionPython service!";
48 abort();
49 }
50 optionService->implGenerator<OptionPythonGenerator>(OptionPythonGenerator::kitName());
51
52 return true;
53}
54
55dpf::Plugin::ShutdownFlag PythonPlugin::stop()
56{
57 qInfo() << __FUNCTION__;
58 return Sync;
59}
60
61
62