Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build static/shared lib based on option value #104

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion easy_profiler_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ set(SOURCES
${INCLUDE_FILES}
)

add_library(easy_profiler ${SOURCES} resources.rc)
set(LIBRARY_TYPE SHARED)
if (NOT BUILD_SHARED_LIBS)
set(LIBRARY_TYPE STATIC)
endif ()

add_library(easy_profiler ${LIBRARY_TYPE} ${SOURCES} resources.rc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vladislav-horbatiuk in case you didn't know, if you leave add_library without a type (without STATIC nor SHARED), it will automatically build as shared if BUILD_SHARED_LIBS is set to on/true, and will automatically build as static otherwise. This change is redundant and unecessary since cmake does exactly that already.

# End adding source files.
#################################################

Expand Down
12 changes: 12 additions & 0 deletions profiler_gui/blocks_graphics_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,18 @@ const BlocksGraphicsView::Items &BlocksGraphicsView::getItems() const
return m_items;
}

void BlocksGraphicsView::saveSelectionToFile(const QString& _filename) const
{
if (m_selectedBlocks.empty())
return;

// profiler::timestamp_t beginTime = ~0ULL;
// for (const auto& selection : m_selectedBlocks)
// {
// const auto& tree = easy
// }
}

qreal BlocksGraphicsView::setTree(BlocksGraphicsItem* _item, const ::profiler::BlocksTree::children_t& _children, qreal& _height, uint32_t& _maxDepthChild, qreal _y, short _level)
{
if (_children.empty())
Expand Down
2 changes: 2 additions & 0 deletions profiler_gui/blocks_graphics_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class BlocksGraphicsView : public QGraphicsView

const Items& getItems() const;

void saveSelectionToFile(const QString& _filename) const;

void inspectCurrentView(bool _strict) {
onInspectCurrentView(_strict);
}
Expand Down
2 changes: 2 additions & 0 deletions profiler_gui/images/attribution.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ default/binoculars.svg - Icon made by Gregor Cresnar from www.flaticon
default/close-white.svg - Icon made by Cole Bemis from www.flaticon.com
default/close-white-hover.svg - Icon made by Cole Bemis from www.flaticon.com
default/close-white-pressed.svg - Icon made by Cole Bemis from www.flaticon.com
default/crop.svg - Icon made by Freepik from www.flaticon.com
default/maximize-white.svg - Icon made by Freepik from www.flaticon.com
default/maximize-white-hover.svg - Icon made by Freepik from www.flaticon.com
default/maximize-white-pressed.svg - Icon made by Freepik from www.flaticon.com
Expand All @@ -46,3 +47,4 @@ default/yx.svg - Icon made by Freepik from www.flaticon.com
default/svg2.svg - Icon made by Freepik from www.flaticon.com
default/svg3.svg - Icon made by Freepik from www.flaticon.com
default/window.svg - Icon made by Freepik from www.flaticon.com

15 changes: 15 additions & 0 deletions profiler_gui/images/default/crop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions profiler_gui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos
static_cast<DiagramWidget*>(m_graphicsView->widget())->view()->inspectCurrentView(true);
});

action = toolbar->addAction(QIcon(imagePath("crop")), "Crop and save");
action->setToolTip("Crop and save selected area\nas separate .prof file.");
connect(action, &QAction::triggered, this, &This::onCropAndSaveClicked);

toolbar->addSeparator();
auto menu = new QMenu("Settings", this);
menu->setToolTipsVisible(true);
Expand Down Expand Up @@ -2142,6 +2146,28 @@ void MainWindow::onFrameTimeChanged()

//////////////////////////////////////////////////////////////////////////

void MainWindow::onCropAndSaveClicked(bool)
{
QString lastFile = m_lastFiles.empty() ? QString() : m_lastFiles.front();

const auto i = lastFile.lastIndexOf(QChar('/'));
const auto j = lastFile.lastIndexOf(QChar('\\'));
auto k = std::max(i, j);

QString dir;
if (k > 0)
dir = lastFile.mid(0, ++k);

auto filename = QFileDialog::getSaveFileName(this, "Save cropped area to EasyProfiler File", dir,
"EasyProfiler File (*.prof);;All Files (*.*)");
if (filename.isEmpty())
return;

static_cast<DiagramWidget*>(m_graphicsView->widget())->view()->saveSelectionToFile(filename);
}

//////////////////////////////////////////////////////////////////////////

void MainWindow::onConnectClicked(bool)
{
if (EASY_GLOBALS.connected)
Expand Down
1 change: 1 addition & 0 deletions profiler_gui/main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ protected slots:
void onEventTracingEnableChange(bool _checked);
void onFrameTimeEditFinish();
void onFrameTimeChanged();
void onCropAndSaveClicked(bool);

void onBlockStatusChange(profiler::block_id_t _id, profiler::EasyBlockStatus _status);

Expand Down
1 change: 1 addition & 0 deletions profiler_gui/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</qresource>
<qresource prefix="/images/default">
<file alias="binoculars">images/default/binoculars.svg</file>
<file alias="crop">images/default/crop.svg</file>
<file alias="exit">images/default/off.svg</file>
<file alias="open">images/default/open-folder2.svg</file>
<file alias="reload">images/default/reload.svg</file>
Expand Down