Patch public.bzl change from cl/298337962

Bug: b/150386856
Change-Id: Ic200bda7b63f0bde84df4b32e2d7967d8572740c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274541
Reviewed-by: Ben Wagner aka dogben <benjaminwagner@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Nathaniel Nifong <nifong@google.com>
diff --git a/public.bzl b/public.bzl
index 3f871ab..0306284 100644
--- a/public.bzl
+++ b/public.bzl
@@ -20,19 +20,19 @@
         return select(select_dict)
 
 def skia_select(conditions, results):
-    """Replaces select() for conditions [UNIX, ANDROID, IOS]
+    """Replaces select() for conditions [UNIX, ANDROID, IOS, WASM]
 
     Args:
-      conditions: [CONDITION_UNIX, CONDITION_ANDROID, CONDITION_IOS]
-      results: [RESULT_UNIX, RESULT_ANDROID, RESULT_IOS]
+      conditions: [CONDITION_UNIX, CONDITION_ANDROID, CONDITION_IOS, CONDITION_WASM]
+      results: [RESULT_UNIX, RESULT_ANDROID, RESULT_IOS, RESULT_WASM]
     Returns:
       The result matching the platform condition.
     """
-    if len(conditions) != 3 or len(results) != 3:
-        fail("Must provide exactly 3 conditions and 3 results")
+    if len(conditions) != 4 or len(results) != 4:
+        fail("Must provide exactly 4 conditions and 4 results")
 
     selector = {}
-    for i in range(3):
+    for i in range(4):
         selector[conditions[i]] = results[i]
     return portable_select(selector, conditions[2], conditions[0])
 
@@ -378,6 +378,48 @@
     ],
 )
 
+GL_SRCS_WASM = struct(
+    include = [
+        "src/gpu/gl/GrGLMakeNativeInterface_egl.cpp",
+        "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp",
+    ],
+    exclude = [],
+)
+PORTS_SRCS_WASM = struct(
+    include = [
+        "src/ports/**/*.cpp",
+        "src/ports/**/*.h",
+    ],
+    exclude = [
+        # commented lines below left in because they indicate specifically what is
+        # included here and not in other PORTS_SRCS lists.
+        "src/ports/*FontConfig*",
+        "src/ports/*FreeType*",
+        "src/ports/*WIC*",
+        "src/ports/*CG*",
+        "src/ports/*android*",
+        "src/ports/*chromium*",
+        "src/ports/*fontconfig*",
+        "src/ports/*mac*",
+        "src/ports/*mozalloc*",
+        "src/ports/*nacl*",
+        "src/ports/*win*",
+        #"src/ports/SkDebug_stdio.cpp",
+        "src/ports/SkFontMgr_custom.cpp",
+        "src/ports/SkFontMgr_custom_directory.cpp",
+        "src/ports/SkFontMgr_custom_directory_factory.cpp",
+        "src/ports/SkFontMgr_custom_embedded.cpp",
+        "src/ports/SkFontMgr_custom_embedded_factory.cpp",
+        "src/ports/SkFontMgr_custom_empty.cpp",
+        "src/ports/SkFontMgr_custom_empty_factory.cpp",
+        # "src/ports/SkFontMgr_empty_factory.cpp",
+        "src/ports/SkFontMgr_fontconfig_factory.cpp",
+        "src/ports/SkFontMgr_fuchsia.cpp",
+        "src/ports/SkImageGenerator_none.cpp",
+        "src/ports/SkTLS_none.cpp",
+    ],
+)
+
 def base_srcs():
     return skia_glob(BASE_SRCS_ALL)
 
@@ -388,6 +430,7 @@
             skia_glob(PORTS_SRCS_UNIX),
             skia_glob(PORTS_SRCS_ANDROID),
             skia_glob(PORTS_SRCS_IOS),
+            skia_glob(PORTS_SRCS_WASM),
         ],
     )
 
@@ -398,6 +441,7 @@
             skia_glob(GL_SRCS_UNIX),
             skia_glob(GL_SRCS_ANDROID),
             skia_glob(GL_SRCS_IOS),
+            skia_glob(GL_SRCS_WASM),
         ],
     )
 
@@ -562,6 +606,7 @@
             ["tests/FontMgrFontConfigTest.cpp"],
             ["tests/FontMgrAndroidParserTest.cpp"],
             [],
+            [],
         ],
     )
 
@@ -605,6 +650,10 @@
             [
                 "-Wno-implicit-fallthrough",  # Some intentional fallthrough.
             ],
+            # WASM
+            [
+                "-Wno-implicit-fallthrough",  # Some intentional fallthrough.
+            ],
         ],
     )
 
@@ -654,6 +703,17 @@
                 "SK_BUILD_NO_OPTS",
                 "SKNX_NO_SIMD",
             ],
+            # WASM
+            [
+                "SK_DISABLE_LEGACY_SHADERCONTEXT",
+                "SK_DISABLE_TRACING",
+                "GR_GL_CHECK_ALLOC_WITH_GET_ERROR=0",
+                "SK_SUPPORT_GPU=1",
+                "SK_DISABLE_AAA",
+                "SK_DISABLE_EFFECT_DESERIALIZATION",
+                "SK_FORCE_8_BYTE_ALIGNMENT",
+                "SKNX_NO_SIMD",
+            ],
         ],
     )
 
@@ -682,6 +742,8 @@
                 "-framework ImageIO",
                 "-framework MobileCoreServices",
             ],
+            # WASM
+            [],
         ],
     )