| 1 |
# Copyright (C) 2003-2025 Free Software Foundation, Inc. |
| 2 |
# Contributed by Kelley Cook, June 2004. |
| 3 |
# Original code from Neil Booth, May 2003. |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or modify it |
| 6 |
# under the terms of the GNU General Public License as published by the |
| 7 |
# Free Software Foundation; either version 3, or (at your option) any |
| 8 |
# later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program; see the file COPYING3. If not see |
| 17 |
# <http://www.gnu.org/licenses/>. |
| 18 |
|
| 19 |
# Read in the option records generated from opt-gather.awk. |
| 20 |
|
| 21 |
BEGIN { |
| 22 |
n_opts = 0 |
| 23 |
n_langs = 0 |
| 24 |
n_target_save = 0 |
| 25 |
n_target_vars = 0 |
| 26 |
n_extra_vars = 0 |
| 27 |
n_extra_target_vars = 0 |
| 28 |
n_extra_masks = 0 |
| 29 |
n_extra_c_includes = 0 |
| 30 |
n_extra_h_includes = 0 |
| 31 |
n_enums = 0 |
| 32 |
have_save = 0; |
| 33 |
quote = "\042" |
| 34 |
comma = "," |
| 35 |
FS=SUBSEP |
| 36 |
# Default the name of header created from opth-gen.awk to options.h |
| 37 |
if (header_name == "") header_name="options.h" |
| 38 |
} |
| 39 |
|
| 40 |
# Collect the text and flags of each option into an array |
| 41 |
{ |
| 42 |
if ($1 == "Language") { |
| 43 |
langs[n_langs] = $2 |
| 44 |
lang_numbers[$2] = n_langs |
| 45 |
n_langs++; |
| 46 |
} |
| 47 |
else if ($1 == "TargetSave") { |
| 48 |
# Make sure the declarations are put in source order |
| 49 |
target_save_decl[n_target_save] = $2 |
| 50 |
n_target_save++ |
| 51 |
} |
| 52 |
else if ($1 == "Variable") { |
| 53 |
extra_vars[n_extra_vars] = $2 |
| 54 |
n_extra_vars++ |
| 55 |
name = host_wide_int_var_name($2) |
| 56 |
if (name != "") |
| 57 |
host_wide_int[name] = "yes" |
| 58 |
} |
| 59 |
else if ($1 == "TargetVariable") { |
| 60 |
# Combination of TargetSave and Variable |
| 61 |
extra_vars[n_extra_vars] = $2 |
| 62 |
n_extra_vars++ |
| 63 |
|
| 64 |
var = $2 |
| 65 |
sub(" *=.*", "", var) |
| 66 |
orig_var = var |
| 67 |
name = var |
| 68 |
type = var |
| 69 |
sub("^.*[ *]", "", name) |
| 70 |
sub(" *" name "$", "", type) |
| 71 |
target_save_decl[n_target_save] = type " x_" name |
| 72 |
n_target_save++ |
| 73 |
|
| 74 |
extra_target_vars[n_extra_target_vars] = name |
| 75 |
extra_target_var_types[n_extra_target_vars] = type |
| 76 |
n_extra_target_vars++ |
| 77 |
} |
| 78 |
else if ($1 == "HeaderInclude") { |
| 79 |
extra_h_includes[n_extra_h_includes++] = $2; |
| 80 |
} |
| 81 |
else if ($1 == "SourceInclude") { |
| 82 |
extra_c_includes[n_extra_c_includes++] = $2; |
| 83 |
} |
| 84 |
else if ($1 == "Enum") { |
| 85 |
props = $2 |
| 86 |
name = opt_args_non_empty("Name", props) |
| 87 |
type = opt_args_non_empty("Type", props) |
| 88 |
unknown_error = opt_args("UnknownError", props) |
| 89 |
enum_names[n_enums] = name |
| 90 |
enum_type[name] = type |
| 91 |
enum_index[name] = n_enums |
| 92 |
enum_unknown_error[name] = unknown_error |
| 93 |
enum_help[name] = $3 |
| 94 |
n_enums++ |
| 95 |
} |
| 96 |
else if ($1 == "EnumValue") { |
| 97 |
props = $2 |
| 98 |
enum_name = opt_args_non_empty("Enum", props) |
| 99 |
string = opt_args_non_empty("String", props) |
| 100 |
value = opt_args_non_empty("Value", props) |
| 101 |
set = opt_args("Set", props) |
| 102 |
val_flags = "0" |
| 103 |
val_flags = val_flags \ |
| 104 |
test_flag("Canonical", props, "| CL_ENUM_CANONICAL") \ |
| 105 |
test_flag("DriverOnly", props, "| CL_ENUM_DRIVER_ONLY") |
| 106 |
if (set != "") |
| 107 |
val_flags = val_flags "| ((" set \ |
| 108 |
") << CL_ENUM_SET_SHIFT)" |
| 109 |
enum_data[enum_name] = enum_data[enum_name] \ |
| 110 |
" { " quote string quote ", " value ", " val_flags \ |
| 111 |
" },\n" |
| 112 |
} |
| 113 |
else { |
| 114 |
name = opt_args("Mask", $1) |
| 115 |
if (name == "") { |
| 116 |
opts[n_opts] = $1 |
| 117 |
opt_numbers[$1] = n_opts |
| 118 |
flags[n_opts] = $2 |
| 119 |
help[n_opts] = $3 |
| 120 |
for (i = 4; i <= NF; i++) |
| 121 |
help[n_opts] = help[n_opts] " " $i |
| 122 |
n_opts++; |
| 123 |
} |
| 124 |
else { |
| 125 |
target_var = opt_args("Var", $0) |
| 126 |
if (target_var) |
| 127 |
{ |
| 128 |
target_var = opt_args("Var", $1) |
| 129 |
var_index = find_index(target_var, target_vars, n_target_vars) |
| 130 |
if (var_index == n_target_vars) |
| 131 |
{ |
| 132 |
target_vars[n_target_vars++] = target_var |
| 133 |
} |
| 134 |
other_masks[var_index "," n_other_mask[var_index]++] = name |
| 135 |
} |
| 136 |
else |
| 137 |
{ |
| 138 |
extra_masks[n_extra_masks++] = name |
| 139 |
} |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
|