From 049ededf9fa1c8ad719f37d7f1f95269d6dc25dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ust=C3=BB=C5=BEanin?= Date: Sat, 4 Sep 2021 22:29:29 +0300 Subject: [PATCH] Add gcc 32-bit build and improve build process 1. Include SciLexer build in Notepad++ build. 2. Remove -fpermissive, auto -j in make. Fix #9989, close #10540 --- .gitignore | 11 +- BUILD.md | 40 +-- PowerEditor/gcc/gcc-fixes.h | 14 + PowerEditor/gcc/include/various.h | 52 ---- PowerEditor/gcc/makefile | 243 +++++++++++++----- .../gcc/{gcc-manifest.rc => manifest.rc} | 0 PowerEditor/gcc/readme.txt | 24 -- PowerEditor/src/DarkMode/DarkMode.cpp | 10 +- PowerEditor/src/DarkMode/IatHook.h | 2 +- PowerEditor/src/NppDarkMode.cpp | 7 +- appveyor.yml | 133 +++++----- 11 files changed, 292 insertions(+), 244 deletions(-) create mode 100644 PowerEditor/gcc/gcc-fixes.h delete mode 100644 PowerEditor/gcc/include/various.h rename PowerEditor/gcc/{gcc-manifest.rc => manifest.rc} (100%) delete mode 100644 PowerEditor/gcc/readme.txt diff --git a/.gitignore b/.gitignore index ee6bdb5c6..e7ba21dde 100644 --- a/.gitignore +++ b/.gitignore @@ -149,18 +149,11 @@ PowerEditor/bin/SourceCodePro-Regular.ttf *.zip #------------------------------------------------------------------------------- -# GNU GCC MinGW +# MinGW-w64 GCC -#-- Generated during makefile build -PowerEditor/gcc/*.build/ -PowerEditor/bin/NotepadPP*.exe +bin.* scintilla/win32/*.o -scintilla/bin/libscilexer.a -#-- Generated manually to make Notepad++ execute properly on Linux using Wine -/PowerEditor/bin/libgcc_s_sjlj-1.dll -/PowerEditor/bin/libstdc++-6.dll -/PowerEditor/bin/libwinpthread-1.dll PowerEditor/src/MISC/md5/RCa06792 *.db diff --git a/BUILD.md b/BUILD.md index 4d9450daa..9771026c6 100644 --- a/BUILD.md +++ b/BUILD.md @@ -1,5 +1,4 @@ -How to build Notepad++ ----------------------- +# Building Notepad++ with Microsoft Visual Studio **Pre-requisites:** @@ -41,33 +40,22 @@ More about the previous build process: https://community.notepad-plus-plus.org/t Since `Notepad++` version 6.0 - 7.9.5, the build of dynamic linked `SciLexer.dll` that is distributed uses features from Boost's `Boost.Regex` library. -## Build 64 bits binaries with GCC: +# Building Notepad++ with GCC -If you have installed [MinGW-w64](https://mingw-w64.org/doku.php/start), then you can compile Notepad++ & libscilexer.a 64 bits binaries with GCC. +If you have [MinGW-w64](https://www.mingw-w64.org/) installed, you can compile Notepad++ with GCC. -* Compile libscilexer.a +MinGW-w64 can be downloaded from [SourceForge](https://sourceforge.net/projects/mingw-w64/files/). Building Notepad++ is regularly tested on a Windows system with [x86_64-8.1.0-release-posix-seh-rt_v6-rev0](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z) and with [i686-8.1.0-release-posix-dwarf-rt_v6-rev0](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-posix/dwarf/i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z) versions of MinGW-w64 GCC. Other versions may also work but are untested. -This step is not necessary anymore as it will be build in the process of compiling the Notepad++ binary. It is here just for completeness sake as this option is still available. +**Note:** If you use MinGW-w64 GCC from a package (7z), you need to manually add the `$MinGW-root$\bin` directory to the system `PATH` environment variable for the `mingw32-make` invocation below to work. One can use a command like `set PATH=$MinGW-root$\bin;%PATH%` each time `cmd` is launched. But beware that if `PATH` contains several versions of MinGW-w64 GCC, only the first one will be usable. -1. Launch cmd. -2. Change dir into `notepad-plus-plus\scintilla\win32`. -3. Type `mingw32-make.exe -j%NUMBER_OF_PROCESSORS%` -4. `libscilexer.a` is generated in `notepad-plus-plus\scintilla\bin\`. +## Comping Notepad++ binary -* Compile Notepad++ binary +1. Launch `cmd` and add `$MinGW-root$\bin` to `PATH` if necessary. +2. `cd` into `notepad-plus-plus\PowerEditor\gcc`. +3. Run `mingw32-make`. +4. The 32-bit or 64-bit `notepad++.exe` will be generated either in `bin.i686` or in `bin.x86_64` directory respectively, depending on the target CPU of the compiler — look for the full path to the resulting binary at the end of the build process. -1. Launch cmd. -2. Change dir into `notepad-plus-plus\PowerEditor\gcc`. -3. Type `mingw32-make.exe -j%NUMBER_OF_PROCESSORS%` -4. `NotepadPP-release.exe` is generated in `notepad-plus-plus\PowerEditor\bin\`. - -To have a debug build just add `DEBUG=1` to the `mingw32-make.exe` invocation. The binary will be called `NotepadPP-debug.exe` in this case. - -To see commands being executed add `VERBOSE=1` to the same command. - -You can download MinGW-w64 from https://sourceforge.net/projects/mingw-w64/files/. On Notepad++ Github page (this project), the build system use [MinGW 8.1](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z). - - -Note 1: if you use MinGW from the package (7z), you need manually add the MinGW/bin folder path to system Path variable to make mingw32-make.exe invoke works (or you can use command :`set PATH=%PATH%;C:\xxxx\mingw64\bin` for adding it on each time you launch cmd). - -Note 2: For 32-bit build, https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-posix/sjlj/i686-8.1.0-release-posix-sjlj-rt_v6-rev0.7z could be used. The rest of the instructions are still valid. +* The directory containing `notepad++.exe` will also contain everything needed for Notepad++ to start. +* To have a debug build just add `DEBUG=1` to the `mingw32-make` invocation above. The output directory then will be suffixed with `-debug`. +* To see commands being executed add `VERBOSE=1` to the same command. +* When switching between compilers or between release/debug modes, `mingw32-make clean` must be executed first. diff --git a/PowerEditor/gcc/gcc-fixes.h b/PowerEditor/gcc/gcc-fixes.h new file mode 100644 index 000000000..9a7da9a52 --- /dev/null +++ b/PowerEditor/gcc/gcc-fixes.h @@ -0,0 +1,14 @@ +// this file contains fixes needed for Notepad++ to be built by GCC +// the makefile automatically includes this file + +static constexpr unsigned int max(unsigned int a, unsigned int b) { + return a > b ? a : b; +} + +static constexpr unsigned int min(unsigned int a, unsigned int b) { + return a < b ? a : b; +} + +// __try and __except are unknown to GCC, so convert them to something eligible +#define __try try +#define __except(x) catch(...) diff --git a/PowerEditor/gcc/include/various.h b/PowerEditor/gcc/include/various.h deleted file mode 100644 index f75677e62..000000000 --- a/PowerEditor/gcc/include/various.h +++ /dev/null @@ -1,52 +0,0 @@ -//this file contains definitions not available in gcc 3.4.5, -//but are needed for Notepad++ -//the makefile will automatically include this header file - -//GetLongPathName = 410 -//Multimonitor: 410 -//#define _WIN32_WINDOWS 0x0410 -//Toolbar imagelist = 300 -//TCS_BOTTOM = 300 -//LVS_EX_BORDERSELECT = 500 -//TBSTYLE_EX_HIDECLIPPEDBUTTONS = 501 -//#define _WIN32_IE 0x501 -//Theme (uxtheme) -//#define _WIN32_WINNT 0x0600 - -//#include - -//#if (_WIN32_IE >= 0x0400) -//#define TCN_GETOBJECT (TCN_FIRST - 3) -//#endif - -//#if (_WIN32_IE >= 0x0500) -//#define RBN_CHEVRONPUSHED (RBN_FIRST - 10) -//#endif // _WIN32_IE >= 0x0500 -/* -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif -*/ - -static inline int max(unsigned int a, unsigned int b) { - return (((a) > (b)) ? (a) : (b)); -} - -static inline int min(unsigned int a, unsigned int b) { - return (((a) < (b)) ? (a) : (b)); -} - -//__try and __except dont work in gcc, so heres some defines to take em out -#define __try try -#define __except(x) catch(...) - -//Missing unicode CRT funcs -//double _wtof(const wchar_t * string); - -// from MinGW include/driverspecs.h -//#define __inout -//#define __inout_opt diff --git a/PowerEditor/gcc/makefile b/PowerEditor/gcc/makefile index 2b1454473..2d1e4ec68 100644 --- a/PowerEditor/gcc/makefile +++ b/PowerEditor/gcc/makefile @@ -14,58 +14,127 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Definitions: -SOURCE_DIR := ../src -SOURCE_EXCLUDE := $(SOURCE_DIR)/tools/% -TARGET_DIR := ../bin -TARGET_BASE := NotepadPP -TARGET_SUFFIX := .exe -CONFIG_FILES := langs.model.xml stylers.model.xml shortcuts.xml contextMenu.xml -GCC_DIR := . -SCINTILLA_DIR := ../../scintilla +# +# definitions +# + +GCC_DIRECTORY := ../gcc +GCC_EXCLUDE := $(GCC_DIRECTORY)/gcc-% +SRC_DIRECTORY := ../src +SRC_EXCLUDE := $(SRC_DIRECTORY)/tools/% +BIN_DIRECTORY := ../bin +INSTALLER_DIRECTORY := ../installer + +TARGET_BINARY := notepad++.exe +SRC_DATA := contextMenu.xml langs.model.xml shortcuts.xml stylers.model.xml +BIN_DATA := change.log doLocalConf.xml readme.txt userDefineLangs/ +INSTALLER_DATA := autoCompletion/ functionList/ localization/ themes/ + +SCINTILLA_DIRECTORY := ../../scintilla +SCINTILLA_TARGET := libscilexer.a CXX := $(CROSS_COMPILE)g++ -CXXFLAGS := -include $(GCC_DIR)/include/various.h -std=c++17 -fpermissive -Wno-conversion-null +CXXFLAGS := -include $(GCC_DIRECTORY)/gcc-fixes.h -std=c++17 -Wno-conversion-null RC := $(CROSS_COMPILE)windres RCFLAGS := -DEFINES := UNICODE _UNICODE _WIN32_WINNT=0x0600 TIXML_USE_STL TIXMLA_USE_STL -INCLUDES := $(SCINTILLA_DIR)/include -LD := $(CROSS_COMPILE)g++ +CPP_PATH := $(SCINTILLA_DIRECTORY)/include +CPP_DEFINE := UNICODE _UNICODE _WIN32_WINNT=0x0600 TIXML_USE_STL TIXMLA_USE_STL +LD := $(CXX) LDFLAGS := -municode -mwindows -LIBRARIES := comctl32 crypt32 dbghelp ole32 sensapi shlwapi uuid uxtheme version wininet wintrust -SCINTILLA_TARGET := $(SCINTILLA_DIR)/bin/libscilexer.a -SCINTILLA_LIBRARIES := imm32 msimg32 oleaut32 +LD_PATH := +LD_LINK := comctl32 crypt32 dbghelp ole32 sensapi shlwapi uuid uxtheme version wininet wintrust +LD_LINK += $(patsubst lib%.a,%,$(SCINTILLA_TARGET)) imm32 msimg32 ole32 oleaut32 SUBMAKEFLAGS := -O --no-print-directory -ifeq "$(strip $(DEBUG))" "" +# detect a request for a debug build +ifeq "$(filter-out 0,$(DEBUG))" "" +BUILD_TYPE := release +BUILD_SUFFIX := CXXFLAGS += -O2 -Os +CPP_DEFINE += NDEBUG LDFLAGS += -s -DEFINES += NDEBUG -BUILD_TYPE := $(CROSS_COMPILE)release else -CXXFLAGS += -g -Wall -Wpedantic -Wconversion-null -#DEFINES += DEBUG -BUILD_TYPE := $(CROSS_COMPILE)debug +BUILD_TYPE := debug +BUILD_SUFFIX := -debug +CXXFLAGS += -Og -g -Wall -Wpedantic -Wconversion-null +#CPP_DEFINE += DEBUG +endif + +# +# preparations +# + +# detect target CPU +TARGET_CPU := $(firstword $(subst -, ,$(shell $(CXX) -dumpmachine))) +ifeq "$(TARGET_CPU)" "" +$(error TARGET_CPU detection failed) endif +ifneq "$(filter-out x86_64 i686,$(TARGET_CPU))" "" +$(error $(TARGET_CPU) build is unsupported) +endif +ifeq "$(TARGET_CPU)" "i686" +# for some reason i686 versions of MinGW-w64 GCC don't include a linking library for SensApi.dll +# thus it is generated on the fly, but first check if the DLL is available +ifeq "$(wildcard $(windir)/system32/SensApi.dll)" "" +$(error $(TARGET_CPU) build requires "%windir%/system32/SensApi.dll" to be present) +endif +# detect explicit definition of TARGET_CPU via command line to force a 32-bit build +ifeq "$(origin TARGET_CPU)" "command line" +export CXX += -m32 +export LD += -m32 +export RC += -Fpe-i386 +endif +endif + +# define target and build directories and update dependent variables +TARGET_DIRECTORY := bin.$(TARGET_CPU)$(BUILD_SUFFIX) +BUILD_DIRECTORY := $(TARGET_DIRECTORY).build + +TARGET_BINARY := $(TARGET_DIRECTORY)/$(TARGET_BINARY) +SRC_DATA := $(addprefix $(TARGET_DIRECTORY)/,$(SRC_DATA)) +BIN_DATA := $(addprefix $(TARGET_DIRECTORY)/,$(BIN_DATA)) +INSTALLER_DATA := $(addprefix $(TARGET_DIRECTORY)/,$(INSTALLER_DATA)) + +SCINTILLA_TARGET := $(BUILD_DIRECTORY)/$(SCINTILLA_TARGET) + +LD_PATH += $(BUILD_DIRECTORY) + +# detect a build outside of PowerEditor/gcc and update dependent variables +MAKEFILE_DIRECTORY := $(patsubst %/,%,$(dir $(subst \,/,$(firstword $(MAKEFILE_LIST))))) +ifneq "$(MAKEFILE_DIRECTORY)" "." +MAKEFILE_PARENT := $(patsubst %/,%,$(dir $(MAKEFILE_DIRECTORY))) -BUILD_DIR := $(BUILD_TYPE).build -TARGET_BINARY := $(TARGET_DIR)/$(TARGET_BASE)-$(BUILD_TYPE)$(TARGET_SUFFIX) +BIN_DIRECTORY := $(patsubst ../%,$(MAKEFILE_PARENT)/%,$(BIN_DIRECTORY)) +GCC_DIRECTORY := $(patsubst ../%,$(MAKEFILE_PARENT)/%,$(GCC_DIRECTORY)) +GCC_EXCLUDE := $(patsubst ../%,$(MAKEFILE_PARENT)/%,$(GCC_EXCLUDE)) +SRC_DIRECTORY := $(patsubst ../%,$(MAKEFILE_PARENT)/%,$(SRC_DIRECTORY)) +SRC_EXCLUDE := $(patsubst ../%,$(MAKEFILE_PARENT)/%,$(SRC_EXCLUDE)) +INSTALLER_DIRECTORY := $(patsubst ../%,$(MAKEFILE_PARENT)/%,$(INSTALLER_DIRECTORY)) -# Preparations: -ifeq "$(strip $(VERBOSE))" "" +SCINTILLA_DIRECTORY := $(patsubst ../%,$(MAKEFILE_PARENT)/%,$(SCINTILLA_DIRECTORY)) + +CXXFLAGS := $(patsubst ../%,$(MAKEFILE_PARENT)/%,$(CXXFLAGS)) +CPP_PATH := $(patsubst ../%,$(MAKEFILE_PARENT)/%,$(CPP_PATH)) +endif + +# detect a request for a verbose output +ifeq "$(filter-out 0,$(VERBOSE))" "" AT := @ endif -ifeq "$(strip $(windir))" "" +# detect the current operating system +ifeq "$(windir)" "" # not a Windows system MKDIR := mkdir -p +CPDIR := cp -r RMDIR := rm -rf CP := cp RM := rm -f normalize-path = $1 else ifneq "$(wildcard $(dir $(SHELL))ls.exe)" "" -# a Windows system with UNIX-like shell +# a Windows system with a proper shell MKDIR := $(dir $(SHELL))mkdir.exe -p +CPDIR := $(dir $(SHELL))cp.exe -r RMDIR := $(dir $(SHELL))rm.exe -rf CP := $(dir $(SHELL))cp.exe RM := $(dir $(SHELL))rm.exe -f @@ -73,72 +142,116 @@ normalize-path = $1 else # a standard Windows system MKDIR := mkdir +CPDIR := xcopy /q /e /i /y RMDIR := rmdir /q /s CP := copy /y RM := del /q normalize-path = $(subst /,\,$1) endif -list-subtree = $(foreach entry,$(wildcard $1/*),$(entry) $(call list-subtree,$(entry))) -GCC_DIR_TREE := $(patsubst $(GCC_DIR)/%,%,$(call list-subtree,$(GCC_DIR))) -SOURCE_DIR_TREE := $(patsubst $(SOURCE_DIR)/%,%,$(filter-out $(SOURCE_EXCLUDE),$(call list-subtree,$(SOURCE_DIR)))) +# discover files +list-subtree = $(foreach i,$(wildcard $1/*),$i $(call list-subtree,$i)) -INCLUDES += $(addprefix $(SOURCE_DIR)/,$(sort $(dir $(filter %.h %.hpp,$(SOURCE_DIR_TREE))))) +GCC_SUBTREE := $(patsubst $(GCC_DIRECTORY)/%,%,$(filter-out $(GCC_EXCLUDE),$(call list-subtree,$(GCC_DIRECTORY)))) +SRC_SUBTREE := $(patsubst $(SRC_DIRECTORY)/%,%,$(filter-out $(SRC_EXCLUDE),$(call list-subtree,$(SRC_DIRECTORY)))) -vpath %.cpp $(GCC_DIR) $(SOURCE_DIR) -CXX_TARGETS := $(patsubst %.cpp,$(BUILD_DIR)/%.o,$(sort $(filter %.cpp,$(GCC_DIR_TREE)) $(filter %.cpp,$(SOURCE_DIR_TREE)))) +CPP_PATH += $(addprefix $(GCC_DIRECTORY)/,$(sort $(patsubst %/,%,$(dir $(filter %.h %.hpp,$(GCC_SUBTREE)))))) +CPP_PATH += $(addprefix $(SRC_DIRECTORY)/,$(sort $(patsubst %/,%,$(dir $(filter %.h %.hpp,$(SRC_SUBTREE)))))) -vpath %.rc $(GCC_DIR) $(SOURCE_DIR) -RC_TARGETS := $(patsubst %.rc,$(BUILD_DIR)/%.res,$(sort $(filter %.rc,$(GCC_DIR_TREE)) $(filter %.rc,$(SOURCE_DIR_TREE)))) +vpath %.cpp $(GCC_DIRECTORY) $(SRC_DIRECTORY) +CXX_TARGETS := $(patsubst %.cpp,$(BUILD_DIRECTORY)/%.o,$(sort $(filter %.cpp,$(GCC_SUBTREE) $(SRC_SUBTREE)))) -CONFIG_TARGETS := $(addprefix $(TARGET_DIR)/,$(CONFIG_FILES)) +vpath %.rc $(GCC_DIRECTORY) $(SRC_DIRECTORY) +RC_TARGETS := $(patsubst %.rc,$(BUILD_DIRECTORY)/%.res,$(sort $(filter %.rc,$(GCC_SUBTREE) $(SRC_SUBTREE)))) -# Actions: -.PHONY: .force all binary clean -.force: +# +# actions +# GOALS := $(addprefix $(MAKELEVEL)-,$(if $(MAKECMDGOALS),$(MAKECMDGOALS),all)) +.PHONY: .force all binary data clean fullclean +.force: + ifneq "$(filter 0-all,$(GOALS))" "" +SUBMAKEFLAGS += $(if $(NUMBER_OF_PROCESSORS),-j$(NUMBER_OF_PROCESSORS),) .NOTPARALLEL: all: $(SCINTILLA_TARGET) - $(AT)$(MAKE) $(SUBMAKEFLAGS) binary + $(AT)$(MAKE) -f $(firstword $(MAKEFILE_LIST)) $(SUBMAKEFLAGS) binary else all: binary endif +ifeq "$(filter 1-binary,$(GOALS))" "" +$(SCINTILLA_TARGET): .force +endif -$(SCINTILLA_TARGET): $(if $(filter 1-binary,$(GOALS)),,.force) - $(AT)$(MAKE) $(SUBMAKEFLAGS) -C $(SCINTILLA_DIR)/win32 $(SCINTILLA_TARGET:$(SCINTILLA_DIR)/%=../%) +$(BUILD_DIRECTORY): + @echo * creating BUILD_DIRECTORY $@ + $(AT)$(MKDIR) $(call normalize-path,$(sort $@ $(patsubst %/,%,$(dir $(CXX_TARGETS) $(RC_TARGETS))))) -binary: $(TARGET_BINARY) $(CONFIG_TARGETS) +$(SCINTILLA_TARGET): | $(BUILD_DIRECTORY) + $(AT)$(MAKE) $(SUBMAKEFLAGS) -C $(SCINTILLA_DIRECTORY)/win32 LIBLEX=$(CURDIR)/$(SCINTILLA_TARGET) $(CURDIR)/$(SCINTILLA_TARGET) -$(BUILD_DIR): - @echo BUILD_DIR = $@ - $(AT)$(MKDIR) $(call normalize-path,$(sort $(BUILD_DIR)/ $(dir $(CXX_TARGETS) $(dir $(RC_TARGETS))))) +binary: $(TARGET_BINARY) data + @echo *** $(TARGET_CPU) $(BUILD_TYPE) : $(CURDIR)/$(TARGET_BINARY) *** -$(CXX_TARGETS): | $(BUILD_DIR) -$(CXX_TARGETS): $(BUILD_DIR)/%.o: %.cpp - @echo compiling $< - $(AT)$(CXX) $(CXXFLAGS) $(addprefix -D,$(DEFINES)) $(addprefix -I,$(INCLUDES)) -MMD -c -o $@ $< +$(CXX_TARGETS): $(BUILD_DIRECTORY)/%.o: %.cpp | $(BUILD_DIRECTORY) + @echo * compiling $< + $(AT)$(CXX) $(CXXFLAGS) $(addprefix -I,$(CPP_PATH)) $(addprefix -D,$(CPP_DEFINE)) -MMD -c -o $@ $< -$(RC_TARGETS): | $(BUILD_DIR) -$(RC_TARGETS): $(BUILD_DIR)/%.res: %.rc - @echo compiling $< - $(AT)$(RC) $(RCFLAGS) $(addprefix -D,$(DEFINES)) $(addprefix -I,$(INCLUDES)) -O coff -o $@ -i $< +$(RC_TARGETS): $(BUILD_DIRECTORY)/%.res: %.rc | $(BUILD_DIRECTORY) + @echo * compiling $< + $(AT)$(RC) $(RCFLAGS) $(addprefix -I,$(CPP_PATH)) $(addprefix -D,$(CPP_DEFINE)) -O coff -o $@ -i $< -$(TARGET_BINARY): $(CXX_TARGETS) $(RC_TARGETS) $(SCINTILLA_TARGET) - @echo linking $@ - $(AT)$(LD) $(LDFLAGS) $^ $(addprefix -l,$(LIBRARIES) $(SCINTILLA_LIBRARIES)) -static -o $@ +ifeq "$(TARGET_CPU)" "i686" +$(TARGET_BINARY): $(BUILD_DIRECTORY)/libsensapi.a +$(BUILD_DIRECTORY)/libsensapi.a: | $(BUILD_DIRECTORY) + @echo * generating $@ + $(AT)gendef $(call normalize-path,$(firstword $(wildcard $(windir)/syswow64/SensApi.dll $(windir)/system32/SensApi.dll))) + $(AT)dlltool -mi386 -f--32 -d SensApi.def -k -l $(call normalize-path,$@) + $(AT)$(RM) SensApi.def +endif + +$(TARGET_DIRECTORY): + @echo * creating TARGET_DIRECTORY $@ + $(AT)$(MKDIR) $(call normalize-path,$@) + +$(TARGET_BINARY): $(CXX_TARGETS) $(RC_TARGETS) $(SCINTILLA_TARGET) | $(TARGET_DIRECTORY) + @echo * linking $@ + $(AT)$(LD) $(LDFLAGS) $(filter-out %.a,$^) $(addprefix -L,$(LD_PATH)) $(addprefix -l,$(LD_LINK)) -static -o $@ -$(CONFIG_TARGETS): $(TARGET_DIR)/%.xml: $(SOURCE_DIR)/%.xml - @echo config $@ +data: $(patsubst %/,%,$(SRC_DATA) $(BIN_DATA) $(INSTALLER_DATA)) + +$(patsubst %/,%,$(filter %/,$(SRC_DATA))): $(TARGET_DIRECTORY)/%: $(SRC_DIRECTORY)/% | $(TARGET_DIRECTORY) + @echo * copying $@ + $(AT)$(CPDIR) $(call normalize-path,$< $@) +$(filter-out %/,$(SRC_DATA)): $(TARGET_DIRECTORY)/%: $(SRC_DIRECTORY)/% | $(TARGET_DIRECTORY) + @echo * copying $@ + $(AT)$(CP) $(call normalize-path,$< $@) + +$(patsubst %/,%,$(filter %/,$(BIN_DATA))): $(TARGET_DIRECTORY)/%: $(BIN_DIRECTORY)/% | $(TARGET_DIRECTORY) + @echo * copying $@ + $(AT)$(CPDIR) $(call normalize-path,$< $@) +$(filter-out %/,$(BIN_DATA)): $(TARGET_DIRECTORY)/%: $(BIN_DIRECTORY)/% | $(TARGET_DIRECTORY) + @echo * copying $@ + $(AT)$(CP) $(call normalize-path,$< $@) + +$(TARGET_DIRECTORY)/autoCompletion: $(INSTALLER_DIRECTORY)/APIs +$(TARGET_DIRECTORY)/functionList: $(INSTALLER_DIRECTORY)/functionList +$(TARGET_DIRECTORY)/localization: $(INSTALLER_DIRECTORY)/nativeLang +$(TARGET_DIRECTORY)/themes: $(INSTALLER_DIRECTORY)/themes +$(patsubst %/,%,$(filter %/,$(INSTALLER_DATA))): | $(TARGET_DIRECTORY) + @echo * copying $@ + $(AT)$(CPDIR) $(call normalize-path,$< $@) +$(filter-out %/,$(INSTALLER_DATA)): | $(TARGET_DIRECTORY) + @echo * copying $@ $(AT)$(CP) $(call normalize-path,$< $@) clean: - -$(AT)$(RM) $(call normalize-path,$(TARGET_BINARY) $(CONFIG_TARGETS)) - -$(AT)$(RMDIR) $(call normalize-path,$(BUILD_DIR)) - -$(AT)$(MAKE) $(SUBMAKEFLAGS) -C $(SCINTILLA_DIR)/win32 $@ -# the `clean` target of Scintilla leaves some artifacts, thus clean up after it - -$(AT)$(RM) $(call normalize-path,$(SCINTILLA_DIR)/bin/*.a $(SCINTILLA_DIR)/bin/*.dll) + -$(AT)$(RMDIR) $(call normalize-path,$(BUILD_DIRECTORY)) + -$(AT)$(MAKE) $(SUBMAKEFLAGS) -C $(SCINTILLA_DIRECTORY)/win32 $@ + +fullclean: clean + -$(AT)$(RMDIR) $(call normalize-path,$(TARGET_DIRECTORY)) -include $(CXX_TARGETS:%.o=%.d) diff --git a/PowerEditor/gcc/gcc-manifest.rc b/PowerEditor/gcc/manifest.rc similarity index 100% rename from PowerEditor/gcc/gcc-manifest.rc rename to PowerEditor/gcc/manifest.rc diff --git a/PowerEditor/gcc/readme.txt b/PowerEditor/gcc/readme.txt deleted file mode 100644 index e6602b2b7..000000000 --- a/PowerEditor/gcc/readme.txt +++ /dev/null @@ -1,24 +0,0 @@ -makefile was renewed after the v6.8.7 release. - -It was tested with a MinGW-w64 distribution containing -GCC 5.2.0 (cross-compiled with i686-w64-mingw32 on Arch Linux) and -GCC 4.9.2 (natively on Windows 7, will not work anymore with this version). - -The default make rule should suffice for building Notepad++, -and copying the required .xml config files. -If cross-compiling you may have to pass a custom CROSS_COMPILE -variable depending on your Linux distribution. -The clean rule removes .o/.d and .res and the copied .xml files - -For localization support in the editor preferences you have to copy the -PowerEditor/installer/nativeLang/ directory to PowerEditor/bin/ with the new -directory name "localization". -On Linux a symbolic link suffices: - $ ln -s ../installer/nativeLang localization - -For execution with Wine some additional DLLs from the MinGW package have to be -found inside of the PowerEditor/bin/ directory, which can be achieved by using -links again, e.g.: - $ ln -s /usr/i686-w64-mingw32/bin/libgcc_s_sjlj-1.dll - $ ln -s /usr/i686-w64-mingw32/bin/libstdc++-6.dll - $ ln -s /usr/i686-w64-mingw32/bin/libwinpthread-1.dll diff --git a/PowerEditor/src/DarkMode/DarkMode.cpp b/PowerEditor/src/DarkMode/DarkMode.cpp index 0b2589196..dea942634 100644 --- a/PowerEditor/src/DarkMode/DarkMode.cpp +++ b/PowerEditor/src/DarkMode/DarkMode.cpp @@ -10,6 +10,14 @@ #include #include +#if defined(__GNUC__) && __GNUC__ > 8 +#define WINAPI_LAMBDA_RETURN(return_t) -> return_t WINAPI +#elif defined(__GNUC__) +#define WINAPI_LAMBDA_RETURN(return_t) WINAPI -> return_t +#else +#define WINAPI_LAMBDA_RETURN(return_t) -> return_t +#endif + enum IMMERSIVE_HC_CACHE_MODE { IHCM_USE_CACHED_VALUE, @@ -221,7 +229,7 @@ void FixDarkScrollBar() DWORD oldProtect; if (VirtualProtect(addr, sizeof(IMAGE_THUNK_DATA), PAGE_READWRITE, &oldProtect) && _OpenNcThemeData) { - auto MyOpenThemeData = [](HWND hWnd, LPCWSTR classList) -> HTHEME { + auto MyOpenThemeData = [](HWND hWnd, LPCWSTR classList) WINAPI_LAMBDA_RETURN(HTHEME) { if (wcscmp(classList, L"ScrollBar") == 0) { if (IsWindowOrParentUsingDarkScrollBar(hWnd)) { diff --git a/PowerEditor/src/DarkMode/IatHook.h b/PowerEditor/src/DarkMode/IatHook.h index ba042d86b..7d5d153db 100644 --- a/PowerEditor/src/DarkMode/IatHook.h +++ b/PowerEditor/src/DarkMode/IatHook.h @@ -30,7 +30,7 @@ PIMAGE_THUNK_DATA FindAddressByName(void *moduleBase, PIMAGE_THUNK_DATA impName, continue; auto import = RVA2VA(moduleBase, impName->u1.AddressOfData); - if (strcmp(import->Name, funcName) != 0) + if (strcmp(reinterpret_cast(import->Name), funcName) != 0) continue; return impAddr; } diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index 2688190ab..a3756df84 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -28,8 +28,11 @@ #include -#ifdef __MINGW32__ +#ifdef __GNUC__ #include +#define WINAPI_LAMBDA WINAPI +#else +#define WINAPI_LAMBDA #endif #pragma comment(lib, "uxtheme.lib") @@ -1435,7 +1438,7 @@ namespace NppDarkMode ::EnableThemeDialogTexture(hwndParent, theme && !NppDarkMode::isEnabled() ? ETDT_ENABLETAB : ETDT_DISABLE); - EnumChildWindows(hwndParent, [](HWND hwnd, LPARAM lParam) { + EnumChildWindows(hwndParent, [](HWND hwnd, LPARAM lParam) WINAPI_LAMBDA { auto& p = *reinterpret_cast(lParam); const size_t classNameLen = 16; TCHAR className[classNameLen] = { 0 }; diff --git a/appveyor.yml b/appveyor.yml index a4471cb70..e8dde625a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,77 +1,79 @@ version: 8.1.{build} image: Visual Studio 2019 +#skip_commits: +# files: +# - PowerEditor/bin/*/*.xml +# - PowerEditor/installer/*/*.xml environment: matrix: - - platform: Win32 - archi: x86 - platform_input: Win32 - PYTHON: "C:\\Python38" + - compiler: MSC + platform: Win32 - - platform: x64 - archi: amd64 - platform_input: x64 + - compiler: MSC + platform: x64 - - platform: mingw-w64_810_X64 - platform_input: mingw + - compiler: MSC + platform: arm64 - - platform: arm64 - archi: amd64_arm64 - platform_input: arm64 + - compiler: GCC + platform: i686 + - compiler: GCC + platform: x86_64 configuration: - Release - Debug -install: - - if "%Platform%"=="mingw-w64_810_X64" set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH:C:\Program Files\Git\usr\bin;=% - - if "%archi%" NEQ "" call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" %archi% +matrix: + exclude: + - compiler: GCC + configuration: Debug -build_script: +before_build: - ps: | - Write-Output "Configuration: $env:CONFIGURATION" - Write-Output "Platform: $env:PLATFORM" - - - if "%configuration%"=="Debug" set build_options=DEBUG=1 - - if "%configuration%"=="Release" set build_options= - - cd "%APPVEYOR_BUILD_FOLDER%"\PowerEditor\visual.net\ - - if "%archi%" NEQ "" msbuild /m notepadPlus.sln /p:configuration="%configuration%" /p:platform="%platform_input%" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - - if "%Platform%"=="mingw-w64_810_X64" cd c:\projects\notepad-plus-plus\PowerEditor\gcc\ & mingw32-make -j%NUMBER_OF_PROCESSORS% VERBOSE=1 %build_options% - - -after_build: - - cd "%APPVEYOR_BUILD_FOLDER%" - #xml files syntax checks - - if "%platform_input%"=="Win32" if "%configuration%"=="Debug" SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH% - - if "%platform_input%"=="Win32" if "%configuration%"=="Debug" python -m pip install requests rfc3987 pywin32 lxml - - if "%platform_input%"=="Win32" if "%configuration%"=="Debug" call python PowerEditor\Test\xmlValidator\validator_xml.py - - - ps: >- - if ($env:CONFIGURATION -eq "Release") { - $nppFileName = "Notepad++.$env:PLATFORM_INPUT.Release.exe" + Write-Output "Compiler : $env:compiler" + Write-Output "Platform : $env:platform" + Write-Output "Configuration : $env:configuration" + +for: +- matrix: + only: + - compiler: MSC + build: + parallel: true + project: PowerEditor\visual.net\notepadPlus.sln + after_build: + # artifacts + - ps: | + $nppFileName = "Notepad++.$env:platform.$env:configuration.exe" + if ("$env:platform/$env:configuration" -eq "Win32/Release") { + Push-AppveyorArtifact "PowerEditor\bin\Notepad++.exe" -FileName "$nppFileName" } - else - { - $nppFileName = "Notepad++.$env:PLATFORM_INPUT.Debug.exe" + if ("$env:platform/$env:configuration" -eq "Win32/Debug") { + Push-AppveyorArtifact "PowerEditor\visual.net\Debug\Notepad++.exe" -FileName "$nppFileName" } - - if ($env:PLATFORM_INPUT -eq "x64" -and $env:CONFIGURATION -eq "Release") { + if ("$env:platform/$env:configuration" -eq "x64/Release") { Push-AppveyorArtifact "PowerEditor\bin64\Notepad++.exe" -FileName "$nppFileName" } - - if ($env:PLATFORM_INPUT -eq "x64" -and $env:CONFIGURATION -eq "Debug") { + if ("$env:platform/$env:configuration" -eq "x64/Debug") { Push-AppveyorArtifact "PowerEditor\visual.net\x64\Debug\Notepad++.exe" -FileName "$nppFileName" } - - if ($env:PLATFORM_INPUT -eq "Win32" -and $env:CONFIGURATION -eq "Release") { - Push-AppveyorArtifact "PowerEditor\bin\Notepad++.exe" -FileName "$nppFileName" + if ("$env:platform/$env:configuration" -eq "arm64/Release") { + Push-AppveyorArtifact "PowerEditor\binarm64\Notepad++.exe" -FileName "$nppFileName" } - - if ($env:PLATFORM_INPUT -eq "Win32" -and $env:CONFIGURATION -eq "Debug") { - Push-AppveyorArtifact "PowerEditor\visual.net\Debug\Notepad++.exe" -FileName "$nppFileName" - + if ("$env:platform/$env:configuration" -eq "arm64/Debug") { + Push-AppveyorArtifact "PowerEditor\visual.net\arm64\Debug\Notepad++.exe" -FileName "$nppFileName" + } + # xml files syntax checks + - if "%platform%/%configuration%" EQU "Win32/Debug" set PATH=C:\Python38;C:\Python38\Scripts;%PATH% + - if "%platform%/%configuration%" EQU "Win32/Debug" python -m pip install requests rfc3987 pywin32 lxml + - if "%platform%/%configuration%" EQU "Win32/Debug" python PowerEditor\Test\xmlValidator\validator_xml.py + # tests + - ps: | + if ("$env:platform/$env:configuration" -eq "Win32/Debug") { Copy-Item "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\visual.net\Debug\Notepad++.exe" -Destination "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\bin" Copy-Item "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\src\langs.model.xml" -Destination "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\bin" Copy-Item "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\src\stylers.model.xml" -Destination "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\bin" @@ -86,24 +88,27 @@ after_build: .\unitTestLauncher.ps1 if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) } - #ATTENTION: current working dir is no longer at APPVEYOR_BUILD_FOLDER cd ..\UrlDetection .\verifyUrlDetection.ps1 - } - if ($env:PLATFORM_INPUT -eq "arm64" -and $env:CONFIGURATION -eq "Release") { - Push-AppveyorArtifact "PowerEditor\binarm64\Notepad++.exe" -FileName "$nppFileName" + cd "$env:APPVEYOR_BUILD_FOLDER" } - if ($env:PLATFORM_INPUT -eq "arm64" -and $env:CONFIGURATION -eq "Debug") { - Push-AppveyorArtifact "PowerEditor\visual.net\arm64\Debug\Notepad++.exe" -FileName "$nppFileName" - } - - if ($env:PLATFORM_INPUT -eq "mingw" -and $env:CONFIGURATION -eq "Release") { - Push-AppveyorArtifact "PowerEditor\bin\NotepadPP-release.exe" -FileName "$nppFileName" +- matrix: + only: + - compiler: GCC + install: + - if "%platform%" EQU "i686" set PATH=C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;%PATH:C:\Program Files\Git\usr\bin;=% + - if "%platform%" EQU "x86_64" set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH:C:\Program Files\Git\usr\bin;=% + build_script: + - mingw32-make -f PowerEditor\gcc\makefile + after_build: + # artifacts + - ps: | + $nppFileName = "Notepad++.$env:compiler.$env:platform.$env:configuration.exe" + if ("$env:platform/$env:configuration" -eq "i686/Release") { + Push-AppveyorArtifact "bin.i686\notepad++.exe" -FileName "$nppFileName" } - - if ($env:PLATFORM_INPUT -eq "mingw" -and $env:CONFIGURATION -eq "Debug") { - Push-AppveyorArtifact "PowerEditor\bin\NotepadPP-debug.exe" -FileName "$nppFileName" + if ("$env:platform/$env:configuration" -eq "x86_64/Release") { + Push-AppveyorArtifact "bin.x86_64\notepad++.exe" -FileName "$nppFileName" } -