forked from emscripten-core/emsdk
    
        
        - 
                Notifications
    You must be signed in to change notification settings 
- Fork 33
          [wasm] move emsdk config and emsdk_env files from runtime to emsdk
          #851
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Closed
      
      
    
  
     Closed
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            3 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,64 +1,75 @@ | ||
| @echo off | ||
|  | ||
| set CURRENT_SCRIPT=%~dp0 | ||
| set EMSDK_PATH=%CURRENT_SCRIPT:~0,-1%\ | ||
|  | ||
| set EMSDK_PYTHON=%EMSDK_PATH%python\python.exe | ||
| set DOTNET_EMSCRIPTEN_LLVM_ROOT=%EMSDK_PATH%bin\ | ||
| set DOTNET_EMSCRIPTEN_NODE_JS=%EMSDK_PATH%node\bin\node | ||
| set DOTNET_EMSCRIPTEN_NODE_PATH=%EMSDK_PATH%node\bin\ | ||
| set DOTNET_EMSCRIPTEN_BINARYEN_ROOT=%EMSDK_PATH% | ||
|  | ||
| @echo off | ||
| echo *** .NET EMSDK path setup *** | ||
|  | ||
| REM emscripten (emconfigure, em++, etc) | ||
| if "%EMSDK_PATH%"=="" ( | ||
| echo %EMSDK_PATH% is empty | ||
| exit /b 1 | ||
| echo %EMSDK_PATH% is empty | ||
| exit /b 1 | ||
| ) | ||
| set "TOADD_PATH_EMSCRIPTEN=%EMSDK_PATH%emscripten" | ||
| echo PATH += %TOADD_PATH_EMSCRIPTEN% | ||
| set "PATH=%TOADD_PATH_EMSCRIPTEN%;%PATH%" | ||
|  | ||
| REM python | ||
| if "%EMSDK_PYTHON%"=="" ( | ||
| echo %EMSDK_PYTHON% is empty | ||
| exit /b 1 | ||
| echo %EMSDK_PYTHON% is empty | ||
| exit /b 1 | ||
| ) | ||
| set "TOADD_PATH_PYTHON=%EMSDK_PYTHON%" | ||
| echo PATH += %TOADD_PATH_PYTHON% | ||
| set "PATH=%TOADD_PATH_PYTHON%;%PATH%" | ||
|  | ||
| REM llvm (clang, etc) | ||
| if "%DOTNET_EMSCRIPTEN_LLVM_ROOT%"=="" ( | ||
| echo %DOTNET_EMSCRIPTEN_LLVM_ROOT% is empty | ||
| exit /b 1 | ||
| echo %DOTNET_EMSCRIPTEN_LLVM_ROOT% is empty | ||
| exit /b 1 | ||
| ) | ||
| set "TOADD_PATH_LLVM=%DOTNET_EMSCRIPTEN_LLVM_ROOT%" | ||
| if not "%TOADD_PATH_EMSCRIPTEN%"=="%TOADD_PATH_LLVM%" ( | ||
| echo PATH += %TOADD_PATH_LLVM% | ||
| set "PATH=%TOADD_PATH_LLVM%;%PATH%" | ||
| echo PATH += %TOADD_PATH_LLVM% | ||
| set "PATH=%TOADD_PATH_LLVM%;%PATH%" | ||
| ) | ||
|  | ||
| REM nodejs (node) | ||
| if "%DOTNET_EMSCRIPTEN_NODE_JS%"=="" ( | ||
| echo %DOTNET_EMSCRIPTEN_NODE_JS% is empty | ||
| exit /b 1 | ||
| echo %DOTNET_EMSCRIPTEN_NODE_JS% is empty | ||
| exit /b 1 | ||
| ) | ||
| if "%DOTNET_EMSCRIPTEN_NODE_PATH%"=="" ( | ||
| echo %DOTNET_EMSCRIPTEN_NODE_PATH% is empty | ||
| exit /b 1 | ||
| echo %DOTNET_EMSCRIPTEN_NODE_PATH% is empty | ||
| exit /b 1 | ||
| ) | ||
| set "TOADD_PATH_NODEJS=%DOTNET_EMSCRIPTEN_NODE_JS%" | ||
| if not "%TOADD_PATH_EMSCRIPTEN%"=="%TOADD_PATH_NODEJS%" ( | ||
| if not "%TOADD_PATH_LLVM%"=="%TOADD_PATH_NODEJS%" ( | ||
| echo NODE PATH += %TOADD_PATH_NODEJS% | ||
| set "PATH=%TOADD_PATH_NODEJS%;%PATH%" | ||
| set "PATH=%DOTNET_EMSCRIPTEN_NODE_PATH%;%PATH%" | ||
| ) | ||
| if not "%TOADD_PATH_LLVM%"=="%TOADD_PATH_NODEJS%" ( | ||
| echo NODE PATH += %TOADD_PATH_NODEJS% | ||
| set "PATH=%TOADD_PATH_NODEJS%;%PATH%" | ||
| set "PATH=%DOTNET_EMSCRIPTEN_NODE_PATH%;%PATH%" | ||
| ) | ||
| ) | ||
|  | ||
| REM binaryen (wasm-opt, etc) | ||
| if "%DOTNET_EMSCRIPTEN_BINARYEN_ROOT%"=="" ( | ||
| echo %DOTNET_EMSCRIPTEN_BINARYEN_ROOT% is empty | ||
| exit /b 1 | ||
| echo %DOTNET_EMSCRIPTEN_BINARYEN_ROOT% is empty | ||
| exit /b 1 | ||
| ) | ||
| set "TOADD_PATH_BINARYEN=%DOTNET_EMSCRIPTEN_BINARYEN_ROOT%bin" | ||
| if not "%TOADD_PATH_EMSCRIPTEN%"=="%TOADD_PATH_BINARYEN%" ( | ||
| if not "%TOADD_PATH_LLVM%"=="%TOADD_PATH_BINARYEN%" ( | ||
| if not "%TOADD_PATH_NODEJS%"=="%TOADD_PATH_BINARYEN%" ( | ||
| echo PATH += %TOADD_PATH_BINARYEN% | ||
| set "PATH=%TOADD_PATH_BINARYEN%;%PATH%" | ||
| if not "%TOADD_PATH_LLVM%"=="%TOADD_PATH_BINARYEN%" ( | ||
| if not "%TOADD_PATH_NODEJS%"=="%TOADD_PATH_BINARYEN%" ( | ||
| echo PATH += %TOADD_PATH_BINARYEN% | ||
| set "PATH=%TOADD_PATH_BINARYEN%;%PATH%" | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,44 +1,98 @@ | ||
| #!/bin/bash | ||
| CURRENT_SCRIPT= | ||
| DIR="." | ||
|  | ||
| # use shell specific method to get the path | ||
| # to the current file being source'd. | ||
| # | ||
| # To add a shell, add another conditional below, | ||
| # then add tests to scripts/test_source_env.sh | ||
|  | ||
| if [ -n "${BASH_SOURCE-}" ]; then | ||
| CURRENT_SCRIPT="$BASH_SOURCE" | ||
| elif [ -n "${ZSH_VERSION-}" ]; then | ||
| CURRENT_SCRIPT="${(%):-%x}" | ||
| elif [ -n "${KSH_VERSION-}" ]; then | ||
| CURRENT_SCRIPT=${.sh.file} | ||
| fi | ||
|  | ||
| if [ -n "${CURRENT_SCRIPT-}" ]; then | ||
| DIR=$(dirname "$CURRENT_SCRIPT") | ||
| if [ -h "$CURRENT_SCRIPT" ]; then | ||
| # Now work out actual DIR since this is part of a symlink. | ||
| # Since we can't be sure that readlink or realpath | ||
| # are available, use tools more likely to be installed. | ||
| # (This will still fail if sed is not available.) | ||
| SYMDIR=$(dirname "$(ls -l "$CURRENT_SCRIPT" | sed -n "s/.*-> //p")") | ||
| if [ -z "$SYMDIR" ]; then | ||
| SYMDIR="." | ||
| fi | ||
| FULLDIR="$DIR/$SYMDIR" | ||
| DIR=$(cd "$FULLDIR" > /dev/null 2>&1; /bin/pwd) | ||
| unset SYMDIR | ||
| unset FULLDIR | ||
| fi | ||
| fi | ||
| unset CURRENT_SCRIPT | ||
|  | ||
| # Verify the emsdk directory | ||
| if [ ! -f "$DIR/emscripten/emcmake.py" ]; then | ||
| echo "Error: unable to determine 'emsdk' directory. Perhaps you are using a shell or" 1>&2 | ||
| echo " environment that this script does not support." 1>&2 | ||
| echo 1>&2 | ||
| echo "A possible solution is to source this script while in the 'emsdk' directory." 1>&2 | ||
| echo 1>&2 | ||
| unset DIR | ||
| return | ||
| fi | ||
|  | ||
| # Set environment variables | ||
| export EMSDK_PATH=${DIR}/ | ||
| unset DIR | ||
|  | ||
| export DOTNET_EMSCRIPTEN_LLVM_ROOT=${EMSDK_PATH}bin/ | ||
| export DOTNET_EMSCRIPTEN_NODE_JS=${EMSDK_PATH}node/bin/node | ||
| export DOTNET_EMSCRIPTEN_BINARYEN_ROOT=${EMSDK_PATH} | ||
|  | ||
| echo "*** .NET EMSDK path setup ***" | ||
|  | ||
| fail_if_empty() { | ||
| local var_name="$1" | ||
| local var_value="${!var_name}" | ||
| if [ -z "${var_value}" ]; then | ||
| echo "/${var_name} is empty" | ||
| exit 1 | ||
| fi | ||
| } | ||
|  | ||
| add_to_path() { | ||
| local dir_path="$1" | ||
| echo "PATH += $dir_path" | ||
| export PATH="$dir_path:$PATH" | ||
| } | ||
|  | ||
| # emscripten (emconfigure, em++, etc) | ||
| if [ -z "${EMSDK_PATH}" ]; then | ||
| echo "\$EMSDK_PATH is empty" | ||
| exit 1 | ||
| fi | ||
| fail_if_empty "EMSDK_PATH" | ||
| TOADD_PATH_EMSCRIPTEN="$(realpath ${EMSDK_PATH}/emscripten)" | ||
| echo "PATH += ${TOADD_PATH_EMSCRIPTEN}" | ||
| export PATH=${TOADD_PATH_EMSCRIPTEN}:$PATH | ||
| add_to_path "$TOADD_PATH_EMSCRIPTEN" | ||
|  | ||
| # llvm (clang, etc) | ||
| if [ -z "${DOTNET_EMSCRIPTEN_LLVM_ROOT}" ]; then | ||
| echo "\$DOTNET_EMSCRIPTEN_LLVM_ROOT is empty" | ||
| exit 1 | ||
| fi | ||
| fail_if_empty "DOTNET_EMSCRIPTEN_LLVM_ROOT" | ||
| TOADD_PATH_LLVM="$(realpath ${DOTNET_EMSCRIPTEN_LLVM_ROOT})" | ||
| if [ "${TOADD_PATH_EMSCRIPTEN}" != "${TOADD_PATH_LLVM}" ]; then | ||
| echo "PATH += ${TOADD_PATH_LLVM}" | ||
| export PATH=${TOADD_PATH_LLVM}:$PATH | ||
| add_to_path "$TOADD_PATH_LLVM" | ||
| fi | ||
|  | ||
| # nodejs (node) | ||
| if [ -z "${DOTNET_EMSCRIPTEN_NODE_JS}" ]; then | ||
| echo "\$DOTNET_EMSCRIPTEN_NODE_JS is empty" | ||
| exit 1 | ||
| fi | ||
| fail_if_empty "DOTNET_EMSCRIPTEN_NODE_JS" | ||
| TOADD_PATH_NODEJS="$(dirname ${DOTNET_EMSCRIPTEN_NODE_JS})" | ||
| if [ "${TOADD_PATH_EMSCRIPTEN}" != "${TOADD_PATH_NODEJS}" ] && [ "${TOADD_PATH_LLVM}" != "${TOADD_PATH_NODEJS}" ]; then | ||
| echo "PATH += ${TOADD_PATH_NODEJS}" | ||
| export PATH=${TOADD_PATH_NODEJS}:$PATH | ||
| add_to_path "$TOADD_PATH_NODEJS" | ||
| fi | ||
|  | ||
| # binaryen (wasm-opt, etc) | ||
| if [ -z "${DOTNET_EMSCRIPTEN_BINARYEN_ROOT}" ]; then | ||
| echo "\$DOTNET_EMSCRIPTEN_BINARYEN_ROOT is empty" | ||
| exit 1 | ||
| fi | ||
| fail_if_empty "DOTNET_EMSCRIPTEN_BINARYEN_ROOT" | ||
| TOADD_PATH_BINARYEN="$(realpath ${DOTNET_EMSCRIPTEN_BINARYEN_ROOT}/bin)" | ||
| if [ "${TOADD_PATH_EMSCRIPTEN}" != "${TOADD_PATH_BINARYEN}" ] && [ "${TOADD_PATH_LLVM}" != "${TOADD_PATH_BINARYEN}" ] && [ "${TOADD_PATH_NODEJS}" != "${TOADD_PATH_BINARYEN}" ]; then | ||
| echo "PATH += ${TOADD_PATH_BINARYEN}" | ||
| export PATH=${TOADD_PATH_BINARYEN}:$PATH | ||
| add_to_path "$TOADD_PATH_BINARYEN" | ||
| fi | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're setting these here, I don't think we can just remove them: https://github.com/dotnet/runtime/blob/28c4dce2c6a9a3619faa612095ed2125d03fbecd/src/mono/browser/build/BrowserWasmApp.targets#L202-L204
i.e. we need to make sure the toolchain still works when using the nuget packages on end-user machines.
I'm not sure everything uses the emsdk_env scripts for example.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current state we are overwriting the contents of this file anyway, during provisioning, before it gets used.
I produced nugets in this repo, copied them to runtime repo and tested how the build process goes and it worked fine. If that succeeded, where else it could go wrong? What other tests do you propose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runtime build is kinda special. I'd recommend trying a normal blazor wasm build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, tested blazor:
No errors detected.