aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-06-06 12:29:37 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-06-06 12:29:37 +0200
commit54825bc0aeb8192c4526a43a5e0fd78cda9561af (patch)
treef16b6f4d524d6aeff8fe6c222af7d4d20d62b1d0
parentab0db69a7b11ba1a9dc52d50c94e9e321b70ebf0 (diff)
downloademscripten-tutorial-54825bc0aeb8192c4526a43a5e0fd78cda9561af.tar.gz
emscripten-tutorial-54825bc0aeb8192c4526a43a5e0fd78cda9561af.zip
Updated README.md
-rw-r--r--README.md40
1 files changed, 21 insertions, 19 deletions
diff --git a/README.md b/README.md
index 84b0066..de7ef81 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,21 @@
1# How to port a complex C codebase to the web 1# How to port a complex C codebase to the web
2 2
3*This repository is still work in progress*
4
5This repository contains the source code for the examples discussed in 3This repository contains the source code for the examples discussed in
6a post walkthrough that is going to appear shortly on my website. 4[this blog post / tutorial](https://sebastiano.tronto.net/blog/2025-06-06-webdev).
7It will be linked here once published.
8 5
9Each sub-folder is a self-contained example of a C program (or library) 6Each sub-folder is a self-contained example of a C or C++ program (or
10that can be compiled to [WebAssembly](https://webassembly.org/) using 7library) that can be compiled to [WebAssembly](https://webassembly.org/)
11[Emscripten](https://emscripten.org), and some JavaScript and HTML code 8using [Emscripten](https://emscripten.org), and some JavaScript and HTML
12that can be used to run the C or C++ code in a web page or in a JavaScript 9code that can be used to run this program in a web page or in a JavaScript
13runtime such as [Node.js](https://nodejs.org). Following these steps in 10runtime such as [Node.js](https://nodejs.org). Following these steps in
14order will walk you through the process of deploying a complex C or C++ 11order will walk you through the process of deploying a complex application
15program (including multithreading, persistent storage, callback functions 12(including multithreading, persistent storage and callback functions)
16and so on) as a web app. 13as a web app.
17 14
18Besides the source files, each folder contains a few one-line shell 15Besides the source files, each folder contains a few one-line shell
19scripts, for convenience: 16scripts, for convenience. Usually, the following are present:
20 17
21* `build.sh`: to build the C / C++ code with Emscripten. 18* `build.sh`: to compile the C code with Emscripten.
22* `run-node.sh`: to run an example program in Node.js. 19* `run-node.sh`: to run an example program in Node.js.
23* `run-server.sh`: to start a web server on 20* `run-server.sh`: to start a web server on
24 [localhost:8080](http://localhost:8080) running an example web page 21 [localhost:8080](http://localhost:8080) running an example web page
@@ -43,7 +40,9 @@ In order to follow this tutorial, you are going to need the following:
43 40
44## 0. Hello world 41## 0. Hello world
45 42
46The folder `00_hello_world` contains the simplest possible example. 43The folder `00_hello_world` contains the simplest possible example:
44a C program that prints "Hello world" to standard output. The default
45Emscripten HTML template is used to run this code in a web page.
47 46
48## 1. Building a library 47## 1. Building a library
49 48
@@ -56,9 +55,10 @@ one-line function), and some JavaScript code to run it from a web page.
56 55
57## 2. Making it a module 56## 2. Making it a module
58 57
59In `02_library_modularized` we review the previous example and we build it 58In `02_library_modularized` we review
60into a 59the previous example and we build it into a
61[module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). The result is the same, but more convenient to use. 60[module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules).
61The result is the same, but it is more convenient to use.
62 62
63## 3. Multi-threading 63## 3. Multi-threading
64 64
@@ -75,6 +75,8 @@ thread by using a web worker.
75## 5. Callback functions 75## 5. Callback functions
76 76
77In `05_callback` the example is extended to include a callback function. 77In `05_callback` the example is extended to include a callback function.
78The C program uses this function to log its progress back to the
79JavaScript side.
78 80
79## 6. Storage 81## 6. Storage
80 82
@@ -85,6 +87,6 @@ using as backend the
85This example only works in the browser, as other runtimes (such as 87This example only works in the browser, as other runtimes (such as
86Node.js) require different backends. 88Node.js) require different backends.
87 89
88In this example we make use for the first time of the `--pre-js` option of 90In this example we make use time of the `--pre-js` option of the
89the compiler to include custom JavaScript code that is run when our module 91compiler to include custom JavaScript code that is run when our module
90loads. Moreover, the C code is split into multiple files for convenience. 92loads. Moreover, the C code is split into multiple files for convenience.

Generated with cgit - Back to sebastiano.tronto.net