Skip to content

Commit

Permalink
added unity build
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkorsukov committed Dec 17, 2020
1 parent 83a1604 commit 1b6e66f
Show file tree
Hide file tree
Showing 49 changed files with 639 additions and 595 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ option(PACKAGE_FILE_ASSOCIATION "File types association" OFF)

option(TRY_USE_CCACHE "Try use ccache" ON)
option(BUILD_PCH "Build using precompiled headers." ON)
option(BUILD_UNITY "Build using unity build." ON)
option(BUILD_SHARED_LIB_IN_DEBUG "Build shared libs if possible in debug" ON)
option(QML_LOAD_FROM_SOURCE "Load qml files from source (not resource)" OFF)

option(USE_SYSTEM_FREETYPE "Use system FreeType" OFF) # requires freetype >= 2.5.2, does not work on win
option(USE_SYSTEM_FREETYPE "Use system FreeType" OFF) # requires freetype >= 2.5.2, does not work on win
option(BUILD_WEBENGINE "Built in webengine support" ON)
set(SCRIPT_INTERFACE TRUE)

Expand Down
5 changes: 3 additions & 2 deletions build/cmake/SetupBuildEnvironment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ include(GetBuildType)

set(BUILD_SHARED_LIBS OFF)
set(SHARED_LIBS_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)

set(CMAKE_UNITY_BUILD_BATCH_SIZE 12)

if (CC_IS_GCC)
message(STATUS "Using Compiler GCC ${CMAKE_CXX_COMPILER_VERSION}")

Expand All @@ -14,8 +17,6 @@ if (CC_IS_GCC)
set(BUILD_SHARED_LIBS ON)
endif(BUILD_IS_DEBUG)

#add_compile_options(-H)

elseif(CC_IS_MSVC)
message(STATUS "Using Compiler MSVC ${CMAKE_CXX_COMPILER_VERSION}")

Expand Down
11 changes: 10 additions & 1 deletion build/module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# set(MODULE_UI ...) - set ui headers
# set(MODULE_QML_IMPORT ...) - set Qml import for QtCreator (so that there is code highlighting, jump, etc.)
# set(MODULE_USE_PCH_NONE ON) - set for disable PCH for module
# set(MODULE_USE_UNITY_NONE ON) - set for disable UNITY BUILD for module


# After all the settings you need to do:
Expand Down Expand Up @@ -59,7 +60,7 @@ endif()

if (BUILD_PCH)
if (MODULE_USE_PCH_NONE)
# disables pch for current module
# disabled pch for current module
else()
if(NOT ${MODULE} MATCHES global)
target_precompile_headers(${MODULE} REUSE_FROM global)
Expand All @@ -70,6 +71,14 @@ if (BUILD_PCH)
endif()
endif(BUILD_PCH)

if (BUILD_UNITY)
if (MODULE_USE_UNITY_NONE)
# disabled unity build for current module
else()
set_target_properties(${MODULE} PROPERTIES UNITY_BUILD ON)
endif()
endif(BUILD_UNITY)

target_sources(${MODULE} PRIVATE
${ui_headers}
${RCC_SOURCES}
Expand Down
6 changes: 3 additions & 3 deletions src/appshell/dockwindow/docktoolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

using namespace mu::dock;

static const QString qss = QString("QToolBar { background: %1; border: 0; padding: 0; }");
static const QString qtoolbarQss = QString("QToolBar { background: %1; border: 0; padding: 0; }");

static const qreal MOVING_BUTTON_WIDTH(10);

Expand Down Expand Up @@ -57,7 +57,7 @@ DockToolBar::~DockToolBar()
void DockToolBar::onComponentCompleted()
{
m_tool.bar->setObjectName("w_" + objectName());
m_tool.bar->setStyleSheet(qss.arg(color().name()));
m_tool.bar->setStyleSheet(qtoolbarQss.arg(color().name()));

QWidget* w = view();
w->setMinimumWidth(minimumWidth());
Expand All @@ -67,7 +67,7 @@ void DockToolBar::onComponentCompleted()

void DockToolBar::updateStyle()
{
m_tool.bar->setStyleSheet(qss.arg(color().name()));
m_tool.bar->setStyleSheet(qtoolbarQss.arg(color().name()));
}

void DockToolBar::onToolbarEvent(QEvent* e)
Expand Down
1 change: 1 addition & 0 deletions src/framework/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ if(OS_IS_LIN)
endif()

set(MODULE_USE_PCH_NONE ON) # strange error
set(MODULE_USE_UNITY_NONE ON) # soloud not compile
include(${PROJECT_SOURCE_DIR}/build/module.cmake)

# for soloud
Expand Down
1 change: 1 addition & 0 deletions src/framework/fonts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/fontsmodule.h
)

set(MODULE_USE_UNITY_NONE ON)
include(${PROJECT_SOURCE_DIR}/build/module.cmake)
4 changes: 2 additions & 2 deletions src/framework/global/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void Settings::setValue(const Key& key, const Val& value)

auto it = m_channels.find(key);
if (it != m_channels.end()) {
Channel<Val> channel = it->second;
async::Channel<Val> channel = it->second;
channel.send(value);
}
}
Expand Down Expand Up @@ -154,7 +154,7 @@ Settings::Item& Settings::findItem(const Key& key) const
return it->second;
}

Channel<Val> Settings::valueChanged(const Key& key) const
async::Channel<Val> Settings::valueChanged(const Key& key) const
{
return m_channels[key];
}
Expand Down
6 changes: 4 additions & 2 deletions src/framework/global/uri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ const Uri::Scheme Uri::MuseScore("musescore");
const Uri::Scheme Uri::Http("http");
const Uri::Scheme Uri::Https("https");

namespace uri_prv {
static const std::string VAL_TRUE("true");
static const std::string VAL_FALSE("false");
}

// musescore://module/target/name

Expand Down Expand Up @@ -120,8 +122,8 @@ void UriQuery::parceParams(const std::string& uri, Params& out) const
std::string val = param.at(1);

//! NOTE Val is bool?
if (VAL_TRUE == val || VAL_FALSE == val) {
out[key] = Val(val == VAL_TRUE);
if (uri_prv::VAL_TRUE == val || uri_prv::VAL_FALSE == val) {
out[key] = Val(val == uri_prv::VAL_TRUE);
continue;
}

Expand Down
4 changes: 3 additions & 1 deletion src/framework/midi/internal/zerberussynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
using namespace mu;
using namespace mu::midi;

namespace zerb_prv {
template<class T>
static const T& clamp(const T& v, const T& lo, const T& hi)
{
return (v < lo) ? lo : (hi < v) ? hi : v;
}
}

ZerberusSynth::ZerberusSynth()
{
Expand Down Expand Up @@ -200,7 +202,7 @@ void ZerberusSynth::channelSoundsOff(channel_t chan)
bool ZerberusSynth::channelVolume(channel_t chan, float volume)
{
int val = static_cast<int>(volume * 100.f);
val = clamp(val, 0, 127);
val = zerb_prv::clamp(val, 0, 127);

m_zerb->controller(chan, zerberus::CTRL_VOLUME, val);
return false;
Expand Down
1 change: 1 addition & 0 deletions src/framework/vst/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,5 @@ if (build_mode STREQUAL "debug")
set(MODULE_DEF -D_DEBUG)
endif()

set(MODULE_USE_UNITY_NONE ON) # not linking
include(${PROJECT_SOURCE_DIR}/build/module.cmake)
1 change: 1 addition & 0 deletions src/importexport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ set(MODULE_LINK
notation
)

set(MODULE_USE_UNITBUILD ON)
include(${PROJECT_SOURCE_DIR}/build/module.cmake)

17 changes: 9 additions & 8 deletions src/importexport/internal/bww/importbww.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
#include "libmscore/volta.h"
#include "libmscore/segment.h"


namespace Bww {
/**
The writer that imports into MuseScore.
*/

//---------------------------------------------------------
// addText
// copied from importxml.cpp
Expand Down Expand Up @@ -121,11 +127,6 @@ static void setTempo(Ms::Score* score, int tempo)
segment->add(tt);
}

namespace Bww {
/**
The writer that imports into MuseScore.
*/

class MsScWriter : public Writer
{
public:
Expand Down Expand Up @@ -439,9 +440,9 @@ void MsScWriter::header(const QString title, const QString type,

// score->setWorkTitle(title);
Ms::VBox* vbox = 0;
addText(vbox, score, title, Ms::Tid::TITLE);
addText(vbox, score, type, Ms::Tid::SUBTITLE);
addText(vbox, score, composer, Ms::Tid::COMPOSER);
Bww::addText(vbox, score, title, Ms::Tid::TITLE);
Bww::addText(vbox, score, type, Ms::Tid::SUBTITLE);
Bww::addText(vbox, score, composer, Ms::Tid::COMPOSER);
// addText(vbox, score, strPoet, Ms::Tid::POET);
// addText(vbox, score, strTranslator, Ms::Tid::TRANSLATOR);
if (vbox) {
Expand Down
11 changes: 7 additions & 4 deletions src/importexport/internal/musicxml/importmxmllogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ static QString xmlLocation(const QXmlStreamReader* const xmlreader)
// logDebugTrace
//---------------------------------------------------------

static void log(MxmlLogger::Level level, const QString& text, const QXmlStreamReader* const xmlreader)
namespace ixl_prv {

static void to_log(MxmlLogger::Level level, const QString& text, const QXmlStreamReader* const xmlreader)
{
QString str;
switch (level) {
Expand All @@ -52,6 +54,7 @@ static void log(MxmlLogger::Level level, const QString& text, const QXmlStreamRe

qDebug("%s", qPrintable(str));
}
}

//---------------------------------------------------------
// logDebugTrace
Expand All @@ -64,7 +67,7 @@ static void log(MxmlLogger::Level level, const QString& text, const QXmlStreamRe
void MxmlLogger::logDebugTrace(const QString& trace, const QXmlStreamReader* const xmlreader)
{
if (_level <= Level::MXML_TRACE) {
log(Level::MXML_TRACE, trace, xmlreader);
ixl_prv::to_log(Level::MXML_TRACE, trace, xmlreader);
}
}

Expand All @@ -79,7 +82,7 @@ void MxmlLogger::logDebugTrace(const QString& trace, const QXmlStreamReader* con
void MxmlLogger::logDebugInfo(const QString& info, const QXmlStreamReader* const xmlreader)
{
if (_level <= Level::MXML_INFO) {
log(Level::MXML_INFO, info, xmlreader);
ixl_prv::to_log(Level::MXML_INFO, info, xmlreader);
}
}

Expand All @@ -94,7 +97,7 @@ void MxmlLogger::logDebugInfo(const QString& info, const QXmlStreamReader* const
void MxmlLogger::logError(const QString& error, const QXmlStreamReader* const xmlreader)
{
if (_level <= Level::MXML_ERROR) {
log(Level::MXML_ERROR, error, xmlreader);
ixl_prv::to_log(Level::MXML_ERROR, error, xmlreader);
}
}
}
22 changes: 16 additions & 6 deletions src/importexport/internal/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ static void setPartInstruments(MxmlLogger* logger, const QXmlStreamReader* const
/**
Convert SMuFL code points to MuseScore <sym>...</sym>
*/
namespace xmlpass2 {

static QString text2syms(const QString& t)
{
Expand Down Expand Up @@ -640,6 +641,7 @@ static QString text2syms(const QString& t)
//qDebug("text2syms total time elapsed: %d ms, res '%s'", time.elapsed(), qPrintable(res));
return res;
}
}

//---------------------------------------------------------
// decodeEntities
Expand All @@ -649,6 +651,8 @@ static QString text2syms(const QString& t)
Decode &#...; in string \a src into UNICODE (utf8) character.
*/

namespace xmlpass2 {

static QString decodeEntities(const QString& src)
{
QString ret(src);
Expand All @@ -663,6 +667,8 @@ static QString decodeEntities(const QString& src)
return ret;
}

}

//---------------------------------------------------------
// nextPartOfFormattedString
//---------------------------------------------------------
Expand All @@ -673,6 +679,8 @@ static QString decodeEntities(const QString& src)
Read the next part of a MusicXML formatted string and convert to MuseScore internal encoding.
*/

namespace xmlpass2 {

static QString nextPartOfFormattedString(QXmlStreamReader& e)
{
//QString lang = e.attribute(QString("xml:lang"), "it");
Expand All @@ -685,8 +693,8 @@ static QString nextPartOfFormattedString(QXmlStreamReader& e)

QString txt = e.readElementText();
// replace HTML entities
txt = decodeEntities(txt);
QString syms = text2syms(txt);
txt = xmlpass2::decodeEntities(txt);
QString syms = xmlpass2::text2syms(txt);

QString importedtext;

Expand Down Expand Up @@ -736,6 +744,8 @@ static QString nextPartOfFormattedString(QXmlStreamReader& e)
return importedtext;
}

}

//---------------------------------------------------------
// addLyric
//---------------------------------------------------------
Expand Down Expand Up @@ -2647,13 +2657,13 @@ void MusicXMLParserDirection::directionType(QList<MusicXmlSpannerDesc>& starts,
_metroText = metronome(_tpoMetro);
} else if (_e.name() == "words") {
_enclosure = _e.attributes().value("enclosure").toString();
_wordsText += nextPartOfFormattedString(_e);
_wordsText += xmlpass2::nextPartOfFormattedString(_e);
} else if (_e.name() == "rehearsal") {
_enclosure = _e.attributes().value("enclosure").toString();
if (_enclosure == "") {
_enclosure = "square"; // note different default
}
_rehearsalText += nextPartOfFormattedString(_e);
_rehearsalText += xmlpass2::nextPartOfFormattedString(_e);
} else if (_e.name() == "pedal") {
pedal(type, n, starts, stops);
} else if (_e.name() == "octave-shift") {
Expand Down Expand Up @@ -5408,7 +5418,7 @@ void MusicXMLParserLyric::parse()
formattedText += " ";
else
*/
formattedText += nextPartOfFormattedString(_e);
formattedText += xmlpass2::nextPartOfFormattedString(_e);
} else if (_e.name() == "extend") {
hasExtend = true;
extendType = _e.attributes().value("type").toString();
Expand All @@ -5427,7 +5437,7 @@ void MusicXMLParserLyric::parse()
qDebug("unknown syllabic %s", qPrintable(syll)); // TODO
}
} else if (_e.name() == "text") {
formattedText += nextPartOfFormattedString(_e);
formattedText += xmlpass2::nextPartOfFormattedString(_e);
} else {
skipLogCurrElem();
}
Expand Down
Loading

0 comments on commit 1b6e66f

Please sign in to comment.