1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 02:32:29 +01:00

Add automatic moc include for faster compile times

This commit is contained in:
Elias Steurer 2023-02-04 11:42:32 +01:00
parent 58340a2bf1
commit 6501a4c79f
42 changed files with 145 additions and 2 deletions

View File

@ -506,3 +506,5 @@ void App::setWizards(Wizards* wizards)
emit wizardsChanged(m_wizards.get());
}
}
#include "moc_app.cpp"

View File

@ -360,3 +360,5 @@ void Create::abortAndCleanup()
}
}
#include "moc_create.cpp"

View File

@ -766,3 +766,5 @@ QString CreateImportVideo::waitForFinished(
}
}
#include "moc_createimportvideo.cpp"

View File

@ -20,3 +20,5 @@ ScreenPlay::GlobalVariables::GlobalVariables(QObject* parent)
}
}
#include "moc_globalvariables.cpp"

View File

@ -83,3 +83,5 @@ void InstalledListFilter::resetFilter()
}
}
#include "moc_installedlistfilter.cpp"

View File

@ -280,3 +280,5 @@ void InstalledListModel::reset()
}
}
#include "moc_installedlistmodel.cpp"

View File

@ -272,3 +272,5 @@ void MonitorListModel::reset()
}
}
#include "moc_monitorlistmodel.cpp"

View File

@ -95,3 +95,5 @@ void ProfileListModel::append(const Profile& profile)
{
}
}
#include "moc_profilelistmodel.cpp"

View File

@ -204,3 +204,5 @@ QHash<int, QByteArray> ProjectSettingsListModel::roleNames() const
}
}
#include "moc_projectsettingslistmodel.cpp"

View File

@ -737,3 +737,5 @@ void ScreenPlayManager::setIsKDEConnected(bool isKDEConnected)
}
}
#include "moc_screenplaymanager.cpp"

View File

@ -282,3 +282,5 @@ bool ScreenPlayWallpaper::replace(
}
}
#include "moc_screenplaywallpaper.cpp"

View File

@ -133,3 +133,5 @@ QJsonObject ScreenPlayWidget::getActiveSettingsJson()
return obj;
}
}
#include "moc_screenplaywidget.cpp"

View File

@ -125,3 +125,5 @@ bool ScreenPlay::SDKConnection::close()
return m_socket->state() == QLocalSocket::UnconnectedState;
}
}
#include "moc_sdkconnection.cpp"

View File

@ -329,3 +329,5 @@ QString Settings::fixLanguageCode(const QString& languageCode)
}
}
#include "moc_settings.cpp"

View File

@ -439,3 +439,5 @@ bool Util::copyPreviewThumbnail(QJsonObject& obj, const QString& previewThumbnai
}
}
#include "moc_util.cpp"

View File

@ -409,3 +409,5 @@ const std::optional<QString> Wizards::createTemporaryFolder() const
return folderName;
}
}
#include "moc_wizards.cpp"

View File

@ -38,3 +38,5 @@ ShaderLibrary::ShaderLibrary(QQuickItem* parent)
ShaderLibrary::~ShaderLibrary()
{
}
#include "moc_shaderlibrary.cpp"

View File

@ -58,3 +58,5 @@ void CPU::update()
// publish result
setUsage(currentUsage);
}
#include "moc_cpu.cpp"

View File

@ -57,3 +57,5 @@ GPU::GPU(QObject* parent)
setMaxFrequency(properties_of_device.max_frequency);
}
}
#include "moc_gpu.cpp"

View File

@ -48,3 +48,5 @@ IpAddress::IpAddress(QObject* parent)
});
}
}
#include "moc_ipaddress.cpp"

View File

@ -42,3 +42,5 @@ void RAM::update()
// set overall usage
setUsage(memoryStatus.dwMemoryLoad);
}
#include "moc_ram.cpp"

View File

@ -100,3 +100,5 @@ void Storage::loadStorageDevices()
}
endInsertRows();
}
#include "moc_storage.cpp"

View File

@ -26,3 +26,5 @@ SysInfo::SysInfo(QQuickItem* parent)
, m_uptime(std::make_unique<Uptime>())
{
}
#include "moc_sysinfo.cpp"

View File

@ -43,3 +43,5 @@ void Uptime::update()
setYears(years);
#endif
}
#include "moc_uptime.cpp"

View File

@ -27,3 +27,5 @@ void HttpFileServer::stopServer()
m_thread.join();
}
}
#include "moc_httpfileserver.cpp"

View File

@ -47,8 +47,8 @@ int main(int argc, char* argv[])
// For testing purposes when starting the ScreenPlayWallpaper directly.
if (argumentList.length() == 1) {
window.setActiveScreensList({ 0 });
//window.setProjectPath("test");
window.setProjectPath("C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/particles");
// window.setProjectPath("test");
window.setProjectPath("C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/2023_01_05_141855");
window.setAppID("test");
window.setVolume(1);
window.setFillMode("fill");

View File

@ -243,3 +243,5 @@ void BaseWindow::setVideoCodec(ScreenPlay::VideoCodec::VideoCodec newVideoCodec)
m_videoCodec = newVideoCodec;
emit videoCodecChanged(newVideoCodec);
}
#include "moc_basewindow.cpp"

View File

@ -141,3 +141,5 @@ void LinuxX11Window::terminate()
{
QCoreApplication::quit();
}
#include "moc_linuxx11window.cpp"

View File

@ -12,3 +12,5 @@ void MacIntegration::SetBackgroundLevel(QWindow* window)
{
MacBridge::SetBackgroundLevel(window);
}
#include "moc_macintegration.cpp"

View File

@ -55,3 +55,5 @@ void MacWindow::clearComponentCache()
{
m_window.engine()->clearComponentCache();
}
#include "moc_macwindow.cpp"

View File

@ -58,3 +58,5 @@ WindowsDesktopProperties::WindowsDesktopProperties(QObject* parent)
if (canParse)
setWindowsVersion(value);
}
#include "moc_windowsdesktopproperties.cpp"

View File

@ -507,3 +507,5 @@ void WinWindow::clearComponentCache()
{
m_window.engine()->clearComponentCache();
}
#include "moc_winwindow.cpp"

View File

@ -144,3 +144,5 @@ QNetworkRequest ScreenPlayWeather::defaultRequest() const
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
return request;
}
#include "moc_screenplayweather.cpp"

View File

@ -220,3 +220,5 @@ void WidgetWindow::setupLiveReloading()
QObject::connect(&m_liveReloadLimiter, &QTimer::timeout, this, reloadQMLLambda);
m_fileSystemWatcher.addPaths({ projectPath() });
}
#include "moc_widgetwindow.cpp"

View File

@ -155,3 +155,5 @@ void InstalledListModel::reset()
loadInstalledContent();
}
}
#include "moc_installedlistmodel.cpp"

View File

@ -12,3 +12,5 @@ ScreenPlayWorkshop::ScreenPlayWorkshop()
}
}
#include "moc_screenplayworkshop.cpp"

View File

@ -81,3 +81,5 @@ void SteamAccount::onAvatarImageLoaded(AvatarImageLoaded_t* avatarImage)
m_avatarLoaded = true;
}
}
#include "moc_steamaccount.cpp"

View File

@ -8,3 +8,5 @@ SteamQMLImageProvider::SteamQMLImageProvider(QQuickItem* parent)
setFlag(QQuickItem::ItemHasContents);
}
}
#include "moc_steamqmlimageprovider.cpp"

View File

@ -396,3 +396,5 @@ void SteamWorkshop::onRequestUserItemsReturned(SteamUGCQueryCompleted_t* pCallba
// }
}
}
#include "moc_steamworkshop.cpp"

View File

@ -221,3 +221,5 @@ void SteamWorkshopItem::saveWorkshopID()
}
}
#include "moc_steamworkshopitem.cpp"

View File

@ -76,3 +76,5 @@ void SteamWorkshopListModel::clear()
}
}
#include "moc_steamworkshoplistmodel.cpp"

View File

@ -0,0 +1,63 @@
#!/usr/bin/python3
# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
import os
from pathlib import Path
import util
import argparse
def find_files(path, pattern, file_extensions):
files = []
for root, dirnames, filenames in os.walk(path):
for filename in filenames:
if any(filename.endswith(ext) for ext in file_extensions):
file_path = os.path.join(root, filename)
with open(file_path) as f:
contents = f.read()
if any(substring in contents for substring in pattern):
files.append(file_path)
print(f"Found file {file_path}")
return files
def check_moc_include(filename, add_include=False):
cppfile = Path(filename)
# replace cppfile ending with .cpp
cppfile = cppfile.with_suffix(".cpp").resolve()
# check if cpp file exists
if not cppfile.exists():
# check if cpp file exists but 3 directories up and then in src
cppfile = cppfile.joinpath(
"../../../../src/{}".format(cppfile.name)).resolve()
if not cppfile.exists():
print(f"FAIL: {cppfile} does not exist")
return
print(f"Check {cppfile}")
with open(cppfile) as f:
if '#include "moc_{}"'.format(os.path.basename(cppfile)) in f.read():
print("OK: {} HAS moc include".format(cppfile))
else:
print("FAIL: {} MISSES moc include".format(cppfile))
if add_include:
with open(cppfile, 'a') as f:
f.write("\n#include \"moc_{}\"\n".format(
os.path.basename(cppfile)))
print("Adding include...")
else:
print("Add this line to the end of the file:")
print("#include \"moc_{}\"".format(os.path.basename(cppfile)))
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Check if moc includes are present and add them if requested.")
parser.add_argument('-a', '--addinclude', action='store_true',
help='Automatically add missing moc includes')
args = parser.parse_args()
repo_root = util.repo_root_path()
filenames = find_files(repo_root, ['Q_OBJECT', 'Q_GADGET', 'Q_NAMESPACE'], [
'.cpp', '.h', "main.cpp"])
for filename in filenames:
check_moc_include(filename, args.addinclude)
if not args.addinclude:
print("Run this script with the '-a' or '--addinclude' flag to automatically add the moc includes")