"Helpers for rules running on windows" # cmd.exe function for looking up runfiles. # Equivalent of the BASH_RLOCATION_FUNCTION in paths.bzl. # Use this to write actions that don't require bash. # Originally by @meteorcloudy in # https://github.com/bazelbuild/rules_nodejs/commit/f06553a BATCH_RLOCATION_FUNCTION = r""" rem Usage of rlocation function: rem call :rlocation rem The rlocation function maps the given to its absolute rem path and stores the result in a variable named . rem This function fails if the doesn't exist in mainifest rem file. :: Start of rlocation goto :rlocation_end :rlocation if "%~2" equ "" ( echo>&2 ERROR: Expected two arguments for rlocation function. exit 1 ) if "%RUNFILES_MANIFEST_ONLY%" neq "1" ( set %~2=%~1 exit /b 0 ) if exist "%RUNFILES_DIR%" ( set RUNFILES_MANIFEST_FILE=%RUNFILES_DIR%_manifest ) if "%RUNFILES_MANIFEST_FILE%" equ "" ( set RUNFILES_MANIFEST_FILE=%~f0.runfiles\MANIFEST ) if not exist "%RUNFILES_MANIFEST_FILE%" ( set RUNFILES_MANIFEST_FILE=%~f0.runfiles_manifest ) set MF=%RUNFILES_MANIFEST_FILE:/=\% if not exist "%MF%" ( echo>&2 ERROR: Manifest file %MF% does not exist. exit 1 ) set runfile_path=%~1 for /F "tokens=2* usebackq" %%i in (`%SYSTEMROOT%\system32\findstr.exe /l /c:"!runfile_path! " "%MF%"`) do ( set abs_path=%%i ) if "!abs_path!" equ "" ( echo>&2 ERROR: !runfile_path! not found in runfiles manifest exit 1 ) set %~2=!abs_path! exit /b 0 :rlocation_end :: End of rlocation """