From ed80c33a39c6e682cc8f9993ce9375e7f0370d3c Mon Sep 17 00:00:00 2001 From: Ionut Muthi Date: Mon, 20 May 2024 09:56:12 +0300 Subject: [PATCH] doc: Included documentation for building Scopy locally on Windows environment Signed-off-by: John Lloyd Juanillo --- .gitignore | 1 + doc/local-windows-build-readme.md | 58 +++++++++++++++++++ plugins/CMakeLists.txt | 15 +++++ .../templates/cmakelists_template.mako | 10 +++- 4 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 doc/local-windows-build-readme.md diff --git a/.gitignore b/.gitignore index e0dda138fd..7229d161e2 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ html/ build_arm64-v8a/ doc/* !doc/Doxyfile +!doc/local-windows-build-readme.md .cache/* build/* .vscode/* diff --git a/doc/local-windows-build-readme.md b/doc/local-windows-build-readme.md new file mode 100644 index 0000000000..95b10837e4 --- /dev/null +++ b/doc/local-windows-build-readme.md @@ -0,0 +1,58 @@ +This is a guide for installing the dependencies and setting up the environment for Scopy 2.0. The commands shown in this guide came from the [ci-for-scopy2](https://github.com/analogdevicesinc/scopy-mingw-build-deps/blob/ci-for-scopy2/docker/Dockerfile) dockerfile which can be visited and used as a reference. + +## Build prerequisites +- IDE + - [QTCreator](https://doc.qt.io/qtcreator/) + - [Visual Studio Code](https://code.visualstudio.com/download) +- [MSYS2](https://www.msys2.org/) + +## Configuring PATH + +1. Make a **backup** of your user PATH variable. + + > To make a backup, open run window using keyboard command **`WIN`**+**`R`** > Type **`SystemPropertiesAdvanced.exe`** and press the **`ENTER`** key > *System Properties* window will appear > Under the *Advanced* tab, click **`Environment Variables...`** > Under *User variables for (your user name)* find and click on *Path* and click **`Edit...`** > Then click **`Edit text...`** > copy and store the variable value in your preferred text editor > Save and close all opened windows. + +2. Append MSYS to PATH + ```sh + set PATH=%PATH%;C:\msys64\bin;C:\msys64\mingw64\bin;C:\msys64\usr\bin + ``` + +## Setting up dependencies + +1. Launch bash using the following command using Windows Command prompt + + ```sh + C:\msys64\usr\bin\bash.exe + ``` + +2. Execute the following commands in the bash terminal + + ```bash + pacman --noconfirm -Syyuu + pacman --noconfirm --needed -Sy git + git clone https://github.com/analogdevicesinc/scopy-mingw-build-deps --branch ci-for-scopy2 + cd /home/docker/scopy-mingw-build-deps/build.sh install_tools install_deps build_deps + ``` + +3. Clone **Scopy** using tag **dev** + + ```bash + git clone https://github.com/analogdevicesinc/scopy/ --branch dev + ``` + +4. Install GDB for build debugging + ```bash + pacman --noconfirm -S mingw-w64-x86_64-gdb + ``` + +## Building in Visual Studio Code + +1. In VS Code, install [**C/C++ Extension Pack**](vscode:extension/ms-vscode.cpptools-extension-pack) + +2. Open Scopy folder in VS Code + + > When opening Scopy folder for the first time, a popup may appear to ask to trust the authors of the files in this folder. Simply click on **`Yes, I trust the authors`** + +3. In VS Code, go to the toolbar on your left and locate CMake tool. On the **`PROJECT OUTLINE`** dropdown, click on the icon for *Configure All Projects*. This will instruct CMake to build the scripts necessary in building the source code. + +4. Under the **`PROJECT STATUS`** dropdown in CMake tool, click on the icon for *Build* to build the project. \ No newline at end of file diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 6dd8acb914..d3812fdef9 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -46,6 +46,21 @@ if(ENABLE_PLUGIN_TEST) list(APPEND PLUGINS ${PLUGIN_NAME}) endif() +# If in DEV_MODE remove all ".so" files on each build to ensure only ENABLED plugins have the ".so" file generated +if(SCOPY_DEV_MODE) + if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + file(GLOB DLL_FILES "${SCOPY_PLUGIN_BUILD_PATH}/*.dll") + if(NOT DLL_FILES STREQUAL "") + file(REMOVE ${DLL_FILES}) + endif() + else() + file(GLOB SO_FILES "${SCOPY_PLUGIN_BUILD_PATH}/*.so") + if(NOT SO_FILES STREQUAL "") + file(REMOVE ${SO_FILES}) + endif() + endif() +endif() + if(ENABLE_PLUGIN_ADC) add_subdirectory(adc) list(APPEND PLUGINS ${PLUGIN_NAME}) diff --git a/tools/plugingenerator/templates/cmakelists_template.mako b/tools/plugingenerator/templates/cmakelists_template.mako index b0ab99cbb2..3ae58033cc 100644 --- a/tools/plugingenerator/templates/cmakelists_template.mako +++ b/tools/plugingenerator/templates/cmakelists_template.mako @@ -47,9 +47,13 @@ endif() set(PROJECT_SOURCES ${"${SRC_LIST}"} ${"${HEADER_LIST}"} ${"${UI_LIST}"}) find_package(Qt${"${QT_VERSION_MAJOR}"} COMPONENTS REQUIRED Widgets Core) -if(NOT "${"${SCOPY_PLUGIN_BUILD_PATH}"}" STREQUAL "") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${"${SCOPY_PLUGIN_BUILD_PATH}"}) -endif() +if(${"${CMAKE_SYSTEM_NAME}"} MATCHES "Windows") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${"${SCOPY_PLUGIN_BUILD_PATH}"}) +elseif(${"${CMAKE_SYSTEM_NAME}"} MATCHES "Darwin") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${"${CMAKE_BINARY_DIR}/Scopy.app/Contents/MacOS/plugins/plugins"}) +else() + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${"${SCOPY_PLUGIN_BUILD_PATH}"}) +endif() qt_add_resources(PROJECT_RESOURCES res/resources.qrc) add_library(${"${PROJECT_NAME}"} SHARED ${"${PROJECT_SOURCES}"} ${"${PROJECT_RESOURCES}"})