VPN termux about China.net

Webasembly no.1

 step 1 login to github and open new project call wasm 


Step 2. Upload c/c++ file hello Word 
Step 3. Pull "actions" 

Step 4. Workflow yourself 

Step 5. main.yml

name: Compile C to WebAssembly

on:

  push:

    branches:

      - main

jobs:

  build:

    runs-on: ubuntu-latest

    steps:

      - name: Checkout repository

        uses: actions/checkout@v4

      - name: Install Emscripten

        run: |

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

          cd emsdk

          ./emsdk install latest

          ./emsdk activate latest

          source ./emsdk_env.sh

        shell: bash


      - name: Compile C to WebAssembly

        run: |

          source emsdk/emsdk_env.sh

          emcc hello.c -o hello.html

        shell: bash


      - name: Upload WebAssembly files

        uses: actions/upload-artifact@v4

        with:

          name: wasm

          path: hello.*

Step 6. Comitchanges and actions >
Step 7. The files hello.js, hello.wasm, and hello.html have been generated, but a server is required to run them. You can quickly start one using python3 -m http.server.
Step 8. Download files 


All hello.c wasm project -> Wasm no.1


No comments:

Post a Comment