Repository: flutter
Issue: Cannot Generate Custom Web Engine Build on Windows
Labels: engine,platform-windows,platform-web,P3,e: local-engine-development,team-web,triaged-web

I want to create a custom build of _specifically_ Web Engine _specifically_ on Windows.

### Expected results
Generated `wasm_release` folder.

### Actual results
Exception in `vs_toolchain.py` while using the `felt` tool as recommended.

---

### Steps to Reproduce:

<details><summary>Engine Development Environment Setup:</summary>

I have set up my Engine development environment [as per this readme](https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment):

- [✔️] `git`
- [✔️] `python3`
- [✔️] `flutter` and `dart`
- [✔️] `depot-tools`
- [✔️] `Visual Studio` (although 2022, not 2017 as was written)
- [✔️] [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/)
- [✔️] `GYP_MSVS_VERSION` enviroment variable is set to `2022`
- [✔️] `GYP_MSVS_OVERRIDE_PATH` environment variable is set to `MY:\path\to\msvs_2022`
- [✔️] `DEPOT_TOOLS_WIN_TOOLCHAIN` environment variable is set to `0`
- [✔️] `src/flutter/lib/web_ui/dev` has beed added to my `path`
---

My folder setup looks kinda like this:

`engine_directory`
├─ `engine`
│         ├─ `.gclient`
│         └─ `...`
└─ `flutter` <-- a separate instance of flutter specifially to pair it with the custom engine build

---

My `.gclient` file content:

```
solutions = [
  {
    "custom_deps": {},
    "deps_file": "DEPS",
    "managed": False,
    "name": "src/flutter",
    "safesync_url": "",
    "url": "git@github.com:antosha-surf/Flutter-Engine.git",
    "custom_vars": {
      "download_emsdk": True,
    },
  },
]
```

</details>

<details><summary>My actions:</summary>

I did `fetch flutter`, set `upstream` and did `gclient sync`

Then, following [these](https://github.com/flutter/flutter/wiki/Compiling-the-engine#compiling-for-the-web-on-windows) instructions:

I did `python .\flutter\tools\gn --unoptimized --full-dart-sdk`

It created `out\host_debug_unopt`

I did `ninja -C .\out\host_debug_unopt`, which filled this `host_debug_unopt` with many built files.

</details>

<details><summary>Using felt tool:</summary>

When using `felt build` from cmd (both regualrly and as Administrator - the results are identical):

```
A:\flutterCustomEngine\engine\src>felt build
Resolving dependencies... (1.4s)
Downloading packages...
  archive 3.4.2 (3.4.10 available)
  collection 1.17.0 (1.18.0 available)
  crypto 3.0.1 (3.0.3 available)
! engine_repo_tools 0.0.0 from path ..\..\tools\pkg\engine_repo_tools (overridden)
  file 6.1.4 (7.0.0 available)
  frontend_server_client 3.2.0 (4.0.0 available)
  http 1.1.0 (1.2.1 available)
  image 3.0.1 (4.1.7 available)
  js 0.6.4 (0.7.1 available)
  matcher 0.12.16 (0.12.16+1 available)
  path 1.8.0 (1.9.0 available)
  petitparser 5.4.0 (6.0.2 available)
  process 4.2.3 (5.0.2 available)
  stack_trace 1.10.0 (1.11.1 available)
  stream_channel 2.1.1 (2.1.2 available)
  test 1.24.8 (1.25.2 available)
  test_api 0.6.1 (0.7.0 available)
  test_core 0.5.8 (0.6.0 available)
  typed_data 1.3.0 (1.3.2 available)
  uuid 4.1.0 (4.3.3 available)
  vm_service 12.0.0 (14.2.0 available)
  webkit_inspection_protocol 1.0.0 (1.2.1 available)
  xml 5.4.1 (6.5.0 available)
  yaml 3.0.0 (3.1.2 available)
Got dependencies!
23 packages have newer versions incompatible with dependency constraints.
Try `dart pub outdated` for more information.
Running gn...
Generating GN files in: out\wasm_release
Traceback (most recent call last):
  File "A:/flutterCustomEngine/engine/src/build/vs_toolchain.py", line 561, in <module>
    sys.exit(main())
  File "A:/flutterCustomEngine/engine/src/build/vs_toolchain.py", line 557, in main
    return commands[sys.argv[1]](*sys.argv[2:])
  File "A:/flutterCustomEngine/engine/src/build/vs_toolchain.py", line 379, in CopyDlls
    raise Exception('Unknown target_cpu: ' + target_cpu)
Exception: Unknown target_cpu: wasm
ERROR at //build/toolchain/win/BUILD.gn:58:3: Script returned non-zero exit code.
  exec_script("//build/vs_toolchain.py",
  ^----------
Current dir: A:/flutterCustomEngine/engine/src/out/wasm_release/
Command: A:/.vpython-root/store/python_venv-feu4nmtoont0shce467kvt509k/contents/Scripts/python3.exe A:/flutterCustomEngine/engine/src/build/vs_toolchain.py copy_dlls A:/flutterCustomEngine/engine/src/out/wasm_release Release wasm
Returned 1.
See //BUILD.gn:5:1: which caused the file to be included.
group("default") {
^------------------
Running autoninja...
ninja: error: loading 'build.ninja':
ninja: Entering directory `A:\flutterCustomEngine\engine\src\out\wasm_release'
Pipeline experienced the following failures:
  "gn": Sub-process failed.
Command: A:\flutterCustomEngine\engine\src\flutter\tools\gn --web --runtime-mode=release
Working directory: A:\flutterCustomEngine\engine\src\flutter\lib\web_ui
Exit code: 1

  "ninja": Sub-process failed.
Command: autoninja -C A:\flutterCustomEngine\engine\src\out\wasm_release
Working directory: A:\flutterCustomEngine\engine\src\flutter\lib\web_ui
Exit code: 1

Test pipeline failed.

A:\flutterCustomEngine\engine\src>
```

So it tries to generate a `wasm_release` output (as expected) but fails.

</details>

---

### Flutter Doctor Output:

<details><summary>FLUTTER DOCTOR OUTPUT</summary>

```
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel main, 3.21.0-7.0.pre.1, on Microsoft Windows [Version 10.0.19042.985], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.5)
[√] Android Studio (version 2023.1)
[√] IntelliJ IDEA Community Edition (version 2023.3)
[√] VS Code (version 1.74.0)
[√] Connected device (3 available)
[√] Network resources
```
</details>

Am I doing something horribly wrong?

Any help is appreciated.

Thanks in advance!