From 010363f4b99e7d3c4eab043adcb25eb053ce4a7a Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Thu, 23 Nov 2023 11:17:24 +0100 Subject: [PATCH 1/7] unify --- CMakeLists.txt | 4 ++-- src/xembind.cpp | 1 + test/CMakeLists.txt | 18 ++++++++++++++++++ test/kernel.json | 13 +++++++++++++ test/logo-32x32.png | Bin 0 -> 4254 bytes test/logo-64x64.png | Bin 0 -> 16598 bytes 6 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 test/kernel.json create mode 100644 test/logo-32x32.png create mode 100644 test/logo-64x64.png diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bfab04..a801182 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,8 +126,8 @@ if(XEUS_LITE_BUILD_TESTS) set(BUILD_TESTING ON) message(STATUS "tests enabled") else () - set(BUILD_TESTING OFF) - message(STATUS "tests disabled") + #set(BUILD_TESTING OFF) + #message(STATUS "tests disabled") endif() if(BUILD_TESTING) diff --git a/src/xembind.cpp b/src/xembind.cpp index d778cd7..adc764c 100644 --- a/src/xembind.cpp +++ b/src/xembind.cpp @@ -18,6 +18,7 @@ namespace nl = nlohmann; namespace ems = emscripten; + namespace xeus { nl::json json_from_js_object(ems::val js_obj) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f7eb7b4..5f41ce0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -9,4 +9,22 @@ add_executable(emscripten_wasm_test main_emscripten_wasm.cpp xmock_interpreter.cpp) target_link_libraries(emscripten_wasm_test PRIVATE xeus-lite) +xeus_wasm_compile_options(emscripten_wasm_test) xeus_wasm_link_options(emscripten_wasm_test "node") + + +add_executable(xlite main_emscripten_wasm.cpp xmock_interpreter.cpp) +target_link_libraries(xlite PRIVATE xeus-lite) +xeus_wasm_compile_options(xlite) +xeus_wasm_link_options(xlite "web,worker") + + +SET(KERNEL_INSTALL_DIR "share/jupyter/kernels/xlite") + + +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/logo-64x64.png" + "${CMAKE_CURRENT_SOURCE_DIR}/logo-32x32.png" + "$/xlite.wasm" + "$/xlite.js" + "${CMAKE_CURRENT_SOURCE_DIR}/kernel.json" + DESTINATION ${KERNEL_INSTALL_DIR}) diff --git a/test/kernel.json b/test/kernel.json new file mode 100644 index 0000000..cec87ea --- /dev/null +++ b/test/kernel.json @@ -0,0 +1,13 @@ +{ + "display_name": "XLite", + "argv": [ + "xlite", + "-f", + "{connection_file}" + ], + "language": "lua", + "metadata": { + "wasm_name" : "xlite" + } + } + \ No newline at end of file diff --git a/test/logo-32x32.png b/test/logo-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..e1cccd6111180bf8c806849c4ed2d6430830bbf3 GIT binary patch literal 4254 zcmb_feP~r>7=NDkoa@JGH4@RLiGSFK7@7%&&BeWIqI2`&N17jfscD(uhFh(qA|rwl zODxC_Qi32fF`YA$bXVGD&5sD8BC#?d)bIx2L5RjaOn^skySubRlYPk(&$)Nhqw-d!_k zZq2O9r8Tt+S1zI2+S<{}RxGbxys&D?=*pEZY`!?Lkf>l(S!wKvx&3)~!C#j+R{z~( z82ZDC?L%zFlF&>h9ux3y2^Bg5)=M2+nL*_aJEyUE4vNF

;V1fe!%0ZXxea<#}QX4ADD8 zG9oa}g~IU(woZ8>KH;R=mF#USw?Z!=yP9AcMQp z>&nXrK$Wrf`IepgbyGbLjqYQnl%7* zB-YMLSsLj(b$NG3DgKdEa+UJ*q{Bvh+LvefmlFW(3D5b#YCH1T~#*XbNNKdlf0TBMYp}hV5ewkVyM1bQWc3)3{ z!eqSxaMnphs?=fZ>!v9#nfAMaFw(1$l7&bfx`GX0l?<_0;%7r&RV_XhamT$E5?ZB66G0(j^L2`M(5d%TmYPp+%WB_ z-`iA*mRlGE!I`jvE#IZj*3cI8>g7O|iRJ)6mhGSM=)anJtolr!L|07vfjL`Crq4cF$S)*|w-Aa+38OF=Px#_9M2;I$u6fkFt)2EcjOi>y%llKRHS zaRMw3@ul~LN=h038jrW5X6aIxZotn7fCalg{>V8^y(QiP!~atscnPSM!ljq}QaEyj zt$ZAa!e}M{I~t}HZCB&gRB}yssZVn(@(}J0QRR!vhw-)LUry8XIv70w;GdJ07pWd@ zI5W_KOTwI_@!3>)!h`gUX_!BP?TIv<4n`P&gHAFM({H#~-S;DK;n)iO@YJV!@9PM! z_Aj$cZ7j~KFi)hb;q17H`3o+cO9!@{nXIQ>XSL}sE`?`WeWJDw;FOIPhrI`f;p;Fa7!k96nkNpm!h8>*Lv#G^Q7;#4aZiW SI^z0mUN$LSy0hfDxBml)>F-bg literal 0 HcmV?d00001 diff --git a/test/logo-64x64.png b/test/logo-64x64.png new file mode 100644 index 0000000000000000000000000000000000000000..a250e2a5271b939fb1ce149100fedc0e08e28d66 GIT binary patch literal 16598 zcmd5^36NC98ScN|Ti8LDqY_L3kpil~928o?3dioo84h7tb|nXR04m|IkZ@l~PzfOz zC`cuWBq~Wz$|FD`7P}iF;?B4SLJU?Yl9)q?kthUEkz--mdENPXmf7v;H#^MCzBkgv z?Cbu!`~SPY{{Q~F`}Jepgz_;3oqBd+j1`oO9rX=7gX)*x0e`p8UU(Fbz=E-NFJ`R6 zc=e-g^EQ12#2!mV-?ikM^JgttK5fxVwtV^WL9^%0Sv-B(f|-NnFM43}M@2mu>%&S$ zg}(J&qF^u_rchF}FEI5^5oxp@L{7kcX*#D#4K?=SE74f00Z&tztZMYyEg8 zq<4{ITZq_2jX`rBqk%A;^+-ToPJ(14?+uq0KW9n{y&UPo zY)b$(>!zT2g3AA;Oqy0X&- zKrzJV_vDNo7m~1^NDPuw71jNkixa+Fz@TkMaL$!e3HMLPU?X|b!LWZTN^_R4}^LX~y{ptwOb=P+r1 zCV{h}6W;`Y+G7eAxW#9hsz0KtwiL9fro3#@o&W&B9dUZFkUI|g+Zrq;E(nqvS}7UF zmYb?SdhgyYSdh6iB4f^1DtH9|<|28kW7$EoArNpND^nm=A30d$+T=tV13!a|&zo|x zO?w9bT7bR6Jj{n(&Bh4Mlvg-!(o>`_fX{vADNeAWz63kF`%~1*ILlK2V3&btR4y=0 z!Itbid}AhFVMQ|4$03Ak9guO4jS8Lupm<|7I5f(wkRgXTwzZ!z5jN>b()+t#JpP19 zk2dE21T@c7KhEEC02E_vnC8b0RO3?cw1h)KSgK>Gyh5Yp$muO-c~|O>sH`0cSMzO+ zoo7*B0DviU(TS9*ZQV>GwmAyN|43m91L8-YEA7G zU=5}zL@{?v|I^^XO?m@IR@96DeWp(HI_@g~P-!>-S}Fx4?9;g|8*sv;kM`Q?(xQWU z=f>>WbDcwcGibi3eq5HX0K|ky`31O!(zw9*(;kTQk8v+JX4;`I3Q^5wt=^t@j@ z?bkC$C%JNlaM)YeAiWpwNb|PY*~nzxiEuD@DNa|07!Z4OTKeD|hf$KuJBXTV;I zc;A+^&ykz~p!xxSeji?D^vA^LTx!gJ+g$L3D(iwM_Mj@8tB_Lwpwl=xriD^CpX{4B z>?6ICYSu^km-u<3`rkj-8_b&T0_cKL#B&OUY6o_Y9r6NA|1{flIa;75!Oxm>ztcGf z00$ehUL7^+6TM@hs(k|iOcTx&;UV-K|Km9Y0D8U!$K1R1ZrxE|UqGx8E5|6qorF59 z0wa39-|<`maJ-4wVzWbMKW-YVzhuT_`6RUAj9JdFbnXC>wbt>LnwO1-!QcO zJMs48Ezl!TC-JrkfPuLPb+GDd@EHL4d}MslPQ3?8^@)jRL2EfVLT7tgoZqdNQ*qos zsDWF2-K2Y&_7i|pj>X)nFB{Z0xWBs-ax$*t_0{RvAYq!Ir?E~2b;B!>-*Ui4Rf6H&gHh04!!+tS&45o!&WhXAd_03}`K?uji|{ zG6n1$?lkGhh(H-?TyzfzegJSf?=oLtwk^MtSc47@FzK$eq$xN^>8I0UrXcZx#0OLG z0RTDsm9Gy!sdqrBK1Oh!PD>RhPAg1PAd608TkU#pn2Jw2d7c7*72I~*=K8HJc--#Y z9T^F=!F-1mLvo>$FVb;JE@PcDbh9E0PZ-GX=QEcHbRnF8~$h z)pd_l-vp1u(* zrL_sCNN06=Ch=?mh%!M_!sCJ`bYUZ_YKCJ%T%^-HjKe9&hXF)Fnem|7Hdjdg3@GiH^;;Pxi9xe^bb-_jBvbCFzz^M`*Wm0?@9xa*()GhFsN`#zsBA=M12}8iKmFEiCsr==@=9p*M2j zyqB(Y$*gW_EpgTI>NqRElY@l_Q$GHtt5*0_3kaMS@NIbG^p1Mpm@1?MAQXw%bk-Uo zEt(3qGYO2krDB%zyzea=0X=4=>i-3}if|0^QH=C1!T1}tO=oad!DT8K+=9ZdKKIhr Tu1jM#*-A#2k9uju{XhIakLb(q literal 0 HcmV?d00001 From 41e69d33cbe366ffeaf5202d2958d693435e8b9c Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Mon, 27 Nov 2023 10:31:01 +0100 Subject: [PATCH 2/7] remove worker templates from lite --- share/xeus-lite/web_worker_kernel.ts | 206 ------------------------- share/xeus-lite/worker.ts | 220 --------------------------- 2 files changed, 426 deletions(-) delete mode 100644 share/xeus-lite/web_worker_kernel.ts delete mode 100644 share/xeus-lite/worker.ts diff --git a/share/xeus-lite/web_worker_kernel.ts b/share/xeus-lite/web_worker_kernel.ts deleted file mode 100644 index f3c6156..0000000 --- a/share/xeus-lite/web_worker_kernel.ts +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (c) Thorsten Beier -// Copyright (c) JupyterLite Contributors -// Distributed under the terms of the Modified BSD License. - -import { wrap } from 'comlink'; -import type { Remote } from 'comlink'; - -import { ISignal, Signal } from '@lumino/signaling'; -import { PromiseDelegate } from '@lumino/coreutils'; - -import { PageConfig } from '@jupyterlab/coreutils'; -import { KernelMessage } from '@jupyterlab/services'; - -import { IKernel } from '@jupyterlite/kernel'; - -interface IXeusKernel { - ready(): Promise; - - mount(driveName: string, mountpoint: string, baseUrl: string): Promise; - - cd(path: string): Promise; - - processMessage(msg: any): Promise; -} - -export class WebWorkerKernel implements IKernel { - /** - * Instantiate a new WebWorkerKernel - * - * @param options The instantiation options for a new WebWorkerKernel - */ - constructor(options: WebWorkerKernel.IOptions) { - const { id, name, sendMessage, location } = options; - this._id = id; - this._name = name; - this._location = location; - this._sendMessage = sendMessage; - this._worker = new Worker(new URL('./worker.js', import.meta.url), { - type: 'module' - }); - this._worker.onmessage = e => { - this._processWorkerMessage(e.data); - }; - this._remote = wrap(this._worker); - this.initFileSystem(options); - } - - async handleMessage(msg: KernelMessage.IMessage): Promise { - this._parent = msg; - this._parentHeader = msg.header; - await this._sendMessageToWorker(msg); - } - - private async _sendMessageToWorker(msg: any): Promise { - // TODO Remove this?? - if (msg.header.msg_type !== 'input_reply') { - this._executeDelegate = new PromiseDelegate(); - } - await this._remote.processMessage({ msg, parent: this.parent }); - if (msg.header.msg_type !== 'input_reply') { - return await this._executeDelegate.promise; - } - } - - /** - * Get the last parent header - */ - get parentHeader(): - | KernelMessage.IHeader - | undefined { - return this._parentHeader; - } - - /** - * Get the last parent message (mimick ipykernel's get_parent) - */ - get parent(): KernelMessage.IMessage | undefined { - return this._parent; - } - - /** - * Get the kernel location - */ - get location(): string { - return this._location; - } - - /** - * Process a message coming from the pyodide web worker. - * - * @param msg The worker message to process. - */ - private _processWorkerMessage(msg: any): void { - if (!msg.header) { - return; - } - - msg.header.session = this._parentHeader?.session ?? ''; - msg.session = this._parentHeader?.session ?? ''; - this._sendMessage(msg); - - // resolve promise - if ( - msg.header.msg_type === 'status' && - msg.content.execution_state === 'idle' - ) { - this._executeDelegate.resolve(); - } - } - - /** - * A promise that is fulfilled when the kernel is ready. - */ - get ready(): Promise { - return Promise.resolve(); - } - - /** - * Return whether the kernel is disposed. - */ - get isDisposed(): boolean { - return this._isDisposed; - } - - /** - * A signal emitted when the kernel is disposed. - */ - get disposed(): ISignal { - return this._disposed; - } - - /** - * Dispose the kernel. - */ - dispose(): void { - if (this.isDisposed) { - return; - } - this._worker.terminate(); - (this._worker as any) = null; - (this._remote as any) = null; - this._isDisposed = true; - this._disposed.emit(void 0); - } - - /** - * Get the kernel id - */ - get id(): string { - return this._id; - } - - /** - * Get the name of the kernel - */ - get name(): string { - return this._name; - } - - private async initFileSystem(options: WebWorkerKernel.IOptions) { - let driveName: string; - let localPath: string; - - if (options.location.includes(':')) { - const parts = options.location.split(':'); - driveName = parts[0]; - localPath = parts[1]; - } else { - driveName = ''; - localPath = options.location; - } - - await this._remote.ready(); - - if (options.mountDrive) { - await this._remote.mount(driveName, '/drive', PageConfig.getBaseUrl()); - await this._remote.cd(localPath); - } - } - - private _id: string; - private _name: string; - private _location: string; - private _remote: Remote; - private _isDisposed = false; - private _disposed = new Signal(this); - private _worker: Worker; - private _sendMessage: IKernel.SendMessage; - private _executeDelegate = new PromiseDelegate(); - private _parentHeader: - | KernelMessage.IHeader - | undefined = undefined; - private _parent: KernelMessage.IMessage | undefined = undefined; -} - -/** - * A namespace for WebWorkerKernel statics. - */ -export namespace WebWorkerKernel { - /** - * The instantiation options for a Pyodide kernel - */ - export interface IOptions extends IKernel.IOptions { - mountDrive: boolean; - } -} diff --git a/share/xeus-lite/worker.ts b/share/xeus-lite/worker.ts deleted file mode 100644 index 28a784f..0000000 --- a/share/xeus-lite/worker.ts +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (c) Thorsten Beier -// Copyright (c) JupyterLite Contributors -// Distributed under the terms of the Modified BSD License. - -import { expose } from 'comlink'; - -import { - DriveFS, - DriveFSEmscriptenNodeOps, - IEmscriptenFSNode, - IStats -} from '@jupyterlite/contents'; - -declare function createXeusModule(options: any): any; - -globalThis.Module = {}; - -const WASM_KERNEL_FILE = XEUS_KERNEL_FILE; -const DATA_FILE = LANGUAGE_DATA_FILE; - -// TODO Remove this. This is to ensure we always perform node ops on Nodes and -// not Streams, but why is it needed??? Why do we get Streams and not Nodes from -// emscripten in the case of xeus-python??? -class StreamNodeOps extends DriveFSEmscriptenNodeOps { - private getNode(nodeOrStream: any) { - if (nodeOrStream['node']) { - return nodeOrStream['node']; - } - return nodeOrStream; - } - - lookup(parent: IEmscriptenFSNode, name: string): IEmscriptenFSNode { - return super.lookup(this.getNode(parent), name); - } - - getattr(node: IEmscriptenFSNode): IStats { - return super.getattr(this.getNode(node)); - } - - setattr(node: IEmscriptenFSNode, attr: IStats): void { - super.setattr(this.getNode(node), attr); - } - - mknod( - parent: IEmscriptenFSNode, - name: string, - mode: number, - dev: any - ): IEmscriptenFSNode { - return super.mknod(this.getNode(parent), name, mode, dev); - } - - rename( - oldNode: IEmscriptenFSNode, - newDir: IEmscriptenFSNode, - newName: string - ): void { - super.rename(this.getNode(oldNode), this.getNode(newDir), newName); - } - - rmdir(parent: IEmscriptenFSNode, name: string): void { - super.rmdir(this.getNode(parent), name); - } - - readdir(node: IEmscriptenFSNode): string[] { - return super.readdir(this.getNode(node)); - } -} - -// TODO Remove this when we don't need StreamNodeOps anymore -class LoggingDrive extends DriveFS { - constructor(options: DriveFS.IOptions) { - super(options); - - this.node_ops = new StreamNodeOps(this); - } -} - -// when a toplevel cell uses an await, the cell is implicitly -// wrapped in a async function. Since the webloop - eventloop -// implementation does not support `eventloop.run_until_complete(f)` -// we need to convert the toplevel future in a javascript Promise -// this `toplevel` promise is then awaited before we -// execute the next cell. After the promise is awaited we need -// to do some cleanup and delete the python proxy -// (ie a js-wrapped python object) to avoid memory leaks -globalThis.toplevel_promise = null; -globalThis.toplevel_promise_py_proxy = null; - -let resolveInputReply: any; - -async function get_stdin() { - const replyPromise = new Promise(resolve => { - resolveInputReply = resolve; - }); - return replyPromise; -} - -(self as any).get_stdin = get_stdin; - -class XeusKernel { - constructor() { - this._ready = new Promise(resolve => { - this.initialize(resolve); - }); - } - - async ready(): Promise { - return await this._ready; - } - - mount(driveName: string, mountpoint: string, baseUrl: string): void { - const { FS, PATH, ERRNO_CODES } = globalThis.Module; - - if (!FS) { - return; - } - - this._drive = new LoggingDrive({ - FS, - PATH, - ERRNO_CODES, - baseUrl, - driveName, - mountpoint - }); - - FS.mkdir(mountpoint); - FS.mount(this._drive, {}, mountpoint); - FS.chdir(mountpoint); - } - - cd(path: string) { - if (!path || !globalThis.Module.FS) { - return; - } - - globalThis.Module.FS.chdir(path); - } - - async processMessage(event: any): Promise { - await this._ready; - - if ( - globalThis.toplevel_promise !== null && - globalThis.toplevel_promise_py_proxy !== null - ) { - await globalThis.toplevel_promise; - globalThis.toplevel_promise_py_proxy.delete(); - globalThis.toplevel_promise_py_proxy = null; - globalThis.toplevel_promise = null; - } - - const msg_type = event.msg.header.msg_type; - - if (msg_type === 'input_reply') { - resolveInputReply(event.msg); - } else { - this._raw_xserver.notify_listener(event.msg); - } - } - - private async initialize(resolve: () => void) { - importScripts(WASM_KERNEL_FILE); - - globalThis.Module = await createXeusModule({}); - try { - if (DATA_FILE.length !== 0) { - importScripts(DATA_FILE); - await this.waitRunDependency(); - } - // if the kernel has an async_initialize function, we need to - // call it before we can start the kernel - if(globalThis.Module.async_initialize) { - await globalThis.Module.async_initialize(); - } - this._raw_xkernel = new globalThis.Module.xkernel(); - this._raw_xserver = this._raw_xkernel.get_server(); - if (!this._raw_xkernel) { - console.error('Failed to start kernel!'); - } - this._raw_xkernel.start(); - } - catch (e) { - if( typeof e === 'number' ) { - const msg = globalThis.Module.get_exception_message(e); - console.error(msg); - throw new Error(msg); - } - else { - console.error(e); - throw(e); - } - } - resolve(); - } - - private async waitRunDependency() { - const promise = new Promise(resolve => { - globalThis.Module.monitorRunDependencies = (n: number) => { - if (n === 0) { - resolve(); - } - }; - }); - // If there are no pending dependencies left, monitorRunDependencies will - // never be called. Since we can't check the number of dependencies, - // manually trigger a call. - globalThis.Module.addRunDependency('dummy'); - globalThis.Module.removeRunDependency('dummy'); - return promise; - } - - private _raw_xkernel: any; - private _raw_xserver: any; - private _drive: DriveFS | null = null; - private _ready: PromiseLike; -} - -expose(new XeusKernel()); From ff7c070ffc1277858fee97f235a29bcc6a886c49 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Tue, 28 Nov 2023 09:36:39 +0100 Subject: [PATCH 3/7] cleanup --- CMakeLists.txt | 3 --- src/xembind.cpp | 1 - test/CMakeLists.txt | 3 --- 3 files changed, 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a801182..288ecbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,9 +125,6 @@ include(CTest) if(XEUS_LITE_BUILD_TESTS) set(BUILD_TESTING ON) message(STATUS "tests enabled") -else () - #set(BUILD_TESTING OFF) - #message(STATUS "tests disabled") endif() if(BUILD_TESTING) diff --git a/src/xembind.cpp b/src/xembind.cpp index adc764c..d778cd7 100644 --- a/src/xembind.cpp +++ b/src/xembind.cpp @@ -18,7 +18,6 @@ namespace nl = nlohmann; namespace ems = emscripten; - namespace xeus { nl::json json_from_js_object(ems::val js_obj) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5f41ce0..0a5c526 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,16 +12,13 @@ target_link_libraries(emscripten_wasm_test PRIVATE xeus-lite) xeus_wasm_compile_options(emscripten_wasm_test) xeus_wasm_link_options(emscripten_wasm_test "node") - add_executable(xlite main_emscripten_wasm.cpp xmock_interpreter.cpp) target_link_libraries(xlite PRIVATE xeus-lite) xeus_wasm_compile_options(xlite) xeus_wasm_link_options(xlite "web,worker") - SET(KERNEL_INSTALL_DIR "share/jupyter/kernels/xlite") - install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/logo-64x64.png" "${CMAKE_CURRENT_SOURCE_DIR}/logo-32x32.png" "$/xlite.wasm" From 33fbee7032b9985994cc3a4d6e378813abee291c Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Tue, 28 Nov 2023 09:47:30 +0100 Subject: [PATCH 4/7] cleanup --- BuildWasmDockerfile | 3 ++- CMakeLists.txt | 15 +++++---------- test/CMakeLists.txt | 35 ++++++++++++++++++++--------------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/BuildWasmDockerfile b/BuildWasmDockerfile index e210965..2675442 100644 --- a/BuildWasmDockerfile +++ b/BuildWasmDockerfile @@ -71,7 +71,8 @@ RUN mkdir -p /xeus-build && cd /xeus-build && \ -Dnlohmann_json_DIR=/install/lib/cmake/nlohmann_json \ -Dxtl_DIR=/install/share/cmake/xtl \ -Dxeus_DIR=/install/lib/cmake/xeus \ - -DXEUS_LITE_BUILD_TESTS=ON + -DXEUS_LITE_BUILD_BROWSER_TEST_KERNEL=ON \ + -DXEUS_LITE_BUILD_NODE_TESTS=ON \ RUN cd /xeus-build && \ emmake make -j8 diff --git a/CMakeLists.txt b/CMakeLists.txt index 288ecbb..60fb0e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,13 +35,13 @@ message(STATUS "xeus-lite version: v${XEUS_LITE_VERSION}") # ============= # Test options -option(XEUS_LITE_BUILD_TESTS "xeus test suite" OFF) - +option(XEUS_LITE_BUILD_NODE_TESTS "xeus-lite test suite (node)" OFF) +option(XEUS_LITE_BUILD_BROWSER_TEST_KERNEL "xeus-lte test kernel (browser)" OFF) # Emscripten wasm build configuration # ========================== # Tests are run in Node, while production builds in the browser. -if(XEUS_LITE_BUILD_TESTS) +if(XEUS_LITE_BUILD_NODE_TESTS) # this variable is used in the export_core function add_compile_definitions(XEUS_LITE_EMSCRIPTEN_WASM_TEST_BUILD) endif() @@ -49,7 +49,7 @@ endif() # Print build configuration # ========================== -message(STATUS "XEUS_LITE_BUILD_TESTS: ${XEUS_LITE_BUILD_TESTS}") +message(STATUS "XEUS_LITE_BUILD_NODE_TESTS: ${XEUS_LITE_BUILD_NODE_TESTS}") # Dependencies # ============ @@ -122,12 +122,7 @@ xeus_wasm_compile_options(xeus-lite) include(CTest) -if(XEUS_LITE_BUILD_TESTS) - set(BUILD_TESTING ON) - message(STATUS "tests enabled") -endif() - -if(BUILD_TESTING) +if(XEUS_LITE_BUILD_NODE_TESTS OR XEUS_LITE_BUILD_BROWSER_TEST_KERNEL) add_subdirectory(test) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0a5c526..eb35ecf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,27 +1,32 @@ ############################################################################ # Copyright (c) 2016, Johan Mabille, Sylvain Corlay, Martin Renou # # Copyright (c) 2016, QuantStack # +# Copyright (c) 2023, Thorsten Beier # # # # Distributed under the terms of the BSD 3-Clause License. # # # # The full license is in the file LICENSE, distributed with this software. # ############################################################################ -add_executable(emscripten_wasm_test main_emscripten_wasm.cpp xmock_interpreter.cpp) -target_link_libraries(emscripten_wasm_test PRIVATE xeus-lite) -xeus_wasm_compile_options(emscripten_wasm_test) -xeus_wasm_link_options(emscripten_wasm_test "node") +if(XEUS_LITE_BUILD_NODE_TESTS) + add_executable(emscripten_wasm_test main_emscripten_wasm.cpp xmock_interpreter.cpp) + target_link_libraries(emscripten_wasm_test PRIVATE xeus-lite) + xeus_wasm_compile_options(emscripten_wasm_test) + xeus_wasm_link_options(emscripten_wasm_test "node") +endif() -add_executable(xlite main_emscripten_wasm.cpp xmock_interpreter.cpp) -target_link_libraries(xlite PRIVATE xeus-lite) -xeus_wasm_compile_options(xlite) -xeus_wasm_link_options(xlite "web,worker") +if(XEUS_LITE_BUILD_BROWSER_TEST_KERNEL) + add_executable(xlite main_emscripten_wasm.cpp xmock_interpreter.cpp) + target_link_libraries(xlite PRIVATE xeus-lite) + xeus_wasm_compile_options(xlite) + xeus_wasm_link_options(xlite "web,worker") -SET(KERNEL_INSTALL_DIR "share/jupyter/kernels/xlite") + SET(KERNEL_INSTALL_DIR "share/jupyter/kernels/xlite") -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/logo-64x64.png" - "${CMAKE_CURRENT_SOURCE_DIR}/logo-32x32.png" - "$/xlite.wasm" - "$/xlite.js" - "${CMAKE_CURRENT_SOURCE_DIR}/kernel.json" - DESTINATION ${KERNEL_INSTALL_DIR}) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/logo-64x64.png" + "${CMAKE_CURRENT_SOURCE_DIR}/logo-32x32.png" + "$/xlite.wasm" + "$/xlite.js" + "${CMAKE_CURRENT_SOURCE_DIR}/kernel.json" + DESTINATION ${KERNEL_INSTALL_DIR}) +elseif() From f3ac0699ea5ffad5c2d900409e7cc164597b8349 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Tue, 28 Nov 2023 09:52:05 +0100 Subject: [PATCH 5/7] cleanup test logic --- BuildWasmDockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BuildWasmDockerfile b/BuildWasmDockerfile index 2675442..18d81f1 100644 --- a/BuildWasmDockerfile +++ b/BuildWasmDockerfile @@ -72,7 +72,7 @@ RUN mkdir -p /xeus-build && cd /xeus-build && \ -Dxtl_DIR=/install/share/cmake/xtl \ -Dxeus_DIR=/install/lib/cmake/xeus \ -DXEUS_LITE_BUILD_BROWSER_TEST_KERNEL=ON \ - -DXEUS_LITE_BUILD_NODE_TESTS=ON \ + -DXEUS_LITE_BUILD_NODE_TESTS=ON RUN cd /xeus-build && \ emmake make -j8 From 434c04b9f0e4e7a5f6169431ecb3d469a4350b69 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Tue, 28 Nov 2023 09:53:53 +0100 Subject: [PATCH 6/7] fixed syntax err --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eb35ecf..261da69 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -29,4 +29,4 @@ if(XEUS_LITE_BUILD_BROWSER_TEST_KERNEL) "$/xlite.js" "${CMAKE_CURRENT_SOURCE_DIR}/kernel.json" DESTINATION ${KERNEL_INSTALL_DIR}) -elseif() +endif() From 0a10529ed0f9b63bb57a3ab0d25ed7e77b17a8ac Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Wed, 29 Nov 2023 09:59:10 +0100 Subject: [PATCH 7/7] removed superflous options --- CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60fb0e3..094162f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,8 +134,6 @@ include(CMakePackageConfigHelpers) set(XEUS_LITE_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for xeus-liteConfig.cmake") -set(XEUS_LITE_TS_INSTALL_DIR - "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}" CACHE STRING "install path for typescript files") install(TARGETS xeus-lite EXPORT ${PROJECT_NAME}-targets @@ -173,6 +171,3 @@ install(EXPORT ${PROJECT_NAME}-targets FILE ${PROJECT_NAME}Targets.cmake DESTINATION ${XEUS_LITE_CMAKECONFIG_INSTALL_DIR}) -install(DIRECTORY share/${PROJECT_NAME}/ - DESTINATION ${XEUS_LITE_TS_INSTALL_DIR}) -