clean_up_vcproj.awk (2350B)
1 # gawk script to convert CMake-generated Visual Studio projects into 2 # stand-alone project files 3 # 4 # Roger Dannenberg, October 2009 5 # 6 # the result uses relative path names (so you can install the project on 7 # any machine and use it) 8 # 9 # NOTE: to run this, you must assign base_relative to the relative path 10 # from the vcproj file to portmidi, e.g. base_relative=.. or base_relative=. 11 12 BEGIN { 13 state = "normal"; 14 #=================IMPORTANT==================== 15 # change the following path to the path in which 16 # the CMakeLists.txt file resides: 17 base_path = "C:\\\\Users\\\\rbd\\\\portmedia\\\\portmidi"; 18 #============================================== 19 20 base_path_2 = base_path; 21 gsub("\\\\\\\\", "/", base_path_2) 22 cmake_stuff = 0; # flag to print <file> ... </file> text 23 } 24 # this case removes CMake phases from project 25 state == "cmakelists" { 26 # print "IN CMAKELISTS " 27 file_text = file_text "\n" $0 # collect the <file> ... </file> section 28 if (index($0, "CMakeLists.txt") > 0) { 29 cmake_stuff = 1 # remember to delete this <file> ... </file> section 30 } 31 32 if (index($0, "</File>") > 0) { 33 state = "normal"; 34 if (cmake_stuff == 0) { 35 gsub(base_path, base_relative, file_text) 36 gsub(base_path_2, base_relative, file_text) 37 print file_text; 38 } 39 cmake_stuff = 0; 40 }; 41 next 42 } 43 44 # this is the normal case, not in buildPhases list 45 state == "normal" { 46 # print "NOT IN BUILD PHASES" 47 # take out all the absolute paths 48 gsub(base_path, base_relative, $0); 49 gsub(base_path_2, base_relative, $0); 50 # special processing for <file> ... </file> text: 51 if ($0 ~ "<File$") { 52 file_text = $0; 53 cmake_stuff = 0; # innocent (keep text) until proven guilty 54 state = "cmakelists"; 55 next # do not print this line 56 }; 57 # THIS CODE WOULD ALLOW portmidi-static and portmidi-dynamic IN 58 # pm_commmon. I DECIDED TO TRY PUTTING THEM IN SEPARATE DIRECTORIES 59 # INSTEAD. 60 # Use static libraries for everything except portmidi-dynamic 61 #if (($0 ~ "RuntimeLibrary=") && (base_relative ~ "dynamic")) { 62 # if ($0 ~ 2) { 63 # $0 = "\t\t\t\tRuntimeLibrary=\"0\""; 64 # } else if ($0 ~ 3) { 65 # $0 = "\t\t\t\tRuntimeLibrary=\"1\""; 66 # } 67 print $0; 68 next 69 } 70