From f32ad08ac4a7047e04706be97191ad0a976e6b27 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Mon, 11 Oct 2021 15:47:47 -0400 Subject: [PATCH] [infra] Deduplicate serve.py Change-Id: I25bd987faedd7e9c322bcec487ab07583bad6b9a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/458197 Reviewed-by: Erik Rose --- experimental/skottiekit/Makefile | 2 +- experimental/tskit/Makefile | 2 +- experimental/tskit/serve.py | 21 ------------------- experimental/wasm-skp-debugger/serve.py | 21 ------------------- modules/canvaskit/Makefile | 2 +- modules/canvaskit/serve.py | 21 ------------------- .../wasm_tools/SIMD/build_simd_test.sh | 2 +- modules/pathkit/Makefile | 8 +++---- modules/pathkit/compile.sh | 4 ---- modules/pathkit/serve.py | 21 ------------------- .../serve.py => tools/serve_wasm.py | 2 ++ 11 files changed, 10 insertions(+), 96 deletions(-) delete mode 100644 experimental/tskit/serve.py delete mode 100644 experimental/wasm-skp-debugger/serve.py delete mode 100644 modules/canvaskit/serve.py delete mode 100644 modules/pathkit/serve.py rename experimental/skottiekit/serve.py => tools/serve_wasm.py (86%) diff --git a/experimental/skottiekit/Makefile b/experimental/skottiekit/Makefile index 5eb22a5343..452d16b41f 100644 --- a/experimental/skottiekit/Makefile +++ b/experimental/skottiekit/Makefile @@ -45,4 +45,4 @@ clean_npm: serve: echo "Go check out http://localhost:8001/" - cd examples && python3 ../serve.py + cd examples && python3 python3 ../../../tools/serve_wasm.py diff --git a/experimental/tskit/Makefile b/experimental/tskit/Makefile index 6eec614a15..5661878ef5 100644 --- a/experimental/tskit/Makefile +++ b/experimental/tskit/Makefile @@ -16,7 +16,7 @@ release: serve: echo "Go check out http://localhost:8000/npm_build/example.html" - python3 serve.py + python3 ../../tools/serve_wasm.py lint: npx eslint . --ext .ts diff --git a/experimental/tskit/serve.py b/experimental/tskit/serve.py deleted file mode 100644 index a3e1f26877..0000000000 --- a/experimental/tskit/serve.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2018 Google LLC -# -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import http.server -import socketserver - -PORT = 8000 - -class Handler(http.server.SimpleHTTPRequestHandler): - pass - -Handler.extensions_map['.js'] = 'application/javascript' -# Without the correct MIME type, async compilation doesn't work -Handler.extensions_map['.wasm'] = 'application/wasm' - -httpd = socketserver.TCPServer(("", PORT), Handler) - -httpd.serve_forever() diff --git a/experimental/wasm-skp-debugger/serve.py b/experimental/wasm-skp-debugger/serve.py deleted file mode 100644 index a3e1f26877..0000000000 --- a/experimental/wasm-skp-debugger/serve.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2018 Google LLC -# -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import http.server -import socketserver - -PORT = 8000 - -class Handler(http.server.SimpleHTTPRequestHandler): - pass - -Handler.extensions_map['.js'] = 'application/javascript' -# Without the correct MIME type, async compilation doesn't work -Handler.extensions_map['.wasm'] = 'application/wasm' - -httpd = socketserver.TCPServer(("", PORT), Handler) - -httpd.serve_forever() diff --git a/modules/canvaskit/Makefile b/modules/canvaskit/Makefile index 1019f967ea..44e326a751 100644 --- a/modules/canvaskit/Makefile +++ b/modules/canvaskit/Makefile @@ -98,7 +98,7 @@ local-example: mkdir -p node_modules ln -s ../npm_build node_modules/canvaskit echo "Go check out http://localhost:8000/npm_build/example.html" - python3 serve.py + python3 ../../tools/serve_wasm.py test-continuous: echo "Assuming npm ci has been run by user" diff --git a/modules/canvaskit/serve.py b/modules/canvaskit/serve.py deleted file mode 100644 index a3e1f26877..0000000000 --- a/modules/canvaskit/serve.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2018 Google LLC -# -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import http.server -import socketserver - -PORT = 8000 - -class Handler(http.server.SimpleHTTPRequestHandler): - pass - -Handler.extensions_map['.js'] = 'application/javascript' -# Without the correct MIME type, async compilation doesn't work -Handler.extensions_map['.wasm'] = 'application/wasm' - -httpd = socketserver.TCPServer(("", PORT), Handler) - -httpd.serve_forever() diff --git a/modules/canvaskit/wasm_tools/SIMD/build_simd_test.sh b/modules/canvaskit/wasm_tools/SIMD/build_simd_test.sh index 69f8cb615d..8c017c2b18 100755 --- a/modules/canvaskit/wasm_tools/SIMD/build_simd_test.sh +++ b/modules/canvaskit/wasm_tools/SIMD/build_simd_test.sh @@ -33,4 +33,4 @@ grep -f wasm_simd_types.txt output/simd_test.wat # Serve the compiled WASM so output can be manually inspected for correctness. echo "Go check out http://localhost:8000/output/simd_test.html in Chrome Canary 86.0.4186.0 \ or later and enable the chrome://flags#enable-webassembly-simd flag!" -python3 ../../serve.py +python3 ../../../../tools/serve_wasm.py diff --git a/modules/pathkit/Makefile b/modules/pathkit/Makefile index 10495ecec7..5260093b3f 100644 --- a/modules/pathkit/Makefile +++ b/modules/pathkit/Makefile @@ -109,7 +109,7 @@ npm-debug: example: npm install pathkit-asmjs pathkit-wasm echo "Go check out localhost:8000/npm-wasm/example.html" - python3 serve.py + python3 ../../tools/serve_wasm.py local-example: rm -rf node_modules/pathkit-wasm @@ -119,7 +119,7 @@ local-example: ln -s -T ../npm-asmjs node_modules/pathkit-asmjs echo "Go check out http://localhost:8000/npm-wasm/example.html" echo "or http://localhost:8000/npm-asmjs/example.html" - python3 serve.py + python3 ../../tools/serve_wasm.py local-example-test: rm -rf node_modules/pathkit-wasm @@ -130,7 +130,7 @@ local-example-test: ln -s -T ../../npm-asmjs/bin/test node_modules/pathkit-asmjs/bin echo "Go check out localhost:8000/npm-wasm/example.html" echo "or http://localhost:8000/npm-asmjs/example.html" - python3 serve.py + python3 ../../tools/serve_wasm.py local-example-debug: rm -rf node_modules/pathkit-wasm @@ -141,5 +141,5 @@ local-example-debug: ln -s -T ../../npm-asmjs/bin/debug node_modules/pathkit-asmjs/bin echo "Go check out localhost:8000/npm-wasm/example.html" echo "or http://localhost:8000/npm-asmjs/example.html" - python3 serve.py + python3 ../../tools/serve_wasm.py diff --git a/modules/pathkit/compile.sh b/modules/pathkit/compile.sh index 01c1f42db3..d45496669f 100755 --- a/modules/pathkit/compile.sh +++ b/modules/pathkit/compile.sh @@ -125,8 +125,4 @@ $OUTPUT \ $BASE_DIR/pathkit_wasm_bindings.cpp \ ${BUILD_DIR}/libpathkit.a -if [[ $@ == *serve* ]]; then - pushd $BUILD_DIR - python3 serve.py -fi diff --git a/modules/pathkit/serve.py b/modules/pathkit/serve.py deleted file mode 100644 index a3e1f26877..0000000000 --- a/modules/pathkit/serve.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2018 Google LLC -# -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import http.server -import socketserver - -PORT = 8000 - -class Handler(http.server.SimpleHTTPRequestHandler): - pass - -Handler.extensions_map['.js'] = 'application/javascript' -# Without the correct MIME type, async compilation doesn't work -Handler.extensions_map['.wasm'] = 'application/wasm' - -httpd = socketserver.TCPServer(("", PORT), Handler) - -httpd.serve_forever() diff --git a/experimental/skottiekit/serve.py b/tools/serve_wasm.py similarity index 86% rename from experimental/skottiekit/serve.py rename to tools/serve_wasm.py index a3e1f26877..57bc133185 100644 --- a/experimental/skottiekit/serve.py +++ b/tools/serve_wasm.py @@ -3,6 +3,8 @@ # # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +# +# This is a simple webserver that applies the correct MIME type for .wasm files. import http.server import socketserver