mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0032315: Configuration, CMake - fix building Draw Harness plugins as static libraries
DPLUGIN() macros no more defines exported function PLUGINFACTORY when building static libraries. DRAWEXE executable now pre-loads a set of plugins when building static libraries. dversion - added WebAssembly info.
This commit is contained in:
@@ -1,5 +1,41 @@
|
||||
project(DRAWEXE)
|
||||
|
||||
unset (CUSTOM_EXTERNLIB)
|
||||
if (NOT BUILD_SHARED_LIBS)
|
||||
# link specific list of plugins explicitly
|
||||
FILE_TO_LIST ("src/${PROJECT_NAME}/EXTERNLIB_STATIC" CUSTOM_EXTERNLIB)
|
||||
if (USE_OPENGL)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGles)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGlesTest)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB CSF_OpenGlesLibs)
|
||||
elseif(USE_GLES2)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGl)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGlTest)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB CSF_OpenGlLibs)
|
||||
else()
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGles)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGlesTest)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB CSF_OpenGlesLibs)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGl)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB TKOpenGlTest)
|
||||
list (REMOVE_ITEM CUSTOM_EXTERNLIB CSF_OpenGlLibs)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set (EXECUTABLE_PROJECT ON)
|
||||
OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
|
||||
unset (EXECUTABLE_PROJECT)
|
||||
unset (CUSTOM_EXTERNLIB)
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s MAX_WEBGL_VERSION=2")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --bind")
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s MODULARIZE=1")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXPORT_NAME='createDRAWEXE'")
|
||||
|
||||
install(FILES ${PROJECT_NAME}.html DESTINATION "${INSTALL_DIR_BIN}/${OCCT_INSTALL_BIN_LETTER}")
|
||||
install(FILES ../DrawResources/lamp.ico DESTINATION "${INSTALL_DIR_BIN}/${OCCT_INSTALL_BIN_LETTER}")
|
||||
endif()
|
||||
|
@@ -16,6 +16,20 @@
|
||||
#include <Draw.hxx>
|
||||
#include <DBRep.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_PrinterSystemLog.hxx>
|
||||
|
||||
#ifdef OCCT_NO_PLUGINS
|
||||
#include <BOPTest.hxx>
|
||||
#include <DPrsStd.hxx>
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_GLES2)
|
||||
#include <OpenGlTest.hxx>
|
||||
#endif
|
||||
#include <TObjDRAW.hxx>
|
||||
#include <ViewerTest.hxx>
|
||||
#include <XSDRAWSTLVRML.hxx>
|
||||
#include <XDEDRAW.hxx>
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
//function : Draw_InitAppli
|
||||
@@ -24,9 +38,29 @@
|
||||
|
||||
void Draw_InitAppli (Draw_Interpretor& di)
|
||||
{
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
// open JavaScript console within the Browser to see this output
|
||||
Handle(Message_PrinterSystemLog) aJSConsolePrinter = new Message_PrinterSystemLog ("DRAWEXE");
|
||||
Message::DefaultMessenger()->AddPrinter (aJSConsolePrinter);
|
||||
#endif
|
||||
|
||||
Draw::Commands (di);
|
||||
DBRep::BasicCommands (di);
|
||||
DrawTrSurf::BasicCommands (di);
|
||||
|
||||
#ifdef OCCT_NO_PLUGINS
|
||||
// load a couple of plugins
|
||||
BOPTest::Factory (di);
|
||||
DPrsStd::Factory (di);
|
||||
XSDRAWSTLVRML::Factory (di);
|
||||
XDEDRAW::Factory (di);
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_GLES2)
|
||||
ViewerTest::Factory (di);
|
||||
OpenGlTest::Factory (di);
|
||||
#endif
|
||||
//TObjDRAW::Factory (di);
|
||||
//QADraw::Factory (di);
|
||||
#endif
|
||||
}
|
||||
|
||||
#include <Draw_Main.hxx>
|
||||
|
68
src/DRAWEXE/DRAWEXE.html
Normal file
68
src/DRAWEXE/DRAWEXE.html
Normal file
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang=en-us>
|
||||
<head>
|
||||
<meta charset=utf-8><meta content="text/html; charset=utf-8" http-equiv=Content-Type>
|
||||
<link rel="shortcut icon" href="lamp.ico" type="image/x-icon" />
|
||||
<title>OCCT Draw Harness</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>OCCT Draw Harness</h2>
|
||||
<div>
|
||||
<canvas id=occViewerCanvas oncontextmenu=event.preventDefault() tabindex=-1 style="border:0 none;background-color:#000" width="409" height="409"></canvas>
|
||||
</div>
|
||||
<h4>Output (open JavaScript console):</h4>
|
||||
<p id="output"></p>
|
||||
<script type="text/javascript" src="DRAWEXE.js" charset="utf-8"></script>
|
||||
<script>
|
||||
//! Check browser support.
|
||||
function isWasmSupported()
|
||||
{
|
||||
try {
|
||||
if (typeof WebAssembly === "object"
|
||||
&& typeof WebAssembly.instantiate === "function") {
|
||||
const aDummyModule = new WebAssembly.Module (Uint8Array.of (0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
|
||||
if (aDummyModule instanceof WebAssembly.Module)
|
||||
{
|
||||
return new WebAssembly.Instance(aDummyModule) instanceof WebAssembly.Instance;
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
return false;
|
||||
}
|
||||
if (!isWasmSupported())
|
||||
{
|
||||
var anElement = document.getElementById('output');
|
||||
anElement.innerHTML += "Browser is too old - WebAssembly support is missing!<br>Please check updates or install a modern browser.<br>";
|
||||
}
|
||||
|
||||
var DRAWEXE =
|
||||
{
|
||||
print: (function() {
|
||||
var anElement = document.getElementById('output');
|
||||
//return function(theText) { anElement.innerHTML += theText + "<br>"; };
|
||||
return function(theText) { console.warn(theText); };
|
||||
})(),
|
||||
printErr: function(theText) {
|
||||
//var anElement = document.getElementById('output');
|
||||
//anElement.innerHTML += theText + "<br>";
|
||||
console.warn(theText);
|
||||
},
|
||||
canvas: (function() {
|
||||
var aCanvas = document.getElementById('occViewerCanvas');
|
||||
return aCanvas;
|
||||
})(),
|
||||
|
||||
onRuntimeInitialized: function() {
|
||||
//
|
||||
}
|
||||
};
|
||||
|
||||
const DRAWEXEInitialized = createDRAWEXE(DRAWEXE);
|
||||
DRAWEXEInitialized.then(function(Module) {
|
||||
//DRAWEXE.eval("dversion");
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
75
src/DRAWEXE/EXTERNLIB_STATIC
Normal file
75
src/DRAWEXE/EXTERNLIB_STATIC
Normal file
@@ -0,0 +1,75 @@
|
||||
TKTopTest
|
||||
TKDCAF
|
||||
TKXSDRAW
|
||||
TKXDEDRAW
|
||||
TKOpenGlTest
|
||||
TKOpenGlesTest
|
||||
TKViewerTest
|
||||
TKDraw
|
||||
TKMeshVS
|
||||
TKXDESTEP
|
||||
TKSTEP
|
||||
TKSTEPAttr
|
||||
TKSTEP209
|
||||
TKSTEPBase
|
||||
TKXDEIGES
|
||||
TKIGES
|
||||
TKXSBase
|
||||
TKVRML
|
||||
TKSTL
|
||||
TKRWMesh
|
||||
TKBinXCAF
|
||||
TKXmlXCAF
|
||||
TKBin
|
||||
TKXml
|
||||
TKXmlL
|
||||
TKBinL
|
||||
TKOpenGl
|
||||
TKOpenGles
|
||||
TKXCAF
|
||||
TKVCAF
|
||||
TKStd
|
||||
TKCAF
|
||||
TKV3d
|
||||
TKHLR
|
||||
TKMesh
|
||||
TKService
|
||||
TKOffset
|
||||
TKFillet
|
||||
TKFeat
|
||||
TKBool
|
||||
TKBO
|
||||
TKShHealing
|
||||
TKPrim
|
||||
TKTopAlgo
|
||||
TKGeomAlgo
|
||||
TKBRep
|
||||
TKGeomBase
|
||||
TKG3d
|
||||
TKG2d
|
||||
TKMath
|
||||
TKStdL
|
||||
TKLCAF
|
||||
TKCDF
|
||||
TKernel
|
||||
CSF_TclLibs
|
||||
CSF_OpenVR
|
||||
CSF_OpenGlLibs
|
||||
CSF_OpenGlesLibs
|
||||
CSF_FFmpeg
|
||||
CSF_FreeImagePlus
|
||||
CSF_FREETYPE
|
||||
CSF_user32
|
||||
CSF_advapi32
|
||||
CSF_XwLibs
|
||||
CSF_dpsLibs
|
||||
CSF_XmuLibs
|
||||
CSF_fontconfig
|
||||
CSF_objc
|
||||
CSF_Appkit
|
||||
CSF_IOKit
|
||||
CSF_winmm
|
||||
CSF_ThreadLibs
|
||||
CSF_wsock32
|
||||
CSF_psapi
|
||||
CSF_androidlog
|
@@ -452,6 +452,12 @@ static Standard_Integer dversion(Draw_Interpretor& di, Standard_Integer, const c
|
||||
#else
|
||||
di << "Architecture: ARM 32-bit\n";
|
||||
#endif
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#if defined(__LP64__)
|
||||
di << "Architecture: WASM 64-bit\n";
|
||||
#else
|
||||
di << "Architecture: WASM 32-bit\n";
|
||||
#endif
|
||||
#else
|
||||
di << "Architecture: unrecognized\n";
|
||||
#endif
|
||||
@@ -475,6 +481,8 @@ static Standard_Integer dversion(Draw_Interpretor& di, Standard_Integer, const c
|
||||
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
||||
#include <sys/param.h>
|
||||
di << "OS: BSD (BSD = " << BSD << ")\n";
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
di << "OS: WebAssembly (Emscripten SDK " << __EMSCRIPTEN_major__ << "." << __EMSCRIPTEN_minor__ << "." << __EMSCRIPTEN_tiny__ << ")\n";
|
||||
#else
|
||||
di << "OS: unrecognized\n";
|
||||
#endif
|
||||
|
@@ -16,10 +16,13 @@
|
||||
#ifndef _Draw_PluginMacro_HeaderFile
|
||||
#define _Draw_PluginMacro_HeaderFile
|
||||
|
||||
#ifdef OCCT_NO_PLUGINS
|
||||
#define DPLUGIN(name)
|
||||
#else
|
||||
#define DPLUGIN(name) \
|
||||
extern "C" {Standard_EXPORT void PLUGINFACTORY(Draw_Interpretor&);} \
|
||||
void PLUGINFACTORY(Draw_Interpretor& theDI) { \
|
||||
name::Factory(theDI);} \
|
||||
\
|
||||
extern "C" Standard_EXPORT void PLUGINFACTORY(Draw_Interpretor& theDI) { \
|
||||
name::Factory(theDI); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -11,9 +11,7 @@
|
||||
# Alternatively, this file may be used under the terms of Open CASCADE
|
||||
# commercial license or contractual agreement.
|
||||
|
||||
;#
|
||||
;# Liste des toolkits WOK sous forme de full path
|
||||
;#
|
||||
;# Return list of toolkits
|
||||
proc Draw:toolkits { } {
|
||||
set aResult [list TKDraw TKTopTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw]
|
||||
|
||||
@@ -35,41 +33,23 @@ proc Draw:toolkits { } {
|
||||
return $aResult
|
||||
}
|
||||
|
||||
;#
|
||||
;# Autres UDs a prendre. Listes de triplets
|
||||
;# { ar typ UD str } Tous les types de UD vont dans un sous directory nomme root/str
|
||||
;# Ils seront dans CAS3.0/str de l'archive de type ar (source/runtime)
|
||||
;# { ar typ UD {} } Tous les types de UD vont dans root/UD/src => CAS3.0/src
|
||||
;#
|
||||
proc Draw:ressources { } {
|
||||
return [list \
|
||||
[list both r DrawResources {}] \
|
||||
[list both x DRAWEXE {}] \
|
||||
]
|
||||
}
|
||||
proc Draw:freefiles { } {
|
||||
return {}
|
||||
}
|
||||
;#
|
||||
;# Nom du module
|
||||
;#
|
||||
proc Draw:name { } {
|
||||
return Draw
|
||||
}
|
||||
proc Draw:alias { } {
|
||||
return DRAW
|
||||
}
|
||||
proc Draw:depends { } {
|
||||
return [list DataExchange]
|
||||
return [list \
|
||||
[list both r DrawResources {}] \
|
||||
[list both x DRAWEXE {}] \
|
||||
]
|
||||
}
|
||||
|
||||
proc Draw:acdepends { } {
|
||||
return [list TCLTK]
|
||||
}
|
||||
proc Draw:freefiles { } { return {} }
|
||||
|
||||
proc Draw:name { } { return Draw }
|
||||
proc Draw:alias { } { return DRAW }
|
||||
proc Draw:depends { } { return [list DataExchange] }
|
||||
proc Draw:acdepends { } { return [list TCLTK] }
|
||||
|
||||
;#
|
||||
;# Returns a list of exported features.
|
||||
;#
|
||||
proc Draw:Export { } {
|
||||
return [list source runtime wokadm api]
|
||||
}
|
||||
proc Draw:Export { } { return [list source runtime wokadm api] }
|
||||
|
Reference in New Issue
Block a user