diff --git a/native/wasm/build.cake b/native/wasm/build.cake index dd3ad005..2c54effc 100644 --- a/native/wasm/build.cake +++ b/native/wasm/build.cake @@ -5,6 +5,12 @@ DirectoryPath OUTPUT_PATH = MakeAbsolute(ROOT_PATH.Combine("output/native")); string SUPPORT_GPU_VAR = Argument("supportGpu", EnvironmentVariable("SUPPORT_GPU") ?? "true").ToLower(); string EMSCRIPTEN_VERSION = Argument("emscriptenVersion", EnvironmentVariable("EMSCRIPTEN_VERSION") ?? "").ToLower(); +string[] EMSCRIPTEN_FEATURES = + Argument("emscriptenFeatures", EnvironmentVariable("EMSCRIPTEN_FEATURES") ?? "") + .ToLower() + .Split(",") + .Where(f => f != "none") + .ToArray(); bool SUPPORT_GPU = SUPPORT_GPU_VAR == "1" || SUPPORT_GPU_VAR == "true"; string CC = Argument("cc", "emcc"); @@ -17,6 +23,7 @@ Task("libSkiaSharp") .WithCriteria(IsRunningOnLinux()) .Does(() => { + bool hasSimdEnabled = EMSCRIPTEN_FEATURES.Contains("simd"); GnNinja($"wasm", "SkiaSharp", $"target_os='linux' " + @@ -51,10 +58,11 @@ Task("libSkiaSharp") $"use_PIC=false " + $"extra_cflags=[ " + $" '-DSKIA_C_DLL', '-DXML_POOR_ENTROPY', " + - $" '-DSKNX_NO_SIMD', '-DSK_DISABLE_AAA', '-DGR_GL_CHECK_ALLOC_WITH_GET_ERROR=0', " + + $" {(!hasSimdEnabled ? "'-DSKNX_NO_SIMD', " : "")} '-DSK_DISABLE_AAA', '-DGR_GL_CHECK_ALLOC_WITH_GET_ERROR=0', " + $" '-s', 'WARN_UNALIGNED=1' " + // '-s', 'USE_WEBGL2=1' (experimental) $"] " + - $"extra_cflags_cc=[ '-frtti' ] " + + // SIMD support is based on https://github.com/google/skia/blob/1f193df9b393d50da39570dab77a0bb5d28ec8ef/modules/canvaskit/compile.sh#L57 + $"extra_cflags_cc=[ '-frtti' { (hasSimdEnabled ? ", '-msimd128'" : "") } ] " + COMPILERS + ADDITIONAL_GN_ARGS); @@ -88,6 +96,8 @@ Task("libSkiaSharp") var outDir = OUTPUT_PATH.Combine($"wasm"); if (!string.IsNullOrEmpty(EMSCRIPTEN_VERSION)) outDir = outDir.Combine("libSkiaSharp.a").Combine(EMSCRIPTEN_VERSION); + if (EMSCRIPTEN_FEATURES.Length != 0) + outDir = outDir.Combine(string.Join(",", EMSCRIPTEN_FEATURES)); EnsureDirectoryExists(outDir); CopyFileToDirectory(a, outDir); }); diff --git a/scripts/azure-templates-stages.yml b/scripts/azure-templates-stages.yml index 02ec35c1..20397551 100644 --- a/scripts/azure-templates-stages.yml +++ b/scripts/azure-templates-stages.yml @@ -368,13 +368,26 @@ stages: vmImage: ${{ parameters.VM_IMAGE_LINUX_NATIVE }} artifactName: native emscripten: - - 2.0.5 - - 2.0.6 - - 2.0.9 - - 2.0.11 - - 2.0.12 - - 2.0.23 - - 3.1.7 + - 2.0.6: + displayName: 2.0.6 + version: 2.0.6 + features: none + - 2.0.23: + displayName: 2.0.23 + version: 2.0.23 + features: none + - 3.1.7: + displayName: 3.1.7 + version: 3.1.7 + features: none + - 3.1.12: + displayName: 3.1.12 + version: 3.1.12 + features: st + - 3.1.12: + displayName: '3.1.12_SIMD' + version: 3.1.12 + features: simd - ${{ if ne(parameters.buildPipelineType, 'tests') }}: - stage: managed diff --git a/scripts/azure-templates-wasm-matrix.yml b/scripts/azure-templates-wasm-matrix.yml index 5386a2bb..52730c71 100644 --- a/scripts/azure-templates-wasm-matrix.yml +++ b/scripts/azure-templates-wasm-matrix.yml @@ -9,15 +9,15 @@ jobs: - ${{ each version in parameters.emscripten }}: - template: azure-templates-bootstrapper.yml parameters: - name: native_wasm_${{ replace(version, '.', '_') }}_linux - displayName: WASM (${{ version }}) + name: native_wasm_${{ replace(version.displayName, '.', '_') }}_linux + displayName: WASM (${{ version.displayName }}) buildExternals: ${{ parameters.buildExternals }} buildPipelineType: ${{ parameters.buildPipelineType }} vmImage: ${{ parameters.vmImage }} docker: scripts/Docker/wasm target: externals-wasm - dockerArgs: --build-arg EMSCRIPTEN_VERSION=${{ version }} - additionalArgs: --emscriptenVersion=${{ version }} + dockerArgs: --build-arg EMSCRIPTEN_VERSION=${{ version.version }} + additionalArgs: --emscriptenVersion=${{ version.version }} --emscriptenFeatures="${{ version.features }}" artifactName: ${{ parameters.artifactName }} postBuildSteps: - task: PublishBuildArtifacts@1