Skip to content

Commit

Permalink
dac: bundle test .csv waveform files in installers on all platforms.
Browse files Browse the repository at this point in the history
Signed-off-by: AlexandraTrifan <[email protected]>
  • Loading branch information
AlexandraTrifan committed Sep 26, 2024
1 parent c1280dd commit feb11a4
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ci/armhf/armhf_build_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ create_appdir(){
PLUGINS=$BUILD_FOLDER/plugins/plugins
SCOPY_DLL=$(find $BUILD_FOLDER -maxdepth 1 -type f -name "libscopy*")
REGMAP_XMLS=$PLUGINS/regmap/xmls
DAC_WAVEFORM_CSV=$SRC_DIR/plugins/dac/res/csv
TRANSLATIONS_QM=$(find $BUILD_FOLDER/translations -type f -name "*.qm")
COPY_DEPS=$SRC_DIR/ci/armhf/copy-deps.sh

Expand Down Expand Up @@ -323,6 +324,8 @@ create_appdir(){
cp -r $REGMAP_XMLS $APP_DIR/usr/lib/scopy/plugins
fi

cp -r $DAC_WAVEFORM_CSV $DEST_FOLDER/plugins

$COPY_DEPS $APP_DIR/usr/bin/scopy $APP_DIR/usr/lib
$COPY_DEPS $APP_DIR/usr/bin/iio-emu $APP_DIR/usr/lib
$COPY_DEPS $APP_DIR/usr/bin/scopy $APP_DIR/usr/lib
Expand Down
1 change: 1 addition & 0 deletions ci/macOS/package_darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SCOPYPLUGINS=$(find $BUILDDIR/Scopy.app/Contents/MacOs/plugins -name "*.dylib" -
SCOPYLIBS=$(find $BUILDDIR/Scopy.app/Contents/Frameworks -name "*.dylib" -type f)

echo "### Copy DLLs to Frameworks folder"
cp -R $REPO_SRC/plugins/dac/res/csv Scopy.app/Contents/MacOS/plugins/
cp -R $STAGING_AREA/libiio/build/iio.framework Scopy.app/Contents/Frameworks/
cp -R $STAGING_AREA/libad9361/build/ad9361.framework Scopy.app/Contents/Frameworks/

Expand Down
8 changes: 8 additions & 0 deletions ci/windows/build_and_create_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ DEBUG_FOLDER=$ARTIFACT_FOLDER/debug-$ARCH
PYTHON_FILES=$STAGING_DIR/lib/python3.*
EMU_BUILD_FOLDER=$WORKDIR/iio-emu/build
REGMAP_XMLS=$BUILD_FOLDER/plugins/plugins/regmap/xmls
DAC_WAVEFORM_CSV=$SRC_FOLDER/plugins/dac/res/csv
# Generate build status info for the about page

# to be added back later
# cp $BUILD_STATUS_FILE $SRC_FOLDER/build-status

pacman -Qe >> $SRC_FOLDER/build-status

download_tools() {
mkdir -p $STAGING_AREA
Expand Down Expand Up @@ -124,6 +130,8 @@ deploy_app(){
if [ -d $REGMAP_XMLS ]; then
cp -r $REGMAP_XMLS $DEST_FOLDER/plugins
fi

cp -r $DAC_WAVEFORM_CSV $DEST_FOLDER/plugins
}

extract_debug_symbols(){
Expand Down
3 changes: 3 additions & 0 deletions ci/x86_64/x86-64_appimage_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ create_appdir(){
PLUGINS=$BUILD_FOLDER/plugins/plugins
SCOPY_DLL=$(find $BUILD_FOLDER -maxdepth 1 -type f -name "libscopy*")
REGMAP_XMLS=$BUILD_FOLDER/plugins/regmap/xmls
DAC_WAVEFORM_CSV=$SRC_DIR/plugins/dac/res/csv
TRANSLATIONS_QM=$(find $BUILD_FOLDER/translations -type f -name "*.qm")
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$STAGING_AREA_DEPS/lib:$QT_LOCATION/lib
DLL_FOLDER=${STAGING_AREA}/dll_folder
Expand Down Expand Up @@ -416,6 +417,8 @@ create_appdir(){
cp -r $REGMAP_XMLS $APP_DIR/usr/lib/scopy/plugins
fi

cp -r $DAC_WAVEFORM_CSV $APP_DIR/usr/lib/scopy/plugins

cp $STAGING_AREA_DEPS/lib/libspdlog.so* $APP_DIR/usr/lib
cp -r $QT_LOCATION/plugins $APP_DIR/usr
cp $QT_LOCATION/lib/libQt5XcbQpa.so* $APP_DIR/usr/lib
Expand Down
3 changes: 2 additions & 1 deletion plugins/dac/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include/dac/scopy-dac_export.h
include/dac/scopy-dac_export.h
include/adc/scopy-dac_config.h
14 changes: 14 additions & 0 deletions plugins/dac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,27 @@ if(NOT "${SCOPY_PLUGIN_BUILD_PATH}" STREQUAL "")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SCOPY_PLUGIN_BUILD_PATH})
endif()

set(DAC_CSV_SYSTEM_PATH ${SCOPY_PLUGIN_INSTALL_PATH}/csv)
set(DAC_CSV_BUILD_PATH ${CMAKE_CURRENT_BINARY_DIR}/csv)

install(FILES res/csv/* DESTINATION ${SCOPY_PLUGIN_INSTALL_PATH}/csv)
file(GLOB CSVS ${CMAKE_CURRENT_SOURCE_DIR}/res/csv/*)
foreach(_csv ${CSVS})
file(COPY ${_csv} DESTINATION ${DAC_CSV_BUILD_PATH})
endforeach()

qt_add_resources(PROJECT_RESOURCES res/resources.qrc)
add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCES} ${PROJECT_RESOURCES})

generate_export_header(
${PROJECT_NAME} EXPORT_FILE_NAME ${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE}/${PROJECT_NAME}_export.h
)

configure_file(
include/${SCOPY_MODULE}/scopy-${SCOPY_MODULE}_config.h.cmakein
${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE}/scopy-${SCOPY_MODULE}_config.h @ONLY
)

target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/${SCOPY_MODULE})

Expand Down
11 changes: 11 additions & 0 deletions plugins/dac/include/dac/scopy-dac_config.h.cmakein
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef SCOPY_DAC_CONFIG_H_CMAKEIN
#define SCOPY_DAC_CONFIG_H_CMAKEIN

#define DAC_CSV_PATH_LOCAL "./plugins/csv"
#define DAC_CSV_SYSTEM_PATH "@DAC_CSV_SYSTEM_PATH@"
#define DAC_CSV_BUILD_PATH "@DAC_CSV_BUILD_PATH@"

#cmakedefine ENABLE_SCOPYJS

#endif // SCOPY_DAC_CONFIG_H_CMAKEIN

19 changes: 17 additions & 2 deletions plugins/dac/src/bufferdacaddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "databufferbuilder.h"
#include "databuffer.h"
#include "dac_logging_categories.h"
#include "scopy-dac_config.h"

#include <menusectionwidget.h>
#include <menucollapsesection.h>
Expand Down Expand Up @@ -145,7 +146,21 @@ BufferDacAddon::BufferDacAddon(DacDataModel *model, QWidget *parent)
fileBrowserSection->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
QLabel *fileLbl = new QLabel("Choose file");
StyleHelper::MenuSmallLabel(fileLbl);

// Determine default search dir
QString defaultDir = "";
#ifdef Q_OS_WINDOWS
defaultDir = DAC_CSV_PATH_LOCAL;
#elif defined __APPLE__
defaultDir = QCoreApplication::applicationDirPath() + "/plugins/csv";
#elif defined(__appimage__)
defaultDir = QCoreApplication::applicationDirPath() + "/../lib/scopy/plugins/csv";
#else
defaultDir = DAC_CSV_BUILD_PATH;
#endif

fm = new FileBrowser(fileBrowserSection);
fm->setDefaultDir(defaultDir);
fm->setProperty("tutorial_name", "FILE_MANAGER");
connect(fm, &FileBrowser::load, this, &BufferDacAddon::load);
fileBrowserSection->contentLayout()->addWidget(fileLbl);
Expand Down Expand Up @@ -295,15 +310,15 @@ void BufferDacAddon::onLoadFinished()
m_runBtn->setEnabled(true);
updateGuiStrategyWidget();
auto data = m_dataBuffer->getDataBufferStrategy()->data();
if (data.size()) {
if(data.size()) {
enableFirstChannels(data[0].size());
}
}

void BufferDacAddon::enableFirstChannels(int channelCount)
{
int i = 0;
for (auto btn : qAsConst(m_channelBtns)) {
for(auto btn : qAsConst(m_channelBtns)) {
btn->checkBox()->setChecked(i < channelCount);
i++;
}
Expand Down
9 changes: 7 additions & 2 deletions plugins/dac/src/filebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using namespace scopy::dac;
FileBrowser::FileBrowser(QWidget *parent)
: QWidget(parent)
, m_filename("")
, m_defaultDir("")
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
auto m_layout = new QVBoxLayout();
Expand All @@ -22,6 +23,7 @@ FileBrowser::FileBrowser(QWidget *parent)

MenuSectionWidget *fileBufferContainer = new MenuSectionWidget(this);
fileBufferContainer->contentLayout()->setSpacing(10);
fileBufferContainer->contentLayout()->setMargin(0);

m_fileBufferPath = new ProgressLineEdit(this);
m_fileBufferPath->getLineEdit()->setReadOnly(true);
Expand All @@ -45,13 +47,16 @@ QString FileBrowser::getFilePath() const { return m_filename; }

void FileBrowser::loadFile() { Q_EMIT load(m_filename); }

void FileBrowser::setDefaultDir(QString dir) { m_defaultDir = dir; }

void FileBrowser::chooseFile()
{
QString selectedFilter;

bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool();
QString tmpFilename = QFileDialog::getOpenFileName(this, tr("Import"), "", tr("All Files(*)"), &selectedFilter,
(useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog));
QString tmpFilename = QFileDialog::getOpenFileName(
this, tr("Import"), m_defaultDir, tr("All Files(*)"), &selectedFilter,
(useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog));
if(!tmpFilename.isEmpty()) {
m_filename = tmpFilename;
m_fileBufferPath->getLineEdit()->setText(m_filename);
Expand Down
2 changes: 2 additions & 0 deletions plugins/dac/src/filebrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class SCOPY_DAC_EXPORT FileBrowser : public QWidget
explicit FileBrowser(QWidget *parent = nullptr);
~FileBrowser();
QString getFilePath() const;
void setDefaultDir(QString dir);
Q_SIGNALS:
void load(QString path);
private Q_SLOTS:
Expand All @@ -27,6 +28,7 @@ private Q_SLOTS:
QPushButton *m_fileBufferBrowseBtn;
QPushButton *m_fileBufferLoadBtn;
QString m_filename;
QString m_defaultDir;
};
} // namespace dac
} // namespace scopy
Expand Down
1 change: 1 addition & 0 deletions windows/scopy-64.iss.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ Source: "{#DestFolder}\*.dll"; DestDir: "{app}"; Components: main; Flags: ignore
Source: "{#DestFolder}\qt.conf"; DestDir: "{app}"; Components: main; Flags: ignoreversion onlyifdoesntexist
//Plugins
Source: "{#DestFolder}\plugins\plugins\xmls\*"; DestDir: "{app}\plugins\plugins\xmls"; Components: main; Flags: ignoreversion skipifsourcedoesntexist recursesubdirs createallsubdirs onlyifdoesntexist
Source: "{#DestFolder}\plugins\plugins\csv\*"; DestDir: "{app}\plugins\plugins\csv"; Components: main; Flags: ignoreversion skipifsourcedoesntexist recursesubdirs createallsubdirs onlyifdoesntexist
@PLUGIN_COMPONENTS_FILES@

[Tasks]
Expand Down

0 comments on commit feb11a4

Please sign in to comment.