Skip to content

Commit

Permalink
build MCU project according to UI parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mmertama committed Feb 20, 2024
1 parent 98ab93d commit 73fa700
Show file tree
Hide file tree
Showing 19 changed files with 610 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ builds
__pycachhe
__pycache
__pycache__
build-mcu_figma-Qt_for_MCUs_2_6_STM32F769I_DISCOVERY_BAREMETAL_32bpp_ARMGCC_a0a53d-Debug
34 changes: 31 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.21)

project(FigmaQML LANGUAGES CXX)

Expand Down Expand Up @@ -34,8 +34,9 @@ else()
endif()
endif()

option(HAS_QUL "Build Qt for MCU support" FALSE)

SET(SOURCES
set(SOURCES
src/main.cpp
qml/qml.qrc
src/figmaget.cpp
Expand All @@ -57,6 +58,14 @@ SET(SOURCES
include/figmaprovider.h
)

if(HAS_QUL)
set(SOURCES
${SOURCES}
src/executeQul.cpp
mcu_figma/mcu.qrc
)
endif()

if(EMSCRIPTEN)
SET(SOURCES ${SOURCES} src/wasmdialogs.cpp)
endif()
Expand Down Expand Up @@ -99,6 +108,9 @@ target_compile_definitions(FigmaQML
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
endif()

option(QT6_CONCURRENT FALSE)
option(QT6_SSL FALSE)

if(Qt5_FOUND)
target_compile_definitions(FigmaQML PRIVATE -DQT5)
target_link_libraries(FigmaQML
Expand Down Expand Up @@ -141,7 +153,23 @@ elseif(EMSCRIPTEN)
PRIVATE QuaZip
PRIVATE Qt6::Core Qt6::Quick Qt6::Network Qt6::Widgets Qt6::Core5Compat ${EXTRA})
else()
target_compile_definitions(FigmaQML PRIVATE -DNO_CONCURRENT -DNO_SSL)
find_package(OpenSSL REQUIRED)
string(REPLACE "." ";" VERSION_LIST OPENSSL_VERSION)
list(GET VERSION_LIST 0 SSL_MAJOR)
if(${SSL_MAJOR} LESS 3 )
message(WARNING "SSL version must be at least 3.0.0, your runtime have ${OPENSSL_VERSION}. Hint for QtCreator try add $\{QT_DIR\}/plugins/tls in Run settings (LD_LIBRARY_PATH in Linux)")
endif()
if(NOT QT6_CONCURRENT)
target_compile_definitions(FigmaQML PRIVATE -DNO_CONCURRENT)
endif()
if(NOT QT6_SSL)
target_compile_definitions(FigmaQML PRIVATE -DNO_SSL)
endif()

if(HAS_QUL)
target_compile_definitions(FigmaQML PRIVATE -DHAS_QUL)
endif()

target_link_libraries(FigmaQML
PRIVATE Qt6::Core Qt6::Quick Qt6::Network Qt6::Widgets Qt6::Concurrent Qt6::Core5Compat ${EXTRA})
endif()
4 changes: 3 additions & 1 deletion include/figmaqml.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class FigmaQml : public QObject, public FigmaParserData {
EmbedImages = 0x80,
Timed = 0x100,
AltFontMatch = 0x200,
KeepFigmaFontName = 0x400
KeepFigmaFontName = 0x400,
QulMode = 0x800,
};
Q_ENUM(Flags)
public:
Expand Down Expand Up @@ -92,6 +93,7 @@ class FigmaQml : public QObject, public FigmaParserData {
Q_INVOKABLE void setSignals(bool allow);
//void takeSnap(const QString& pngName) const;
Q_INVOKABLE static QString nearestFontFamily(const QString& requestedFont, bool useQt);
Q_INVOKABLE void executeQul(const QVariantMap& parameters);
#ifdef USE_NATIVE_FONT_DIALOG
// sigh font native dialog wont work on WASM and QML dialog is buggy
Q_INVOKABLE void showFontDialog(const QString& currentFont);
Expand Down
31 changes: 31 additions & 0 deletions mcu_figma/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cmake_minimum_required (VERSION 3.21.1)

project(mcu_figma VERSION 0.0.1 LANGUAGES C CXX ASM)

# Qt bug workaround
set(BUG_199 TRUE)

# This must be before the fetch content below!
find_package(Qul PATHS ${FIGMAQML_QTC_DIR}/QtMCUs/${FIGMAQML_MCU_VER}/lib/cmake/Qul REQUIRED)

qul_add_target(${PROJECT_NAME} QML_PROJECT ${PROJECT_NAME}.qmlproject GENERATE_ENTRYPOINT)

#FREERTOS apps requires this
set_target_properties(${PROJECT_NAME} PROPERTIES FREERTOS_PROVIDE_MEMORY_ALLOCATOR_OVERLOADS TRUE)

if(BUG_199)
# Using workaround for a QT MCU bug: see https://bugreports.qt.io/browse/QTMCU-199"
target_compile_definitions(${PROJECT_NAME} PUBLIC
BUG_199=1
)
endif()

target_sources(${PROJECT_NAME} PUBLIC
${PROJECT_NAME}.qmlproject
${PROJECT_NAME}.qml
)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)

app_target_setup_os(${PROJECT_NAME})

15 changes: 15 additions & 0 deletions mcu_figma/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set -e
mkdir -p build
pushd build
QUL_ROOT=$QT_DIR/QtMCUs/$QUL_VER
if [ ! -d "$QUL_ROOT" ]; then
exit 20
fi
QUL_TOOLS=$QT_DIR/Tools/QtMCUs
if [ ! -d "$QUL_TOOLS" ]; then
exit 21
fi
cmake .. -G "Ninja" -DFIGMAQML_QTC_DIR=$QT_DIR -DFIGMAQML_MCU_VER=$QUL_VER -DQUL_COMPILER_NAME=gnu -DCMAKE_BUILD_TYPE=MinSizeRel -DQul_ROOT=$QUL_ROOT -DCMAKE_TOOLCHAIN_FILE=$QUL_ROOT/lib/cmake/Qul/toolchain/armgcc.cmake -DQUL_TARGET_TOOLCHAIN_DIR=$QUL_TOOLS/arm_gcc_10 -DQUL_BOARD_SDK_DIR:STRING=$QUL_TOOLS/STM/STM32Cube_FW_F7_V1.17.0 -DQUL_PLATFORM=$QUL_PLATFORM -DMCU_PLATFORM:STRING=STM32F769xx -DQMLPRJEXP:FILEPATH=$QUL_ROOT/bin/qmlprojectexporter
cmake --build .
popd

Binary file added mcu_figma/fonts/DejaVuSansMono.ttf
Binary file not shown.
187 changes: 187 additions & 0 deletions mcu_figma/fonts/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)


Bitstream Vera Fonts Copyright
------------------------------

Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
a trademark of Bitstream, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation files (the "Font Software"), to reproduce and distribute the
Font Software, including without limitation the rights to use, copy, merge,
publish, distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to the
following conditions:

The above copyright and trademark notices and this permission notice shall
be included in all copies of one or more of the Font Software typefaces.

The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional glyphs or characters may be added to the Fonts, only if the fonts
are renamed to names not containing either the words "Bitstream" or the word
"Vera".

This License becomes null and void to the extent applicable to Fonts or Font
Software that has been modified and is distributed under the "Bitstream
Vera" names.

The Font Software may be sold as part of a larger software package but no
copy of one or more of the Font Software typefaces may be sold by itself.

THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
FONT SOFTWARE.

Except as contained in this notice, the names of Gnome, the Gnome
Foundation, and Bitstream Inc., shall not be used in advertising or
otherwise to promote the sale, use or other dealings in this Font Software
without prior written authorization from the Gnome Foundation or Bitstream
Inc., respectively. For further information, contact: fonts at gnome dot
org.

Arev Fonts Copyright
------------------------------

Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of the fonts accompanying this license ("Fonts") and
associated documentation files (the "Font Software"), to reproduce
and distribute the modifications to the Bitstream Vera Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to
the following conditions:

The above copyright and trademark notices and this permission notice
shall be included in all copies of one or more of the Font Software
typefaces.

The Font Software may be modified, altered, or added to, and in
particular the designs of glyphs or characters in the Fonts may be
modified and additional glyphs or characters may be added to the
Fonts, only if the fonts are renamed to names not containing either
the words "Tavmjong Bah" or the word "Arev".

This License becomes null and void to the extent applicable to Fonts
or Font Software that has been modified and is distributed under the
"Tavmjong Bah Arev" names.

The Font Software may be sold as part of a larger software package but
no copy of one or more of the Font Software typefaces may be sold by
itself.

THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Except as contained in this notice, the name of Tavmjong Bah shall not
be used in advertising or otherwise to promote the sale, use or other
dealings in this Font Software without prior written authorization
from Tavmjong Bah. For further information, contact: tavmjong @ free
. fr.

TeX Gyre DJV Math
-----------------
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.

Math extensions done by B. Jackowski, P. Strzelczyk and P. Pianowski
(on behalf of TeX users groups) are in public domain.

Letters imported from Euler Fraktur from AMSfonts are (c) American
Mathematical Society (see below).
Bitstream Vera Fonts Copyright
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera
is a trademark of Bitstream, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license (“Fonts”) and associated
documentation
files (the “Font Software”), to reproduce and distribute the Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute,
and/or sell copies of the Font Software, and to permit persons to whom
the Font Software is furnished to do so, subject to the following
conditions:

The above copyright and trademark notices and this permission notice
shall be
included in all copies of one or more of the Font Software typefaces.

The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional
glyphs or characters may be added to the Fonts, only if the fonts are
renamed
to names not containing either the words “Bitstream” or the word “Vera”.

This License becomes null and void to the extent applicable to Fonts or
Font Software
that has been modified and is distributed under the “Bitstream Vera”
names.

The Font Software may be sold as part of a larger software package but
no copy
of one or more of the Font Software typefaces may be sold by itself.

THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL,
SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN
ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR
INABILITY TO USE
THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the names of GNOME, the GNOME
Foundation,
and Bitstream Inc., shall not be used in advertising or otherwise to promote
the sale, use or other dealings in this Font Software without prior written
authorization from the GNOME Foundation or Bitstream Inc., respectively.
For further information, contact: fonts at gnome dot org.

AMSFonts (v. 2.2) copyright

The PostScript Type 1 implementation of the AMSFonts produced by and
previously distributed by Blue Sky Research and Y&Y, Inc. are now freely
available for general use. This has been accomplished through the
cooperation
of a consortium of scientific publishers with Blue Sky Research and Y&Y.
Members of this consortium include:

Elsevier Science IBM Corporation Society for Industrial and Applied
Mathematics (SIAM) Springer-Verlag American Mathematical Society (AMS)

In order to assure the authenticity of these fonts, copyright will be
held by
the American Mathematical Society. This is not meant to restrict in any way
the legitimate use of the fonts, such as (but not limited to) electronic
distribution of documents containing these fonts, inclusion of these fonts
into other public domain or commercial font collections or computer
applications, use of the outline data to create derivative fonts and/or
faces, etc. However, the AMS does require that the AMS copyright notice be
removed from any derivative versions of the fonts which have been altered in
any way. In addition, to ensure the fidelity of TeX documents using Computer
Modern fonts, Professor Donald Knuth, creator of the Computer Modern faces,
has requested that any alterations which yield different font metrics be
given a different name.

$Id$
Binary file added mcu_figma/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions mcu_figma/mcu.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<RCC>
<qresource prefix="/mcu">
<file>mcu_figma.qml</file>
<file>CMakeLists.txt</file>
<file>build.sh</file>
<file>mcu_figma.qmlproject</file>
<file>fonts/DejaVuSansMono.ttf</file>
<file>fonts/LICENSE</file>
<file>images/icon.png</file>
</qresource>
</RCC>
4 changes: 4 additions & 0 deletions mcu_figma/mcu_figma.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import QtQuick
Rectangle {

}
Loading

0 comments on commit 73fa700

Please sign in to comment.