<Project>
  <PropertyGroup>
    <EmscriptenPythonToolsPath>$(MSBuildThisFileDirectory)..\tools\</EmscriptenPythonToolsPath>

    <EmscriptenPythonBinPath Condition="!$([MSBuild]::IsOSPlatform('WINDOWS'))">$(EmscriptenPythonToolsPath)bin\</EmscriptenPythonBinPath>
    <!-- On windows, emsdk has python binary in the tools folder, instead of `bin/` -->
    <EmscriptenPythonBinPath Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">$(EmscriptenPythonToolsPath)</EmscriptenPythonBinPath>

    <_EmscriptenPython Condition="!$([MSBuild]::IsOSPlatform('WINDOWS'))">$(EmscriptenPythonBinPath)\python3</_EmscriptenPython>
    <_EmscriptenPython Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))" >$(EmscriptenPythonBinPath)\python.exe</_EmscriptenPython>
  </PropertyGroup>

  <ItemGroup>
    <EmscriptenPrependPATH Include="$(EmscriptenPythonBinPath)" />
    <EmscriptenEnvVars Include="EMSDK_PYTHON=$(_EmscriptenPython)" />

    <!--
      Python defaults to the system charset, and thus expects the files it's reading to
      match that. But that might not always be true. Eg. system charset=gbk, failing to read
      utf-8 files
      See https://github.com/dotnet/runtime/issues/53367 for the motivating issue
    -->
    <EmscriptenEnvVars Include="PYTHONUTF8=1" />
  </ItemGroup>
</Project>
