Skip to content

Commit

Permalink
Use MyMakefile-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed Jul 1, 2024
1 parent 16ebfeb commit 32b06a0
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 190 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .makefile
Submodule .makefile updated 59 files
+0 −102 .github/workflows/ci.yml
+0 −10 .gitignore
+674 −21 LICENSE
+0 −72 Makefile.color
+0 −328 Makefile.flags
+0 −295 Makefile.footer
+0 −241 Makefile.header
+0 −24 Makefile.help
+0 −336 Makefile.macros
+2 −398 README.md
+1 −0 VERSION
+0 −1 VERSION.txt
+367 −202 assets/doxygen/Doxyfile
+0 −0 assets/doxygen/doxygen.css
+0 −0 assets/doxygen/footer.html
+1 −0 assets/doxygen/header.html
+ assets/icons/logo.png
+ assets/icons/macos.icns
+3 −3 assets/scripts/alib.sh
+23 −26 assets/scripts/compile-external-libs.sh
+18 −18 assets/scripts/config.sh
+61 −0 assets/scripts/download-external-libs.sh
+27 −17 assets/scripts/targz.sh
+91 −0 doc/API.md
+14 −0 doc/demos/00/Makefile
+1 −2 doc/demos/00/src/main.cpp
+16 −0 doc/demos/01/Makefile
+12 −0 doc/demos/01/src/foo.cpp
+1 −1 doc/demos/01/src/foo.hpp
+3 −2 doc/demos/01/src/main.cpp
+16 −0 doc/demos/01/tests/Makefile
+13 −0 doc/demos/01/tests/unit-tests.cpp
+21 −0 doc/demos/02/Makefile
+0 −0 doc/demos/02/include/bar.hpp
+0 −0 doc/demos/02/include/foo.hpp
+15 −0 doc/demos/02/src/bar/Makefile
+0 −0 doc/demos/02/src/bar/bar.cpp
+15 −0 doc/demos/02/src/foo/Makefile
+0 −0 doc/demos/02/src/foo/foo.cpp
+15 −0 doc/demos/02/src/main.cpp
+0 −75 download-external-libs.sh
+0 −18 examples/00/Makefile
+0 −1 examples/00/VERSION.txt
+0 −27 examples/01/Makefile
+0 −1 examples/01/VERSION.txt
+0 −8 examples/01/src/foo.cpp
+0 −22 examples/01/tests/Makefile
+0 −1 examples/01/tests/VERSION.txt
+0 −14 examples/01/tests/unit-tests.cpp
+0 −62 examples/02/Makefile
+0 −1 examples/02/VERSION.txt
+0 −40 examples/02/src/bar/Makefile
+0 −1 examples/02/src/bar/VERSION.txt
+0 −40 examples/02/src/foo/Makefile
+0 −1 examples/02/src/foo/VERSION.txt
+0 −8 examples/02/src/main.cpp
+0 −37 examples/README.md
+397 −0 project/Makefile
+1,175 −0 rules/Makefile
107 changes: 29 additions & 78 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PROJECT_NAME := zipper
PROJECT_VERSION := 2.1.0
COMPILATION_MODE := release
CXX_STANDARD := --std=c++14
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 0 additions & 1 deletion VERSION.txt

This file was deleted.

51 changes: 12 additions & 39 deletions doc/demos/Unzipper/Makefile
Original file line number Diff line number Diff line change
@@ -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
Binary file added doc/doxygen-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions external/compile-external-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down
2 changes: 0 additions & 2 deletions external/download-external-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
79 changes: 20 additions & 59 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions tests/TestZip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 32b06a0

Please sign in to comment.