comparison foosdk/scripts/dump-vcxproj.sh @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #!/bin/bash
2
3 set -e
4
5 target_prefix=$1
6 project_file=$2
7
8 if [ -z "$target_prefix" ] || [ -z "$project_file" ]; then
9 echo "usage: $(basename $0) project_file target_prefix"
10 exit 1
11 fi
12
13 xmlns='http://schemas.microsoft.com/developer/msbuild/2003'
14 compile_xpath='//x:Project/x:ItemGroup/x:ClCompile/@Include'
15 resource_xpath='//x:Project/x:ItemGroup/x:ResourceCompile/@Include'
16 include_xpath='//x:Project/x:ItemGroup/x:ClInclude/@Include'
17
18 project_dir="$(dirname $project_file)"
19
20 if [ "$project_dir" = "." ]; then
21 path_prefix=""
22 else
23 path_prefix="$project_dir/"
24 fi
25
26 if [ -n "$VCXPROJ_IGNORE" ]; then
27 ignore_pattern="$VCXPROJ_IGNORE"
28 else
29 ignore_pattern='$^'
30 fi
31
32 function write_header()
33 {
34 printf '\nset(\n %s_%s\n' "$target_prefix" "$1"
35 }
36
37 function write_footer()
38 {
39 printf ')\n'
40 }
41
42 function write_nodes()
43 {
44 xmlstarlet sel -N x="$xmlns" -t -v "$1" "$project_file" | \
45 grep -viE "$ignore_pattern" | \
46 xargs -n1 --no-run-if-empty printf ' %s%s\n' "$path_prefix"
47 }
48
49 test -f "$project_file"
50
51 write_header SOURCES
52 write_nodes $compile_xpath
53 write_nodes $resource_xpath
54 write_footer
55
56 if [ "$3" != "--skip-headers" ]; then
57 write_header HEADERS
58 write_nodes $include_xpath
59 write_footer
60 fi