From 6756f3898cb72b401ffbf414ea65068809ff6132 Mon Sep 17 00:00:00 2001 From: Michal Princ Date: Thu, 9 Feb 2023 12:17:49 +0100 Subject: [PATCH 1/2] Update Utils.cpp Add missing copyright --- erpcgen/src/Utils.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/erpcgen/src/Utils.cpp b/erpcgen/src/Utils.cpp index ffda544a..619998e2 100644 --- a/erpcgen/src/Utils.cpp +++ b/erpcgen/src/Utils.cpp @@ -1,3 +1,11 @@ +/* Copyright 2023 NXP + * Copyright 2023 ACRIOS Systems s.r.o. + * All rights reserved. + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + #include "Utils.hpp" void erpcgen::replaceAll(std::string &str, const std::string &from, const std::string &to) From 8f77dad9de0d54dd730d23978f9b8ad4e78fcbbb Mon Sep 17 00:00:00 2001 From: Dusan Cervenka Date: Tue, 7 Mar 2023 12:12:05 +0100 Subject: [PATCH 2/2] Feature/mingw support (#344) * Mingw support Signed-off-by: Cervenka Dusan * mkdirc Signed-off-by: Cervenka Dusan * Added circleci build for mingw Signed-off-by: Cervenka Dusan --------- Signed-off-by: Cervenka Dusan --- .circleci/config.yml | 15 ++++++- .gitignore | 4 ++ Makefile | 14 ++++-- erpc_c/Makefile | 10 ++--- erpcgen/Makefile | 20 +++------ erpcgen/VisualStudio_v14/.gitignore | 2 + erpcgen/VisualStudio_v14/erpcgen.vcxproj | 2 +- erpcgen/VisualStudio_v14/readme_erpcgen.txt | 3 +- erpcgen/src/cpptemplate/Makefile | 4 +- erpcsniffer/Makefile | 6 +-- install_dependencies.ps1 | 49 +++++++++++++++++++++ mk/common.mk | 35 ++++++++------- mk/paths.mk | 25 ++++++++--- mk/targets.mk | 2 +- test/Makefile | 2 +- test/mk/test_lib.mk | 2 +- test/mk/unit_test.mk | 4 +- 17 files changed, 144 insertions(+), 55 deletions(-) create mode 100644 install_dependencies.ps1 diff --git a/.circleci/config.yml b/.circleci/config.yml index 363ecfeb..8ae073b3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,8 @@ version: 2.1 +orbs: + win: circleci/windows@5.0 # The Windows orb gives you everything you need to start using the + jobs: build-linux-gcc: machine: @@ -39,7 +42,16 @@ jobs: - run: chmod u+x run_tests.sh && ./run_tests.sh clang - store_artifacts: path: ./Release/Darwin/erpcgen/erpcgen - + build-windows-mingw: + executor: + name: win/default + size: large + steps: + - checkout + - run: powershell.exe .\install_dependencies.ps1 + - run: powershell.exe .\mingw64\bin\mingw32-make erpcgen + - store_artifacts: + path: ./Release/MINGW64/erpcgen/erpcgen.exe workflows: build-workflow: @@ -48,3 +60,4 @@ workflows: - build-linux-clang - build-mac-gcc - build-mac-clang + - build-windows-mingw diff --git a/.gitignore b/.gitignore index 7dfbe108..f0c1fc84 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,7 @@ format-files-to-commit.rb language\.settings\.xml *.vsix null.d +boost.7z +boost*/ +mingw.7z +mingw64/ diff --git a/Makefile b/Makefile index 5dca3bf6..9258e5c2 100644 --- a/Makefile +++ b/Makefile @@ -71,13 +71,21 @@ test-serial: $(TESTDIR) .PHONY: fresh fresh: clean all +# define clean_fun +# $(warning "$(at)$(POWERSHELL) "if (Test-Path $(1)) { $(rmc) $(1) }"") +# $(at)$(POWERSHELL) 'if (Test-Path $(1)) { $(rmc) $(1) }' +# endef + # Target to clean everything. .PHONY: clean clean:: @echo "Deleting output directories..." - @rm -rf Debug Release - @rm -rf out*.* - @rm -rf erpc_outputs + @$(rmc) Debug Release + @$(rmc) out*.* + @$(rmc) erpc_outputs +# @$(call clean_fun,Debug,) +# @$(call clean_fun,Release,) +# @$(call clean_fun,erpc_outputs,) @echo "done." # Process subdirs diff --git a/erpc_c/Makefile b/erpc_c/Makefile index 0525f278..9ad45d15 100644 --- a/erpc_c/Makefile +++ b/erpc_c/Makefile @@ -121,7 +121,7 @@ endif $(TARGET_LIB)(%): % @$(call printmessage,ar,Archiving, $(?F) in $(@F)) - $(at)mkdir -p $(dir $(@)) + $(at)$(mkdirc) -p $(dir $(@)) $(AR) $(ARFLAGS) $@ $? .PHONY: install @@ -130,17 +130,17 @@ install: install_headers install_lib .PHONY: install_headers install_headers: $(HEADERS) | $(INC_INSTALL_DIR) @$(call printmessage,c,Installing, headers in $(INC_INSTALL_DIR)) - $(at)mkdir -p $(INC_INSTALL_DIR) + $(at)$(mkdirc) -p $(INC_INSTALL_DIR) $(at)install $(?) $(INC_INSTALL_DIR) $(INC_INSTALL_DIR): - $(at)mkdir -p $(INC_INSTALL_DIR) + $(at)$(mkdirc) -p $(INC_INSTALL_DIR) .PHONY: install_lib install_lib: $(TARGET_LIB) @$(call printmessage,c,Installing, $(subst $(LIBS_ROOT)/,,$<) in $(LIB_INSTALL_DIR)) - $(at)mkdir -p $(LIB_INSTALL_DIR) + $(at)$(mkdirc) -p $(LIB_INSTALL_DIR) $(at)install $(TARGET_LIB) $(LIB_INSTALL_DIR) clean:: - $(at)rm -rf $(OBJS_ROOT)/*.cpp $(OBJS_ROOT)/*.hpp $(OBJS_ROOT)/*.c + $(at)$(rmc) $(OBJS_ROOT)/*.cpp $(OBJS_ROOT)/*.hpp $(OBJS_ROOT)/*.c diff --git a/erpcgen/Makefile b/erpcgen/Makefile index 08b24eab..470b4fda 100644 --- a/erpcgen/Makefile +++ b/erpcgen/Makefile @@ -40,7 +40,7 @@ INCLUDES += $(ERPC_ROOT) \ $(OBJS_ROOT) ifeq "$(is_mingw)" "1" -INCLUDES += $(ERPC_ROOT)/windows +INCLUDES += $(VISUAL_STUDIO_ROOT) endif SOURCES += $(OBJS_ROOT)/erpcgen_parser.tab.cpp \ @@ -85,15 +85,6 @@ SOURCES += $(OBJS_ROOT)/erpcgen_parser.tab.cpp \ $(OBJS_ROOT)/erpcgen/src/templates/py_coders.c \ $(OBJS_ROOT)/erpcgen/src/templates/py_global_init.c -ifeq "$(is_mingw)" "1" -SOURCES += $(ERPC_ROOT)/erpcgen/VisualStudio_v14/c_common_header.cpp \ - $(ERPC_ROOT)/erpcgen/VisualStudio_v14/c_client_source.cpp \ - $(ERPC_ROOT)/erpcgen/VisualStudio_v14/c_server_header.cpp \ - $(ERPC_ROOT)/erpcgen/VisualStudio_v14/c_server_source.cpp \ - $(ERPC_ROOT)/erpcgen/VisualStudio_v14/c_coders.cpp \ - $(ERPC_ROOT)/erpcgen/VisualStudio_v14/c_common_functions.cpp \ - $(OBJS_ROOT)/erpcgen/src/templates/c_crc.cpp -else SOURCES += $(OBJS_ROOT)/erpcgen/src/templates/c_common_header.c \ $(OBJS_ROOT)/erpcgen/src/templates/c_client_source.c \ $(OBJS_ROOT)/erpcgen/src/templates/c_server_header.c \ @@ -108,7 +99,6 @@ SOURCES += $(OBJS_ROOT)/erpcgen/src/templates/c_common_header.c \ $(OBJS_ROOT)/erpcgen/src/templates/py_interface.c \ $(OBJS_ROOT)/erpcgen/src/templates/py_coders.c \ $(OBJS_ROOT)/erpcgen/src/templates/py_global_init.c -endif OBJECT_DEP := $(OBJS_ROOT)/erpcgen_lexer.cpp @@ -122,6 +112,10 @@ ifeq "$(build)" "release" endif endif +ifeq "$(is_mingw)" "1" +CXXFLAGS += -DBOOST_FILESYSTEM_VERSION=4 +endif + # Run flex $(OBJS_ROOT)/erpcgen_lexer.cpp: $(ERPC_ROOT)/erpcgen/src/erpcgen_lexer.l $(OBJS_ROOT)/erpcgen_parser.tab.hpp | $(OBJECTS_DIRS) @$(call printmessage,orange,Generating, $(subst $(ERPC_ROOT)/,,$<)) @@ -142,8 +136,8 @@ $(OBJS_ROOT)/%.c: $(ERPC_ROOT)/%.template .PHONY: install install: $(MAKE_TARGET) @$(call printmessage,c,Installing, erpcgen in $(BIN_INSTALL_DIR)) - $(at)mkdir -p $(BIN_INSTALL_DIR) + $(at)$(mkdirc) -p $(BIN_INSTALL_DIR) $(at)install $(MAKE_TARGET) $(BIN_INSTALL_DIR) clean:: - $(at)rm -rf $(OBJS_ROOT)/*.cpp $(OBJS_ROOT)/*.hpp $(OBJS_ROOT)/*.c + $(at)$(rmc) $(OBJS_ROOT)/*.cpp $(OBJS_ROOT)/*.hpp $(OBJS_ROOT)/*.c diff --git a/erpcgen/VisualStudio_v14/.gitignore b/erpcgen/VisualStudio_v14/.gitignore index 1d8c5e92..43daf212 100644 --- a/erpcgen/VisualStudio_v14/.gitignore +++ b/erpcgen/VisualStudio_v14/.gitignore @@ -29,6 +29,8 @@ win_bison.exe win_flex.exe README.txt .vs +changelog.md +README.md #boost libraries boost_* diff --git a/erpcgen/VisualStudio_v14/erpcgen.vcxproj b/erpcgen/VisualStudio_v14/erpcgen.vcxproj index 1326cd0b..df0c94cb 100644 --- a/erpcgen/VisualStudio_v14/erpcgen.vcxproj +++ b/erpcgen/VisualStudio_v14/erpcgen.vcxproj @@ -1,4 +1,4 @@ - + diff --git a/erpcgen/VisualStudio_v14/readme_erpcgen.txt b/erpcgen/VisualStudio_v14/readme_erpcgen.txt index 4ab2082d..d7df78c7 100644 --- a/erpcgen/VisualStudio_v14/readme_erpcgen.txt +++ b/erpcgen/VisualStudio_v14/readme_erpcgen.txt @@ -12,7 +12,8 @@ Requirements 2. Win flex-bison Direct link to the latests win flex-bison release download: - [https://sourceforge.net/projects/winflexbison] + [https://sourceforge.net/projects/winflexbison/files/win_flex_bison3-latest.zip/download] + Extract win flex-bison zip contents directly into the erpc/erpcgen/VisualStudio_v14 directory (not into a subdirectory). diff --git a/erpcgen/src/cpptemplate/Makefile b/erpcgen/src/cpptemplate/Makefile index 0c8efb39..624829d1 100644 --- a/erpcgen/src/cpptemplate/Makefile +++ b/erpcgen/src/cpptemplate/Makefile @@ -41,8 +41,8 @@ all: cpptempl_test .PHONY: clean clean: @echo "Cleaning output..." - @rm -rf *.o - @rm -rf *.d + @$(rmc) *.o + @$(rmc) *.d @rm -f $(TARGET) .PHONY: test testv diff --git a/erpcsniffer/Makefile b/erpcsniffer/Makefile index ca010be0..8e4ca755 100644 --- a/erpcsniffer/Makefile +++ b/erpcsniffer/Makefile @@ -45,7 +45,7 @@ INCLUDES += $(ERPC_ROOT) \ $(OBJS_ROOT) ifeq "$(is_mingw)" "1" -INCLUDES += $(ERPC_ROOT)/windows +INCLUDES += $(VISUAL_STUDIO_ROOT) endif SOURCES += $(OBJS_ROOT)/erpcgen_parser.tab.cpp \ @@ -103,8 +103,8 @@ $(OBJS_ROOT)/erpcgen_parser.tab.hpp: $(ERPC_ROOT)/erpcgen/src/erpcgen_parser.y | .PHONY: install install: $(MAKE_TARGET) @$(call printmessage,c,Installing, erpcsniffer in $(BIN_INSTALL_DIR)) - $(at)mkdir -p $(BIN_INSTALL_DIR) + $(at)$(mkdirc) -p $(BIN_INSTALL_DIR) $(at)install $(MAKE_TARGET) $(BIN_INSTALL_DIR) clean:: - $(at)rm -rf $(OBJS_ROOT)/*.cpp $(OBJS_ROOT)/*.hpp $(OBJS_ROOT)/*.c + $(at)$(rmc) $(OBJS_ROOT)/*.cpp $(OBJS_ROOT)/*.hpp $(OBJS_ROOT)/*.c diff --git a/install_dependencies.ps1 b/install_dependencies.ps1 new file mode 100644 index 00000000..06bc8a2c --- /dev/null +++ b/install_dependencies.ps1 @@ -0,0 +1,49 @@ +# Binson/flex +Set-Location ".\erpcgen\VisualStudio_v14" +$PatHBisonFlex7Zip=".\win_flex_bison.zip" +$PatHBisonFlex="win_flex_bison" +Remove-Item -ErrorAction Ignore $PatHBisonFlex7Zip +Remove-Item -ErrorAction Ignore -Recurse $PatHBisonFlex +Remove-Item -ErrorAction Ignore -Recurse ".\custom_build_rules" +Remove-Item -ErrorAction Ignore -Recurse ".\data" +Remove-Item -ErrorAction Ignore -Recurse ".\changelog.md" +Remove-Item -ErrorAction Ignore -Recurse ".\FlexLexer.h" +Remove-Item -ErrorAction Ignore -Recurse ".\README.md" +Remove-Item -ErrorAction Ignore -Recurse ".\win_bison.exe" +Remove-Item -ErrorAction Ignore -Recurse ".\win_flex.exe" +$URLBisonFlex = "https://github.com/lexxmark/winflexbison/releases/download/v2.5.25/win_flex_bison-2.5.25.zip" +Invoke-WebRequest -URI $URLBisonFlex -OutFile $PatHBisonFlex7Zip +Expand-Archive -Path $PatHBisonFlex7Zip +$PatHBisonFlexFull= ".\"+$PatHBisonFlex+"\*" +Move-Item -Path $PatHBisonFlexFull -Destination .\ -force +Remove-Item -ErrorAction Ignore $PatHBisonFlex7Zip +# Remove-Item -ErrorAction Ignore -Recurse $PatHBisonFlex +Set-Location "..\..\" + +if ($args[0] -eq "VS") +{ + # winget install --id=Microsoft.VisualStudio.2019.BuildTools -e + # & 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe' .\erpcgen\VisualStudio_v14\erpcgen.sln /property:Configuration=Release +} +else +{ + # Install 7zip + $URL7Zip = "https://gist.githubusercontent.com/dansmith65/7dd950f183af5f5deaf9650f2ad3226c/raw/8b8f6e96de7469cea73c9fe63a5da4d44a7c1ba7/Install-7zip.ps1" + $Path7Zip = ".\Install-7zip.ps1" + Remove-Item -ErrorAction Ignore $Path7Zip + Invoke-WebRequest -URI $URL7Zip -OutFile $Path7Zip + powershell $Path7Zip + Remove-Item -ErrorAction Ignore $Path7Zip + $Path7zipApp="C:\Program Files\7-Zip\7z.exe" + + # Install mingw + $URLMingw = "https://github.com/niXman/mingw-builds-binaries/releases/download/12.2.0-rt_v10-rev2/x86_64-12.2.0-release-win32-seh-ucrt-rt_v10-rev2.7z" + $PathMingw7Zip = "mingw.7z" + $PathMingw = "mingw64" + $UnzipMingw = 'x',$PathMingw7Zip,'-y' + Remove-Item -ErrorAction Ignore $PathMingw7Zip + Remove-Item -ErrorAction Ignore -Recurse $PathMingw + Invoke-WebRequest -URI $URLMingw -OutFile $PathMingw7Zip + & $Path7zipApp $UnzipMingw + Remove-Item -ErrorAction Ignore $PathMingw7Zip +} diff --git a/mk/common.mk b/mk/common.mk index 998af236..aeb20dab 100644 --- a/mk/common.mk +++ b/mk/common.mk @@ -56,26 +56,31 @@ space := $(empty) $(empty) # Get the OS name. Known values are "Linux", "CYGWIN_NT-5.1", and "Darwin". os_name := $(shell uname -s) -# Set to 1 if running on Darwin. -is_darwin := $(and $(findstring Darwin,$(os_name)),1) - -# Set to 1 if running on cygwin. -is_cygwin := $(and $(findstring CYGWIN,$(os_name)),1) - # Set to 1 if running on mingw. ifeq "$(os_name)" "" - is_mingw := 1 - os_name = MINGW - MAKE := mingw32-make + os_name := $(shell powershell [System.Environment]::OSVersion.Version) + ifneq "$(os_name)" "" + is_mingw := 1 + endif else - is_mingw := 0 -endif + # Set to 1 if running on Darwin. + is_darwin := $(and $(findstring Darwin,$(os_name)),1) + + # Set to 1 if running on cygwin. + is_cygwin := $(and $(findstring CYGWIN,$(os_name)),1) -# Set to 1 if running on redhat. -is_redhat := $(shell if [ -f /etc/redhat-release ]; then echo 1 ; fi) + # Set to 1 if running on redhat. + is_redhat := $(shell if [ -f /etc/redhat-release ]; then echo 1 ; fi) -# Set to 1 if running on Linux. -is_linux := $(and $(findstring Linux,$(os_name)),1) + # Set to 1 if running on Linux. + is_linux := $(and $(findstring Linux,$(os_name)),1) + + is_mingw := $(and $(findstring MSYS_NT,$(os_name)),1) +endif + +ifeq "$(is_mingw)" "1" + os_name = MINGW64 +endif #------------------------------------------------------------------------------- # Logging options diff --git a/mk/paths.mk b/mk/paths.mk index d662ae20..009d6f72 100644 --- a/mk/paths.mk +++ b/mk/paths.mk @@ -24,6 +24,14 @@ CUR_DIR := $(notdir $(CURDIR)) OUTPUT_ROOT := $(ERPC_ROOT) TEST_ROOT := $(ERPC_ROOT)/test +ifeq "$(is_mingw)" "1" + VISUAL_STUDIO_ROOT ?= $(ERPC_ROOT)/erpcgen/VisualStudio_v14 + MINGW64 ?= $(ERPC_ROOT)/mingw64 + export PATH := $(MINGW64):$(MINGW64)/bin:$(PATH) + CC = gcc + CXX = g++ +endif + TARGET_OUTPUT_ROOT = $(OUTPUT_ROOT)/$(DEBUG_OR_RELEASE)/$(os_name)/$(APP_NAME) MAKE_TARGET = $(TARGET_OUTPUT_ROOT)/$(APP_NAME) @@ -45,9 +53,11 @@ INC_INSTALL_DIR = $(PREFIX)/include/erpc # ---------------------------------------------- ERPCGEN ?= $(OUTPUT_ROOT)/$(DEBUG_OR_RELEASE)/$(os_name)/erpcgen/erpcgen -LD := $(CXX) +LD = $(CXX) PYTHON ?= python -ifeq (, $(shell which $(PYTHON))) +ifeq "$(is_mingw)" "1" + PYTHON=$(MINGW64)/opt/bin/python3 +else ifeq (, $(shell which $(PYTHON))) PYTHON=python3 ifeq (, $(shell which $(PYTHON))) $(error "No python found. Please install python3.") @@ -80,14 +90,17 @@ else ifeq "$(is_cygwin)" "1" FLEX ?= /bin/flex BISON ?= /bin/bison else ifeq "$(is_mingw)" "1" - FLEX ?= $(ERPC_ROOT)/erpcgen/VisualStudio_v14/win_flex.exe - BISON ?= $(ERPC_ROOT)/erpcgen/VisualStudio_v14/win_bison.exe + FLEX ?= $(VISUAL_STUDIO_ROOT)/win_flex.exe + BISON ?= $(VISUAL_STUDIO_ROOT)/win_bison.exe endif ifeq "$(is_mingw)" "1" - mkdirc = C:\MinGW\msys\1.0\bin\mkdir.exe - CC+=gcc + MAKE := $(MINGW64)/bin/mingw32-make + POWERSHELL ?= powershell + mkdirc = $(POWERSHELL) mkdir -Force + rmc = $(POWERSHELL) rm -Recurse -Force -ErrorAction Ignore else + rmc = rm -rf mkdirc = mkdir endif diff --git a/mk/targets.mk b/mk/targets.mk index f0ca8b0a..1c603143 100644 --- a/mk/targets.mk +++ b/mk/targets.mk @@ -134,7 +134,7 @@ endif .PHONY: clean clean:: @echo "Cleaning $(APP_NAME)" - $(at)rm -rf $(OBJECTS_ALL) $(OBJECTS_DIRS) $(MAKE_TARGET) + $(at)$(rmc) $(OBJECTS_ALL) $(OBJECTS_DIRS) $(MAKE_TARGET) # Include dependency files. -include $(OBJECTS_ALL:.o=.d) diff --git a/test/Makefile b/test/Makefile index 2631caff..1d1d1a63 100644 --- a/test/Makefile +++ b/test/Makefile @@ -36,6 +36,6 @@ test-serial: all clean:: @echo "Cleaning test results..." - @rm -rf results + @$(rmc) results include $(ERPC_ROOT)/mk/subdirs.mk diff --git a/test/mk/test_lib.mk b/test/mk/test_lib.mk index 27ec17ec..12151df6 100644 --- a/test/mk/test_lib.mk +++ b/test/mk/test_lib.mk @@ -56,5 +56,5 @@ include $(ERPC_ROOT)/mk/targets.mk $(TARGET_LIB)(%): % @$(call printmessage,ar,Archiving, $(?F) in $(@F)) - $(at)mkdir -p $(dir $(@)) + $(at)$(mkdirc) -p $(dir $(@)) $(AR) $(ARFLAGS) $@ $? diff --git a/test/mk/unit_test.mk b/test/mk/unit_test.mk index 8a9fa301..7c80b813 100644 --- a/test/mk/unit_test.mk +++ b/test/mk/unit_test.mk @@ -109,8 +109,8 @@ clean: clean_serial clean_tcp clean_tcp: @echo Cleaning $(TEST_NAME)_tcp... - @rm -rf $(UT_OUTPUT_DIR)/$(os_name)/tcp + @$(rmc) $(UT_OUTPUT_DIR)/$(os_name)/tcp clean_serial: @echo Cleaning $(TEST_NAME)_serial... - @rm -rf $(UT_OUTPUT_DIR)/$(os_name)/serial + @$(rmc) $(UT_OUTPUT_DIR)/$(os_name)/serial