Add version of external libraries (Scintilla/Lexilla/Boost) into Debug Info

Dynamically collects all the version info needed and creates NppLibsVersion.h file by the help of a pre-build event.

Fix https://community.notepad-plus-plus.org/topic/21513/determining-supporting-library-versions

Fix #11466, close #16318
This commit is contained in:
xomx 2025-03-23 08:38:40 +01:00 committed by Don Ho
parent 56795061c5
commit 9eb2598ea4
10 changed files with 123 additions and 4 deletions

1
.gitignore vendored
View File

@ -101,6 +101,7 @@ PowerEditor/visual.net/ARM64
PowerEditor/src/tools/NppShell/build_ARM64
PowerEditor/src/tools/NppShell/build_Win32
PowerEditor/src/tools/NppShell/build_x64
PowerEditor/src/NppLibsVersion.h
# scintilla - generated files
scintilla/bin/SciLexer.*

View File

@ -184,6 +184,7 @@ CPDIR := cp -r
RMDIR := rm -rf
CP := cp
RM := rm -f
PREBUILD_EVENT_CMD := cmd //C "cd PowerEditor/src && NppLibsVersionH-generator.bat"
normalize-path = $1
else ifneq "$(wildcard $(dir $(SHELL))ls.exe)" ""
# a Windows system with a proper shell
@ -195,6 +196,7 @@ CPDIR := $(SHELL_DIRECTORY)cp.exe -r
RMDIR := $(SHELL_DIRECTORY)rm.exe -rf
CP := $(SHELL_DIRECTORY)cp.exe
RM := $(SHELL_DIRECTORY)rm.exe -f
PREBUILD_EVENT_CMD := cmd //C "cd PowerEditor/src && NppLibsVersionH-generator.bat"
normalize-path = $1
else
# a standard Windows system
@ -203,6 +205,7 @@ CPDIR := xcopy /q /e /i /y
RMDIR := rmdir /q /s
CP := copy /y
RM := del /q
PREBUILD_EVENT_CMD := cd ..\src && NppLibsVersionH-generator.bat
normalize-path = $(subst /,\,$1)
endif
@ -230,9 +233,13 @@ RC_TARGETS := $(patsubst %.rc,$(BUILD_DIRECTORY)/%.res,$(sort $(filter %.rc,$(GC
SUBMAKEFLAGS += $(if $(NUMBER_OF_PROCESSORS),-j$(NUMBER_OF_PROCESSORS),)
all: $(SCINTILLA_TARGET) $(LEXILLA_TARGET)
all: pre-build-event $(SCINTILLA_TARGET) $(LEXILLA_TARGET)
$(AT)$(MAKE) -f $(firstword $(MAKEFILE_LIST)) $(SUBMAKEFLAGS) binary
pre-build-event:
@echo Executing pre-build events...
$(AT)$(PREBUILD_EVENT_CMD)
$(BUILD_DIRECTORY):
@echo + creating BUILD_DIRECTORY $@
$(AT)$(MKDIR) $(call normalize-path,$(sort $@ $(patsubst %/,%,$(dir $(CXX_TARGETS) $(RC_TARGETS)))))

View File

@ -423,6 +423,15 @@ find_library(LEXILLA_STATIC_LIBRARY
REQUIRED
)
execute_process(
COMMAND cmd /C "cd ${CMAKE_SOURCE_DIR} && NppLibsVersionH-generator.bat"
RESULT_VARIABLE pre-build-result
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
if(NOT pre-build-result EQUAL 0)
message(FATAL_ERROR "Pre-build event failed with exit code: ${pre-build-result}")
endif()
ADD_EXECUTABLE(notepad++ ${option} ${src_files} ${include_files} ${rcFiles})

View File

@ -0,0 +1,47 @@
@echo off
rem If this batch file is called from the Microsoft Visual Studio pre-build event,
rem then the current dir for this bat-file is set to Notepad++ solution/project dir.
rem Because in this batch file we have to go two dir-levels higher (for finding the files
rem from the external libraries) from both the solution/project dir and from the dir,
rem where this batch file is located, we can run this batch file ok also manually
rem and not only from that MSVS event.
set outputFile="..\..\PowerEditor\src\NppLibsVersion.h"
if exist %outputFile% del %outputFile%
rem First "for" finds and extracts specific one line string like "#define VERSION_SCINTILLA "5.5.4"".
rem Second "for" then uses regex to extract only the "..." version part substring from it.
set sciVerStr="N/A"
for /F "delims=" %%a in ('findstr /L /C:"#define VERSION_SCINTILLA " "..\..\scintilla\win32\ScintRes.rc"') do (
for %%b in (%%a) do (
echo %%b | findstr /R "[0-9]*\.[0-9]*\." > nul 2>&1 && set sciVerStr=%%b
)
)
set lexVerStr="N/A"
for /F "delims=" %%a in ('findstr /L /C:"#define VERSION_LEXILLA " "..\..\lexilla\src\LexillaVersion.rc"') do (
for %%b in (%%a) do (
echo %%b | findstr /R "[0-9]*\.[0-9]*\." > nul 2>&1 && set lexVerStr=%%b
)
)
set boostRegexVerStr="N/A"
for /F "delims=" %%a in ('findstr /L /C:"#define BOOST_LIB_VERSION " "..\..\boostregex\boost\version.hpp"') do (
for %%b in (%%a) do (
echo %%b | findstr /R "[0-9]*_[0-9]*\" > nul 2>&1 && set boostRegexVerStr=%%b
)
)
rem At this point, we should have the quoted version strings collected:
echo Scintilla version detected: %sciVerStr%
echo Lexilla version detected: %lexVerStr%
echo Boost Regex version detected: %boostRegexVerStr%
rem And finally create the output file:
echo // NppLibsVersion.h>%outputFile%
echo // - maintained by NppLibsVersionH-generator.bat>>%outputFile%
echo #define NPP_SCINTILLA_VERSION %sciVerStr%>>%outputFile%
echo #define NPP_LEXILLA_VERSION %lexVerStr%>>%outputFile%
echo #define NPP_BOOST_REGEX_VERSION %boostRegexVerStr%>>%outputFile%

View File

@ -18,6 +18,11 @@
#include "AboutDlg.h"
#include "Parameters.h"
#include "localization.h"
#if defined __has_include
#if __has_include ("NppLibsVersion.h")
#include "NppLibsVersion.h"
#endif
#endif
using namespace std;
@ -197,6 +202,21 @@ intptr_t CALLBACK DebugInfoDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_debugInfoStr += L"Built with : (unknown)\r\n";
#endif
// Scintilla/Lexilla version
_debugInfoStr += L"Scintilla/Lexilla included : ";
{
string strSciLexVer = NPP_SCINTILLA_VERSION;
strSciLexVer += "/";
strSciLexVer += NPP_LEXILLA_VERSION;
_debugInfoStr += wmc.char2wchar(strSciLexVer.c_str(), CP_ACP);
}
_debugInfoStr += L"\r\n";
// Boost Regex version
_debugInfoStr += L"Boost Regex included : ";
_debugInfoStr += wmc.char2wchar(NPP_BOOST_REGEX_VERSION, CP_ACP);
_debugInfoStr += L"\r\n";
// Binary path
_debugInfoStr += L"Path : ";
wchar_t nppFullPath[MAX_PATH]{};

View File

@ -54,6 +54,9 @@
<Manifest>
<AdditionalManifestFiles>..\src\dpiAware.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles>
</Manifest>
<PreBuildEvent>
<Command>call "..\..\PowerEditor\src\NppLibsVersionH-generator.bat"</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(PlatformToolset)'=='ClangCL'">
<ClCompile>

View File

@ -0,0 +1,32 @@
// Boost version.hpp configuration header file ------------------------------//
// (C) Copyright John maddock 1999. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/config for documentation
#ifndef BOOST_VERSION_HPP
#define BOOST_VERSION_HPP
//
// Caution: this is the only Boost header that is guaranteed
// to change with every Boost release. Including this header
// will cause a recompile every time a new Boost version is
// used.
//
// BOOST_VERSION % 100 is the patch level
// BOOST_VERSION / 100 % 1000 is the minor version
// BOOST_VERSION / 100000 is the major version
#define BOOST_VERSION 108500
//
// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
// but as a *string* in the form "x_y[_z]" where x is the major version
// number, y is the minor version number, and z is the patch level if not 0.
// This is used by <config/auto_link.hpp> to select which library version to link to.
#define BOOST_LIB_VERSION "1_85"
#endif

View File

@ -15,7 +15,7 @@ SRC_OBJS=\
INCLUDES=$(INCLUDES) -I../../boostregex
CXXFLAGS=$(CXXFLAGS) -DSCI_OWNREGEX
CXXFLAGS=$(CXXFLAGS) -DSCI_OWNREGEX -DBOOST_REGEX_STANDALONE
$(DIR_O)\UTF8DocumentIterator.obj:: ../../boostregex/UTF8DocumentIterator.cxx

View File

@ -11,7 +11,7 @@ vpath %.h $(DIR_BOOST)
vpath %.cxx $(DIR_BOOST)
INCLUDES += -I $(DIR_BOOST)
CXXFLAGS += -DSCI_OWNREGEX
CXXFLAGS += -DSCI_OWNREGEX -DBOOST_REGEX_STANDALONE
BOOST_OBJS = \
$(DIR_O)/BoostRegExSearch.o \

View File

@ -91,7 +91,7 @@
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_USRDLL;SCI_OWNREGEX;SCI_NAMESPACE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_USRDLL;BOOST_REGEX_STANDALONE;SCI_OWNREGEX;SCI_NAMESPACE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\include;..\src;..\..\boostregex</AdditionalIncludeDirectories>
<BrowseInformation>true</BrowseInformation>
<MultiProcessorCompilation>true</MultiProcessorCompilation>