File tree Expand file tree Collapse file tree 4 files changed +156
-0
lines changed
Expand file tree Collapse file tree 4 files changed +156
-0
lines changed Original file line number Diff line number Diff line change 1+ # Misc Docs
2+
3+ ## Configuration Files
4+
5+ ### ` plugins.json `
6+
7+ ``` json
8+ {
9+ "plugins" : {
10+ "plugin" : {
11+ "dir" : " path-to-plugin" ,
12+ "target" : " cmake-target" ,
13+ "test" : " cmake-target-to-test" ,
14+ "options" : " required-cmake-options" ,
15+ "platforms" : {
16+ "some-os_arch" : {},
17+ "another-os_arch" : {
18+ "options" : " platform-specific-cmake-options"
19+ }
20+ }
21+ }
22+ },
23+ "platforms" : {
24+ "os_arch" : {
25+ "runner" : " github-runner" ,
26+ "docker_tag" : " wasmedge/wasmedge:tag-here" ,
27+ "asset_tag" : " os-arch"
28+ }
29+ }
30+ }
31+ ```
Original file line number Diff line number Diff line change 1+ {
2+ "plugins" : {
3+ "wasi_crypto" : {
4+ "dir" : " wasi_crypto" ,
5+ "target" : " wasmedgePluginWasiCrypto" ,
6+ "test" : " wasiCryptoTests" ,
7+ "options" : " -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON" ,
8+ "platforms" : {
9+ "manylinux_2_28_x86_64" : {},
10+ "ubuntu_2004_x86_64" : {}
11+ }
12+ },
13+ "wasi_nn-openvino" : {
14+ "dir" : " wasi_nn" ,
15+ "target" : " wasmedgePluginWasiNN" ,
16+ "test" : " wasiNNTests" ,
17+ "options" : " -DWASMEDGE_PLUGIN_WASI_NN_BACKEND=OpenVINO" ,
18+ "platforms" : {
19+ "ubuntu_2004_x86_64" : {}
20+ }
21+ },
22+ "wasmedge_stablediffusion" : {
23+ "dir" : " wasmedge_stablediffusion" ,
24+ "target" : " wasmedgePluginWasmEdgeStableDiffusion" ,
25+ "test" : " wasmedgeStableDiffusionTests" ,
26+ "options" : " -DWASMEDGE_PLUGIN_STABLEDIFFUSION=ON" ,
27+ "platforms" : {
28+ "macos_arm64" : {
29+ "options" : " -DWASMEDGE_PLUGIN_STABLEDIFFUSION_METAL=ON"
30+ },
31+ "manylinux_2_28_x86_64" : {}
32+ }
33+ }
34+ },
35+ "platforms" : {
36+ "macos_arm64" : {
37+ "runner" : " macos-14" ,
38+ "asset_tag" : " darwin_23-arm64"
39+ },
40+ "manylinux_2_28_x86_64" : {
41+ "runner" : " ubuntu-latest" ,
42+ "docker_tag" : " manylinux_2_28_x86_64-plugins-deps" ,
43+ "asset_tag" : " manylinux_2_28_x86_64"
44+ }
45+ }
46+ }
Original file line number Diff line number Diff line change 1+ module . exports . parse = ( config ) => {
2+ let map = new Map ( ) ;
3+ for ( const [ platform_key , platform ] of Object . entries ( config . platforms ) ) {
4+ map . set ( platform_key , Object . entries ( config . plugins )
5+ . map ( ( [ plugin_key , plugin ] ) => {
6+ let specific = plugin . platforms [ platform_key ] ;
7+ if ( undefined == specific )
8+ return undefined ;
9+ let copy = { ...plugin , ...platform } ;
10+ delete copy . platforms ;
11+ copy . plugin = plugin_key ;
12+ copy . options = [ plugin . options , specific . options ] . join ( " " ) ;
13+ return copy ;
14+ } )
15+ . filter ( ( plugin ) => undefined != plugin ) ) ;
16+ }
17+ return Object . fromEntries ( map ) ;
18+ } ;
19+
20+ if ( require . main === module ) {
21+ const { parse } = module . exports ;
22+ const fs = require ( "fs" ) ;
23+ const s = fs . readFileSync ( "plugins.json" ) ;
24+ const o = JSON . parse ( s ) ;
25+ let config = parse ( o ) ;
26+ console . log ( JSON . stringify ( config ) ) ;
27+ }
Original file line number Diff line number Diff line change 1+ ---
2+ name : Parse
3+
4+ on :
5+ pull_request :
6+ branches : [main]
7+ paths :
8+ - ' .github/plugins.json'
9+ - ' .github/scripts/parse-plugins.js'
10+ - ' .github/workflows/parse-plugins.yml'
11+
12+ workflow_call :
13+ inputs :
14+ workflow_call : # workaround to distinguish ${{ github.event }}
15+ type : boolean
16+ default : true
17+ outputs :
18+ plugins :
19+ value : ${{ jobs.parse.outputs.plugins }}
20+
21+ jobs :
22+ parse :
23+ name : Parse configuration file
24+ runs-on : ubuntu-latest
25+ outputs :
26+ plugins : ${{ steps.readfile.outputs.plugins }}
27+ steps :
28+ - uses : actions/checkout@v4
29+ - id : readfile
30+ uses : actions/github-script@v7
31+ with :
32+ result-encoding : string
33+ script : |
34+ const { parse } = require(".github/scripts/parse-plugins.js");
35+ const fs = require("fs");
36+ const s = fs.readFileSync(".github/plugins.json");
37+ const config = parse(JSON.parse(s));
38+ core.setOutput("plugins", config);
39+
40+ test :
41+ if : ${{ !inputs.workflow_call }}
42+ needs : parse
43+ name : Self-testing
44+ runs-on : ubuntu-latest
45+ steps :
46+ - name : Get wasi_crypto target
47+ run : |
48+ echo "target=$(echo '${{ needs.parse.outputs.plugins }}' | jq '.manylinux_2_28_x86_64[] | select(.plugin == "wasi_crypto") | .target')" >> "${GITHUB_ENV}"
49+ - name : Check wasi_crypto target
50+ run : |
51+ echo "${target}"
52+ test "${target}" = '"wasmedgePluginWasiCrypto"'
You can’t perform that action at this time.
0 commit comments