Skip to content

Add version to example myapp output #2

@oxr463

Description

@oxr463

Current output:

./myapp
KBuild template sample application... Start!

You have configured
        - Foo
        - Bar

Depending on your configuration, several log messages will be printed now:

2022.05.20-04:00:13 This is a LOG_INFO log message.
2022.05.20-04:00:13 This is a LOG_WARN log message.
2022.05.20-04:00:13 This is a LOG_ERROR log message.
2022.05.20-04:00:13 This is a LOG_DEBUG log message.

KBuild template sample application... Done!

I would like to include the version information:

./myapp
KBuild template sample application... Start!

Your version
    1.0.0

You have configured
        - Foo
        - Bar

Depending on your configuration, several log messages will be printed now:

2022.05.20-04:00:13 This is a LOG_INFO log message.
2022.05.20-04:00:13 This is a LOG_WARN log message.
2022.05.20-04:00:13 This is a LOG_ERROR log message.
2022.05.20-04:00:13 This is a LOG_DEBUG log message.

KBuild template sample application... Done!

I made the following changes:

git diff
diff --git a/main/main.c b/main/main.c
index 2cb474b..bbd7a69 100644
--- a/main/main.c
+++ b/main/main.c
@@ -7,6 +7,7 @@
  */
 
 #include <generated/autoconf.h>
+#include <generated/version.h>
 #include <stdio.h>
 #include <my_functions.h>
 
@@ -16,6 +17,8 @@ int main(void)
 {
        printf("KBuild template sample application... Start!\n\n");
 
+       printf("Your version\n\t%s", MYAPP_VERSION);
+
     printf("You have configured\n");
 #ifdef CONFIG_FOO
     printf("\t- Foo\n");

But it fails to compile:

make
  CHK     include/generated/version.h
  CC      main/main.o
main/main.c: In function 'main':
main/main.c:20:31: error: 'MYAPP_VERSION' undeclared (first use in this function)
   20 |  printf("Your version\n\t%s", MYAPP_VERSION);
      |                               ^~~~~~~~~~~~~
main/main.c:20:31: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [scripts/Makefile.build:182: main/main.o] Error 1
make: *** [Makefile:594: main] Error 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions