Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions _audioif.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "py/mperrno.h"
#include "py/mphal.h"
#include "py/obj.h"
#include "py/objstr.h"
#include "py/runtime.h"

#include "audiocore/__init__.h"
Expand Down Expand Up @@ -1760,8 +1761,18 @@ static MP_DEFINE_CONST_FUN_OBJ_0(audiopump_lock_probe_obj,

#endif


// _audioif.__revision__: which audioif this firmware was built from. The build
// passes AUDIOIF_REVISION (git describe) as a compile definition; a build with no
// git says "unknown" rather than guessing.
#ifndef AUDIOIF_REVISION
#define AUDIOIF_REVISION "unknown"
#endif
static const MP_DEFINE_STR_OBJ(_audioif_revision_obj, AUDIOIF_REVISION);

static const mp_rom_map_elem_t audioif_driver_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__audioif) },
{ MP_ROM_QSTR(MP_QSTR___revision__), MP_ROM_PTR(&_audioif_revision_obj) },
// What this driver says it is. audiopump.driver() asks the ENGINE the same
// question, through the binding; the two agreeing is the proof the
// binding took.
Expand Down
13 changes: 13 additions & 0 deletions micropython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,16 @@ target_include_directories(usermod_audiopump INTERFACE
target_compile_definitions(usermod_audiopump INTERFACE AUDIOIF_DRIVER_ESP32=1)

target_link_libraries(usermod INTERFACE usermod_audiopump)

# --- which audioif this firmware was built from ----------------------
# Computed at build time from this repo's own git, never stored; "unknown" when
# there is no git (a tarball). Read on a target as <module>.__revision__.
execute_process(
COMMAND git -C ${AUDIOPUMP_MOD_DIR} describe --always --dirty --abbrev=7
OUTPUT_VARIABLE AUDIOIF_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
if(NOT AUDIOIF_REVISION)
set(AUDIOIF_REVISION "unknown")
endif()
target_compile_definitions(usermod_audiopump INTERFACE AUDIOIF_REVISION=\"${AUDIOIF_REVISION}\")
6 changes: 6 additions & 0 deletions micropython.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ AUDIODSP_DIR ?= $(abspath $(AUDIOPUMP_MOD_DIR)/../audiodsp)
CFLAGS_USERMOD += -I$(AUDIODSP_DIR)/src
SRC_USERMOD_C += $(AUDIOPUMP_MOD_DIR)/_audioif.c
SRC_USERMOD_C += $(AUDIOPUMP_MOD_DIR)/audiobusio.c

# --- which audioif this firmware was built from ----------------------
# Computed at build time from this repo's own git, never stored; "unknown" when
# there is no git (a tarball). Read on a target as <module>.__revision__.
AUDIOIF_REVISION := $(shell git -C $(AUDIOPUMP_MOD_DIR) describe --always --dirty --abbrev=7 2>/dev/null || echo unknown)
CFLAGS_USERMOD += -DAUDIOIF_REVISION='"$(AUDIOIF_REVISION)"'
Loading