Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,30 @@ jobs:
steps:
- test-sockets-chrome

build-windows-launcher:
executor:
name: win/server-2022
shell: bash.exe -eo pipefail
steps:
- checkout
- run:
name: "build pylauncher"
shell: cmd.exe
command: .circleci\setup_vs2022.bat && cd tools\pylauncher && call build.bat
- store_artifacts:
path: tools/pylauncher/pylauncher.exe
destination: pylauncher.exe
- install-emsdk
- pip-install:
python: "$EMSDK_PYTHON"
- run:
name: "create_entry_points"
command: tools/maint/create_entry_points.py --exe-files
- run:
name: "crossplatform tests"
command: test/runner.exe core0.test_hello_world


# windows and mac do not have separate build and test jobs, as they only run
# a limited set of tests; it is simpler and faster to do it all in one job.
test-windows:
Expand All @@ -1274,6 +1298,10 @@ jobs:
EMTEST_BROWSER: "0"
steps:
- checkout
- run:
name: Build launcher
command: call .circleci\setup_vs2019.bat && cd tools\pylauncher && call build.bat
shell: cmd.exe
- run:
name: Install packages
command: |
Expand All @@ -1283,9 +1311,6 @@ jobs:
- install-emsdk
- pip-install:
python: "$EMSDK_PYTHON"
# run-tests depends on the ./test/runner script which is normally only
# created on UNIX systems (windows uses runner.bat)
- run: $EMSDK_PYTHON tools/maint/create_entry_points.py --all
- run:
name: "crossplatform tests"
command: test/runner.bat --crossplatform-only
Expand Down Expand Up @@ -1390,6 +1415,7 @@ workflows:
- test-node-compat
- test-windows
- test-windows-browser-firefox
- build-windows-launcher
- test-mac-arm64:
requires:
- build-linux
4 changes: 4 additions & 0 deletions .circleci/setup_vs2019.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
echo "setting up x64 toolchain"
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
where cl.exe
echo "done"
4 changes: 4 additions & 0 deletions .circleci/setup_vs2022.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
echo "setting up x64 toolchain"
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
where cl.exe
echo "done"
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ coverage.xml
!/tools/run_python.ps1
!/tools/run_python_compiler.ps1

/tools/maint/pylauncher/pylauncher.obj

# Shell scripts (created by ./tools/maint/create_entry_points.py)
em++
emcc
Expand Down Expand Up @@ -88,3 +90,28 @@ emsymbolizer.bat
test/runner.bat
tools/file_packager.bat
tools/webidl_binder.bat

bootstrap.exe
em++.exe
emcc.exe
em-config.exe
emar.exe
embuilder.exe
emcmake.exe
emconfigure.exe
emdump.exe
emdwp.exe
emmake.exe
emnm.exe
empath-split.exe
emprofile.exe
emranlib.exe
emrun.exe
emscan-deps.exe
emscons.exe
emsize.exe
emstrip.exe
emsymbolizer.exe
tools/file_packager.exe
tools/webidl_binder.exe
test/runner.exe
8 changes: 7 additions & 1 deletion cmake/Modules/Platform/Emscripten.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ get_filename_component(EMSCRIPTEN_ROOT_PATH "${EMSCRIPTEN_ROOT_PATH}" ABSOLUTE)
list(APPEND CMAKE_MODULE_PATH "${EMSCRIPTEN_ROOT_PATH}/cmake/Modules")

if (CMAKE_HOST_WIN32)
set(EMCC_SUFFIX ".bat")
# We use windows executables these days rather than `.bat` files, but we
# still support a fallback of using `.bat` files.
if (EXISTS "${EMSCRIPTEN_ROOT_PATH}/emcc.exe")
set(EMCC_SUFFIX ".exe")
else()
set(EMCC_SUFFIX ".bat")
endif()
else()
set(EMCC_SUFFIX "")
endif()
Expand Down
28 changes: 21 additions & 7 deletions tools/maint/create_entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""

import os
import shutil
import stat
import sys

Expand Down Expand Up @@ -61,12 +62,20 @@
}


windows_exe = os.path.join(__rootdir__, 'tools/pylauncher/pylauncher.exe')


def make_executable(filename):
old_mode = stat.S_IMODE(os.stat(filename).st_mode)
os.chmod(filename, old_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)


def main(all_platforms):
def maybe_remove(filename):
if os.path.exists(filename):
os.remove(filename)


def main(all_platforms, use_exe_files):
is_windows = sys.platform.startswith('win')
is_msys2 = 'MSYSTEM' in os.environ
do_unix = all_platforms or not is_windows or is_msys2
Expand Down Expand Up @@ -99,15 +108,20 @@ def generate_entry_points(cmd, path):
make_executable(launcher)

if do_windows:
with open(launcher + '.bat', 'w') as f:
f.write(bat_data)

with open(launcher + '.ps1', 'w') as f:
f.write(ps1_data)
maybe_remove(launcher + '.bat')
maybe_remove(launcher + '.ps1')
maybe_remove(launcher + '.exe')
if use_exe_files:
shutil.copyfile(windows_exe, launcher + '.exe')
else:
with open(launcher + '.bat', 'w') as f:
f.write(bat_data)
with open(launcher + '.ps1', 'w') as f:
f.write(ps1_data)

generate_entry_points(entry_points, os.path.join(__scriptdir__, 'run_python'))
generate_entry_points(compiler_entry_points, os.path.join(__scriptdir__, 'run_python_compiler'))


if __name__ == '__main__':
sys.exit(main('--all' in sys.argv))
sys.exit(main('--all' in sys.argv, '--exe-files' in sys.argv))
11 changes: 11 additions & 0 deletions tools/pylauncher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Windows Python Script Launcher
==============================

This directory contains a simple launcher program for windows which is used to
execute the emscripten compiler entry points using the python interpreter. It
uses the its own name (the name of the currently running executable) to
determine which python script to run and serves the same purpose as the
``run_python.sh`` script does on non-windows platforms.

We build this executable statically using ``/MT`` so that it is maximally
portable.
4 changes: 4 additions & 0 deletions tools/pylauncher/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:: /MT : Statically link to the C runtime library for max portability
:: /O1 : Favor small code (optimization for size)

cl pylauncher.c /Fe:pylauncher.exe /MT /O1
6 changes: 6 additions & 0 deletions tools/pylauncher/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
cd ${SCRIPT_DIR}

x86_64-w64-mingw32-gcc -Werror -static-libgcc -static-libstdc++ -s -Os pylauncher.c -o pylauncher.exe -lshlwapi -lshell32
Loading