]> git.sesse.net Git - x264/blob - tools/msvsdepend.sh
AvxSynth: Remove a bunch of unused cruft
[x264] / tools / msvsdepend.sh
1 #!/bin/sh
2 # There's a lot of things going on here
3 # expected arguments are $(CC) $(CFLAGS) $(SRC) $(OBJ)
4 # 1) start the dependency line with the object argument
5 # 2) need to add -Zs -showIncludes to the flags to have the compiler output list of include files without compilation
6 # 3) look for notes in the output that start with "Note: including file:"
7 # 4) retain only the filepath from the notes
8 # 5) convert \ foldername separators to /
9 # 6) escape spaces in the filepath
10 # 7) remove system includes (hack: check for "/Program Files" string in filepath)
11 # 8) sort and remove duplicate filepath entries
12 # 9) convert newlines to spaces to collapse the dependencies into the one dependency line
13 # 10) print a newline character, to properly separate dependency lines
14 echo -n "$4: "
15 $1 $2 $3 -Zs -showIncludes 2>&1 |
16     grep '^Note: including file:' |
17     sed 's/^Note: including file:[[:space:]]*\(.*\)$/\1/; s/\\/\//g; s/ /\\ /g' |
18     sed '/\/[Pp]rogram\\ [Ff]iles/d' |
19     sort | uniq |
20     tr -s '\n\r' ' '
21 echo ''