Mercurial > hg > orthanc-stone
changeset 1395:62dc0d737e7b
build script for wasm sample + updated instructions + fixed Sdl sample for Orthanc listening on other ports that 8042
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Wed, 29 Apr 2020 18:11:49 +0200 |
parents | a8ac7e3de0e8 |
children | dd2b75ee644b 3e644f6fadd4 |
files | .hgignore Samples/README.md Samples/Sdl/SingleFrameViewer/SdlSimpleViewer.cpp Samples/build-wasm-SingleFrameViewer.sh |
diffstat | 4 files changed, 76 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Wed Apr 29 15:54:26 2020 +0200 +++ b/.hgignore Wed Apr 29 18:11:49 2020 +0200 @@ -35,6 +35,7 @@ Samples/WebAssembly/*/out Samples/Sdl/*/ThirdPartyDownloads/ Samples/Sdl/*/out +Samples/Sdl/build*/ Samples/Deprecated/Sdl/ThirdPartyDownloads/ Samples/Deprecated/Sdl/CMakeLists.txt.orig Samples/Deprecated/Qt/ThirdPartyDownloads/
--- a/Samples/README.md Wed Apr 29 15:54:26 2020 +0200 +++ b/Samples/README.md Wed Apr 29 18:11:49 2020 +0200 @@ -68,73 +68,28 @@ This barebones sample uses plain Javascript and requires the Emscripten toolchain and cmake, in addition to a few standard packages. -Here's how you can build it: create the following script (for instance, -`build-wasm-SingleFrameViewer.sh`) one level above the orthanc-stone repository, -thus, in the folder we have called `devroot`. - -If you feel confident, you can also simply read the following script and -enter the commands interactively in the terminal. - -``` -#!/bin/bash - -if [ ! -d "orthanc-stone" ]; then - echo "This script must be run from the folder one level above orthanc-stone" - exit 1 -fi - -if [[ ! $# -eq 1 ]]; then - echo "Usage:" - echo " $0 [BUILD_TYPE]" - echo "" - echo " with:" - echo " BUILD_TYPE = Debug, RelWithDebInfo or Release" - echo "" - exit 1 -fi - -# define the variables that we'll use -buildType=$1 -buildFolderName="`pwd`/out/build-stone-wasm-SingleFrameViewer-$buildType" -installFolderName="`pwd`/out/install-stone-wasm-SingleFrameViewer-$buildType" - -# configure the environment to use Emscripten -. ~/apps/emsdk/emsdk_env.sh - - -mkdir -p $buildFolderName - -# change current folder to the build folder -pushd $buildFolderName - -emcmake cmake -G "Ninja" \ - -DCMAKE_BUILD_TYPE=$buildType \ - -DCMAKE_INSTALL_PREFIX=$installFolderName \ - -DSTATIC_BUILD=ON -DOPENSSL_NO_CAPIENG=ON -DALLOW_DOWNLOADS=ON \ - ../orthanc-stone/Samples/WebAssembly/SingleFrameViewer - -# perform build + installation -ninja install - -# restore the original working folder -popd - -echo "If all went well, the output files can be found in $installFolderName:" - -ls $installFolderName``` -``` - -Simply navigate to the dev root, and execute the script: - -``` -./build-wasm-SingleFrameViewer.sh RelWithDebInfo -``` - -I suggest that you do *not* use the `Debug` confirmation unless you really +To build it, just launch the `build-wasm-SingleFrameViewer.sh` script from +this folder. Optionaly, you can pass the build type as an argument. +We suggest that you do *not* use the `Debug` configuration unless you really need it, for the additional checks that are made will lead to a very long build time and much slower execution (more severe than with a native non-wasm target) +In order to run the sample, you may serve it with the ServeFolders plugin. +You can i.e: add such a section in your orthanc configuration file: + +``` +{ + "Plugins" : ["LibServeFolders.so], + "ServeFolders" : { + "/single-frame-viewer" : "..../out/install-stone-wasm-SingleFrameViewer-RelWithDebInfo" + } +} +``` + +You'll then be able to open the demo at `http://localhost:8042/single-frame-viewer/index.html` + + Native samples ================= @@ -181,3 +136,9 @@ An alternative is to execute `cmake --build .` in the build folder created by the script. +In order to run the sample, make sure you've an Orthanc server running i.e. on +port 8042 and launch: + +``` +./SingleFrameViewer --orthanc http://localhost:8042 --instance 7fc84013-abef174e-3354ca83-b9cdb2a4-f1a74368 +```
--- a/Samples/Sdl/SingleFrameViewer/SdlSimpleViewer.cpp Wed Apr 29 15:54:26 2020 +0200 +++ b/Samples/Sdl/SingleFrameViewer/SdlSimpleViewer.cpp Wed Apr 29 18:11:49 2020 +0200 @@ -104,6 +104,10 @@ OrthancStone::GenericLoadersContext context(1, 4, 1); + Orthanc::WebServiceParameters orthancWebService; + orthancWebService.SetUrl(orthancUrl); + context.SetOrthancParameters(orthancWebService); + context.StartOracle(); {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Samples/build-wasm-SingleFrameViewer.sh Wed Apr 29 18:11:49 2020 +0200 @@ -0,0 +1,47 @@ +#!/bin/bash +# +# usage: +# to build the sample in Debug: +# ./build-wasm-SingleFrameViewer.sh +# +# to build the sample in Debug: +# ./build-wasm-SingleFrameViewer.sh Release + +set -e + +if [ ! -d "WebAssembly" ]; then + echo "This script must be run from the Samples folder one level below orthanc-stone" + exit 1 +fi + + +currentDir=$(pwd) +samplesRootDir=$(pwd) +devrootDir=$(pwd)/../../ + +buildType=${1:-RelWithDebInfo} +buildFolderName="$devrootDir/out/build-stone-wasm-SingleFrameViewer-$buildType" +installFolderName="$devrootDir/out/install-stone-wasm-SingleFrameViewer-$buildType" + +mkdir -p $buildFolderName +# change current folder to the build folder +pushd $buildFolderName + +# configure the environment to use Emscripten +source ~/apps/emsdk/emsdk_env.sh + +emcmake cmake -G "Ninja" \ + -DCMAKE_BUILD_TYPE=$buildType \ + -DCMAKE_INSTALL_PREFIX=$installFolderName \ + -DSTATIC_BUILD=ON -DOPENSSL_NO_CAPIENG=ON -DALLOW_DOWNLOADS=ON \ + $samplesRootDir/WebAssembly/SingleFrameViewer + +# perform build + installation +ninja install + +# restore the original working folder +popd + +echo "If all went well, the output files can be found in $installFolderName:" + +ls $installFolderName \ No newline at end of file