### Install and Activate Latest Development SDK (sdk-main-64bit) Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md Build from the very latest sources by installing and activating `sdk-main-64bit`. This requires installing git first if not already present. ```bash # Install git (Skip if the system already has it). ./emsdk install git-1.8.3 # Clone+pull the latest emscripten-core/emscripten/main. ./emsdk install sdk-main-64bit # Set this as the active version. ./emsdk activate sdk-main-64bit ``` -------------------------------- ### Create Example Executable Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/zlib/CMakeLists.txt Builds an executable named 'example' from 'example.c' and links it against the zlib library. Also adds a test for this executable. ```cmake add_executable(example example.c) target_link_libraries(example zlib) add_test(example example) ``` -------------------------------- ### Install a Specific Tool or SDK Version Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md Download and install a new tool or SDK version using its name. ```bash ./emsdk install ``` ```bash ./emsdk install sdk-1.38.21-64bit ``` -------------------------------- ### Build Example with Embind Asyncify or JSPI Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/porting/asyncify.md Build command for a C++ example using Embind, enabling either Asyncify or JSPI. ```default emcc -O3 example.cpp -lembind -s ``` -------------------------------- ### Install and Activate Specific SDK Version Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md Install a specific SDK version and then activate it to set it as the current compiler configuration. ```bash ./emsdk install 4.0.7 ./emsdk activate 4.0.7 ``` -------------------------------- ### Set Binaryen Root Directory Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/building_from_source/configuring_emscripten_settings.md Example of how to set the BINARYEN_ROOT variable in the .emscripten file to point to your Binaryen installation directory. Use forward slashes for paths. ```text BINARYEN_ROOT = 'C:\\tools\\binaryen\\' ``` -------------------------------- ### Install zlib Libraries and Headers Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/zlib/CMakeLists.txt Installs the zlib library targets (runtime, archive, library) and public headers to their respective destinations if installation is not skipped. ```cmake if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) install(TARGETS zlib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) endif() if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION include) endif() if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) install(FILES zlib.3 DESTINATION share/man/man3) endif() ``` -------------------------------- ### Install and Activate SDK Asserts Version Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md Install and activate an SDK version built with additional runtime checks for debugging. ```bash ./emsdk install 4.0.7-asserts ./emsdk activate 4.0.7-asserts ``` -------------------------------- ### List Installed SDKs and Tools Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md Display a list of all installed tools and SDK versions, indicating which are currently active. ```bash ./emsdk list ``` -------------------------------- ### Install Man Pages Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/openjpeg/codec/CMakeLists.txt Installs the man pages for the OpenJPEG command-line tools to the specified installation directory. ```cmake INSTALL( FILES ../doc/man/man1/image_to_j2k.1 ../doc/man/man1/j2k_dump.1 ../doc/man/man1/j2k_to_image.1 DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1) # ``` -------------------------------- ### Update SDK Registry and Install Latest SDK Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md Fetch the latest tool registry and then download and install the most recent SDK release. ```bash # Fetch the latest registry of available tools. ./emsdk update # Download and install the latest SDK tools. ./emsdk install latest # Set up the compiler configuration to point to the "latest" SDK. ./emsdk activate latest ``` -------------------------------- ### Install and Activate Tip-Of-Tree (tot) SDK Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md To use the latest development changes, install and activate the `tot` version, which is continuously built with recent Emscripten and LLVM updates. ```bash ./emsdk install tot ./emsdk activate tot ``` -------------------------------- ### Emscripten Compiler Configuration File Example (Windows) Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md Example of a .emscripten configuration file on Windows, specifying paths to LLVM and Node.js. ```python import os LLVM_ROOT='C:/Program Files/Emscripten/clang/e1.21.0_64bit' NODE_JS='C:/Program Files/Emscripten/node/0.10.17_64bit/node.exe' ``` -------------------------------- ### List and Install Old Emscripten SDK Versions Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md Retrieve a list of archived tool and SDK versions using `list --old`. Install a specific archived version using `install ` and then activate it. ```bash # Get list of the old versions of the tool. ./emsdk list --old # Install the required version. ./emsdk install # Activate required version. ./emsdk activate ``` -------------------------------- ### Example Executable Build Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/freealut/CMakeLists.txt Builds the 'hello_world' example executable. It links against OpenAL, additional libraries, and either the static or shared 'alut' library depending on the EMSCRIPTEN build flag. ```cmake ADD_EXECUTABLE(hello_world examples/hello_world.c) if (EMSCRIPTEN) TARGET_LINK_LIBRARIES(hello_world ${OPENAL_LIB} ${ADD_LIBS} alut_static) else() TARGET_LINK_LIBRARIES(hello_world ${OPENAL_LIB} ${ADD_LIBS} alut) endif() ``` -------------------------------- ### Update Emscripten SDK and Install New Versions Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md First, fetch the latest registry of available tools and SDKs using `update`. Then, install a specific new version using `install `. ```bash # Fetch the latest registry of available tools. ./emsdk update # Download and install the specified new version. ./emsdk install ``` -------------------------------- ### Install Library Files Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/bullet/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/MiniCL/CMakeLists.txt Configures installation rules for the 'BulletSoftBodySolvers_OpenCL_Mini' library, including destination paths and handling for macOS frameworks. ```cmake IF (INSTALL_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletSoftBodySolvers_OpenCL_Mini DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletSoftBodySolvers_OpenCL_Mini DESTINATION lib${LIB_SUFFIX}) #headers are already installed by BulletMultiThreaded library ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(BulletSoftBodySolvers_OpenCL_Mini PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(BulletSoftBodySolvers_OpenCL_Mini PROPERTIES PUBLIC_HEADER "${BulletSoftBodyOpenCLSolvers_HDRS}") ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### Install and Activate MinGW Compiler Toolchain Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/building_from_source/toolchain_what_is_needed.md Use these commands to install and activate the MinGW compiler toolchain for SDK users on Windows. ```bash emsdk install mingw-4.6.2-32bit emsdk activate mingw-4.6.2-32bit ``` -------------------------------- ### Playfile Example Executable Build Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/freealut/CMakeLists.txt Builds the 'playfile' example executable. Similar to 'hello_world', it links against OpenAL, additional libraries, and the appropriate 'alut' library based on the EMSCRIPTEN flag. ```cmake ADD_EXECUTABLE(playfile examples/playfile.c) if (EMSCRIPTEN) TARGET_LINK_LIBRARIES(playfile ${OPENAL_LIB} ${ADD_LIBS} alut_static) else() TARGET_LINK_LIBRARIES(playfile ${OPENAL_LIB} ${ADD_LIBS} alut) endif() ``` -------------------------------- ### Install GCC and CMake on Linux Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/building_from_source/toolchain_what_is_needed.md Commands to install the GCC compiler and CMake build system on Linux distributions using apt-get. ```bash #Install gcc sudo apt-get install build-essential # Install cmake sudo apt-get install cmake ``` -------------------------------- ### Emscripten Compiler Configuration File Example (Linux) Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/tools_reference/emsdk.md Example of a .emscripten configuration file on Linux, specifying Node.js and LLVM paths. ```python import os NODE_JS = 'node' LLVM_ROOT='/home/ubuntu/emsdk/upstream/bin' ``` -------------------------------- ### Install Sphinx Dependencies Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/site/about.md Ensures the correct version of Sphinx is installed for building the site. Run this command in the Emscripten site directory. ```default pip install -r requirements-dev.txt ``` -------------------------------- ### Configure Installation Directories and Pkgconfig Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/bullet/CMakeLists.txt This snippet configures installation directories for libraries and headers if INSTALL_LIBS is enabled. It also sets up the pkgconfig file for Linux systems. ```cmake IF(INSTALL_LIBS) SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) SET (LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Library directory name") ## the following are directories where stuff will be installed to SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/bullet/" CACHE PATH "The subdirectory to the header prefix") SET(PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/" CACHE STRING "Base directory for pkgconfig files") IF(NOT WIN32) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bullet.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/bullet.pc @ONLY) INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/bullet.pc DESTINATION ${PKGCONFIG_INSTALL_PREFIX}) ENDIF(NOT WIN32) ENDIF(INSTALL_LIBS) ``` -------------------------------- ### Shared Library Build and Installation Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/freealut/CMakeLists.txt Defines the shared 'alut' library, sets its version properties, links necessary libraries, and installs the target library and header files. ```cmake ADD_LIBRARY(alut SHARED ${ALUT_SOURCES}) SET_TARGET_PROPERTIES(alut PROPERTIES VERSION ${VERSION} SOVERSION ${MAJOR_VERSION}) TARGET_LINK_LIBRARIES(alut ${OPENAL_LIB} ${ADD_LIBS}) INSTALL_TARGETS(/lib alut) INSTALL_FILES(/include/AL FILES include/AL/alut.h) ``` -------------------------------- ### Install a tip-of-tree Emscripten build Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/getting_started/downloads.md Install a tip-of-tree (tot) build, which represents the very latest code that passes integration tests. This requires specifying the backend explicitly. ```bash ./emsdk install tot ``` -------------------------------- ### Install Latest Emscripten Tip-of-Tree Binaries Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/contributing/developers_guide.md Installs and activates the latest 'tip-of-tree' binaries for Emscripten development. These are necessary for running Emscripten and its core components. ```bash emsdk install tot emsdk activate tot ``` -------------------------------- ### Install MiniCL Library and Headers Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/bullet/src/MiniCL/CMakeLists.txt Configures the installation of the MiniCL library and its header files. This section includes conditional logic for different platforms and build configurations. ```cmake IF (INSTALL_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) #INSTALL of other files requires CMake 2.6 IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) # IF(INSTALL_EXTRA_LIBS) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS MiniCL DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS MiniCL DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) # ENDIF (INSTALL_EXTRA_LIBS) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### Install and activate latest Emscripten SDK tools Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/getting_started/downloads.md Fetch the latest SDK tools from GitHub, install them, and activate the 'latest' SDK version. This sets the tools as active for the current user. ```bash ./emsdk install latest ./emsdk activate latest source ./emsdk_env.sh ``` -------------------------------- ### Verify Emscripten Installation Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/getting_started/Tutorial.md Run this command to check if Emscripten is installed correctly and accessible from your command line. If you see warnings about missing tools, refer to the verification guide. ```bash ./emcc -v ``` -------------------------------- ### Quick Toolchain Profiling Example Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/optimizing/Profiling-Toolchain.md Run this sequence to enable profiling, compile a project, and generate a profiling report. The output is an HTML file showing toolchain performance. ```bash cd path/to/emscripten export EMPROFILE=1 emcc test/hello_world.c -O3 -o a.html emprofile ``` -------------------------------- ### Run Multiple Browser Tests with Wildcards Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/getting_started/test-suite.md Use wildcards to run a group of browser tests. This example runs all tests starting with 'browser.test_sdl2'. ```bash # run all SDL2 browser tests test/runner browser.test_sdl2* ``` -------------------------------- ### Building Projects with Mixed Optimizations Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/compiling/Building-Projects.md This example shows how to apply different optimization levels to specific source files, optimizing one for size and others using a higher optimization level. ```bash # Optimize the first file for size, and the rest using `-O2`. emcc -Oz a.cpp -c -o a.o emcc -O2 b.cpp -c -o b.o emcc -O2 a.o b.o -o project.js ``` -------------------------------- ### Emscripten Check Output Example Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/building_from_source/verify_emscripten_environment.md This output indicates an incorrect LLVM version for clang, suggesting a potential issue with the Emscripten toolchain setup. ```none emcc (Emscripten GCC-like replacement + linker emulating GNU ld) 1.21.0 shared:INFO: (Emscripten: Running sanity checks) emcc: warning: LLVM version for clang executable "/usr/bin/clang" appears incorrect (seeing "16.0", expected "18") [-Wversion-check] ``` -------------------------------- ### Hello World Example in ALUT Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/freealut/doc/alut.html A basic ALUT program that plays a 'Hello, world!' sound. Error checks are omitted for simplicity. Ensure ALUT is initialized with alutInit() and exited with alutExit(). ```c #include #include int main (int argc, char **argv) { ALuint helloBuffer, helloSource; alutInit (&argc, argv); helloBuffer = alutCreateBufferHelloWorld (); alGenSources (1, &helloSource); alSourcei (helloSource, AL_BUFFER, helloBuffer); alSourcePlay (helloSource); alutSleep (1); alutExit (); return EXIT_SUCCESS; } ``` -------------------------------- ### Install Poppler Qt4 Target Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/poppler/qt4/src/CMakeLists.txt Installs the poppler-qt4 library to the appropriate runtime, library, and archive destinations. This makes the library available after installation. ```cmake install(TARGETS poppler-qt4 RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) ``` -------------------------------- ### Create and Navigate to Build Directory Source: https://github.com/emscripten-core/emscripten/blob/main/system/lib/llvm-libc/config/windows/README.md Create an empty directory for building LLVM libc and change the current directory to it. ```bash mkdir libc-build cd libc-build ``` -------------------------------- ### Check CMake Installation Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/building_from_source/toolchain_what_is_needed.md Verify if CMake is installed. ```bash cmake ``` -------------------------------- ### SDL Hello World Example Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/getting_started/Tutorial.md A C program demonstrating basic SDL initialization, surface manipulation for drawing a colored square, and displaying it on screen. This example is intended to be compiled with Emscripten. ```c // Copyright 2011 The Emscripten Authors. All rights reserved. // Emscripten is available under two separate licenses, the MIT license and the // University of Illinois/NCSA Open Source License. Both these licenses can be // found in the LICENSE file. #include #include #ifdef __EMSCRIPTEN__ #include #endif int main(int argc, char** argv) { printf("Hello, world!\n"); SDL_Init(SDL_INIT_VIDEO); SDL_Surface *screen = SDL_SetVideoMode(256, 256, 32, SDL_SWSURFACE); #ifdef TEST_SDL_LOCK_OPTS EM_ASM("SDL.defaults.copyOnLock = false; SDL.defaults.discardOnLock = true; SDL.defaults.opaqueFrontBuffer = false;"); #endif if (SDL_MUSTLOCK(screen)) SDL_LockSurface(screen); for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { #ifdef TEST_SDL_LOCK_OPTS // Alpha behaves like in the browser, so write proper opaque pixels. int alpha = 255; #else // To emulate native behavior with blitting to screen, alpha component is ignored. Test that it is so by outputting // data (and testing that it does get discarded) int alpha = (i+j) % 255; #endif *((Uint32*)screen->pixels + i * 256 + j) = SDL_MapRGBA(screen->format, i, j, 255-i, alpha); } } if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); SDL_Flip(screen); printf("you should see a smoothly-colored square - no sharp lines but the square borders!\n"); printf("and here is some text that should be HTML-friendly: amp: |&| double-quote: |\"| quote: |'| less-than, greater-than, html-like tags: ||\nanother line.\n"); SDL_Quit(); return 0; } ``` -------------------------------- ### FS.init(input, output, error) Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/api_reference/Filesystem-API.md Sets up standard I/O devices (stdin, stdout, stderr) using provided callback functions for input and output operations. ```APIDOC ### FS.init(input, output, error) Sets up standard I/O devices for `stdin`, `stdout`, and `stderr`. The devices are set up using the following (optional) callbacks. If any of the callbacks throw an exception, it will be caught and handled as if the device malfunctioned. * **Arguments:** * **input** – Input callback. This will be called with no parameters whenever the program attempts to read from `stdin`. It should return an ASCII character code when data is available, or `null` when it isn’t. * **output** – Output callback. This will be called with an ASCII character code whenever the program writes to `stdout`. It may also be called with `null` to flush the output. * **error** – Error callback. This is similar to `output`, except it is called when data is written to `stderr`. ``` -------------------------------- ### Change Starting Symbol in PLY Source: https://github.com/emscripten-core/emscripten/blob/main/third_party/ply/doc/ply.html Specifies a starting symbol for the grammar using a 'start' specifier or as an argument to yacc(). Useful for debugging or subsetting grammars. ```python start = 'foo' def p_bar(p): 'bar : A B' # This is the starting rule due to the start specifier above def p_foo(p): 'foo : bar X' ... ``` ```python yacc.yacc(start='foo') ``` -------------------------------- ### Compiling and Running Async Fetch Example Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/porting/asyncify.md Instructions for compiling the C code using Asyncify or JSPI and the necessary steps to run it, which involves using a local webserver. ```default emcc example.c -O3 -o a.html -s ``` -------------------------------- ### Start ETW Profiling with WPR Source: https://github.com/emscripten-core/emscripten/blob/main/system/lib/mimalloc/src/prim/windows/readme.md Use Windows Performance Recorder (WPR) to start profiling. This command starts recording with the specified profile and file mode. ```bash > wpr -start src\prim\windows\etw-mimalloc.wprp -filemode ``` -------------------------------- ### Initializing standard I/O devices Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/api_reference/Filesystem-API.md Set up standard I/O devices for stdin, stdout, and stderr using custom callbacks. This configuration should be done before the main `run()` method, typically within `Module.preRun`. ```javascript FS.init(input, output, error); ``` -------------------------------- ### Build C Library and Link with Main File Source: https://context7.com/emscripten-core/emscripten/llms.txt Configure, build, and install a C library using Emscripten tools, then link it with a main application file. ```bash emconfigure ./configure --prefix=$(pwd)/install ``` ```bash emmake make install ``` ```bash emcc -O2 main.c -Linstall/lib -lmylib -o app.js ``` -------------------------------- ### Check GCC/G++ Installation Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/building_from_source/toolchain_what_is_needed.md Verify if GCC and G++ compilers are installed. ```bash gcc --version g++ ``` -------------------------------- ### CoreMark Reporting Example Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/coremark/README.md Example of a CoreMark performance result report. ```text CoreMark 1.0 : 128 / GCC 4.1.2 -O2 -fprofile-use / Heap in TCRAM / FORK:2 or CoreMark 1.0 : 1400 / GCC 3.4 -O4 ``` -------------------------------- ### Install BulletDynamics Library and Headers Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/bullet/src/BulletDynamics/CMakeLists.txt Configures the installation rules for the BulletDynamics library and its headers. This includes handling different installation paths based on platform and build type (static/shared). ```cmake IF (INSTALL_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletDynamics DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletDynamics DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) INSTALL(FILES ../btBulletDynamicsCommon.h DESTINATION ${INCLUDE_INSTALL_DIR}/BulletDynamics) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(BulletDynamics PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(BulletDynamics PROPERTIES PUBLIC_HEADER "${Root_HDRS}") # Have to list out sub-directories manually: SET_PROPERTY(SOURCE ${ConstraintSolver_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/ConstraintSolver) SET_PROPERTY(SOURCE ${Dynamics_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/Dynamics) SET_PROPERTY(SOURCE ${Vehicle_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/Vehicle) SET_PROPERTY(SOURCE ${Character_HDRS} PROPERTY MACOSX_PACKAGE_LOCATION Headers/Character) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### Set Start Rule for PLY Grammar Source: https://github.com/emscripten-core/emscripten/blob/main/third_party/ply/doc/internal.html Specifies the starting rule for the grammar. If omitted, the first added production becomes the start rule. Must be called after all productions are added. ```python g.set_start(start='expr') ``` -------------------------------- ### Install leb128 library Source: https://github.com/emscripten-core/emscripten/blob/main/third_party/leb128/README.md Install the leb128 Python package using pip. ```shell $ pip3 install leb128 ``` -------------------------------- ### PROXYFS Example Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/api_reference/Filesystem-API.md Demonstrates how to mount another module's file system using PROXYFS, allowing shared access without data copying. ```APIDOC ## PROXYFS This allows a module to mount another module’s file system. This is useful when separate modules need to share a file system without manually syncing file contents. For example: ```js // Module 2 can use the path "/fs1" to access and modify Module 1's filesystem module2.FS.mkdir("/fs1"); module2.FS.mount(module2.PROXYFS, { root: "/", fs: module1.FS }, "/fs1"); ``` ``` -------------------------------- ### Install OpenCL Soft Body Solver Library on Apple Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/bullet/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Apple/CMakeLists.txt Configures installation rules for the OpenCL soft body solver library on Apple, handling framework builds and standard library installations. ```cmake IF (INSTALL_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletSoftBodySolvers_OpenCL_Apple DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletSoftBodySolvers_OpenCL_Apple DESTINATION lib${LIB_SUFFIX}) #headers are already installed by BulletMultiThreaded library ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(BulletSoftBodySolvers_OpenCL_Apple PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(BulletSoftBodySolvers_OpenCL_Apple PROPERTIES PUBLIC_HEADER "${BulletSoftBodyOpenCLSolvers_HDRS}") ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### Serve Emscripten Website Locally Source: https://github.com/emscripten-core/emscripten/blob/main/docs/process.md Starts a local web server to view the built emscripten.org website. Browse to http://localhost:8000/ to view. ```bash python3 -m http.server 8000 -d site/build/html ``` -------------------------------- ### Consistent Optimization Flags for Building Projects Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/compiling/Building-Projects.md This example shows the recommended approach for building projects by applying the same optimization flags during both the object file compilation and the final linking stage. ```bash emcc -O2 a.cpp -c -o a.o emcc -O2 b.cpp -c -o b.o emcc -O2 a.o b.o -o project.js ``` -------------------------------- ### Install Poppler GLib Target Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/poppler/glib/CMakeLists.txt Installs the 'poppler-glib' target, specifying runtime, library, and archive destinations. ```cmake install(TARGETS poppler-glib RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) ``` -------------------------------- ### Configure Box2D Hello World Project Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/box2d/HelloWorld/CMakeLists.txt Sets up the build environment for the Hello World example using CMake. It includes the Box2D source directory, defines the executable, and links the Box2D library. ```cmake include_directories (${Box2D_SOURCE_DIR}) add_executable(HelloWorld HelloWorld.cpp) target_link_libraries (HelloWorld Box2D) ``` -------------------------------- ### Install Poppler GLib Headers Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/poppler/glib/CMakeLists.txt Installs the public and generated header files for Poppler GLib to the include directory. ```cmake install(FILES ${poppler_glib_public_headers} ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h ${CMAKE_CURRENT_BINARY_DIR}/poppler-features.h DESTINATION include/poppler/glib) ``` -------------------------------- ### alutLoadMemoryHelloWorld Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/freealut/doc/alut.html Loads a pre-recorded 'Hello, world!' sound into OpenAL-compatible data. The sound data is guaranteed to be in a standard OpenAL format. ```APIDOC ## alutLoadMemoryHelloWorld ### Description Loads the sound of someone saying 'Hello, world!' into a newly allocated buffer. The sound data is guaranteed to be in a standard OpenAL format, with a sample frequency chosen by the ALUT implementation. ### Synopsis ```c ALvoid *alutLoadMemoryHelloWorld (ALenum *format, ALsizei *size, ALfloat *frequency); ``` ### Parameters - **format** (ALenum *) - Pointer to an ALenum to receive the sound format (e.g., AL_FORMAT_MONO8, AL_FORMAT_STEREO16). - **size** (ALsizei *) - Pointer to an ALsizei to receive the size of the sound data in bytes. - **frequency** (ALfloat *) - Pointer to an ALfloat to receive the sample frequency of the sound. ### Return Value On success, returns a pointer to a newly allocated memory area containing the sound data. This memory should be freed by the caller when no longer needed. Returns NULL on failure. ### Errors - ALUT_ERROR_OUT_OF_MEMORY: ALUT ran out of memory. - ALUT_ERROR_INVALID_OPERATION: ALUT has not been initialized. - ALUT_ERROR_NO_CURRENT_CONTEXT: There is no current AL context. - ALUT_ERROR_AL_ERROR_ON_ENTRY: An AL error occurred before the function call. - ALUT_ERROR_ALC_ERROR_ON_ENTRY: An ALC error occurred before the function call. ``` -------------------------------- ### Create 64-bit Example and minigzip Executables Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/zlib/CMakeLists.txt Conditionally creates 64-bit versions of 'example' and 'minigzip' executables if HAVE_OFF64_T is defined. These are compiled with '-D_FILE_OFFSET_BITS=64' to enable 64-bit file offset support. ```cmake if(HAVE_OFF64_T) add_executable(example64 example.c) target_link_libraries(example64 zlib) set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") add_test(example64 example64) add_executable(minigzip64 minigzip.c) target_link_libraries(minigzip64 zlib) set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") endif() ``` -------------------------------- ### Conditional Installation of BulletSoftBody Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/bullet/src/BulletSoftBody/CMakeLists.txt Handles the installation of the BulletSoftBody library and its headers based on the INSTALL_LIBS flag and specific platform conditions. ```cmake IF (INSTALL_LIBS) IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletSoftBody DESTINATION .) ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) INSTALL(TARGETS BulletSoftBody DESTINATION lib${LIB_SUFFIX}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "CMakeFiles" EXCLUDE) ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) SET_TARGET_PROPERTIES(BulletSoftBody PROPERTIES FRAMEWORK true) SET_TARGET_PROPERTIES(BulletSoftBody PROPERTIES PUBLIC_HEADER "${BulletSoftBody_HDRS}") ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK) ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) ENDIF (INSTALL_LIBS) ``` -------------------------------- ### Lua Table Constructor Example Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/lua/doc/manual.html Demonstrates the creation and initialization of a Lua table using various field syntaxes. Fields with explicit keys, named fields, and sequential fields are shown. ```lua a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 } ``` -------------------------------- ### Install a specific Emscripten SDK version Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/getting_started/downloads.md Install a specific tagged version of the Emscripten SDK by providing the version number. ```bash ./emsdk install 1.38.45 ``` -------------------------------- ### Install OpenJPEG Library Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/openjpeg/libopenjpeg/CMakeLists.txt Installs the built OpenJPEG library to the specified destination directory. This ensures the library is available for linking by other projects. ```cmake INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME} EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries ) ``` -------------------------------- ### Enable CPU Demos Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/bullet/CMakeLists.txt Enables the building of original Bullet CPU demos. ```cmake OPTION(BUILD_CPU_DEMOS "Build original Bullet CPU demos" ON) ``` -------------------------------- ### Show Test Suite Help Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/getting_started/test-suite.md Run the test suite runner with the --help flag to view available options and commands. ```bash test/runner --help ``` -------------------------------- ### Mounting NODEFS in Node.js Source: https://github.com/emscripten-core/emscripten/blob/main/site/source/docs/api_reference/Filesystem-API.md Example demonstrating how to mount a directory using NODEFS within a Node.js environment. This maps host filesystem directories to Emscripten's virtual filesystem. ```c /* * See [this test](https://github.com/emscripten-core/emscripten/blob/main/test/fs/test_nodefs_rw.c) * for an example. */ ``` -------------------------------- ### Initialize ALUT with Command-Line Arguments Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/freealut/doc/alut.html Pass argc and argv from main to alutInit to allow ALUT to process its own command-line options. Recognized options are consumed. ```c int main (int argc, char **argv) { alutInit (&argc, argv); ... } ``` -------------------------------- ### Serve HTML Page with Local Server Source: https://context7.com/emscripten-core/emscripten/llms.txt Compile a C file with the `--emrun` flag and then use `emrun` to serve the generated HTML page locally. ```bash emcc --emrun hello.c -o hello.html ``` ```bash emrun hello.html ``` -------------------------------- ### Install Sphinx Dependencies Source: https://github.com/emscripten-core/emscripten/blob/main/docs/process.md Installs the necessary Sphinx version for developing the emscripten.org website. You may need to add ~/.local/bin to your PATH. ```bash pip3 install -r requirements-dev.txt ``` -------------------------------- ### sys/uio.h Entrypoints Source: https://github.com/emscripten-core/emscripten/blob/main/system/lib/llvm-libc/config/linux/aarch64/entrypoints.txt Entrypoints for functions related to scatter/gather I/O. ```APIDOC ## writev ### Description Write data from multiple buffers to a file descriptor. ### Method N/A (C function) ### Endpoint N/A ## readv ### Description Read data into multiple buffers from a file descriptor. ### Method N/A (C function) ### Endpoint N/A ``` -------------------------------- ### alutCreateBufferHelloWorld Source: https://github.com/emscripten-core/emscripten/blob/main/test/third_party/freealut/doc/alut.html Creates an OpenAL buffer containing a 'Hello, world!' sound. This function is useful for quick testing or simple audio playback scenarios. ```APIDOC ## alutCreateBufferHelloWorld ### Description Creates an OpenAL buffer containing the sound of someone saying 'Hello, world!'. ### Synopsis ALuint alutCreateBufferHelloWorld (void); ### Return Value On success, returns a handle to an OpenAL buffer. Returns AL_NONE on failure. ### Errors - ALUT_ERROR_OUT_OF_MEMORY - ALUT_ERROR_INVALID_OPERATION - ALUT_ERROR_NO_CURRENT_CONTEXT - ALUT_ERROR_AL_ERROR_ON_ENTRY - ALUT_ERROR_ALC_ERROR_ON_ENTRY - ALUT_ERROR_GEN_BUFFERS - ALUT_ERROR_BUFFER_DATA ```