Skip to content

Commit

Permalink
merge origin/monaco-editor-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
nadeemyaseen-rs committed Jan 16, 2024
2 parents 1aaea27 + 8a25bd1 commit f1e65f1
Show file tree
Hide file tree
Showing 15 changed files with 259 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .github/bin/run-clang-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ hash ${CLANG_TIDY} || exit 2 # make sure it is installed.

if [ ! -r compile_commands.json ]; then
echo "To get compile_commands.json, run in root of project and "
echo " make run-cmake-release"
echo " make MONACO_EDITOR=1 run-cmake-release"
exit 1
fi

Expand Down
70 changes: 35 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,38 +76,38 @@ jobs:
- name: Test/unittest-d
if: matrix.mode == 'test/unittest-d'
run: |
make debug test/unittest-d
make MONACO_EDITOR=1 debug test/unittest-d
# make test/openfpga

- name: Test/batch
if: matrix.mode == 'test/batch'
run: |
make debug test/unittest-d
make release test/batch
make MONACO_EDITOR=1 debug test/unittest-d
make MONACO_EDITOR=1 release test/batch
# make test/openfpga

- name: Test/gui
if: matrix.mode == 'test/gui'
run: |
make debug
make test/gui
make MONACO_EDITOR=1 debug
make MONACO_EDITOR=1 test/gui
# make test/openfpga

- name: Regression
if: matrix.mode == 'regression'
run: |
make regression
make MONACO_EDITOR=1 regression
- name: Coverage
if: matrix.mode == 'coverage'
run: |
make test/coverage
make MONACO_EDITOR=1 test/coverage
- name: Valgrind
if: matrix.mode == 'valgrind'
run: |
make debug
make test/valgrind
make MONACO_EDITOR=1 debug
make MONACO_EDITOR=1 test/valgrind
- name: Valgrind cat log
if: matrix.mode == 'valgrind' && always()
Expand All @@ -126,10 +126,10 @@ jobs:
- name: Install Test
if: matrix.mode == 'install'
run: |
make release
make install
make clean # make sure we only see installation artifacts
make test_install
make MONACO_EDITOR=1 release
make MONACO_EDITOR=1 install
make MONACO_EDITOR=1 clean # make sure we only see installation artifacts
make MONACO_EDITOR=1 test_install
- name: Archive regression artifacts
if: matrix.mode == 'regression' && always()
Expand Down Expand Up @@ -276,15 +276,15 @@ jobs:
- name: Build
run: |
make VERBOSE=1 release
make debug
make install
make MONACO_EDITOR=0 VERBOSE=1 release
make MONACO_EDITOR=0 debug
make MONACO_EDITOR=0 install
- name: Test
run: |
make test_install
make XVFB="" test/unittest
make regression
make MONACO_EDITOR=0 test_install
make MONACO_EDITOR=0 XVFB="" test/unittest
make MONACO_EDITOR=0 regression
windows-msvc:
runs-on: windows-2022
Expand Down Expand Up @@ -364,17 +364,17 @@ jobs:
where python && python --version
where ninja && ninja --version
make release
make MONACO_EDITOR=1 release
if %errorlevel% neq 0 exit /b %errorlevel%
make install
make MONACO_EDITOR=1 install
if %errorlevel% neq 0 exit /b %errorlevel%
make XVFB="" test/unittest
make MONACO_EDITOR=1 XVFB="" test/unittest
if %errorlevel% neq 0 exit /b %errorlevel%
make test_install
make MONACO_EDITOR=1 test_install
if %errorlevel% neq 0 exit /b %errorlevel%
make regression
make MONACO_EDITOR=1 regression
if %errorlevel% neq 0 exit /b %errorlevel%
make test/batch
make MONACO_EDITOR=1 test/batch
- name: Archive build artifacts
if: always ()
Expand Down Expand Up @@ -450,16 +450,16 @@ jobs:
- name: Build
run: |
make release
make install
make MONACO_EDITOR=1 release
make MONACO_EDITOR=1 install
#- name: Unit tests
# run: |
# make test_install

- name: Regression tests
run: |
make regression
make MONACO_EDITOR=1 regression
macos-clang:
Expand Down Expand Up @@ -513,18 +513,18 @@ jobs:
- name: Build
run: |
make release
make install
make MONACO_EDITOR=1 release
make MONACO_EDITOR=1 install
- name: Unit tests
run: |
# make test_install
make XVFB="" test/unittest
make XVFB="" debug test/gui_mac
# make MONACO_EDITOR=1 test_install
make MONACO_EDITOR=1 XVFB="" test/unittest
make MONACO_EDITOR=1 XVFB="" debug test/gui_mac
- name: Regression tests
run: |
make regression
make MONACO_EDITOR=1 regression
CodeFormatting:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -582,7 +582,7 @@ jobs:
- name: Prepare source
run: |
make run-cmake-release
make MONACO_EDITOR=1 run-cmake-release
ln -s build/compile_commands.json .
- name: Run clang tidy
Expand Down
48 changes: 13 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ endif(PRODUCTION_BUILD)
# Check system
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")

set(FOEDAG_WITH_MONACO_EDITOR ON CACHE BOOL "" FORCE)
if (MONACO_EDITOR)
message("Using Monaco Editor")
set(USE_MONACO_EDITOR ON CACHE BOOL "" FORCE)
else(MONACO_EDITOR)
message("Using QScintilla Editor")
set(USE_MONACO_EDITOR OFF CACHE BOOL "" FORCE)
endif(MONACO_EDITOR)

include(cmake/cmake_qt.txt)

# NOTE: Policy changes has to happen before adding any subprojects
Expand All @@ -85,6 +92,7 @@ add_subdirectory(third_party/gtkwave_cmake)
add_subdirectory(third_party/scope_guard)
add_subdirectory(third_party/openocd_cmake)
add_subdirectory(third_party/openssl_cmake)
add_subdirectory(third_party/monaco-editor)

add_subdirectory(tests/tclutils)
add_subdirectory(tests/unittest)
Expand Down Expand Up @@ -123,36 +131,6 @@ message(STATUS "Python3_INCLUDE_DIRS = ${Python3_INCLUDE_DIRS}")
message(STATUS "Python3_RUNTIME_LIBRARY_DIRS = ${Python3_RUNTIME_LIBRARY_DIRS}")
endif()

# monaco-editor
if (FOEDAG_WITH_MONACO_EDITOR)
set(MONACO_EDITOR_VERSION 0.45.0)
# download the monaco editor tgz, extract it, and rename the dir from 'package' to 'monaco-editor'
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/third_party/monaco-editor/monaco-editor-${MONACO_EDITOR_VERSION}.tgz)
message("Downloading monaco-editor tgz package: " ${MONACO_EDITOR_VERSION} " ...")
file(DOWNLOAD
https://registry.npmjs.org/monaco-editor/-/monaco-editor-${MONACO_EDITOR_VERSION}.tgz
${CMAKE_SOURCE_DIR}/third_party/monaco-editor/monaco-editor-${MONACO_EDITOR_VERSION}.tgz
)
endif()
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/third_party/monaco-editor/monaco-editor/)
message("Extracting monaco-editor tgz package: " ${MONACO_EDITOR_VERSION} " ...")
execute_process(
COMMAND_ECHO
STDOUT
COMMAND
tar -xf ${CMAKE_SOURCE_DIR}/third_party/monaco-editor/monaco-editor-${MONACO_EDITOR_VERSION}.tgz
RESULT_VARIABLE result
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}/third_party/monaco-editor
)
if(result AND NOT result EQUAL 0)
message(FATAL_ERROR "monaco editor extraction failed!")
endif()
file(RENAME ${CMAKE_SOURCE_DIR}/third_party/monaco-editor/package ${CMAKE_SOURCE_DIR}/third_party/monaco-editor/monaco-editor)
endif()
endif()


if(NOT NO_TCMALLOC)
find_library(TCMALLOC_LIBRARY NAMES tcmalloc)
if(TCMALLOC_LIBRARY)
Expand Down Expand Up @@ -353,7 +331,7 @@ if(MSVC)
else()
add_dependencies(tcl_build zlib_build)
endif()
if (FOEDAG_WITH_MONACO_EDITOR)
if (USE_MONACO_EDITOR)
add_dependencies(texteditor tcl_build)
else()
add_dependencies(foedagcore qscintilla2_qt)
Expand Down Expand Up @@ -424,7 +402,7 @@ target_link_libraries(foedag PUBLIC
cfgcompiler
rapidgpt
)
if (FOEDAG_WITH_MONACO_EDITOR)
if (USE_MONACO_EDITOR)
else()
target_link_libraries(foedag PUBLIC
qscintilla2_qt
Expand Down Expand Up @@ -575,7 +553,7 @@ install(
DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if (FOEDAG_WITH_MONACO_EDITOR)
if (USE_MONACO_EDITOR)
install(
DIRECTORY
${PROJECT_SOURCE_DIR}/third_party/monaco-editor/monaco-editor
Expand Down Expand Up @@ -631,7 +609,7 @@ add_custom_command(TARGET foedag-bin POST_BUILD
${PROJECT_SOURCE_DIR}/tests/Arch
${CMAKE_CURRENT_BINARY_DIR}/share/foedag/Arch/)

if (FOEDAG_WITH_MONACO_EDITOR)
if (USE_MONACO_EDITOR)
add_custom_command(TARGET foedag-bin POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/share/foedag/etc/monaco-editor/
COMMAND ${CMAKE_COMMAND} -E copy_directory
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ RULE_MESSAGES ?= on

# make PRODUCTION_BUILD=1 triggers the production build where some features are more controlled (Like Bitstream generation, eventual licensing...)

# make MONACO_EDITOR=1 enables the the WebEngine based Monaco Editor in place of the QScintilla based Editor

release: run-cmake-release
cmake --build build -j $(CPU_CORES)

Expand All @@ -53,16 +55,16 @@ debug: run-cmake-debug
cmake --build dbuild -j $(CPU_CORES)

run-cmake-release:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) -DPRODUCTION_BUILD=$(PRODUCTION_BUILD) -DSTICK_RELEASE_VERSION=$(STICK_RELEASE_VERSION) $(ADDITIONAL_CMAKE_OPTIONS) -S . -B build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) -DPRODUCTION_BUILD=$(PRODUCTION_BUILD) -DSTICK_RELEASE_VERSION=$(STICK_RELEASE_VERSION) -DMONACO_EDITOR=$(MONACO_EDITOR) $(ADDITIONAL_CMAKE_OPTIONS) -S . -B build

run-cmake-release_no_tcmalloc:
cmake -DNO_TCMALLOC=On -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) $(ADDITIONAL_CMAKE_OPTIONS) -DSTICK_RELEASE_VERSION=$(STICK_RELEASE_VERSION) -S . -B build
cmake -DNO_TCMALLOC=On -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) $(ADDITIONAL_CMAKE_OPTIONS) -DSTICK_RELEASE_VERSION=$(STICK_RELEASE_VERSION) -DMONACO_EDITOR=$(MONACO_EDITOR) -S . -B build

run-cmake-debug:
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) -DPRODUCTION_BUILD=$(PRODUCTION_BUILD) -DSTICK_RELEASE_VERSION=$(STICK_RELEASE_VERSION) -DNO_TCMALLOC=On $(ADDITIONAL_CMAKE_OPTIONS) -S . -B dbuild
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) -DPRODUCTION_BUILD=$(PRODUCTION_BUILD) -DSTICK_RELEASE_VERSION=$(STICK_RELEASE_VERSION) -DMONACO_EDITOR=$(MONACO_EDITOR) -DNO_TCMALLOC=On $(ADDITIONAL_CMAKE_OPTIONS) -S . -B dbuild

run-cmake-coverage:
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) -DMY_CXX_WARNING_FLAGS="--coverage" $(ADDITIONAL_CMAKE_OPTIONS) -DSTICK_RELEASE_VERSION=$(STICK_RELEASE_VERSION) -S . -B coverage-build
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCMAKE_RULE_MESSAGES=$(RULE_MESSAGES) -DMY_CXX_WARNING_FLAGS="--coverage" $(ADDITIONAL_CMAKE_OPTIONS) -DSTICK_RELEASE_VERSION=$(STICK_RELEASE_VERSION) -DMONACO_EDITOR=$(MONACO_EDITOR) -S . -B coverage-build

test/unittest: run-cmake-release
cmake --build build --target unittest -j $(CPU_CORES)
Expand Down
10 changes: 7 additions & 3 deletions cmake/cmake_qt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if(USE_MONACO_EDITOR)
find_package(Qt6 COMPONENTS Core Gui Widgets Xml WebEngineWidgets WebChannel REQUIRED)
else()
find_package(Qt6 COMPONENTS Core Gui Widgets Xml REQUIRED)
endif()

find_package(Qt6 COMPONENTS Core Gui Widgets Xml WebEngineWidgets WebChannel REQUIRED)
if (NOT Qt6Widgets_FOUND)
message(STATUS "Failed to find Qt6Widgets required (on debian/ubuntu try 'sudo apt install qt6-base-dev')")
elseif (NOT Qt6Gui_FOUND)
Expand All @@ -28,9 +32,9 @@ elseif (NOT Qt6Core_FOUND)
message(STATUS "Failed to find Qt6Core required (on debian/ubuntu try 'sudo apt install qt6-base-dev')")
elseif (NOT Qt6Xml_FOUND)
message(STATUS "Failed to find Qt6Xml required (on debian/ubuntu try 'sudo apt install qt6-base-dev')")
elseif (FOEDAG_WITH_MONACO_EDITOR AND NOT Qt6WebEngineWidgets_FOUND)
elseif (USE_MONACO_EDITOR AND NOT Qt6WebEngineWidgets_FOUND)
message(STATUS "Failed to find Qt6WebEngineWidgets required (on debian/ubuntu try 'sudo apt install qt6-webengine-dev qt6-webengine* libqt6webenginecore6*')")
elseif (FOEDAG_WITH_MONACO_EDITOR AND NOT Qt6WebChannel_FOUND)
elseif (USE_MONACO_EDITOR AND NOT Qt6WebChannel_FOUND)
message(STATUS "Failed to find Qt6WebChannel required (on debian/ubuntu try 'sudo apt install qt6-webengine-dev qt6-webengine* libqt6webenginecore6*')")
else()
set(CMAKE_AUTOMOC ON)
Expand Down
4 changes: 2 additions & 2 deletions src/Main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ else()
endif()

target_link_libraries(foedagcore PUBLIC Qt6::Widgets Qt6::Core Qt6::Gui Qt6::Xml compiler)
if(FOEDAG_WITH_MONACO_EDITOR)
if(USE_MONACO_EDITOR)
target_link_libraries(foedagcore PUBLIC Qt6::WebEngineWidgets)
target_compile_definitions(foedagcore PUBLIC FOEDAG_WITH_MONACO_EDITOR=${FOEDAG_WITH_MONACO_EDITOR})
target_compile_definitions(foedagcore PUBLIC USE_MONACO_EDITOR=${USE_MONACO_EDITOR})
endif()

target_compile_definitions(foedagcore PUBLIC FOEDAG_CORE_LIBRARY)
Expand Down
8 changes: 4 additions & 4 deletions src/MainWindow/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "WidgetFactory.h"
#include "foedag_version.h"
#include "rapidgpt/RapigGptSettingsWindow.h"
#ifdef FOEDAG_WITH_MONACO_EDITOR
#ifdef USE_MONACO_EDITOR
#include <QWebEngineView>
#endif // FOEDAG_WITH_MONACO_EDITOR
#endif // USE_MONACO_EDITOR

using namespace FOEDAG;
extern const char* release_version;
Expand Down Expand Up @@ -126,7 +126,7 @@ void centerWidget(QWidget& widget) {

MainWindow::MainWindow(Session* session)
: m_session(session), m_settings("settings", QSettings::IniFormat) {
#ifdef FOEDAG_WITH_MONACO_EDITOR
#ifdef USE_MONACO_EDITOR
/*
ref:
https://forum.qt.io/topic/141398/qwebengineview-closes-reopens-window-when-added-dynamically
Expand All @@ -140,7 +140,7 @@ MainWindow::MainWindow(Session* session)
QWebEngineView* preloadWebView = new QWebEngineView(this);
preloadWebView->resize(0, 0);
QTimer::singleShot(1, [preloadWebView]() { preloadWebView->deleteLater(); });
#endif // FOEDAG_WITH_MONACO_EDITOR
#endif // USE_MONACO_EDITOR

/* Window settings */
m_compiler = session->GetCompiler();
Expand Down
Loading

0 comments on commit f1e65f1

Please sign in to comment.