|
79 | 79 | - uses: subosito/flutter-action@v2 |
80 | 80 | with: |
81 | 81 | channel: stable |
82 | | - - run: cd example && flutter build windows |
| 82 | + - uses: ilammy/msvc-dev-cmd@v1 |
| 83 | + |
| 84 | + - name: Verify /utf-8 is set for MSVC in windows/CMakeLists.txt |
| 85 | + shell: bash |
| 86 | + run: | |
| 87 | + grep -q '/utf-8' windows/CMakeLists.txt \ |
| 88 | + || { echo "::error::windows/CMakeLists.txt is missing /utf-8 — see chinese-pc-compat.md"; exit 1; } |
| 89 | +
|
| 90 | + - name: Verify ci/cp936_repro.cpp covers every non-ASCII char in windows/ |
| 91 | + shell: bash |
| 92 | + run: python ci/check_unicode_inventory.py |
| 93 | + |
| 94 | + - name: Verify ci/cp936_repro.cpp has no UTF-8 BOM |
| 95 | + shell: bash |
| 96 | + run: | |
| 97 | + bom=$(head -c 3 ci/cp936_repro.cpp | od -An -tx1 | tr -d ' \n') |
| 98 | + if [ "$bom" = "efbbbf" ]; then |
| 99 | + echo "::error::ci/cp936_repro.cpp must not have a BOM (MSVC would auto-detect UTF-8 and bypass /source-charset:.936)" |
| 100 | + exit 1 |
| 101 | + fi |
| 102 | + echo "OK: no BOM" |
| 103 | +
|
| 104 | + - name: CP936 simulation without /utf-8 must fail with C4819/C2220 |
| 105 | + shell: cmd |
| 106 | + run: | |
| 107 | + cl /c /WX /source-charset:.936 /execution-charset:.936 /nologo ci\cp936_repro.cpp > cl.log 2>&1 |
| 108 | + set CL_EXIT=%errorlevel% |
| 109 | + type cl.log |
| 110 | + if %CL_EXIT% equ 0 ( |
| 111 | + echo ::error::Expected C4819/C2220 but compile succeeded — CP936 simulation is not triggering the bug |
| 112 | + exit /b 1 |
| 113 | + ) |
| 114 | + findstr /c:"C4819" cl.log >nul |
| 115 | + if errorlevel 1 ( |
| 116 | + echo ::error::cl.exe failed but did not emit C4819 — test is not reproducing the real bug |
| 117 | + exit /b 1 |
| 118 | + ) |
| 119 | + findstr /c:"C2220" cl.log >nul |
| 120 | + if errorlevel 1 ( |
| 121 | + echo ::error::cl.exe failed but did not emit C2220 — /WX promotion is not working as expected |
| 122 | + exit /b 1 |
| 123 | + ) |
| 124 | + echo OK: CP936 simulation reproduced C4819/C2220 as expected |
| 125 | + exit /b 0 |
| 126 | +
|
| 127 | + # Note: MSVC refuses `/source-charset:.936` together with `/utf-8` |
| 128 | + # (error D8016: options are incompatible). On a real Chinese Windows |
| 129 | + # host, CP936 is NOT a flag — it's an implicit default from GetACP(). |
| 130 | + # `/utf-8` overrides that implicit default. We prove the fix in two |
| 131 | + # independent invocations: the previous step shows CP936 is hostile |
| 132 | + # to our bytes; this step shows `/utf-8` makes MSVC read them as UTF-8 |
| 133 | + # and compile cleanly with /WX. Together they imply that on a real |
| 134 | + # CP936 host, adding `/utf-8` switches MSVC from CP936-mode (fail) |
| 135 | + # to UTF-8-mode (pass). |
| 136 | + - name: Compile with /utf-8 must succeed (proves /utf-8 resolves our chars) |
| 137 | + shell: cmd |
| 138 | + run: cl /c /WX /utf-8 /nologo ci\cp936_repro.cpp |
| 139 | + |
| 140 | + - name: Build the example (generates the plugin vcxproj) |
| 141 | + run: cd example && flutter build windows |
| 142 | + |
| 143 | + - name: Verify /utf-8 is threaded into the generated plugin vcxproj |
| 144 | + shell: bash |
| 145 | + run: | |
| 146 | + vcxproj=$(find example/build/windows -name 'camera_desktop_plugin.vcxproj' | head -n1) |
| 147 | + if [ -z "$vcxproj" ]; then |
| 148 | + echo "::error::camera_desktop_plugin.vcxproj not found under example/build/windows" |
| 149 | + find example/build/windows -name '*.vcxproj' || true |
| 150 | + exit 1 |
| 151 | + fi |
| 152 | + echo "Inspecting: $vcxproj" |
| 153 | + if ! grep -q '/utf-8' "$vcxproj"; then |
| 154 | + echo "::error::/utf-8 missing from $vcxproj — CMake did not thread the flag through" |
| 155 | + echo "--- vcxproj contents ---" |
| 156 | + cat "$vcxproj" |
| 157 | + exit 1 |
| 158 | + fi |
| 159 | + echo "OK: /utf-8 present in $vcxproj" |
0 commit comments