当前位置: 首页 > 工具软件 > WebAssembly > 使用案例 >

web开发入门到深入-WebAssembly(1)

胡夕
2023-12-01

WebAssembly
WebAssembly是一种新型的可以在现代web浏览器中运行的代码——这是一种低级assembly-like语言与一个紧凑的二进制格式,近乎本机的性能,并提供语言如C / c++, c#和rust的编译目标,这样他们就可以在web上运行。它还被设计为与JavaScript一起运行,允许两者一起工作。

WebAssembly目标
WebAssembly是W3C WebAssembly Community Group内部的一个开放标准,其目标如下:
快速、高效和可移植——WebAssembly代码可以在不同的平台上以接近本机的速度执行,这是通过利用通用的硬件功能实现的。
可读性和可调试性——WebAssembly是一种低级汇编语言,但它确实有一种人类可读的文本格式(该规范仍在最终确定中),允许手工编写、查看和调试代码。
保持安全——WebAssembly被指定在一个安全的沙箱执行环境中运行。像其他web代码一样,它将强制执行浏览器的同源和权限策略。
不要破坏web - WebAssembly被设计成可以很好地与其他web技术兼容并保持向后兼容性。

Get the emsdk repo

git clone https://github.com/emscripten-core/emsdk.git

Enter that directory

cd emsdk
Note

You can also get the emsdk without git, by selecting “Clone or download => Download ZIP” on the emsdk GitHub page.

Run the following emsdk commands to get the latest tools from GitHub and set them as active:

Fetch the latest version of the emsdk (not needed the first time you clone)

git pull

Download and install the latest SDK tools.

./emsdk install latest

Make the “latest” SDK “active” for the current user. (writes .emscripten file)

./emsdk activate latest

Activate PATH and other environment variables in the current terminal

source ./emsdk_env.sh
Note

On Windows, run emsdk instead of ./emsdk, and emsdk_env.bat instead of source ./emsdk_env.sh.

Note

git pull will fetch the current list of tags, but very recent ones may not yet be present there. You can run ./emsdk update-tags to update the list of tags directly.

If you change the location of the SDK (e.g. take it to another computer on an USB), re-run the ./emsdk activate latest and source ./emsdk_env.sh commands.

Emsdk install targets
In the description above we asked the emsdk to install and activate latest, which is the latest tagged release. That is often what you want.

You can also install a specific version by specifying it, for example,

./emsdk install 1.38.45

 类似资料: