Skip to content

Commit

Permalink
autobot configure options
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkorsukov committed Apr 5, 2021
1 parent 88e7737 commit 3faae5a
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 92 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ option(BUILD_PLAYBACK_MODULE "Build playback module" ON)
option(BUILD_PALETTE_MODULE "Build palette module" ON)
option(BUILD_INSTRUMENTS_MODULE "Build instruments module" ON)
option(BUILD_INSPECTOR_MODULE "Build inspector module" ON)
option(BUILD_AUTOBOT_MODULE "Build autobot module" OFF)

option(SOUNDFONT3 "Ogg Vorbis compressed fonts" ON) # Enable Ogg Vorbis compressed fonts, requires Ogg & Vorbis
option(DOWNLOAD_SOUNDFONT "Download the latest soundfont version as part of the build process" ON)
Expand Down
1 change: 1 addition & 0 deletions build/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#cmakedefine BUILD_PALETTE_MODULE
#cmakedefine BUILD_INSTRUMENTS_MODULE
#cmakedefine BUILD_INSPECTOR_MODULE
#cmakedefine BUILD_AUTOBOT_MODULE
#cmakedefine BUILD_VST

#cmakedefine WIN_SPARKLE_ENABLED
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ if (BUILD_INSPECTOR_MODULE)
add_subdirectory(inspector)
endif (BUILD_INSPECTOR_MODULE)

add_subdirectory(autobot)
if (BUILD_AUTOBOT_MODULE)
add_subdirectory(autobot)
endif()

# Stubs
add_subdirectory(stubs)
Expand Down
1 change: 1 addition & 0 deletions src/appshell/appshell.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
<file>qml/Preferences/internal/CommonAudioApiConfiguration.qml</file>
<file>qml/Preferences/internal/ComboBoxWithTitle.qml</file>
<file>qml/Preferences/internal/IncrementalPropertyControlWithTitle.qml</file>
<file>qml/DevTools/Autobot/AutobotControl.qml</file>
</qresource>
</RCC>
19 changes: 19 additions & 0 deletions src/appshell/qml/DevTools/Autobot/AutobotControl.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import QtQuick 2.15
import MuseScore.Ui 1.0
import MuseScore.UiComponents 1.0

Rectangle {

color: ui.theme.backgroundPrimaryColor

FlatButton {
anchors.top: parent.top
anchors.left: parent.left
anchors.topMargin: 24
anchors.leftMargin: 24
text: "Open Autobot"
onClicked: api.launcher.open("musescore://autobot/main")
}

//! NOTE Will be some settings here
}
4 changes: 2 additions & 2 deletions src/appshell/qml/DevTools/DevToolsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ DockPage {
case "midiports": currentComp = midiPortsComp; break
case "vst": currentComp = vstComponent; break
case "plugins": currentComp = pluginsComp; break
case "autobot": api.launcher.open("musescore://autobot/main"); break
case "autobot": currentComp = autobotComp; break
}
}

Expand Down Expand Up @@ -149,7 +149,7 @@ DockPage {
Component {
id: autobotComp
Loader {
source: "qrc:/qml/DevTools/Autobot/AutobotPanel.qml"
source: "qrc:/qml/DevTools/Autobot/AutobotControl.qml"
}
}
}
6 changes: 0 additions & 6 deletions src/autobot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ set(MODULE_QRC autobot.qrc)

set(MODULE_QML_IMPORT ${CMAKE_CURRENT_LIST_DIR}/qml )

set(MODULE_DEF
SCORES_ROOT="${PROJECT_SOURCE_DIR}/vtest/scores"
)

set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/autobotmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/autobotmodule.h
Expand All @@ -48,8 +44,6 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/abcontext.h
${CMAKE_CURRENT_LIST_DIR}/internal/abrunner.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/abrunner.h
${CMAKE_CURRENT_LIST_DIR}/internal/abscorelist.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/abscorelist.h
${CMAKE_CURRENT_LIST_DIR}/internal/typicaltc.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/typicaltc.h
${CMAKE_CURRENT_LIST_DIR}/internal/abbasestep.cpp
Expand Down
6 changes: 4 additions & 2 deletions src/autobot/iautobotconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ class IAutobotConfiguration : MODULE_EXPORT_INTERFACE
virtual ~IAutobotConfiguration() = default;

virtual io::path dataPath() const = 0;
virtual io::path drawDataPath() const = 0;

virtual io::path scoreDrawData(const io::path& scorePath) const = 0;
virtual io::path filesPath() const = 0;

virtual io::path drawDataPath() const = 0;
virtual io::path fileDrawDataPath(const io::path& filePath) const = 0;

virtual io::path reportsPath() const = 0;
};
Expand Down
33 changes: 0 additions & 33 deletions src/autobot/internal/abscorelist.cpp

This file was deleted.

37 changes: 0 additions & 37 deletions src/autobot/internal/abscorelist.h

This file was deleted.

23 changes: 18 additions & 5 deletions src/autobot/internal/autobot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "log.h"

#include "abcontext.h"
#include "abscorelist.h"
#include "typicaltc.h"

#include "steps/abscoreloadstep.h"
Expand Down Expand Up @@ -100,6 +99,16 @@ const mu::ValCh<ITestCasePtr>& Autobot::currentTestCase() const
return m_currentTestCase;
}

mu::RetVal<mu::io::paths> Autobot::filesList() const
{
using namespace mu::system;

io::path filesPath = configuration()->filesPath();
LOGI() << "filesPath: " << filesPath;
RetVal<io::paths> paths = fileSystem()->scanFiles(filesPath, QStringList(), IFileSystem::ScanMode::OnlyCurrentDir);
return paths;
}

void Autobot::init()
{
m_status.val = Status::Stoped;
Expand All @@ -118,14 +127,14 @@ void Autobot::init()

m_currentTestCase.set(m_testCases.front());

RetVal<io::paths> scores = AbScoreList().scoreList();
if (!scores.ret) {
LOGE() << "failed get score list, err: " << scores.ret.toString();
RetVal<io::paths> files = filesList();
if (!files.ret) {
LOGE() << "failed get score list, err: " << files.ret.toString();
return;
}

m_files.val.clear();
for (const io::path& p : scores.val) {
for (const io::path& p : files.val) {
File f;
f.path = p;
m_files.val.push_back(std::move(f));
Expand Down Expand Up @@ -212,6 +221,10 @@ void Autobot::nextFile()
return;
}

IF_ASSERT_FAILED(!m_files.val.empty()) {
return;
}

if (m_status.val == Status::Stoped) {
doStop();
return;
Expand Down
7 changes: 7 additions & 0 deletions src/autobot/internal/autobot.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@
#include "../iautobot.h"
#include "io/path.h"
#include "async/asyncable.h"
#include "modularity/ioc.h"
#include "../iautobotconfiguration.h"
#include "system/ifilesystem.h"

#include "abrunner.h"
#include "abreport.h"

namespace mu::autobot {
class Autobot : public IAutobot, public async::Asyncable
{
INJECT(autobot, IAutobotConfiguration, configuration)
INJECT(autobot, system::IFileSystem, fileSystem)

public:
Autobot();

Expand All @@ -51,6 +57,7 @@ class Autobot : public IAutobot, public async::Asyncable

private:

mu::RetVal<mu::io::paths> filesList() const;
void nextFile();
void onFileFinished(const IAbContextPtr& ctx);
void doStop();
Expand Down
9 changes: 7 additions & 2 deletions src/autobot/internal/autobotconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ mu::io::path AutobotConfiguration::dataPath() const
return io::path(std::getenv("MU_AUTOBOT_DATA_PATH"));
}

mu::io::path AutobotConfiguration::filesPath() const
{
return io::path(std::getenv("MU_AUTOBOT_FILES_PATH"));
}

mu::io::path AutobotConfiguration::drawDataPath() const
{
return dataPath() + "/draw_data";
}

mu::io::path AutobotConfiguration::scoreDrawData(const io::path& scorePath) const
mu::io::path AutobotConfiguration::fileDrawDataPath(const io::path& filePath) const
{
return drawDataPath() + "/" + io::basename(scorePath) + ".json";
return drawDataPath() + "/" + io::basename(filePath) + ".json";
}

mu::io::path AutobotConfiguration::reportsPath() const
Expand Down
6 changes: 4 additions & 2 deletions src/autobot/internal/autobotconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ class AutobotConfiguration : public IAutobotConfiguration
AutobotConfiguration() = default;

io::path dataPath() const override;
io::path drawDataPath() const override;

io::path scoreDrawData(const io::path& scorePath) const override;
io::path filesPath() const override;

io::path drawDataPath() const override;
io::path fileDrawDataPath(const io::path& filePath) const override;

io::path reportsPath() const override;
};
Expand Down
2 changes: 1 addition & 1 deletion src/autobot/internal/steps/abdrawcurrentstep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void AbDrawCurrentStep::doRun(IAbContextPtr ctx)
QByteArray data = draw::DrawBufferJson::toJson(buf);

io::path scorePath = ctx->globalVal<io::path>(IAbContext::Key::FilePath);
io::path filePath = configuration()->scoreDrawData(scorePath);
io::path filePath = configuration()->fileDrawDataPath(scorePath);
QFile file(filePath.toQString());
if (!file.open(QIODevice::WriteOnly)) {
LOGE() << "failed open file to write draw data, path: " << filePath;
Expand Down
2 changes: 1 addition & 1 deletion src/autobot/internal/steps/abdrawrefstep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ std::string AbDrawRefStep::name() const
void AbDrawRefStep::doRun(IAbContextPtr ctx)
{
io::path scorePath = ctx->globalVal<io::path>(IAbContext::Key::FilePath);
io::path filePath = configuration()->scoreDrawData(scorePath);
io::path filePath = configuration()->fileDrawDataPath(scorePath);
Ret ret = fileSystem()->exists(filePath);
if (!ret) {
LOGE() << "failed open file to write draw data, path: " << filePath;
Expand Down
3 changes: 3 additions & 0 deletions src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ if (NOT CC_IS_EMSCRIPTEN)
list(APPEND LINK_LIB iex_audioexport)
list(APPEND LINK_LIB iex_imagesexport)
list(APPEND LINK_LIB plugins)
endif()

if (BUILD_AUTOBOT_MODULE)
list(APPEND LINK_LIB autobot)
endif()

Expand Down
4 changes: 4 additions & 0 deletions src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@
#include "stubs/languages/languagesstubmodule.h"
#endif

#ifdef BUILD_AUTOBOT_MODULE
#include "autobot/autobotmodule.h"
#endif

#else
#include "wasmtest/wasmtestmodule.h"
Expand Down Expand Up @@ -257,7 +259,9 @@ int main(int argc, char** argv)
app.addModule(new mu::languages::LanguagesStubModule());
#endif

#ifdef BUILD_AUTOBOT_MODULE
app.addModule(new mu::autobot::AutobotModule());
#endif

#else
app.addModule(new mu::wasmtest::WasmTestModule());
Expand Down

0 comments on commit 3faae5a

Please sign in to comment.