status-desktop/storybook
alexjba 1b2fd40b20 Adding qmake project file for wasm
This changeset contains the prerequisites required to compile StoryBook on wasm_32 and the README file with instructions
2022-11-23 16:20:37 +02:00
..
mocks/DotherSide fix(Storybook): mock for DotherSide types added 2022-10-17 10:50:12 -04:00
pages Adding qmake project file for wasm 2022-11-23 16:20:37 +02:00
src feat(Storybook): add basic Figma integration 2022-11-22 15:34:18 +01:00
stubs/AppLayouts feat(storybook): add browser settings in the storybook 2022-10-25 14:27:50 -04:00
tests feat(Storybook): Foldable sections in pages list 2022-11-21 12:51:22 +01:00
CMakeLists.txt Adding qmake project file for wasm 2022-11-23 16:20:37 +02:00
PagesModel.qml feat(Storybook): Pages model excluded to a separate file, figma links added 2022-11-22 15:34:18 +01:00
README.md Adding qmake project file for wasm 2022-11-23 16:20:37 +02:00
StoryBook.pro Adding qmake project file for wasm 2022-11-23 16:20:37 +02:00
cachecleaner.cpp feat(Storybook): Hot reloading for pages 2022-10-20 20:34:35 +02:00
cachecleaner.h feat(Storybook): Hot reloading for pages 2022-10-20 20:34:35 +02:00
directorieswatcher.cpp chore(Storybook): add pages for InviteFriendsToCommunityPopup and related components 2022-10-25 17:03:44 +02:00
directorieswatcher.h feat(Storybook): Hot reloading for pages 2022-10-20 20:34:35 +02:00
main.cpp Adding qmake project file for wasm 2022-11-23 16:20:37 +02:00
main.qml feat(Storybook): Pages model excluded to a separate file, figma links added 2022-11-22 15:34:18 +01:00
sectionsdecoratormodel.cpp feat(Storybook): Foldable sections in pages list 2022-11-21 12:51:22 +01:00
sectionsdecoratormodel.h feat(Storybook): sections decorator model impl and basic tests 2022-11-21 12:51:22 +01:00

README.md

Building Storybook with Webassembly and Qt 5.14

Configuring the environment

Install Emscripten v1.38.27

# Get the emsdk repo
git clone https://github.com/emscripten-core/emsdk.git

#go to emsdk folder
cd emsdk

#install Emscripten v1.38.27
./emsdk install emscripten-1.38.27

#activate emscripten-1.38.27
./emsdk activate emscripten-1.38.27

#install Fastcomp backend
./emsdk install fastcomp-clang-tag-e1.38.27-64bit

#activate Fastcomp backend
./emsdk activate fastcomp-clang-tag-e1.38.27-64bit

#add emsdk tools to env variables
#this can be done by following instructions received from previous activate command
#there are two options:

#1. Configure the env variables for the current shell only:
source emsdk_env.sh

#2. Configure the env variables using the shell startup script:
echo 'source "[path to emsdk folder]/emsdk_env.sh"' >> $HOME/.zprofile

#WARNING: this will configure the environment to use the emsdk compiler
#Ex:"which clang" command will now point to the emscripten clang instead of the system clang
#to disable the env configuration comment the source command added earlier in ~/.zprofile

#check environment
#python needs to be installed. The emsdk scripts state that it should work with pyton 2 and 3
#make sure python command can be resolved
which python
em++ --version
emcc --version
#clang should point to fastcomp-clang-tag-e1.38.27-64bit
which clang
which clang++

More documentation: https://emscripten.org/docs/getting_started/downloads.html

Configure QtCreator (optional)

Newer versions of QtCreator won't support Qt5.14 with Webassembly. Latest version found to support Qt5.14 with WebAssembly is 4.14.2 Download: https://download.qt.io/archive/qtcreator/4.14/

Adding the Emscripten compilers (emcc and em++) Details here: https://doc.qt.io/qtcreator/creator-tool-chains.html

Adding Qt version 5.14: https://doc.qt.io/qtcreator/creator-project-qmake.html

Adding Qt5.14 for Webassembly kit: https://doc.qt.io/qtcreator/creator-targets.html

Open StoryBook.pro in Qt Creator and configure it using the new kit.

Qt creator might not set the env paths correctly. In this case manually set build environment variables (Projects -> 5.14.2 kit -> Build -> Build Environment -> Batch edit). Ex:

EMSCRIPTEN=~/Repos/emsdk/emscripten/1.38.27
EMSDK=~/Repos/emsdk
EMSDK_NODE=~/Repos/emsdk/node/14.18.2_64bit/bin/node
EMSDK_PYTHON=~/Repos/emsdk/python/3.9.2_64bit/bin/python3
EM_CONFIG=~/Repos/emsdk/.emscripten
LLVM_ROOT=~/Repos/emsdk/fastcomp-clang/tag-e1.38.27/build_tag-e1.38.27_64/bin
PATH=[check echo $PATH]

Running qmake (without qt Creator)

#create build folder
mkdir buildStoryBook

#go to folder
cd buildStoryBook

#run qmake (add CONFIG+=debug CONFIG+=qml_debug to qmake command for debug build)
~/Qt/5.14.2/wasm_32/bin/qmake [path to StoryBook.pro] -spec wasm-emscripten && /usr/bin/make qmake_all

#build (add -j[nb of cores] for parallel execution)
make

#run
emrun StoryBook.html