Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version to binary info #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ pico_generate_pio_header(debugprobe ${CMAKE_CURRENT_LIST_DIR}/src/probe_oen.pio)

target_include_directories(debugprobe PRIVATE src)

# add version
add_custom_target(version
${CMAKE_SOURCE_DIR}/get-version.sh
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

target_include_directories(debugprobe PRIVATE
${CMAKE_BINARY_DIR}/generated
)

add_dependencies(debugprobe version)

target_compile_definitions (debugprobe PRIVATE
PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1
)
Expand Down
21 changes: 21 additions & 0 deletions get-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
if command -v git &>/dev/null
then
VERSION=$(git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD)
else
VERSION="unknown"
fi

if [ ! -e generated/probe ]
then
mkdir -p generated/probe
fi

cat > generated/probe/version.h << EOF
#ifndef _PROBE_VERSION_H
#define _PROBE_VERSION_H

#define PROBE_VERSION "${VERSION}"

#endif
EOF
3 changes: 2 additions & 1 deletion src/probe_config.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "probe_config.h"
#include "pico/binary_info.h"

#include "probe/version.h"

#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)


void bi_decl_config()
{
bi_decl(bi_program_version_string(PROBE_VERSION));
#ifdef PROBE_PIN_RESET
bi_decl(bi_1pin_with_name(PROBE_PIN_RESET, "PROBE RESET"));
#endif
Expand Down