File: clean_up_vcproj.awk

package info (click to toggle)
portmidi 1%3A184-2.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,432 kB
  • ctags: 1,295
  • sloc: ansic: 7,287; java: 860; lisp: 363; makefile: 142; awk: 83; cpp: 63; python: 29; sh: 3
file content (60 lines) | stat: -rw-r--r-- 1,884 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# gawk script to convert CMake-generated Visual Studio projects into
# stand-alone project files
#
# Roger Dannenberg, October 2009
#
# the result uses relative path names (so you can install the project on 
# any machine and use it)
#
# NOTE: to run this, you must assign base_relative to the relative path
# from the vcproj file to portmidi, e.g. base_relative=.. or base_relative=.

BEGIN {
    state = "normal";
    #=================IMPORTANT====================
    # change the following path to the path in which
    # the CMakeLists.txt file resides:
    base_path = "C:\\\\Users\\\\rbd\\\\portmidi";
    #==============================================

    base_path_2 = base_path;
    gsub("\\\\\\\\", "/", base_path_2)
    cmake_stuff = 0; # flag to print <file> ... </file> text
}
# this case removes CMake phases from project
state == "cmakelists" {
    # print "IN CMAKELISTS " 
    file_text = file_text "\n" $0 # collect the <file> ... </file> section
    if (index($0, "CMakeLists.txt") > 0) { 
        cmake_stuff = 1 # remember to delete this <file> ... </file> section
    }

    if (index($0, "</File>") > 0) { 
        state = "normal";
        if (cmake_stuff == 0) {
            gsub(base_path, base_relative, file_text)
            gsub(base_path_2, base_relative, file_text)
            print file_text;
        }
        cmake_stuff = 0;
    };
    next
}

# this is the normal case, not in buildPhases list
state == "normal" {
    # print "NOT IN BUILD PHASES"
    # take out all the absolute paths
    gsub(base_path, base_relative, $0); 
    gsub(base_path_2, base_relative, $0); 
    # special processing for <file> ... </file> text:
    if ($0 ~ "<File$") {
        file_text = $0;
        cmake_stuff = 0; # innocent (keep text) until proven guilty
        state = "cmakelists";
        next # do not print this line
    };
    print $0;
    next
}