Resending without the first patch since it may trigger size filters.

---------- Forwarded message ---------
From: Gedare Bloom <ged...@rtems.org>
Date: Mon, Oct 31, 2022 at 12:55 PM
Subject: Identify 3rd party source in spec?
To: devel@rtems.org <devel@rtems.org>


Hello all,

I would like to float the idea of managing 3rd party source tracking
through the build system spec files. I believe this would be the most
efficient way to maintain this information, and we can leverage the
existing build system code for tasks such as automatic format checks,
generating lists of third-party code, etc.

This will require refactoring some spec files to pull 3rd party code
out to a separate .yml file that gets linked. Once that is done, then
we could add another attribute for this tracking purpose. I would like
to keep it simple as a boolean, maybe just "third-party: true/false"
Attached is an example patch showing how this might work for the
dtc/libfdt code as a build objects item type 'obj', and for zlib
library as a build library item type 'lib' with some proof-of-concept
code for generating a listing of third party source files.

As an initial step before making this refactoring, I have added an
explicit default "third-party: false" attribute to every yml file
preceding the enabled-by: attribute, using the following bit of shell:
rtems.git/spec/build$ find . -name "*.yml" | xargs sed -i -e
's/\(enabled-by.*\)/third-party: false\n\1/'

This touches 2333 files adding that one line, which is the contents of
the first 1 MiB patch attached in the series. The remaining patches
then layer on the top and are functional, outputting:

rtems.git$ ./waf third_party_list
cpukit/dtc/libfdt/fdt.c
cpukit/dtc/libfdt/fdt_addresses.c
cpukit/dtc/libfdt/fdt_empty_tree.c
cpukit/dtc/libfdt/fdt_ro.c
cpukit/dtc/libfdt/fdt_rw.c
cpukit/dtc/libfdt/fdt_strerror.c
cpukit/dtc/libfdt/fdt_sw.c
cpukit/dtc/libfdt/fdt_wip.c
cpukit/zlib/adler32.c
cpukit/zlib/compress.c
cpukit/zlib/crc32.c
cpukit/zlib/deflate.c
cpukit/zlib/gzclose.c
cpukit/zlib/gzlib.c
cpukit/zlib/gzread.c
cpukit/zlib/gzwrite.c
cpukit/zlib/infback.c
cpukit/zlib/inffast.c
cpukit/zlib/inflate.c
cpukit/zlib/inftrees.c
cpukit/zlib/trees.c
cpukit/zlib/uncompr.c
cpukit/zlib/zutil.c

I'll continue to work on this, feedback is requested though if this is
a good direction or how to improve.

Gedare
From 44ae3a1ae62875047c57fbd25163fa78e21c4ed5 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare@rtems.org>
Date: Mon, 31 Oct 2022 12:52:35 -0600
Subject: [PATCH 4/4] wscript: add command to print third-party sources

---
 wscript | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/wscript b/wscript
index 4071cc9ef8..051f35ca52 100755
--- a/wscript
+++ b/wscript
@@ -226,6 +226,17 @@ class Item(object):
                 p.build(bld, bic)
             self.do_build(bld, bic)
 
+    def third_parties(self, ctx):
+        tpl = []
+        for p in self.links():
+            x = p.third_parties(ctx)
+            if x is not None:
+                tpl.extend(x)
+        x = self.do_third_parties(ctx)
+        if x is not None:
+            tpl.extend(x)
+        return tpl
+
     def do_defaults(self, variant, family):
         return
 
@@ -241,6 +252,11 @@ class Item(object):
     def do_build(self, bld, bic):
         return
 
+    def do_third_parties(self, ctx):
+        if self.data["third-party"]:
+            source = self.data["source"]
+            return source
+
     def substitute(self, ctx, value):
         if isinstance(value, str):
             try:
@@ -1711,3 +1727,15 @@ def bsp_list(ctx):
                 print(variant)
     if first:
         no_matches_error(ctx, white_list)
+
+def third_party_list(ctx):
+    """lists third-party sources"""
+    check_forbidden_options(
+        ctx, ["compiler", "config", "options", "tools", "top_group", "version"]
+    )
+    add_log_filter(ctx.cmd)
+    load_items_from_options(ctx)
+    top_group = get_top_group(ctx)
+    tp = items[top_group].third_parties(ctx)
+    for s in tp:
+        print(s)
-- 
2.34.1

From a0cf7dc9dc56c83c3949a67f9c5aa439aef94994 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare@rtems.org>
Date: Mon, 31 Oct 2022 12:52:09 -0600
Subject: [PATCH 3/4] spec/build: mark objdtc and libz as third-party

---
 spec/build/cpukit/libz.yml   | 2 +-
 spec/build/cpukit/objdtc.yml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/spec/build/cpukit/libz.yml b/spec/build/cpukit/libz.yml
index d1ade6c18c..90f804f44b 100644
--- a/spec/build/cpukit/libz.yml
+++ b/spec/build/cpukit/libz.yml
@@ -5,7 +5,7 @@ copyrights:
 - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
 cppflags: []
 cxxflags: []
-third-party: false
+third-party: true
 enabled-by: true
 includes: []
 install:
diff --git a/spec/build/cpukit/objdtc.yml b/spec/build/cpukit/objdtc.yml
index 2492cbca74..43f16f2b02 100644
--- a/spec/build/cpukit/objdtc.yml
+++ b/spec/build/cpukit/objdtc.yml
@@ -5,7 +5,7 @@ copyrights:
 - Copyright (C) 2022 Gedare Bloom
 cppflags: []
 cxxflags: []
-third-party: false
+third-party: true
 enabled-by: true
 includes: []
 install:
-- 
2.34.1

From 8def5156fa17c2c66fe94015bd3d56608fe16b62 Mon Sep 17 00:00:00 2001
From: Gedare Bloom <gedare@rtems.org>
Date: Mon, 31 Oct 2022 12:49:25 -0600
Subject: [PATCH 2/4] spec/build: split dtc sources from librtemscpu

---
 spec/build/cpukit/librtemscpu.yml | 13 ++-----------
 spec/build/cpukit/objdtc.yml      | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 11 deletions(-)
 create mode 100644 spec/build/cpukit/objdtc.yml

diff --git a/spec/build/cpukit/librtemscpu.yml b/spec/build/cpukit/librtemscpu.yml
index 57a25c7222..396adfeca0 100644
--- a/spec/build/cpukit/librtemscpu.yml
+++ b/spec/build/cpukit/librtemscpu.yml
@@ -15,9 +15,6 @@ install:
   - cpukit/include/crypt.h
   - cpukit/include/dlfcn.h
   - cpukit/include/endian.h
-  - cpukit/include/fdt.h
-  - cpukit/include/libfdt.h
-  - cpukit/include/libfdt_env.h
   - cpukit/include/link.h
   - cpukit/include/link_elf.h
   - cpukit/include/md4.h
@@ -508,6 +505,8 @@ links:
   uid: objdl
 - role: build-dependency
   uid: objdrvmgr
+- role: build-dependency
+  uid: objdtc
 - role: build-dependency
   uid: objexceptionmapping
 - role: build-dependency
@@ -542,14 +541,6 @@ source:
 - cpukit/dev/serial/sc16is752.c
 - cpukit/dev/spi/spi-bus.c
 - cpukit/dev/can/can.c
-- cpukit/dtc/libfdt/fdt.c
-- cpukit/dtc/libfdt/fdt_addresses.c
-- cpukit/dtc/libfdt/fdt_empty_tree.c
-- cpukit/dtc/libfdt/fdt_ro.c
-- cpukit/dtc/libfdt/fdt_rw.c
-- cpukit/dtc/libfdt/fdt_strerror.c
-- cpukit/dtc/libfdt/fdt_sw.c
-- cpukit/dtc/libfdt/fdt_wip.c
 - cpukit/libblock/src/bdbuf.c
 - cpukit/libblock/src/bdpart-create.c
 - cpukit/libblock/src/bdpart-dump.c
diff --git a/spec/build/cpukit/objdtc.yml b/spec/build/cpukit/objdtc.yml
new file mode 100644
index 0000000000..2492cbca74
--- /dev/null
+++ b/spec/build/cpukit/objdtc.yml
@@ -0,0 +1,27 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: objects
+cflags: []
+copyrights:
+- Copyright (C) 2022 Gedare Bloom
+cppflags: []
+cxxflags: []
+third-party: false
+enabled-by: true
+includes: []
+install:
+- destination: ${BSP_INCLUDEDIR}
+  source:
+  - cpukit/include/fdt.h
+  - cpukit/include/libfdt.h
+  - cpukit/include/libfdt_env.h
+links: []
+source:
+- cpukit/dtc/libfdt/fdt.c
+- cpukit/dtc/libfdt/fdt_addresses.c
+- cpukit/dtc/libfdt/fdt_empty_tree.c
+- cpukit/dtc/libfdt/fdt_ro.c
+- cpukit/dtc/libfdt/fdt_rw.c
+- cpukit/dtc/libfdt/fdt_strerror.c
+- cpukit/dtc/libfdt/fdt_sw.c
+- cpukit/dtc/libfdt/fdt_wip.c
+type: build
-- 
2.34.1

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to