Changeset 2717 for trunk/src/kmk/variable.c
- Timestamp:
- Dec 30, 2013, 1:58:43 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/variable.c
r2591 r2717 202 202 #endif 203 203 204 205 #ifdef KMK /* Drop the 'static' */ 206 struct variable_set global_variable_set; 207 struct variable_set_list global_setlist 208 #else 204 209 static struct variable_set global_variable_set; 205 210 static struct variable_set_list global_setlist 211 #endif 206 212 = { 0, &global_variable_set, 0 }; 207 213 struct variable_set_list *current_variable_set_list = &global_setlist; … … 249 255 struct variable var_key; 250 256 257 if (env_overrides && origin == o_env) 258 origin = o_env_override; 259 251 260 #ifndef KMK 252 261 if (set == NULL) 253 262 set = &global_variable_set; 254 #else 263 #else /* KMK */ 264 /* Intercept kBuild object variable definitions. */ 265 if (name[0] == '[' && length > 3) 266 { 267 v = try_define_kbuild_object_variable_via_accessor (name, length, 268 value, value_len, duplicate_value, 269 origin, recursive, flocp); 270 if (v != VAR_NOT_KBUILD_ACCESSOR) 271 return v; 272 } 255 273 if (set == NULL) 256 274 { 257 /* underscore prefixed variables are automatically local in 258 kBuild-define-* scopes. They also get a global definition with 259 the current scope prefix. */ 260 if (g_pTopKbDef && length > 0 && name[0] == '_') 261 { 262 char *prefixed_nm; 263 unsigned int prefixed_nm_len; 264 265 set = get_top_kbuild_variable_set(); 266 v = define_variable_in_set(name, length, value, value_len, 267 1 /* duplicate_value */, 268 origin, recursive, set, flocp); 269 270 prefixed_nm_len = length; 271 prefixed_nm = kbuild_prefix_variable(name, &prefixed_nm_len); 272 define_variable_in_set(prefixed_nm, prefixed_nm_len, 273 value, value_len, duplicate_value, 274 origin, recursive, &global_variable_set, 275 flocp); 276 free(prefixed_nm); 277 return v; 278 } 275 if (g_pTopKbEvalData) 276 return define_kbuild_object_variable_in_top_obj (name, length, 277 value, value_len, duplicate_value, 278 origin, recursive, flocp); 279 279 set = &global_variable_set; 280 280 } 281 #endif 281 #endif /* KMK */ 282 282 283 283 #ifndef CONFIG_WITH_STRCACHE2 … … 286 286 var_slot = (struct variable **) hash_find_slot (&set->table, &var_key); 287 287 288 if (env_overrides && origin == o_env)289 origin = o_env_override; 288 /* if (env_overrides && origin == o_env) 289 origin = o_env_override; - bird moved this up */ 290 290 291 291 v = *var_slot; 292 292 #else /* CONFIG_WITH_STRCACHE2 */ 293 var_key.name = name = strcache2_add (&variable_strcache, name, length); 294 var_key.length = length; 293 name = strcache2_add (&variable_strcache, name, length); 295 294 if ( set != &global_variable_set 296 || !(v = strcache2_get_user_val (&variable_strcache, var_key.name))) 297 { 295 || !(v = strcache2_get_user_val (&variable_strcache, name))) 296 { 297 var_key.name = name; 298 var_key.length = length; 298 299 var_slot = (struct variable **) hash_find_slot_strcached (&set->table, &var_key); 299 300 v = *var_slot; … … 470 471 set = &global_variable_set; 471 472 473 #ifndef CONFIG_WITH_STRCACHE2 472 474 var_key.name = (char *) name; 473 475 var_key.length = length; 474 476 var_slot = (struct variable **) hash_find_slot (&set->table, &var_key); 477 #else 478 var_key.name = strcache2_lookup(&variable_strcache, name, length); 479 if (!var_key.name) 480 return; 481 var_key.length = length; 482 var_slot = (struct variable **) hash_find_slot_strcached (&set->table, &var_key); 483 #endif 475 484 476 485 if (env_overrides && origin == o_env) … … 490 499 { 491 500 hash_delete_at (&set->table, var_slot); 501 #ifdef CONFIG_WITH_STRCACHE2 502 if (set == &global_variable_set) 503 strcache2_set_user_val (&variable_strcache, v->name, NULL); 504 #endif 492 505 free_variable_name_and_value (v); 493 506 } … … 735 748 #ifdef CONFIG_WITH_STRCACHE2 736 749 const char *cached_name; 737 750 #endif 751 752 # ifdef KMK 753 /* Check for kBuild-define- local variable accesses and handle these first. */ 754 if (length > 3 && name[0] == '[') 755 { 756 struct variable *v = lookup_kbuild_object_variable_accessor(name, length); 757 if (v != VAR_NOT_KBUILD_ACCESSOR) 758 return v; 759 } 760 # endif 761 762 #ifdef CONFIG_WITH_STRCACHE2 738 763 /* lookup the name in the string case, if it's not there it won't 739 764 be in any of the sets either. */ … … 851 876 #else /* CONFIG_WITH_STRCACHE2 */ 852 877 const char *cached_name; 878 879 # ifdef KMK 880 /* Check for kBuild-define- local variable accesses and handle these first. */ 881 if (length > 3 && name[0] == '[' && set == &global_variable_set) 882 { 883 struct variable *v = lookup_kbuild_object_variable_accessor(name, length); 884 if (v != VAR_NOT_KBUILD_ACCESSOR) 885 return v; 886 } 887 # endif 853 888 854 889 /* lookup the name in the string case, if it's not there it won't … … 1914 1949 } 1915 1950 1916 st atic struct variable *1951 struct variable * 1917 1952 do_variable_definition_append (const struct floc *flocp, struct variable *v, 1918 1953 const char *value, unsigned int value_len, … … 1996 2031 int conditional = 0; 1997 2032 const size_t varname_len = strlen (varname); /* bird */ 2033 1998 2034 #ifdef CONFIG_WITH_VALUE_LENGTH 1999 assert (value_len == ~0U || value_len == strlen (value)); 2035 if (value_len == ~0U) 2036 value_len = strlen (value); 2037 else 2038 assert (value_len == strlen (value)); 2000 2039 #endif 2001 2040 … … 2066 2105 #endif 2067 2106 2068 #ifdef CONFIG_WITH_LOCAL_VARIABLES2069 /* If we have += but we're in a target or local variable context,2070 we want to append only with other variables in the context of2071 this target. */2072 if (target_var || origin == o_local)2073 #else2074 2107 /* If we have += but we're in a target variable context, we want to 2075 2108 append only with other variables in the context of this target. */ 2076 2109 if (target_var) 2077 #endif2078 2110 { 2079 2111 append = 1; … … 2086 2118 append = 0; 2087 2119 } 2120 #ifdef KMK 2121 else if ( g_pTopKbEvalData 2122 || ( varname_len > 3 2123 && varname[0] == '[' 2124 && is_kbuild_object_variable_accessor (varname, varname_len)) ) 2125 { 2126 v = kbuild_object_variable_pre_append (varname, varname_len, 2127 value, value_len, simple_value, 2128 origin, org_flavor == f_append, flocp); 2129 if (free_value) 2130 free (free_value); 2131 return v; 2132 } 2133 #endif 2134 #ifdef CONFIG_WITH_LOCAL_VARIABLES 2135 /* If 'local', restrict it to the current variable context. */ 2136 else if (origin == o_local) 2137 v = lookup_variable_in_set (varname, varname_len, 2138 current_variable_set_list->set); 2139 #endif 2088 2140 else 2089 2141 v = lookup_variable (varname, varname_len);
Note:
See TracChangeset
for help on using the changeset viewer.