Skip to content

Commit

Permalink
tree-wide: adjust version handling for meson
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Braunwarth <[email protected]>
  • Loading branch information
d4nuu8 committed Jan 22, 2025
1 parent bd328f3 commit 41f4174
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Makefile.flags
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ KBUILD_CPPFLAGS += $(call cc-option,-std=gnu99,)
KBUILD_CPPFLAGS += -D_GNU_SOURCE -DNDEBUG

# Generate version
KBUILD_CPPFLAGS += -DVERSION=$(VERSION)
KBUILD_CPPFLAGS += -DVERSION_PATCHLEVEL=$(PATCHLEVEL)
KBUILD_CPPFLAGS += -DVERSION_SUBLEVEL=$(SUBLEVEL)
KBUILD_CPPFLAGS += -DVERSION_EXTRAVERSION=$(shell $(srctree)/scripts/gen_extraversion)
KBUILD_CPPFLAGS += -DVERSION_YEAR=$(VERSION)
KBUILD_CPPFLAGS += -DVERSION_MONTH=$(PATCHLEVEL)
KBUILD_CPPFLAGS += -DVERSION_PATCH=$(SUBLEVEL)
KBUILD_CPPFLAGS += -DVERSION_EXTRA=$(shell $(srctree)/scripts/gen_extraversion)

KBUILD_CFLAGS += $(call cc-option,-Wall,)
KBUILD_CFLAGS += $(call cc-option,-Wshadow,)
Expand Down
12 changes: 6 additions & 6 deletions corelib/lua_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,18 +1001,18 @@ static void lua_push_enum(lua_State *L, const char *name, int value)

int lua_get_swupdate_version(lua_State *L)
{
const unsigned int version = VERSION;
const unsigned int patchlevel = VERSION_PATCHLEVEL;
const unsigned int version_year = VERSION_YEAR;
const unsigned int version_month = VERSION_MONTH;

lua_newtable (L);
lua_pushnumber(L, 1);
lua_pushnumber(L, version);
lua_pushnumber(L, version_year);
lua_settable(L, -3);
lua_pushnumber(L, 2);
lua_pushnumber(L, patchlevel);
lua_pushnumber(L, version_month);
lua_settable(L, -3);
lua_push_enum(L, "version", version);
lua_push_enum(L, "patchlevel", patchlevel);
lua_push_enum(L, "version", version_year);
lua_push_enum(L, "patchlevel", version_month);
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion include/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define STR(x) STR_HELPER(x)

#define BANNER "SWUpdate v" \
STR(VERSION)"."STR(VERSION_PATCHLEVEL)"."STR(VERSION_SUBLEVEL)"-"STR(VERSION_EXTRAVERSION)
STR(VERSION_YEAR)"."STR(VERSION_MONTH)"."STR(VERSION_PATCH)"-"STR(VERSION_EXTRA)

#define SWUPDATE_GENERAL_STRING_SIZE 256
#define SWUPDATE_UPDATE_DESCRIPTION_STRING_SIZE 512
Expand Down
12 changes: 11 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ project(
version: files('meson.version'),
)

add_global_arguments('-DSWU_VER="1.0.0"', language: 'c')
version_components = meson.project_version().split('.')
version_year = version_components[0]
version_month = version_components[1]
version_patch = version_components[2]
version_extra = run_command('./scripts/gen_extraversion', check: true).stdout().strip()

add_global_arguments('-DVERSION_YEAR=' + version_year, language: 'c')
add_global_arguments('-DVERSION_MONTH=' + version_month, language: 'c')
add_global_arguments('-DVERSION_PATCH=' + version_patch, language: 'c')
add_global_arguments('-DVERSION_EXTRA=' + version_extra, language: 'c')

add_global_arguments('-D_GNU_SOURCE', language: 'c')

cc = meson.get_compiler('c')
Expand Down
1 change: 1 addition & 0 deletions meson.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024.12.0

0 comments on commit 41f4174

Please sign in to comment.