<div dir="ltr">Do these options need some help/explanation?<div><br></div><div>--joel</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 22, 2023 at 12:23 AM <<a href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Chris Johns <<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a>><br>
<br>
---<br>
source-builder/pkg-config | 36 ++++++++++++++++++++++++++++++++++++<br>
1 file changed, 36 insertions(+)<br>
<br>
diff --git a/source-builder/pkg-config b/source-builder/pkg-config<br>
index 10db546..8d0a174 100755<br>
--- a/source-builder/pkg-config<br>
+++ b/source-builder/pkg-config<br>
@@ -86,6 +86,19 @@ def log(s, lf = True):<br>
sys.stdout.flush()<br>
print(s, end = '', file = out)<br>
<br>
+def cflags_filter(cflags, prefixes, include=True):<br>
+ cflags = cflags.split(' ')<br>
+ f_cflags = []<br>
+ for f in cflags:<br>
+ for p in prefixes:<br>
+ if f.startswith(p):<br>
+ f_cflags += [f]<br>
+ if not include:<br>
+ not_f_cflags = [f for f in cflags if f not in f_cflags]<br>
+ f_cflags = not_f_cflags<br>
+ return ' '.join(f_cflags)<br>
+<br>
+<br>
def run(argv):<br>
<br>
class version_action(argparse.Action):<br>
@@ -110,6 +123,7 @@ def run(argv):<br>
help = 'Make error messages short.')<br>
opts.add_argument('--silence-errors', dest = 'silence_errors', action = 'store_true',<br>
default = False,<br>
+<br>
help = 'Do not print any errors.')<br>
opts.add_argument('--errors-to-stdout', dest = 'errors_to_stdout', action = 'store_true',<br>
default = False,<br>
@@ -118,6 +132,14 @@ def run(argv):<br>
default = False,<br>
help = 'This prints pre-processor and compile flags required to' \<br>
' compile the package(s)')<br>
+ opts.add_argument('--cflags-only-I', dest = 'cflags_only_i', action = 'store_true',<br>
+ default = False,<br>
+ help = 'This prints the -I part of "--cflags". That is, it defines the header' \<br>
+ 'search path but doesn\'t specify anything else.')<br>
+ opts.add_argument('--cflags-only-other', dest = 'cflags_only_other', action = 'store_true',<br>
+ default = False,<br>
+ help = 'Return all compiler flags, other than the include path flags, ' \<br>
+ 'required to compile against the package.')<br>
opts.add_argument('--libs', dest = 'libs', action = 'store_true',<br>
default = False,<br>
help = 'This option is identical to "--cflags", only it prints the' \<br>
@@ -193,6 +215,20 @@ def run(argv):<br>
log('cflags: %s' % (flags['cflags']))<br>
else:<br>
log('cflags: empty')<br>
+ if args.cflags_only_i:<br>
+ cflags = cflags_filter(flags['cflags'], ['-I', '-system'], True)<br>
+ if len(cflags):<br>
+ print(cflags)<br>
+ log('cflags: %s' % (flags['cflags']))<br>
+ else:<br>
+ log('cflags: empty')<br>
+ if args.cflags_only_other:<br>
+ cflags = cflags_filter(flags['cflags'], ['-I', '-system'], False)<br>
+ if len(cflags):<br>
+ print(cflags)<br>
+ log('cflags: %s' % (flags['cflags']))<br>
+ else:<br>
+ log('cflags: empty')<br>
if args.libs:<br>
if len(flags['libs']):<br>
print(flags['libs'])<br>
-- <br>
2.37.1<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>