Last active
February 7, 2023 02:42
-
-
Save sky87/a887cef73285ab88b303f03295d0821e to your computer and use it in GitHub Desktop.
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
# Add to ~/.bashrc | |
# call load_msenv from a shell to load the enviroment | |
function load_msenv() { | |
local msenv="$HOME/.msenv_bash" | |
if [ ! -f "$msenv" ]; then | |
local msenvbatch="__print_ms_env.bat" | |
echo "@echo off" > "$msenvbatch" | |
echo "call ${VS140COMNTOOLS}..\..\VC\vcvarsall.bat x64" >> "$msenvbatch" | |
echo "set" >> "$msenvbatch" | |
cmd "/C $msenvbatch" > "$msenv.tmp" | |
rm -f "$msenvbatch" | |
grep -E '^PATH=' "$msenv.tmp" | \ | |
sed \ | |
-e 's/\(.*\)=\(.*\)/export \1="\2"/g' \ | |
-e 's/\([a-zA-Z]\):[\\\/]/\/\1\//g' \ | |
-e 's/\\/\//g' \ | |
-e 's/;\//:\//g' \ | |
> "$msenv" | |
# Don't mess with CL compilation env | |
grep -E '^(INCLUDE|LIB|LIBPATH)=' "$msenv.tmp" | \ | |
sed \ | |
-e 's/\(.*\)=\(.*\)/export \1="\2"/g' \ | |
>> "$msenv" | |
rm "$msenv.tmp" | |
fi | |
source "$msenv" | |
} | |
export -f load_msenv |
Thanks. I made a fork with some improvements:
- Tried to make paths generic
- Works with both VS 2017 and VS 2019
Did not work for me :(
Not even with sudo load_msenv
.
I expect afterwards that ninja --version
would be working, but it still says bash: ninja: command not found
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! Note that you may need to add extra quotes around
${VS140COMNTOOLS}..\..\VC\vcvarsall.bat
depending on... I'm not sure what exactly, but I know I did.