Skip to content

Commit

Permalink
report build in mod menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ngwese committed Sep 24, 2024
1 parent 8ac8bb2 commit a9e440c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build/
#*
*~

src/spn_version.h
19 changes: 19 additions & 0 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
find_package(Git)

if(GIT_EXECUTABLE)
get_filename_component(WORKING_DIR ${SRC} DIRECTORY)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty
WORKING_DIRECTORY ${WORKING_DIR}
OUTPUT_VARIABLE REPO_VERSION
RESULT_VARIABLE ERROR_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()

if(REPO_VERSION STREQUAL "")
set(REPO_VERSION 0.0.0-unknown)
message(WARNING "Failed to determine version from Git tags. Using default version \"${REPO_VERSION}\".")
endif()

configure_file(${SRC} ${DST} @ONLY)
28 changes: 26 additions & 2 deletions mod/lib/mod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ end
local rules_file = "59-soundplane.rules"
local rules_dst = "/etc/udev/rules.d/" .. rules_file

local spn_udev_rules_ok = false

local spn_udev_rules_installed = function()
local f = io.open(rules_dst, "r")
if f ~= nil then
io.close(f)
spn_udev_rules_ok = true
return true
end

Expand All @@ -72,6 +75,8 @@ local spn_install_udev_rules = function()
print(" >> '" .. cmd_reload .. "'")
os.execute(cmd_reload)
print("spn: udev rule installation complete")

spn_udev_rules_ok = true
end

local post_startup = function()
Expand Down Expand Up @@ -106,12 +111,31 @@ menu.enc = function(n, d)
end

menu.redraw = function()
local start_x = 4
local line_y = 10
screen.clear()
screen.move(64,40)
screen.text_center("spn")
screen.move(start_x, 1 * line_y)
screen.text("spn")
screen.move(start_x, 2 * line_y)
screen.text("build: " .. spn.client.VERSION)
screen.move(start_x, 3 * line_y)
if spn_udev_rules_ok then
screen.text("udev: ok")
else
screen.text("udev: not installed")
end

if spn.client.is_running() then
screen.move(start_x, 4 * line_y)
screen.text("client: running")
screen.move(start_x, 5 * line_y)
screen.text("rate: " .. spn.client.get_property('data_rate'))
end

screen.update()
end


menu.init = function() end -- on menu entry, ie, if you wanted to start timers
menu.deinit = function() end -- on menu exit

Expand Down
9 changes: 9 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ include(FindPkgConfig)
pkg_check_modules(LIBLUA REQUIRED lua-5.3)
include_directories(${LIBLUA_INCLUDE_DIRS})

#
# version
#
add_custom_target(spn_version
${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/spn_version.h.in
-D DST=${CMAKE_CURRENT_SOURCE_DIR}/spn_version.h
-P ${CMAKE_SOURCE_DIR}/cmake/version.cmake
)

#
# module
Expand All @@ -26,6 +34,7 @@ set(SOURCE_FILES
)

add_library(lua-extension MODULE ${SOURCE_FILES})
add_dependencies(lua-extension spn_version)
set_target_properties(lua-extension PROPERTIES
PREFIX "" # strip `lib` prefix
OUTPUT_NAME "${LUA_MODULE_NAME}"
Expand Down
2 changes: 1 addition & 1 deletion src/spn_module.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __LUA_SPN_H__
#define __LUA_SPN_H__

#define LUA_SPN_VERSION "0.4"
#include "spn_version.h"

#ifndef LUA_SPN_API
#define LUA_SPN_API __attribute__((visibility("default")))
Expand Down
6 changes: 6 additions & 0 deletions src/spn_version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __LUA_SPN_VERSION_H__
#define __LUA_SPN_VERSION_H__

#define LUA_SPN_VERSION "@REPO_VERSION@"

#endif

0 comments on commit a9e440c

Please sign in to comment.