Using emrun to run emscripten apps.

Answered

Hi,

Is there anyway to use the emscripten 'emrun' utility to launch emscripten apps from within CLion?

I've tried changing the 'Executable' setting in the Run/Debug configuration to 'Custom Executable' and entering the full path to emrun for the custom executable path, but I then get this error:

~~~

"/home/marksibly/dev/emsdk/upstream/emscripten/emrun": not in executable format: file format not recognized

~~~

I assume this is because emrun is a script file, not a native executable , so I tried adding bash at the front but that results in:

~~~
File 'bash /home/marksibly/dev/emsdk/upstream/emscripten/emrun' not found in directory '/home/marksibly/dev/sgf/cmake-build-emscripten' Please specify working directory, or use absolute path for executable
~~~
Any other ideas?

Bye!
Mark

5 comments
Comment actions Permalink

>com.jetbrains.cidr.execution.debugger.backend.gdb.GDBDriver$GDBCommandException: "/home/marksibly/dev/emsdk/upstream/emscripten/emrun": not in executable format: file format not recognized

It's GDB error, not sure we can do something with it.

I thought you were trying to run the configuration, not to debug. Does running work?

>Toolchain settings page needs a 'toolchain file' setting IMO

Feel free to comment or upvote https://youtrack.jetbrains.com/issue/CPP-21087. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.

 

1
Comment actions Permalink

Ok, I managed to get around this by hacking together a little C exe than simply uses the C library system() command to launch emrun, but it'd be convenient if CLion could let you use batch files as custom executables directly.

 

0
Comment actions Permalink

Hello!

In general it is possible to specify script as an executable in a run/debug configuration. As far as I know, Windows executes .bat, .com and .exe files by default. Is emrun marked as executable?

0
Comment actions Permalink
Hi,
 
I'm actually on Manjaro x64, I will try it on windows soon. Here's the error I get when I try to use emrun directly:

com.jetbrains.cidr.execution.debugger.backend.gdb.GDBDriver$GDBCommandException: "/home/marksibly/dev/emsdk/upstream/emscripten/emrun": not in executable format: file format not recognized

It almost looks like it's trying to run emrun with gdb? I've also tried using the toolchain 'debugger' setting to launch with emrun, but to no avail. I've just checked and emrun is just a simple bash script (with shebang and exe bit set) that  just launches emrun.py.
 
IMO, there are 2 changes needed to make emscripten work nicely with CLion:
 
* Toolchain settings page needs an extra 'Launcher' setting for specifying tools like emrun, or maybe the existing Debugger setting tweaked to support emrun . This would probably have to support some kind of pattern matching as emrun needs to be passed an 'blah.html' file, not 'blah.exe'. Without this, I am forced to create 2 'run configs' for every exe target in my cmake project - one that runs the x64 exe, one that runs the html with emrun.

* Toolchain settings page needs a 'toolchain file' setting IMO, perhaps even/or a 'default cmake args'? At the moment, it's impossible to really set up an easy to use emscripten toolchain, as you need to specify -DCMAKE_TOOLCHAIN_FILE in the cmake options in 'build, execution, deployment->cmake' settings since there's no way to do this in toolchain settings. The emscripten toolchain is pretty important as it provides functions for linking with javascript code etc. It also specifies compilers so is all you really need to create a fully functional emscripten toolchain.
 
Anyway, just some ideas. I think these changes would make CLion even better for emscripten coders like me. It's already pretty good, it's the only IDE I've been able to build/launch emscripten apps without having to resort to shell at some point!

Bye,
Mark
0
Comment actions Permalink

Thanks, I've added a comment to the 'tracker' you linked to above.

0

Please sign in to leave a comment.