With apparently a new QA check checking for "overwrites user's optimization (-O*)" filed by ago, I believe it'd be fruitful to have a function to return/change optimization in user's current CFLAGS. I'm currently using: src_configure() { local cflagsoptimization=$(echo "${CFLAGS}" | awk '/-O/ { print $2 }') ... $(use_enable !debug optimize="${cflagsoptimization}") which, without a doubt, will have some conflicts so can you come up with something better since you know more about *FLAGS :)
These work already: my_o=$(get-flag '-O*') replace-flags '-O*' -O2 No other compiler option starts with -O, so I don't think there's worth in checking for valid -Osomething values.
Pfft yeah my brains are already on holiday. Also the example I showed doesn't take into account if multiple occurrences appear, wonder if get-flag does any better though. I'll go with that, thanks!
(In reply to Joonas Niilola from comment #2) > Pfft yeah my brains are already on holiday. Also the example I showed > doesn't take into account if multiple occurrences appear, wonder if get-flag > does any better though. I'll go with that, thanks! But yeah, get-flag isn't the smartest tool in the shed, it gets the first match of the first variable which probably doesn't make much sense for any flags (could have different -O in CXXFLAGS and such too) (In reply to Ionen Wolkens from comment #1) > No other compiler option starts with -O, so I don't think there's worth in > checking for valid -Osomething values. At least gcc afaik anyway, haven't checked much.