Alon merged this feature into incoming, and there is now official
documentation in the wiki:
https://github.com/kripken/emscripten/wiki/Running-html-files-with-emrun

Let me know if you run into any issues!

   Jukka



2013/12/4 Jukka Jylänki <[email protected]>

> Ok, I submitted it as a pull request at
> https://github.com/kripken/emscripten/pull/1896
>
>    Jukka
>
>
> 2013/12/2 Alon Zakai <[email protected]>
>
>> This is great, let's definitely get this into trunk.
>>
>> - Alon
>>
>>
>>
>> On Fri, Nov 29, 2013 at 7:10 PM, Jukka Jylänki <[email protected]> wrote:
>>
>>> Hi there,
>>>
>>> For some time now, the buildbot farm has been running gfxapi (
>>> http://clb.demon.fi/gfxapi/ ) and MathGeoLib (
>>> http://clb.demon.fi/MathGeoLib/nightly/ ) unit tests as part of the
>>> Emscripten test suite. To be able to do that, buildbot needs a model where
>>> .html files are runnable like any other native executables on the system,
>>> unattended, and behave just like native executables do. This has resulted
>>> in a bunch of shell scripts, embedded web server hosting, process spawning
>>> etc. to manage the runs. I figured that these are tasks that others could
>>> find useful, so I have now extracted and cleaned up all that machinery into
>>> a single self-contained python script 'emrun' that can be used from the
>>> command line like this:
>>>
>>>   emrun myhtmlfile.html arg1 arg2 arg3=value
>>>
>>> This runs the given web page as if it was a native executable, and has
>>> the following benefits:
>>>    - waits until the emscripten page exits via a call to
>>> exit(returnCode), and emrun will capture that returnCode and exit with it.
>>>    - detects if user closes the browser, and emrun will close as if it
>>> was a native application.
>>>    - capture stdout and stderr from the emscripten web page and route
>>> those to native stdout and stderr. This allows doing 'emrun myhtmlfile.html
>>> > stdout.txt 2> stderr.txt' to store run results to a file.
>>>    - pass command line to the application, visible as argc and argv and
>>> GET parameters in the launched URL.
>>>
>>> This makes running .html files near-identical to running a native .exe,
>>> so emscripten .html pages are now easily integrated as part of other batch
>>> scripts and can be run in unattended manner. Internally emrun launches a
>>> web server, and uses HTTP requests to route stdio, and to serve the
>>> emscripten page over http:// instead of file:// URLs, which would break
>>> the default CORS rules for XHRs in default-configured Chrome and Opera.
>>>
>>> There's a some amount of extra params that are supported:
>>>    --browser /path/to/browser/exe can be used to specify a custom web
>>> browser executable to launch to open the page. If not specified, the system
>>> default browser is used. Aliases --browser
>>> firefox|firefox_nightly|firefox_beta|firefox_aurora|iexplore|opera|chrome|chrome_canary|safari
>>> can be used, which make the tool try to autofind that particular browser
>>> installation on the system.
>>>    --serve_root /path can be used to control what will be the
>>> DocumentRoot directory for the launched web browser.
>>>    --timeout x and --silence_timeout x parameters allow killing
>>> execution and returning to shell if no response has been received in given
>>> amount of time, or if run took too long. Useful for killing unit tests when
>>> they curiously fail.
>>>    --kill_start, --kill_exit and --only_kill control browser process
>>> cleanup.
>>>    --serve_after_close and --serve_after_exit control web server process
>>> cleanup.
>>>    and there's a few others, see emrun --help for details.
>>>
>>> Setting up requires a few mods to the default shell.html file. In the
>>> zip package, an example shell_emrun.html file is provided that can be used
>>> as a replacement to the default shell. Also, at the moment jQuery is needed
>>> to be able to do HTTP POSTs from the browser, perhaps this requirement can
>>> be easily removed with manual XHR requests.
>>>
>>> Download emrun here:
>>> https://dl.dropboxusercontent.com/u/40949268/emcc/emrun.zip .
>>> Everything that is needed is packaged in that .zip file (contains 4 files)
>>>
>>> If there's sufficient interest in this, perhaps it could be added as
>>> part of the standard Emscripten toolset and e.g. adjust the default shell
>>> file to add support for emrun, or something similar.
>>>
>>> The roadmap/TODO list looks like follows:
>>>   - Add support for --browser android_firefox|android_nightly etc. to
>>> allow automating runs on an Android device.
>>>   - Add support for --browser ffos to automate runs on a Firefox OS
>>> device.
>>>   - Add support for launching multiple pages when tons of web pages are
>>> run in a queue, instead of always killing the browser in between.
>>>   - Add a simple binary file dump support (browser page can dump a raw
>>> byte buffer to a given file on the host system).
>>>   - Remove need of jQuery (nothing against jQuery itself, but it's
>>> easier if there are no extra .js files needed to deploy)
>>>
>>> This cleaned up version of the tool has been tested only on Windows,
>>> although buildbot runs an older version of the code on OSX. Linux is
>>> untested, I can think e.g. locating browsers in a nice way and closing
>>> processes could require adjustments to command line on Linux.
>>>
>>> Let me know if this is something that would be interesting to have as a
>>> standard emscripten toolchain utility, and if you find any issues or bugs.
>>>
>>> Finally a word of warning when testing: The --kill parameters really
>>> mean killing the browser processes, so if you are playing around with this
>>> and running a browser with multiple tabs, be careful about any unsaved data!
>>>
>>>    Jukka
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "emscripten-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to