diff mbox series

[FFmpeg-devel,v2] configure: support msvc build inside WSL

Message ID 20240427201448.26469-1-timo@rothenpieler.org
State Accepted
Commit 95edaf72b4825f8d89627e2f91a1bed6d868ab1b
Headers show
Series [FFmpeg-devel,v2] configure: support msvc build inside WSL | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Timo Rothenpieler April 27, 2024, 8:14 p.m. UTC
---
 configure | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Sean McGovern April 27, 2024, 8:21 p.m. UTC | #1
On Sat, Apr 27, 2024, 16:15 Timo Rothenpieler <timo@rothenpieler.org> wrote:

> ---
>  configure | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 8101b4fce6..89af5f75e7 100755
> --- a/configure
> +++ b/configure
> @@ -5036,7 +5036,12 @@ probe_cc(){
>          else
>              _ident=$($_cc --version 2>/dev/null | head -n1 | tr -d '\r')
>          fi
> -        _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 |
> awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if
> (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
> +        if [ -x "$(command -v wslpath)" ]; then
> +            _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1
> | awk '\''/including/ { sub(/^.*file: */, ""); if (!match($$0, / /)) {
> print $$0 } }'\'' | xargs -d\\n -n1 wslpath -u | awk '\''BEGIN { printf
> "%s:", "$@" }; { sub(/\r/,""); printf " %s", $$0 }; END { print "" }'\'' >
> $(@:.o=.d)'
> +
> +        else
> +            _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1
> | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if
> (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
> +        fi
>          _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
>          _cflags_speed="-O2"
>          _cflags_size="-O1"
> --
> 2.43.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>

Aside: We are now that much closer to summoning a demon inside 'configure'
*laughs*.

-- Sean McGovern

>
Timo Rothenpieler April 27, 2024, 8:47 p.m. UTC | #2
On 27.04.2024 22:21, Sean McGovern wrote:
> Aside: We are now that much closer to summoning a demon inside 'configure'
> *laughs*.

The reasoning behind this complexification in v2 is that v1 put the 
string returned by cl.exe into a shell, allowing potential injection 
vectors.

Granted, the injection would come from inside ffmpeg code, so probably 
all would be lost at that point anyway, but at the very least, this 
approach avoids spawning a bunch of subshells we don't need, though is 
quite a bit uglier.
Alexander Strasser May 1, 2024, 3:06 p.m. UTC | #3
On 2024-04-27 22:14 +0200, Timo Rothenpieler wrote:
> ---
>  configure | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 8101b4fce6..89af5f75e7 100755
> --- a/configure
> +++ b/configure
> @@ -5036,7 +5036,12 @@ probe_cc(){
>          else
>              _ident=$($_cc --version 2>/dev/null | head -n1 | tr -d '\r')
>          fi
> -        _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
> +        if [ -x "$(command -v wslpath)" ]; then
> +            _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); if (!match($$0, / /)) { print $$0 } }'\'' | xargs -d\\n -n1 wslpath -u | awk '\''BEGIN { printf "%s:", "$@" }; { sub(/\r/,""); printf " %s", $$0 }; END { print "" }'\'' > $(@:.o=.d)'
> +
> +        else
> +            _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
> +        fi
>          _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
>          _cflags_speed="-O2"
>          _cflags_size="-O1"
> --

Should be good enough if it doesn't break MSVC builds outside of WSL.


  Alexander
Timo Rothenpieler May 1, 2024, 4:54 p.m. UTC | #4
On 01.05.2024 17:06, Alexander Strasser via ffmpeg-devel wrote:
> On 2024-04-27 22:14 +0200, Timo Rothenpieler wrote:
>> ---
>>   configure | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/configure b/configure
>> index 8101b4fce6..89af5f75e7 100755
>> --- a/configure
>> +++ b/configure
>> @@ -5036,7 +5036,12 @@ probe_cc(){
>>           else
>>               _ident=$($_cc --version 2>/dev/null | head -n1 | tr -d '\r')
>>           fi
>> -        _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
>> +        if [ -x "$(command -v wslpath)" ]; then
>> +            _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); if (!match($$0, / /)) { print $$0 } }'\'' | xargs -d\\n -n1 wslpath -u | awk '\''BEGIN { printf "%s:", "$@" }; { sub(/\r/,""); printf " %s", $$0 }; END { print "" }'\'' > $(@:.o=.d)'
>> +
>> +        else
>> +            _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
>> +        fi
>>           _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
>>           _cflags_speed="-O2"
>>           _cflags_size="-O1"
>> --
> 
> Should be good enough if it doesn't break MSVC builds outside of WSL.

Unless there for some reason is a wslpath binary on the path, that won't 
be an issue.
Will apply shortly
diff mbox series

Patch

diff --git a/configure b/configure
index 8101b4fce6..89af5f75e7 100755
--- a/configure
+++ b/configure
@@ -5036,7 +5036,12 @@  probe_cc(){
         else
             _ident=$($_cc --version 2>/dev/null | head -n1 | tr -d '\r')
         fi
-        _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
+        if [ -x "$(command -v wslpath)" ]; then
+            _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); if (!match($$0, / /)) { print $$0 } }'\'' | xargs -d\\n -n1 wslpath -u | awk '\''BEGIN { printf "%s:", "$@" }; { sub(/\r/,""); printf " %s", $$0 }; END { print "" }'\'' > $(@:.o=.d)'
+
+        else
+            _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
+        fi
         _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
         _cflags_speed="-O2"
         _cflags_size="-O1"