[infra] Port serve.py from Python2 to 3

These scripts are useful when testing WebAssembly locally
because the mimetype impacts how the binaries are loaded.

The porting was achieved by doing the following:
python -m lib2to3 -w -n serve.py


Change-Id: I09673fa881339a9b157c5fc993e190766efcd85e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/443884
Reviewed-by: Erik Rose <erikrose@google.com>
This commit is contained in:
Kevin Lubick 2021-08-31 10:21:57 -04:00
parent 9c975c52d6
commit 29104528cc
12 changed files with 48 additions and 42 deletions

View File

@ -45,4 +45,4 @@ clean_npm:
serve:
echo "Go check out http://localhost:8001/"
cd examples && python ../serve.py
cd examples && python3 ../serve.py

View File

@ -1,20 +1,21 @@
# Copyright 2020 Google LLC
#!/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 SimpleHTTPServer
import SocketServer
import http.server
import socketserver
PORT = 8001
PORT = 8000
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
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 = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()

View File

@ -16,7 +16,7 @@ release:
serve:
echo "Go check out http://localhost:8000/npm_build/example.html"
python2 serve.py
python3 serve.py
lint:
npx eslint . --ext .ts

View File

@ -1,20 +1,21 @@
#!/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 SimpleHTTPServer
import SocketServer
import http.server
import socketserver
PORT = 8000
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
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 = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()

View File

@ -1,20 +1,21 @@
#!/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 SimpleHTTPServer
import SocketServer
import http.server
import socketserver
PORT = 8000
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
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 = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()

View File

@ -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"
python2 serve.py
python3 serve.py
test-continuous:
echo "Assuming npm ci has been run by user"

View File

@ -1,20 +1,21 @@
#!/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 SimpleHTTPServer
import SocketServer
import http.server
import socketserver
PORT = 8000
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
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 = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()

View File

@ -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!"
python ../../serve.py
python3 ../../serve.py

View File

@ -109,7 +109,7 @@ npm-debug:
example:
npm install pathkit-asmjs pathkit-wasm
echo "Go check out localhost:8000/npm-wasm/example.html"
python serve.py
python3 serve.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"
python serve.py
python3 serve.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"
python serve.py
python3 serve.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"
python serve.py
python3 serve.py

View File

@ -127,6 +127,6 @@ ${BUILD_DIR}/libpathkit.a
if [[ $@ == *serve* ]]; then
pushd $BUILD_DIR
python serve.py
python3 serve.py
fi

View File

@ -1,20 +1,21 @@
#!/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 SimpleHTTPServer
import SocketServer
import http.server
import socketserver
PORT = 8000
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
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 = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()

View File

@ -1,20 +1,21 @@
#!/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 SimpleHTTPServer
import SocketServer
import http.server
import socketserver
PORT = 8005
PORT = 8000
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
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 = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()