Switch source build property to DotNetBuildFromSource
[platform/upstream/coreclr.git] / src / nativeresources / processrc.awk
1 # Parse string resources from Windows native resource file 
2 # and pass them to the writestringentry function that 
3 # is responsible for writing the resource id and string
4 # to a platform specific resource file.
5 # A script containing this function needs to be specified
6 # using the -f command line parameter before this script.
7
8 BEGIN {
9     inStringTable = 0;
10     inBeginEnd = 0;
11     arrayName = "nativeStringResourceArray_" name;
12     tableName = "nativeStringResourceTable_" name;
13     writeheader(arrayName, tableName);
14 }
15 {
16     if ($1 == "STRINGTABLE" && $2 == "DISCARDABLE")
17     {
18         inStringTable = 1;
19     }
20     else if ($1 == "BEGIN")
21     {
22         inBeginEnd = inStringTable;
23     }
24     else if (inBeginEnd && $1 == "END")
25     {
26         inBeginEnd = 0;
27         inStringTable = 0;
28     }
29     else if (inBeginEnd && $1 != "")
30     {
31         # combine all items until the first string and remove them 
32         # from the line
33         i = 1
34         expression = ""
35         # string starts with either a quote or L followed by a quote
36         while (substr($i, 1, 1) != "\"" && substr($i, 1, 2) != "L\"")
37         {
38             # some of the resource IDs contain cast to HRESULT
39             gsub(/\(HRESULT\)/, "", $i);
40             # some of the resource IDs have trailing L
41             gsub(/L/, "", $i);
42             expression = expression $i;
43             i++;
44         }
45
46         # evaluate the resource ID expression
47         cmd = "echo $(("expression"))";
48         cmd | getline var;
49         close(cmd);
50         # in case shell returned the result as a string, ensure the var has numeric type
51         var = var + 0;
52
53         # Extract string content starting with either " or L"
54         idx = match($0, /L?\"/);
55         content = substr($0, idx);
56
57         # remove the L prefix from strings
58         gsub(/L"/, "\"", content);
59         # join strings "..." "..." into one
60         gsub(/" +"/, "", content);
61
62         # write the resource entry to the target file
63         writestringentry(var, content);
64     }
65 }
66 END {
67     writefooter(arrayName, tableName);
68 }