You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2018/12/11 00:41:10 UTC

[mynewt-core] branch master updated: Export `id/target` setting if configured

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 3a2e0b9  Export `id/target` setting if configured
3a2e0b9 is described below

commit 3a2e0b990c729b6f23e71eb436f1072e0c16f203
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Thu Dec 6 17:32:15 2018 -0800

    Export `id/target` setting if configured
    
    If the `ID_TARGET_PRESENT` syscfg setting is enabled, the target name is
    readable through the `id/target` config setting.
    
    This feature requires a recent version of newt (prior versions did not
    inject the target name into the syscfg).  If an old version of newt is
    used in a build where `ID_TARGET_PRESENT` is enabled, the build will
    fail with a syscfg restriction violation error.
---
 sys/id/src/id.c   | 7 +++++++
 sys/id/syscfg.yml | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/sys/id/src/id.c b/sys/id/src/id.c
index c43c67d..f1dfe3e 100644
--- a/sys/id/src/id.c
+++ b/sys/id/src/id.c
@@ -94,6 +94,10 @@ id_conf_get(int argc, char **argv, char *val, int val_len_max)
         } else if (!strcmp(argv[0], "model")) {
             return (char *)id_model;
 #endif
+#if MYNEWT_VAL(ID_TARGET_PRESENT)
+        } else if (!strcmp(argv[0], "target")) {
+            return MYNEWT_VAL(TARGET_NAME);
+#endif
         } else if (!strcmp(argv[0], "mfghash")) {
             return id_mfghash;
         }
@@ -141,6 +145,9 @@ id_conf_export(void (*export_func)(char *name, char *val),
         export_func("id/bsp", (char *)id_bsp_str);
         export_func("id/app", (char *)id_app_str);
         export_func("id/mfghash", (char *)id_mfghash);
+#if MYNEWT_VAL(ID_TARGET_PRESENT)
+        export_func("id/target", MYNEWT_VAL(TARGET_NAME));
+#endif
     }
 #if MYNEWT_VAL(ID_SERIAL_PRESENT)
     export_func("id/serial", id_serial);
diff --git a/sys/id/syscfg.yml b/sys/id/syscfg.yml
index 09cd34d..8e5f29b 100644
--- a/sys/id/syscfg.yml
+++ b/sys/id/syscfg.yml
@@ -45,3 +45,10 @@ syscfg.defs:
         value: 0
         restrictions:
             - 'ID_MODEL_PRESENT'
+
+    ID_TARGET_PRESENT:
+        description: 'Target name string exported as `id/target`.'
+        value: 0
+        restrictions:
+            # Older versions of newt don't export the target name.
+            - 'TARGET_NAME'