-
Notifications
You must be signed in to change notification settings - Fork 126
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
What is the best way to use vcvars
?
#347
Comments
say again? |
lots of build tooling expects environment variables set using https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170 My question is how to do this in the context of the busybox shell. |
To run a shell in the context created by running a batch file you could do something like:
Or more concisely:
|
for future reference:
|
How would I do this in a |
The Then when executing |
the side effects of the vcvars script are not applied to the currently running shell here was what I ultimately added: temp_file=$(mktemp)
cmd /c 'C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\AUXILI~1\Build\VCVARS~1.BAT amd64 && set' |
sed '1,5d' |
while IFS= read -r line
do
line=${line%$'\r'}
[ -z "$line" ] && continue
key=${line%%=*}
value=${line#*=}
case "$key" in
*[!a-zA-Z0-9_]*) continue ;;
esac
value=$(echo "$value" | sed 's/[\\()$`]/\\&/g')
echo "export $key=\"$value\"" >> "$temp_file"
done
echo "export CC=cl" >> "$temp_file"
echo "export CXX=cl" >> "$temp_file"
. "$temp_file"
rm "$temp_file" |
It is difficult because I don't have a vcvars file at hand. |
I can't think of anything better than what you're doing: running the batch file and listing the resulting environment in a format suitable for import to the shell. One minor improvement would be to run
I'm also not sure about the |
A different approach: temp_file1=$(mktemp)
temp_file2=$(mktemp)
temp_file3=$(mktemp)
cmd /c 'vcvars.bat >nul & busybox sh -c export' | sort >"$temp_file1"
export | sort >"$temp_file2"
comm -2 -3 "$temp_file1" "$temp_file2" | grep -v 'SHLVL=' >"$temp_file3"
. "$temp_file3"
export CC=cl
export CXX=cl
rm "$temp_file1" "$temp_file2" "$temp_file3" Instead of using Use Add error checking to taste. Use at your own peril. |
I am observing that both our approaches produce errors when compiling the Python package |
Since the busybox environment isn't mingw, it is suitable for native build tools as though it were
cmd
but a better shell.Any opinions how to use the scripts with busybox?
The text was updated successfully, but these errors were encountered: