From 9563e0654fac686f0fe09cfdc39b427b5e3e7cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Sun, 11 Sep 2022 23:52:01 +0000 Subject: [PATCH] rework web scripts --- .gitignore | 1 + host_web.sh | 17 ----------------- run_web.sh | 5 ----- web/bind.sh | 18 ++++++++++++++++++ web/build.sh | 11 +++++++++++ deploy_web.sh => web/deploy.sh | 12 ++++++------ web/host.sh | 13 +++++++++++++ setup_web.sh => web/setup.sh | 0 8 files changed, 49 insertions(+), 28 deletions(-) delete mode 100755 host_web.sh delete mode 100755 run_web.sh create mode 100755 web/bind.sh create mode 100755 web/build.sh rename deploy_web.sh => web/deploy.sh (83%) create mode 100755 web/host.sh rename setup_web.sh => web/setup.sh (100%) diff --git a/.gitignore b/.gitignore index cdddd9d..05bf80c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ build_rel build_web emsdk deploy_web +run_web butler screenshots build.bat diff --git a/host_web.sh b/host_web.sh deleted file mode 100755 index 21eefce..0000000 --- a/host_web.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# Run as "source web_host.sh" to set up environment variables - -# Prompt for URL -read -p "Enter URL: " URL - -# Expose URL to environment -export ECO2D_SERVER_URL=${URL/https:\/\//}build_web -echo ${ECO2D_SERVER_URL} - -# Symlink sources -if [ ! -d "build_web/${ECO2D_SERVER_URL}" ]; then - mkdir -p "build_web/${ECO2D_SERVER_URL}" - pushd build_web - ln -s "/workspaces/eco2d/code" "${ECO2D_SERVER_URL/build_web/}/code" - popd -fi diff --git a/run_web.sh b/run_web.sh deleted file mode 100755 index d988bde..0000000 --- a/run_web.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -xe - -python -m http.server --directory build_web --bind 127.0.0.1 diff --git a/web/bind.sh b/web/bind.sh new file mode 100755 index 0000000..394fda3 --- /dev/null +++ b/web/bind.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Run as "source web/host.sh" to set up environment variables + +# Prompt for URL +read -p "Enter URL: " URL + +# Expose URL to environment +export ECO2D_SERVER_URL=${URL/https:\/\//}run_web +echo ${ECO2D_SERVER_URL} + +# Symlink sources +if [ ! -d "run_web/${ECO2D_SERVER_URL}" ]; then + mkdir -p "run_web/${ECO2D_SERVER_URL/run_/build_}" + pushd run_web + ln -s "/workspaces/eco2d/code" "${ECO2D_SERVER_URL/run_web/}/code" + ln -s "/workspaces/eco2d/build_web/_deps" "${ECO2D_SERVER_URL/run_web/}build_web/_deps" + popd +fi diff --git a/web/build.sh b/web/build.sh new file mode 100755 index 0000000..ff962fa --- /dev/null +++ b/web/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -xe + +cmake --build build_web --parallel + +pushd build_web +if [ -f "eco2d.html" ]; then + mv eco2d.html index.html +fi +popd diff --git a/deploy_web.sh b/web/deploy.sh similarity index 83% rename from deploy_web.sh rename to web/deploy.sh index 4e0eefc..50345b5 100755 --- a/deploy_web.sh +++ b/web/deploy.sh @@ -20,10 +20,12 @@ if [ ! -d "butler" ]; then fi # Build web -if [ -f "build_web/eco2d.html" ]; then - rm -rf build_web/eco2d.html +if [ -f "build_web/index.html" ]; then + rm -rf build_web/index.html fi -cmake --build build_web + +# Build the project +web/build.sh # Package all assets if [ ! -f "build_web/eco2d.html" ]; then @@ -33,9 +35,7 @@ fi mkdir deploy_web cp build_web/eco2d.* deploy_web/ -pushd deploy_web/ - mv eco2d.html index.html -popd +cp buiid_web/index.html deploy_web/ # Deploy to itch.io ./butler/butler push deploy_web/ zaklaus/eco2d:html-latest diff --git a/web/host.sh b/web/host.sh new file mode 100755 index 0000000..0400b26 --- /dev/null +++ b/web/host.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -xe + +if [ -d "run_web" ]; then + rm -rf run_web +fi + +mkdir run_web +cp build_web/eco2d.* run_web/ +cp build_web/index.html run_web/ + +python -m http.server --directory run_web --bind 127.0.0.1 diff --git a/setup_web.sh b/web/setup.sh similarity index 100% rename from setup_web.sh rename to web/setup.sh