all: minor cleanups
This commit is contained in:
+19
-25
@@ -7,18 +7,6 @@
|
|||||||
# A C++ compiler that fully implements C++17: clang-5, gcc-8 or msvc-2019-16.11
|
# A C++ compiler that fully implements C++17: clang-5, gcc-8 or msvc-2019-16.11
|
||||||
# (older or other compilers may work but are unsupported, use at your own risk)
|
# (older or other compilers may work but are unsupported, use at your own risk)
|
||||||
|
|
||||||
# CMake version check; using a somewhat current CMake version is highly recommended
|
|
||||||
if(DEFINED UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION)
|
|
||||||
cmake_minimum_required(VERSION "${UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION}" FATAL_ERROR)
|
|
||||||
else()
|
|
||||||
cmake_minimum_required(VERSION "3.8" FATAL_ERROR) # CMake >= 3.8 is needed for CXX_STANDARD 17
|
|
||||||
endif()
|
|
||||||
|
|
||||||
macro(upx_cmake_include_hook section) # developer convenience
|
|
||||||
include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/hooks/CMakeLists.${section}.txt" OPTIONAL)
|
|
||||||
include("${CMAKE_CURRENT_SOURCE_DIR}/maint/make/CMakeLists.${section}.txt" OPTIONAL)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
# Sections of this CMakeLists.txt:
|
# Sections of this CMakeLists.txt:
|
||||||
# - options
|
# - options
|
||||||
# - init
|
# - init
|
||||||
@@ -29,6 +17,19 @@ endmacro()
|
|||||||
# - install
|
# - install
|
||||||
# - print summary
|
# - print summary
|
||||||
|
|
||||||
|
# CMake version check; using a somewhat current CMake version is highly recommended
|
||||||
|
if(DEFINED UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION)
|
||||||
|
cmake_minimum_required(VERSION "${UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION}" FATAL_ERROR)
|
||||||
|
else()
|
||||||
|
cmake_minimum_required(VERSION "3.8" FATAL_ERROR) # CMake >= 3.8 is needed for CXX_STANDARD 17
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# support config hooks; developer convenience
|
||||||
|
macro(upx_cmake_include_hook section)
|
||||||
|
include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/hooks/CMakeLists.${section}.txt" OPTIONAL)
|
||||||
|
include("${CMAKE_CURRENT_SOURCE_DIR}/maint/make/CMakeLists.${section}.txt" OPTIONAL)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# options
|
# options
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
@@ -59,7 +60,7 @@ option(UPX_CONFIG_DISABLE_SELF_PACK_TEST "Do not test packing UPX with itself" O
|
|||||||
# init
|
# init
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
|
|
||||||
upx_cmake_include_hook(2_init_begin)
|
upx_cmake_include_hook(2_init)
|
||||||
|
|
||||||
# Disallow in-source builds. Note that you will still have to manually
|
# Disallow in-source builds. Note that you will still have to manually
|
||||||
# clean up a few files if you accidentally try an in-source build.
|
# clean up a few files if you accidentally try an in-source build.
|
||||||
@@ -216,8 +217,6 @@ if(NOT DEFINED MINGW AND CMAKE_C_PLATFORM_ID MATCHES "^MinGW")
|
|||||||
set(MINGW 1)
|
set(MINGW 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
upx_cmake_include_hook(2_init_end)
|
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# common compilation flags
|
# common compilation flags
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
@@ -228,7 +227,7 @@ include(CheckIncludeFile)
|
|||||||
include(CheckStructHasMember)
|
include(CheckStructHasMember)
|
||||||
include(CheckSymbolExists)
|
include(CheckSymbolExists)
|
||||||
|
|
||||||
upx_cmake_include_hook(3_common_compilation_flags_begin)
|
upx_cmake_include_hook(3_common_compilation_flags)
|
||||||
|
|
||||||
if(NOT DEFINED HAVE_UNISTD_H)
|
if(NOT DEFINED HAVE_UNISTD_H)
|
||||||
check_include_file("unistd.h" HAVE_UNISTD_H)
|
check_include_file("unistd.h" HAVE_UNISTD_H)
|
||||||
@@ -319,6 +318,7 @@ if(MSVC_FRONTEND OR WIN32 OR MINGW OR CYGWIN)
|
|||||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
|
add_definitions(-D__USE_MINGW_ANSI_STDIO)
|
||||||
endif()
|
endif()
|
||||||
if(MSVC_FRONTEND)
|
if(MSVC_FRONTEND)
|
||||||
# use -funsigned-char; set __cplusplus according to selected C++ standard
|
# use -funsigned-char; set __cplusplus according to selected C++ standard
|
||||||
@@ -426,8 +426,6 @@ endif()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
upx_cmake_include_hook(3_common_compilation_flags_end)
|
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# targets
|
# targets
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
@@ -437,7 +435,7 @@ set(UPX_CONFIG_DISABLE_THREADS ON) # multithreading is currently not used; maybe
|
|||||||
set(UPX_CONFIG_DISABLE_BZIP2 ON) # bzip2 is currently not used; we might need it to decompress linux kernels
|
set(UPX_CONFIG_DISABLE_BZIP2 ON) # bzip2 is currently not used; we might need it to decompress linux kernels
|
||||||
set(UPX_CONFIG_DISABLE_ZSTD ON) # zstd is currently not used; maybe in UPX version 5
|
set(UPX_CONFIG_DISABLE_ZSTD ON) # zstd is currently not used; maybe in UPX version 5
|
||||||
|
|
||||||
upx_cmake_include_hook(4_targets_begin)
|
upx_cmake_include_hook(4_targets)
|
||||||
|
|
||||||
if(NOT UPX_CONFIG_DISABLE_THREADS)
|
if(NOT UPX_CONFIG_DISABLE_THREADS)
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
@@ -502,13 +500,11 @@ if(Threads_FOUND)
|
|||||||
target_link_libraries(upx Threads::Threads)
|
target_link_libraries(upx Threads::Threads)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
upx_cmake_include_hook(4_targets_end)
|
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# target compilation flags
|
# target compilation flags
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
|
|
||||||
upx_cmake_include_hook(5_target_compilation_flags_begin)
|
upx_cmake_include_hook(5_target_compilation_flags)
|
||||||
|
|
||||||
if(NOT UPX_CONFIG_DISABLE_BZIP2)
|
if(NOT UPX_CONFIG_DISABLE_BZIP2)
|
||||||
set(t upx_vendor_bzip2)
|
set(t upx_vendor_bzip2)
|
||||||
@@ -599,8 +595,6 @@ else()
|
|||||||
target_compile_options(${t} PRIVATE ${warn_Wall} ${warn_Werror})
|
target_compile_options(${t} PRIVATE ${warn_Wall} ${warn_Werror})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
upx_cmake_include_hook(5_target_compilation_flags_end)
|
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# test
|
# test
|
||||||
# ctest
|
# ctest
|
||||||
@@ -676,7 +670,7 @@ endif()
|
|||||||
endif() # UPX_CONFIG_CMAKE_DISABLE_INSTALL
|
endif() # UPX_CONFIG_CMAKE_DISABLE_INSTALL
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# show summary
|
# summary
|
||||||
# print some info about the build configuration
|
# print some info about the build configuration
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ UPX_MAKEFILE_EXTRA_MK_INCLUDED := 1
|
|||||||
|
|
||||||
override check_defined = $(foreach 1,$1,$(if $(filter undefined,$(origin $1)),$(error ERROR: variable '$1' is not defined),))
|
override check_defined = $(foreach 1,$1,$(if $(filter undefined,$(origin $1)),$(error ERROR: variable '$1' is not defined),))
|
||||||
override check_undefined = $(foreach 1,$1,$(if $(filter undefined,$(origin $1)),,$(error ERROR: variable '$1' is already defined)))
|
override check_undefined = $(foreach 1,$1,$(if $(filter undefined,$(origin $1)),,$(error ERROR: variable '$1' is already defined)))
|
||||||
|
$(call check_defined,run_config run_build)
|
||||||
$(call check_undefined,run_config_and_build)
|
$(call check_undefined,run_config_and_build)
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
|
|||||||
+8
-8
@@ -36,7 +36,7 @@ class UiPacker;
|
|||||||
class Filter;
|
class Filter;
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// purely abstract minimal base class for all packers
|
// PackerBase: purely abstract minimal base class for all packers
|
||||||
//
|
//
|
||||||
// clients: PackMaster, UiPacker
|
// clients: PackMaster, UiPacker
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
// a recognized format.
|
// a recognized format.
|
||||||
// canPack() can also return -1 to fail early; see class PackMaster
|
// canPack() can also return -1 to fail early; see class PackMaster
|
||||||
virtual tribool canPack() = 0;
|
virtual tribool canPack() = 0;
|
||||||
// canUnpack() should throw a cantUnpackException explaining why it cannot pack
|
// canUnpack() should throw a cantUnpackException explaining why it cannot unpack
|
||||||
// a recognized format.
|
// a recognized format.
|
||||||
// canUnpack() can also return -1 to fail early; see class PackMaster
|
// canUnpack() can also return -1 to fail early; see class PackMaster
|
||||||
virtual tribool canUnpack() = 0;
|
virtual tribool canUnpack() = 0;
|
||||||
@@ -80,16 +80,16 @@ protected:
|
|||||||
InputFile *const fi; // reference
|
InputFile *const fi; // reference
|
||||||
union { // unnamed union
|
union { // unnamed union
|
||||||
const upx_int64_t file_size; // must get set by constructor
|
const upx_int64_t file_size; // must get set by constructor
|
||||||
const upx_uint64_t file_size_u; // (explicitly unsigned)
|
const upx_uint64_t file_size_u; // (explicitly unsigned to avoid casts)
|
||||||
};
|
};
|
||||||
PackHeader ph; // must be filled by canUnpack(); also used by UiPacker
|
PackHeader ph; // must be filled by canUnpack(); also used by UiPacker
|
||||||
};
|
};
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// abstract default implementation class for packers
|
// Packer: default implementation base class for all current packers
|
||||||
//
|
//
|
||||||
// Packer can be viewed as "PackerDefaultImplV1"; it is grown historically
|
// Packer can be viewed as "PackerDefaultImplVersion1"; it is grown
|
||||||
// and still would benefit from a decomposition
|
// historically and really would benefit from a decomposition
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
class Packer : public PackerBase {
|
class Packer : public PackerBase {
|
||||||
@@ -244,7 +244,7 @@ protected:
|
|||||||
static unsigned unoptimizeReloc(SPAN_S(const byte) & in, MemBuffer &out, SPAN_P(byte) image,
|
static unsigned unoptimizeReloc(SPAN_S(const byte) & in, MemBuffer &out, SPAN_P(byte) image,
|
||||||
unsigned image_size, int bits, bool bswap);
|
unsigned image_size, int bits, bool bswap);
|
||||||
|
|
||||||
// Target Endianness abstraction
|
// TE - Target Endianness abstraction
|
||||||
#if 0
|
#if 0
|
||||||
// permissive version using "void *"
|
// permissive version using "void *"
|
||||||
inline unsigned get_te16(const void *p) const noexcept { return bele->get16(p); }
|
inline unsigned get_te16(const void *p) const noexcept { return bele->get16(p); }
|
||||||
@@ -296,7 +296,7 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const N_BELE_RTP::AbstractPolicy *bele = nullptr; // target endianness
|
const N_BELE_RTP::AbstractPolicy *bele = nullptr; // TE - Target Endianness
|
||||||
|
|
||||||
// PackHeader
|
// PackHeader
|
||||||
int ph_format = -1;
|
int ph_format = -1;
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
#define XSPAN_CONFIG_ENABLE_SPAN_CONVERSION 1
|
#define XSPAN_CONFIG_ENABLE_SPAN_CONVERSION 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// actual implementation
|
||||||
#include "xspan_impl.h"
|
#include "xspan_impl.h"
|
||||||
|
|
||||||
#ifdef XSPAN_NAMESPACE_NAME
|
#ifdef XSPAN_NAMESPACE_NAME
|
||||||
|
|||||||
Reference in New Issue
Block a user