| 1 | #!/usr/bin/env bash
|
| 2 | #
|
| 3 | # Test bash, python3, C and C++ under Wine!
|
| 4 | #
|
| 5 | # Notes:
|
| 6 | # python3 is called python.exe on Windows
|
| 7 | #
|
| 8 | # Other things to try:
|
| 9 |
|
| 10 | # - python3
|
| 11 | # - test out asyncio on Windows!
|
| 12 | # - especially process creation
|
| 13 | # - a test framework for stdin/stdout/stderr would be nice
|
| 14 | # - can sh_spec.py work with non-shell scripts?
|
| 15 | #
|
| 16 | # - git
|
| 17 | # - can we clone our repo? commit?
|
| 18 | #
|
| 19 | # And then do this all inside QEMU - it seems more automated than VirtualBox
|
| 20 | #
|
| 21 | # - do automated installation of everything?
|
| 22 |
|
| 23 | readonly DIR=_tmp/win32
|
| 24 |
|
| 25 | my-curl() {
|
| 26 | curl --location --continue-at - \
|
| 27 | --remote-name --output-dir $DIR "$@"
|
| 28 | }
|
| 29 |
|
| 30 | download() {
|
| 31 | mkdir -p $DIR
|
| 32 |
|
| 33 | my-curl 'https://www.python.org/ftp/python/3.13.3/python-3.13.3-amd64.exe'
|
| 34 |
|
| 35 | my-curl \
|
| 36 | 'https://github.com/git-for-windows/git/releases/download/v2.49.0.windows.1/Git-2.49.0-64-bit.exe'
|
| 37 |
|
| 38 | my-curl \
|
| 39 | 'https://github.com/jmeubank/tdm-gcc/releases/download/v10.3.0-tdm64-2/tdm64-gcc-10.3.0-2.exe'
|
| 40 | }
|
| 41 |
|
| 42 | find-python() {
|
| 43 | find ~/.wine/drive_c/|grep python.exe
|
| 44 | }
|
| 45 |
|
| 46 | test-python3() {
|
| 47 | # takes 326 ms
|
| 48 | time wine \
|
| 49 | ~/.wine/drive_c/users/andy/AppData/Local/Programs/Python/Python313/python.exe \
|
| 50 | -c 'print("hi")'
|
| 51 | }
|
| 52 |
|
| 53 | readonly BASH=~/'.wine/drive_c/Program Files/Git/bin/bash.exe'
|
| 54 | readonly GIT_BASH=~/'.wine/drive_c/Program Files/Git/git-bash.exe'
|
| 55 |
|
| 56 | test-bash() {
|
| 57 | # 378 ms
|
| 58 | # works, but getting a bunch of warnings
|
| 59 |
|
| 60 | # Hm this respects $PATH, finds python
|
| 61 | time wine "$BASH" -c 'echo "hi from bash"; python.exe -c "print(\"hi from python3\")"'
|
| 62 |
|
| 63 | #time wine "$GIT_BASH" -c 'echo hi'
|
| 64 | }
|
| 65 |
|
| 66 | test-gcc() {
|
| 67 | echo '
|
| 68 | #include <iostream>
|
| 69 | int main() {
|
| 70 | std::cout << "Hello from C++ in Wine!" << std::endl;
|
| 71 | return 0;
|
| 72 | }' > $DIR/hello.cpp
|
| 73 |
|
| 74 | wine cmd /c "g++ $DIR/hello.cpp -o $DIR/hello.exe"
|
| 75 |
|
| 76 | wine $DIR/hello.exe
|
| 77 |
|
| 78 | }
|
| 79 |
|
| 80 | build-create-process() {
|
| 81 | wine cmd /c "g++ win32/create-process.c -o $DIR/create-process.exe"
|
| 82 | }
|
| 83 |
|
| 84 | run-create-process() {
|
| 85 | wine $DIR/create-process.exe
|
| 86 | }
|
| 87 |
|
| 88 | test-powershell() {
|
| 89 | # this doesn't work? It's a stub?
|
| 90 | wine cmd /c 'powershell.exe -Command "Write-Host hello from powershell"'
|
| 91 | }
|
| 92 |
|
| 93 | test-pipelines() {
|
| 94 | #wine cmd /c 'dir win32/demo_asyncio.py'
|
| 95 |
|
| 96 | echo 'UNIX SUBPROCESS'
|
| 97 | win32/demo_subprocess.py
|
| 98 | echo
|
| 99 |
|
| 100 | echo 'UNIX ASYNCIO'
|
| 101 | win32/demo_asyncio.py
|
| 102 | echo
|
| 103 |
|
| 104 | echo 'WIN32 SUBPROCESS'
|
| 105 | wine cmd /c 'python.exe win32/demo_subprocess.py'
|
| 106 | echo
|
| 107 |
|
| 108 | echo 'WIN32 ASYNCIO'
|
| 109 | wine cmd /c 'python.exe win32/demo_asyncio.py'
|
| 110 | }
|
| 111 |
|
| 112 | "$@"
|