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

Expose plugin version in meson and make builds #142

Merged
merged 1 commit into from
May 29, 2024
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
6 changes: 6 additions & 0 deletions config.h.acr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef R2GHIDRA_CONFIG_H
#define R2GHIDRA_CONFIG_H 1

#define R2GHIDRA_VERSION "@R2GHIDRA_VERSION@"

#endif
5 changes: 3 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ parse_options "$1"
shift
done

ENVWORDS="MANDIR DESCRIPTION INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR ETCDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGCFG_LIBDIR PKGCFG_INCDIR PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CXX CXXFLAGS LDFLAGS HAVE_LANG_CXX CPP HAVE_GIT GIT PKGCONFIG R2_CFLAGS R2_LDFLAGS HAVE_PKGCFG_R_CORE R2ASM_CFLAGS R2ASM_LDFLAGS HAVE_PKGCFG_R_ASM R2ANAL_CFLAGS R2ANAL_LDFLAGS HAVE_PKGCFG_R_ANAL HAVE_R2 R2 HAVE_BISON BISON HAVE_FLEX FLEX R2_PREFIX R2_USER_PLUGINS R2_LIBR_PLUGINS"
ENVWORDS="MANDIR DESCRIPTION INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR ETCDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGCFG_LIBDIR PKGCFG_INCDIR PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CXX CXXFLAGS LDFLAGS HAVE_LANG_CXX CPP HAVE_GIT GIT PKGCONFIG R2_CFLAGS R2_LDFLAGS HAVE_PKGCFG_R_CORE R2ASM_CFLAGS R2ASM_LDFLAGS HAVE_PKGCFG_R_ASM R2ANAL_CFLAGS R2ANAL_LDFLAGS HAVE_PKGCFG_R_ANAL HAVE_R2 R2 HAVE_BISON BISON HAVE_FLEX FLEX R2_PREFIX R2_USER_PLUGINS R2_LIBR_PLUGINS R2GHIDRA_VERSION"

create_environ

Expand Down Expand Up @@ -542,6 +542,7 @@ else
echo "not found"
echo 'required'; exit 1
fi
R2GHIDRA_VERSION="$VERSION"
SEDFLAGS=" -e '"
COUNT=0
for A in ${ENVWORDS} ; do
Expand All @@ -554,7 +555,7 @@ for A in ${ENVWORDS} ; do
SEDFLAGS="${SEDFLAGS}s,@${A}@,${VAR},g;"
done
SEDFLAGS="${SEDFLAGS}'"
for A in config.mk Makefile ; do # SUBDIRS
for A in config.mk config.h Makefile ; do # SUBDIRS
if [ -f "${VPATH}/${A}.acr" ]; then
SD_TARGET=${A}
else
Expand Down
4 changes: 3 additions & 1 deletion configure.acr
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ EXEC! R2_PREFIX r2 -H R2_PREFIX ;
EXEC! R2_USER_PLUGINS r2 -H R2_USER_PLUGINS ;
EXEC! R2_LIBR_PLUGINS r2 -H R2_LIBR_PLUGINS ;

SUBDIRS config.mk Makefile ;
R2GHIDRA_VERSION = $VERSION ;

SUBDIRS config.mk config.h Makefile ;

REPORT VERSION R2_PREFIX PREFIX PKGCONFIG ;
9 changes: 9 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ else
r_core = dependency('r_core')
endif

r2ghidra_version = meson.project_version()
versionconf = configuration_data()
versionconf.set('R2GHIDRA_VERSION', r2ghidra_version)
r_version_h = configure_file(
input: 'config.h.acr',
output: 'config.h',
configuration: versionconf
)

r2ghidra_incdirs = include_directories(incdirs)

ghidra_decompiler_sources = [
Expand Down
2 changes: 2 additions & 0 deletions src/core_ghidra_plugin.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <r_core.h>
#include "../config.h"

extern int r2ghidra_core_fini(void *user, const char *cmd);
extern int r2ghidra_core_init(void *user, const char *cmd);
Expand All @@ -11,6 +12,7 @@ RCorePlugin r_core_plugin_ghidra = {
.desc = "Ghidra decompiler with pdg command",
.license = "GPL3",
.author = "thestr4ng3r, pancake",
.version = R2GHIDRA_VERSION,
},
#else
.name = "r2ghidra",
Expand Down
Loading