Skip to content

Commit

Permalink
Emit the lcm-gen version used in the generated code.
Browse files Browse the repository at this point in the history
  • Loading branch information
judfs committed Mar 20, 2024
1 parent 18fcb8f commit 2d7f297
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 5 deletions.
10 changes: 10 additions & 0 deletions lcm/lcm_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@
#define LCM_MAJOR_VERSION LCM_VERSION_MAJOR
#define LCM_MINOR_VERSION LCM_VERSION_MINOR
#define LCM_MICRO_VERSION LCM_VERSION_PATCH

// Macro required indirection.
#define _MACRO_LCM_STRINGIFY(x) #x
/// Surround x in quotes. x may be the result of another macro.
#define MACRO_LCM_STRINGIFY(x) _MACRO_LCM_STRINGIFY(x)

/// "x.y.z"
#define LCM_VERSION_STRING \
MACRO_LCM_STRINGIFY(LCM_VERSION_MAJOR) \
"." MACRO_LCM_STRINGIFY(LCM_VERSION_MINOR) "." MACRO_LCM_STRINGIFY(LCM_VERSION_PATCH)
3 changes: 2 additions & 1 deletion lcmgen/emit_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#endif
#include <inttypes.h>

#include "../lcm/lcm_version.h"
#include "lcmgen.h"

#define INDENT(n) (4 * (n))
Expand Down Expand Up @@ -78,7 +79,7 @@ static void emit_auto_generated_warning(FILE *f)
"// THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY\n"
"// BY HAND!!\n"
"//\n"
"// Generated by lcm-gen\n\n");
"// Generated by lcm-gen " LCM_VERSION_STRING "\n\n");
}

// Some types do not have a 1:1 mapping from lcm types to native C
Expand Down
4 changes: 3 additions & 1 deletion lcmgen/emit_cpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <sys/stat.h>
#include <sys/types.h>

#include "../lcm/lcm_version.h"
#include "lcmgen.h"

#define INDENT(n) (4 * (n))
Expand Down Expand Up @@ -149,7 +150,8 @@ static void emit_auto_generated_warning(FILE *f)
"/** THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY\n"
" * BY HAND!!\n"
" *\n"
" * Generated by lcm-gen\n"
" * Generated by lcm-gen " LCM_VERSION_STRING
"\n"
" **/\n\n");
}

Expand Down
4 changes: 3 additions & 1 deletion lcmgen/emit_csharp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <sys/stat.h>
#include <sys/types.h>

#include "../lcm/lcm_version.h"
#include "getopt.h"
#include "lcmgen.h"

Expand Down Expand Up @@ -346,7 +347,8 @@ int emit_csharp(lcmgen_t *lcm)

emit(0,
"/* LCM type definition class file\n"
" * This file was automatically generated by lcm-gen\n"
" * This file was automatically generated by lcm-gen " LCM_VERSION_STRING
"\n"
" * DO NOT MODIFY BY HAND!!!!\n"
" */\n");

Expand Down
3 changes: 2 additions & 1 deletion lcmgen/emit_go.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define __STDC_FORMAT_MACROS // Enable integer types
#endif

#include "../lcm/lcm_version.h"
#include "lcmgen.h"

#define TABS "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
Expand Down Expand Up @@ -382,7 +383,7 @@ static void emit_auto_generated_warning(FILE *f)
"// THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY\n"
"// BY HAND!!\n"
"//\n"
"// Generated by lcm-gen\n\n");
"// Generated by lcm-gen " LCM_VERSION_STRING "\n\n");
}

/*
Expand Down
3 changes: 3 additions & 0 deletions lcmgen/emit_java.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <sys/stat.h>
#include <sys/types.h>

#include "../lcm/lcm_version.h"
#include "getopt.h"
#include "lcmgen.h"

Expand Down Expand Up @@ -499,6 +500,8 @@ int emit_java(lcmgen_t *lcm)
"/* LCM type definition class file\n"
" * This file was automatically generated by lcm-gen\n"
" * DO NOT MODIFY BY HAND!!!!\n"
" * lcm-gen " LCM_VERSION_STRING
"\n"
" */\n");

if (strlen(lr->structname->package) > 0)
Expand Down
6 changes: 5 additions & 1 deletion lcmgen/emit_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <sys/types.h>
#include <unistd.h>

#include "../lcm/lcm_version.h"
#include "lcmgen.h"

// lua uses just 2 spaces per indent
Expand Down Expand Up @@ -922,6 +923,8 @@ static int emit_package(lcmgen_t *lcm, _package_contents_t *pc)
"LCM package init.lua file\n"
"This file automatically generated by lcm-gen.\n"
"DO NOT MODIFY BY HAND!!!!\n"
"lcm-gen " LCM_VERSION_STRING
"\n"
"--]]\n"
"\n"
"local M = {}\n"
Expand Down Expand Up @@ -1059,7 +1062,8 @@ static int emit_package(lcmgen_t *lcm, _package_contents_t *pc)
fprintf(f,
"--[[\n"
"LCM type definitions\n"
"This file automatically generated by lcm.\n"
"This file automatically generated by lcm " LCM_VERSION_STRING
".\n"
"DO NOT MODIFY BY HAND!!!!\n"
"--]]\n"
"\n"
Expand Down
3 changes: 3 additions & 0 deletions lcmgen/emit_python.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <sys/types.h>
#include <unistd.h>

#include "../lcm/lcm_version.h"
#include "lcmgen.h"

#define INDENT(n) (4 * (n))
Expand Down Expand Up @@ -808,6 +809,7 @@ emit_package (lcmgen_t *lcm, _package_contents_t *package)
fprintf (init_py_fp, "\"\"\"LCM package __init__.py file\n"
"This file automatically generated by lcm-gen.\n"
"DO NOT MODIFY BY HAND!!!!\n"
"lcm-gen " LCM_VERSION_STRING "\n"
"\"\"\"\n\n");
} else {
while(!feof(init_py_fp)) {
Expand Down Expand Up @@ -862,6 +864,7 @@ emit_package (lcmgen_t *lcm, _package_contents_t *package)
fprintf(f, "\"\"\"LCM type definitions\n"
"This file automatically generated by lcm.\n"
"DO NOT MODIFY BY HAND!!!!\n"
"lcm-gen " LCM_VERSION_STRING "\n"
"\"\"\"\n"
"\n"
"from io import BytesIO\n"
Expand Down

0 comments on commit 2d7f297

Please sign in to comment.