diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cbd62a6..5856330 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -47,11 +47,11 @@ jobs: run: | cd tests V=1 make -j`nproc --all` - ./build/Zipper-UnitTest + ../build/zipper-tests - name: Check the demo run: | cd doc/demos/Unzipper - echo "1234" | ./build/demo_unzip -p -f -o /tmp ../../../tests/issues/issue_05_password.zip + echo "1234" | ./build/unzipper-demo -p -f -o /tmp ../../../tests/issues/issue_05_password.zip ls /tmp/issue_05/foo/bar /tmp/issue_05/Nouveau\ dossier/ /tmp/issue_05/Nouveau\ fichier\ vide - name: Check if the library can be linked against a project run: | @@ -96,12 +96,12 @@ jobs: run: | cd tests V=1 make -j`nproc --all` - ./build/Zipper-UnitTest + ../build/zipper-tests # FIXME https://github.com/Lecrapouille/zipper/issues/10 # - name: Check the demo # run: | # cd doc/demos/Unzipper -# echo "1234" | ./build/demo_unzip -p -f -o /tmp ../../../tests/issues/issue_05_password.zip +# echo "1234" | ./build/unzipper-demo -p -f -o /tmp ../../../tests/issues/issue_05_password.zip # ls /tmp/issue_05/foo/bar /tmp/issue_05/Nouveau\ dossier/ /tmp/issue_05/Nouveau\ fichier\ vide # - name: Check if the library can be linked against a project # run: | diff --git a/.makefile b/.makefile index 9f5eb26..937c117 160000 --- a/.makefile +++ b/.makefile @@ -1 +1 @@ -Subproject commit 9f5eb268d18c518c30d094b937b1a4274142cd1b +Subproject commit 937c1171b1be522d4051a3372c880b7ee1498ceb diff --git a/Makefile b/Makefile index 5179d4c..5c4b600 100644 --- a/Makefile +++ b/Makefile @@ -1,103 +1,54 @@ -################################################### -# Project definition -# -PROJECT = Zipper -TARGET = $(PROJECT) -DESCRIPTION = C++ wrapper around minizip compression library -STANDARD = --std=c++11 -BUILD_TYPE = release - -################################################### -# Documentation -# -LOGO = logo.png - ################################################### # Location of the project directory and Makefiles # P := . M := $(P)/.makefile -include $(M)/Makefile.header - -################################################### -# Inform Makefile where to find *.cpp and *.o files -# -VPATH += $(P)/src $(P)/src/utils $(THIRDPART) ################################################### -# Inform Makefile where to find header files -# -INCLUDES += -I. -I$(P)/include -I$(P)/src - -################################################### -# Compilation +# Project definition # -#CXXFLAGS += -Wno-undef +include $(P)/Makefile.common +TARGET_NAME := $(PROJECT_NAME) +TARGET_DESCRIPTION := An open source implementation of the SimCity 2013 simulation engine GlassBox +include $(M)/project/Makefile ################################################### -# Project defines. +# Compile shared and static libraries # -DEFINES += -DHAVE_AES -ifeq ($(ARCHI),Windows) -DEFINES += -DUSE_WINDOWS +LIB_FILES := $(call rwildcard,src,*.cpp) +INCLUDES := $(P)/include $(P)/src $(P) +VPATH := $(P)/src $(P)/src/utils $(THIRDPART_DIR) +ifeq ($(OS),Windows) + LIB_FILES += src/utils/dirent.c + DEFINES += -DUSE_WINDOWS -DHAVE_AES else -DEFINES += -UUSE_WINDOWS + DEFINES += -UUSE_WINDOWS -DHAVE_AES endif +THIRDPART_LIBS := $(abspath $(THIRDPART_DIR)/minizip/build/libminizip.a) +THIRDPART_LIBS += $(abspath $(THIRDPART_DIR)/minizip/build/libaes.a) +THIRDPART_LIBS += $(abspath $(THIRDPART_DIR)/zlib-ng/build/libz.a) ################################################### -# Compiled files +# Documentation # -ifeq ($(ARCHI),Windows) -LIB_OBJS += dirent.o -endif -LIB_OBJS += Timestamp.o Path.o Zipper.o Unzipper.o +PATH_PROJECT_LOGO := $(PROJECT_DOC_DIR)/doxygen-logo.png ################################################### -# Libraries. +# Generic Makefile rules # -PKG_LIBS += -LINKER_FLAGS += -THIRDPART_LIBS += \ - $(abspath $(THIRDPART)/minizip/build/libminizip.a) \ - $(abspath $(THIRDPART)/minizip/build/libaes.a) \ - $(abspath $(THIRDPART)/zlib-ng/build/libz.a) +include $(M)/rules/Makefile ################################################### -# Compile static and shared libraries -all: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) +# Extra rules +# +all:: demos -################################################### -# Compile the demo as standalone application. .PHONY: demos -demos: | $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) - @$(call print-from,"Compiling demos",$(PROJECT),unzip) - $(MAKE) -C doc/demos/Unzipper all +demos: + $(Q)$(MAKE) --no-print-directory --directory=doc/demos/Unzipper all -################################################### -# Compile and launch unit tests and generate the code coverage html report. -.PHONY: unit-tests -.PHONY: check -unit-tests check: - @$(call print-simple,"Compiling unit tests") - @$(MAKE) -C tests coverage - -################################################### -# Install project. You need to be root. -.PHONY: install -install: $(STATIC_LIB_TARGET) $(SHARED_LIB_TARGET) $(PKG_FILE) - @$(call INSTALL_DOCUMENTATION) - @$(call INSTALL_PROJECT_LIBRARIES) - @$(call INSTALL_PROJECT_HEADERS) +clean:: + $(Q)$(MAKE) --no-print-directory --directory=doc/demos/Unzipper clean -################################################### -# Clean the whole project. -.PHONY: veryclean -veryclean: clean - @rm -fr cov-int $(PROJECT).tgz *.log foo 2> /dev/null - @(cd tests && $(MAKE) -s clean) - @$(call print-simple,"Cleaning","$(THIRDPART)") - @rm -fr $(THIRDPART)/*/ doc/html 2> /dev/null - -################################################### -# Sharable informations between all Makefiles -include $(M)/Makefile.footer +install:: + $(Q)$(MAKE) --no-print-directory --directory=doc/demos/Unzipper install \ No newline at end of file diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 0000000..04275c7 --- /dev/null +++ b/Makefile.common @@ -0,0 +1,4 @@ +PROJECT_NAME := zipper +PROJECT_VERSION := 2.1.0 +COMPILATION_MODE := release +CXX_STANDARD := --std=c++14 \ No newline at end of file diff --git a/README.md b/README.md index c22307d..a7c46b4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Zipper](doc/logo.png) -[Zipper](https://github.com/lecrapouille/zipper) is a C++11 wrapper around minizip compression library. Its goal is to bring the power and simplicity of minizip to a more object-oriented/c++ user-friendly library. +[Zipper](https://github.com/lecrapouille/zipper) is a C++11 wrapper around minizip compression library. Its goal is to bring the power and simplicity of minizip to a more object-oriented/c++ user-friendly library. Note: We are currently using C++14 because the unit tests library needs it. This project is the continuation of the original [project](https://github.com/sebastiandev/zipper/tree/v2.x.y). The original project was born out of the necessity of a compression library that would be reliable, simple, and flexible. By flexibility I mean supporting all kinds of inputs and outputs, but specifically being able to compress into memory instead of being restricted to file compression only, and using data from memory instead of just files as well. diff --git a/VERSION.txt b/VERSION.txt deleted file mode 100644 index 7ec1d6d..0000000 --- a/VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -2.1.0 diff --git a/doc/demos/Unzipper/Makefile b/doc/demos/Unzipper/Makefile index 2c95efc..2296815 100644 --- a/doc/demos/Unzipper/Makefile +++ b/doc/demos/Unzipper/Makefile @@ -1,53 +1,26 @@ -################################################### -# Project definition -# -PROJECT = Zipper -TARGET = demo_unzip -DESCRIPTION = Demo for unzipping a zip -STANDARD = --std=c++11 -BUILD_TYPE = release - ################################################### # Location of the project directory and Makefiles # P := ../../.. M := $(P)/.makefile -include $(M)/Makefile.header - -################################################### -# Inform Makefile where to find *.cpp and *.o files -# -VPATH += $(P) src - -################################################### -# Inform Makefile where to find header files -# -INCLUDES += -I$(P)/include -Isrc ################################################### -# Compilation -# -CXXFLAGS += - -################################################### -# Project defines. +# Project definition # -DEFINES += +include $(P)/Makefile.common +TARGET_NAME := unzipper-demo +TARGET_DESCRIPTION := A demo for unzipping using $(PROJECT_NAME) +include $(M)/project/Makefile ################################################### -# Compile the demo as standalone application. +# Compile the standalone application # -OBJS += demo_unzip.o +SRC_FILES := $(call rwildcard,src,*.cpp) +INCLUDES := $(P)/include src +VPATH := $(P)/demo +INTERNAL_LIBS := $(call internal-lib,$(PROJECT_NAME)) ################################################### -# Libraries: link against our newly compiled lib +# Generic Makefile rules # -THIRDPART_LIBS += $(abspath $(P)/$(BUILD)/libzipper.a) - -################################################### -# Compile static and shared libraries -all: $(TARGET) - -################################################### -# Sharable informations between all Makefiles -include $(M)/Makefile.footer +include $(M)/rules/Makefile diff --git a/doc/doxygen-logo.png b/doc/doxygen-logo.png new file mode 100644 index 0000000..5ed3982 Binary files /dev/null and b/doc/doxygen-logo.png differ diff --git a/external/compile-external-libs.sh b/external/compile-external-libs.sh index 65d33a7..d0805e0 100755 --- a/external/compile-external-libs.sh +++ b/external/compile-external-libs.sh @@ -21,8 +21,6 @@ ### find them when you'll start your application. ############################################################################### -source ../.makefile/compile-external-libs.sh - ### Library zlib-ng print-compile zlib-ng if [ -e zlib-ng ]; diff --git a/external/download-external-libs.sh b/external/download-external-libs.sh index bb2c168..ef363b0 100755 --- a/external/download-external-libs.sh +++ b/external/download-external-libs.sh @@ -5,8 +5,6 @@ ### It replaces git submodules that I dislike. ############################################################################### -source ../.makefile/download-external-libs.sh - ### zlib replacement with optimizations for "next generation" systems. ### License: zlib cloning zlib-ng/zlib-ng diff --git a/tests/Makefile b/tests/Makefile index d9e8bea..0779a3f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,78 +1,39 @@ -################################################### -# Project definition -# -PROJECT = Zipper -TARGET = $(PROJECT)-UnitTest -DESCRIPTION = Unit tests for $(PROJECT) -BUILD_TYPE = debug -USE_COVERAGE = 1 - ################################################### # Location of the project directory and Makefiles # P := .. M := $(P)/.makefile -include $(M)/Makefile.header - -################################################### -# Inform Makefile where to find *.cpp and *.o files -# -VPATH += $(P) $(P)/src $(P)/src/utils ################################################### -# Inform Makefile where to find header files +# Project definition # -INCLUDES += -I$(P) -I$(P)/include -I$(P)/src +include $(P)/Makefile.common +TARGET_NAME := $(PROJECT_NAME)-tests +TARGET_DESCRIPTION := Unit tests for $(PROJECT_NAME) +COMPILATION_MODE := test +include $(M)/project/Makefile ################################################### -# Project defines. +# Compile the unit tests # +SRC_FILES := $(call rwildcard,$(P)/src,*.cpp) +SRC_FILES += $(call rwildcard,$(P)/tests,*.cpp) +INCLUDES := $(P) $(P)/include $(P)/src +VPATH := $(P) $(P)/src $(P)/src/utils DEFINES += -DPWD=\"$(shell pwd)\" DEFINES += -DHAVE_AES ifeq ($(ARCHI),Windows) -DEFINES += -DUSE_WINDOWS + LIB_FILES += $(P)/src/utils/dirent.c + DEFINES += -DUSE_WINDOWS else -DEFINES += -UUSE_WINDOWS -endif - -################################################### -# Compiled files. Note: cannot use libzipper.a as -# THIRDPART_LIBS becasue else lcov is not showing -# c++ code. -# -ifeq ($(ARCHI),Windows) -OBJS += dirent.o + DEFINES += -UUSE_WINDOWS endif -OBJS += Timestamp.o Path.o Zipper.o Unzipper.o -OBJS += TestPath.o TestZip.o -OBJS += main.o - -################################################### -# Library to test. -# -# THIRDPART_LIBS += $(abspath $(P)/build/libzipper.a.$(shell cat $(P)/VERSION.txt)) -THIRDPART_LIBS += \ - $(abspath $(THIRDPART)/minizip/build/libminizip.a) \ - $(abspath $(THIRDPART)/minizip/build/libaes.a) \ - $(abspath $(THIRDPART)/zlib-ng/build/libz.a) - -################################################### -# Libraries. -# +THIRDPART_LIBS := $(abspath $(THIRDPART_DIR)/minizip/build/libminizip.a) +THIRDPART_LIBS += $(abspath $(THIRDPART_DIR)/minizip/build/libaes.a) +THIRDPART_LIBS += $(abspath $(THIRDPART_DIR)/zlib-ng/build/libz.a) PKG_LIBS += gtest gmock ################################################### -# Compile unit tests -all: $(TARGET) - -################################################### -# Run unit tests (better to call: make coverage) -.PHONY: unit-tests -.PHONY: check -unit-tests check: $(TARGET) - @$(call print-to,"Running","$(TARGET)","$(RAPPORT)","") - $(SANITIZER) ./$(BUILD)/$(TARGET) || (cat $(TARGET).log; return 1) - -################################################### -# Sharable informations between all Makefiles -include $(M)/Makefile.footer +# Generic Makefile rules +# +include $(M)/rules/Makefile \ No newline at end of file diff --git a/tests/TestZip.cpp b/tests/TestZip.cpp index bcb1a4a..fe02dc3 100644 --- a/tests/TestZip.cpp +++ b/tests/TestZip.cpp @@ -215,11 +215,11 @@ TEST(FileUnzipTests, UnzipperPathologicalOpenings) } // Opening a non zip file - ASSERT_EQ(Path::exist("./build/Zipper-UnitTest"), true); - ASSERT_EQ(Path::isFile("./build/Zipper-UnitTest"), true); + ASSERT_EQ(Path::exist("../build/zipper-tests"), true); + ASSERT_EQ(Path::isFile("../build/zipper-tests"), true); try { - Unzipper unzipper("./build/Zipper-UnitTest"); + Unzipper unzipper("../build/zipper-tests"); } catch (std::runtime_error const& e) {