Skip to content

Commit d92ecdb

Browse files
committed
Switched polybuild to use libarchive instead of minizip in order to (hopefully) fix creating archives that physfs reads incorrectly
1 parent 8654b57 commit d92ecdb

27 files changed

+154
-12776
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
*.exp
2828
*.zip
2929
*.swo
30+
*.swm
31+
*.swn
3032
*.opensdf
3133
*.user.*
3234
*.xcuserstate

CMake/ExternalLibArchive.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Build a local version
2+
INCLUDE(ExternalProject)
3+
4+
SET(libarchive_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libarchive)
5+
6+
SET(libarchive_CMAKE_ARGS
7+
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
8+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
9+
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
10+
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
11+
-DENABLE_ICONV=OFF
12+
-DENABLE_TAR=OFF
13+
-DENABLE_OPENSSL=OFF
14+
-DENABLE_TEST=OFF
15+
-DCMAKE_DEBUG_POSTFIX=d
16+
)
17+
18+
ExternalProject_Add(libarchive
19+
PREFIX ${libarchive_PREFIX}
20+
21+
DOWNLOAD_DIR ${POLYCODE_DEPS_DOWNLOAD_DIR}
22+
23+
URL http://www.libarchive.org/downloads/libarchive-3.1.2.tar.gz
24+
URL_MD5 efad5a503f66329bb9d2f4308b5de98a
25+
26+
INSTALL_DIR ${POLYCODE_DEPS_TOOLS_PREFIX}
27+
CMAKE_ARGS ${libarchive_CMAKE_ARGS}
28+
)

CMake/FindLibArchive.cmake

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# LIBARCHIVE_FOUND - system has Libarchive
2+
# LIBARCHIVE_INCLUDE_DIR - the Libarchive include directory
3+
# LIBARCHIVE_LIBRARY - Link these to use Libarchive
4+
# LIBARCHIVE_LIBRARIES
5+
6+
SET(LIBARCHIVE_SEARCH_PATHS
7+
${POLYCODE_RELEASE_DIR}/Framework/Tools/Dependencies/lib
8+
${POLYCODE_RELEASE_DIR}/Framework/Tools/Dependencies/include/
9+
)
10+
11+
SET(CMAKE_FIND_LIBRARY_SUFFIXES
12+
.a
13+
.lib
14+
)
15+
16+
17+
find_path (LIBARCHIVE_INCLUDE_DIR NAMES archive.h
18+
HINTS
19+
NO_DEFAULT_PATH
20+
NO_CMAKE_ENVIRONMENT_PATH
21+
NO_CMAKE_SYSTEM_PATH
22+
NO_SYSTEM_ENVIRONMENT_PATH
23+
NO_CMAKE_PATH
24+
CMAKE_FIND_FRAMEWORK NEVER
25+
PATH_SUFFIXES lib lib64 win32/Dynamic_Release "Win32/${MSVC_YEAR_NAME}/x64/Release" "Win32/${MSVC_YEAR_NAME}/Win32/Release"
26+
PATHS ${LIBARCHIVE_SEARCH_PATHS}
27+
)
28+
29+
find_library (LIBARCHIVE_LIBRARY_DEBUG NAMES archived libarchived libarchive_d PATHS ${LIBARCHIVE_SEARCH_PATHS})
30+
find_library (LIBARCHIVE_LIBRARY_RELEASE NAMES archive libarchive PATHS ${LIBARCHIVE_SEARCH_PATHS})
31+
32+
if (LIBARCHIVE_INCLUDE_DIR AND LIBARCHIVE_LIBRARY_RELEASE)
33+
set(LIBARCHIVE_FOUND TRUE)
34+
endif()
35+
36+
if (LIBARCHIVE_LIBRARY_RELEASE)
37+
set (LIBARCHIVE_LIBRARY ${LIBARCHIVE_LIBRARY_RELEASE})
38+
endif()
39+
40+
if (LIBARCHIVE_LIBRARY_DEBUG AND LIBARCHIVE_LIBRARY_RELEASE)
41+
set (LIBARCHIVE_LIBRARY debug ${LIBARCHIVE_LIBRARY_DEBUG} optimized ${LIBARCHIVE_LIBRARY_RELEASE} )
42+
endif()
43+
44+
45+
if (LIBARCHIVE_FOUND)
46+
MESSAGE("-- Found Libarchive: ${LIBARCHIVE_LIBRARY}")
47+
mark_as_advanced (LIBARCHIVE_INCLUDE_DIR LIBARCHIVE_LIBRARY LIBARCHIVE_LIBRARIES)
48+
else()
49+
MESSAGE("-- Could not find LibArchive!")
50+
endif()
51+
52+

CMake/PolycodeIncludes.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ FIND_PACKAGE(Ogg REQUIRED)
2020
FIND_PACKAGE(Vorbis REQUIRED)
2121
FIND_PACKAGE(VorbisFile REQUIRED)
2222
FIND_PACKAGE(Lua REQUIRED)
23+
FIND_PACKAGE(LibArchive REQUIRED)
2324

2425
# Use SDL on non-Apple unixes
2526
IF(UNIX AND NOT APPLE)
@@ -39,4 +40,5 @@ INCLUDE_DIRECTORIES(
3940
${PNG_INCLUDE_DIR}
4041
${OPENGLEXT_INCLUDE_DIR}
4142
${LUA_INCLUDE_DIR}
43+
${LIBARCHIVE_INCLUDE_DIR}
4244
)

Dependencies/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ ENDIF(APPLE)
125125
SET(internal_ASSIMP ON)
126126
#ENDIF(ASSIMP_FOUND)
127127

128+
SET(internal_LIBARCHIVE ON)
129+
128130
OPTION(POLYCODE_DEPS_GLEXT "Download GL/glext.h header" ${internal_GLEXT})
129131
OPTION(POLYCODE_DEPS_WGLEXT "Download GL/wglext.h header" ${internal_WGLEXT})
130132

@@ -138,6 +140,7 @@ OPTION(POLYCODE_DEPS_LUA51 "Download and build the Lua51 package" ${internal_LUA
138140
OPTION(POLYCODE_DEPS_BOX2D "Download and build the Box2D package" ${internal_BOX2D})
139141
OPTION(POLYCODE_DEPS_BULLET "Download and build the Bullet package" ${internal_BULLET})
140142
OPTION(POLYCODE_DEPS_ASSIMP "Download and build the Assimp package" ${internal_ASSIMP})
143+
OPTION(POLYCODE_DEPS_LIBARCHIVE "Download and build the LibArchive package" ${internal_LIBARCHIVE})
141144

142145
IF(POLYCODE_DEPS_PNG)
143146
INCLUDE(ExternalPNG)
@@ -175,6 +178,10 @@ IF(POLYCODE_DEPS_ASSIMP)
175178
INCLUDE(ExternalAssimp)
176179
ENDIF(POLYCODE_DEPS_ASSIMP)
177180

181+
IF(POLYCODE_DEPS_LIBARCHIVE)
182+
INCLUDE(ExternalLibArchive)
183+
ENDIF(POLYCODE_DEPS_LIBARCHIVE)
184+
178185
# Use SDL on non-Apple unixes
179186
#IF(UNIX AND NOT APPLE)
180187
# FIND_PACKAGE(SDL REQUIRED)
Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,23 @@
11
INCLUDE(PolycodeIncludes)
22

3+
FIND_PACKAGE(LibArchive REQUIRED)
34
FIND_PACKAGE(ZLIB)
5+
46
INCLUDE_DIRECTORIES(
5-
${ZLIB_INCLUDE_DIR}
6-
${Polycode_SOURCE_DIR}/Tools/Dependencies/unzip11
7+
${ZLIB_INCLUDE_DIR}
8+
${LIBARCHIVE_INCLUDE_DIR}
79
Include)
810

9-
SET(minizip_SRCS
10-
../../Dependencies/unzip11/ioapi.c
11-
../../Dependencies/unzip11/ioapi.h
12-
../../Dependencies/unzip11/zip.c
13-
../../Dependencies/unzip11/zip.h
14-
)
15-
16-
#IF(POLYCODE_BUILD_SHARED)
17-
# LINK_LIBRARIES(Polycore)
18-
# ADD_EXECUTABLE(polybuild ${minizip_SRCS} Source/polybuild.cpp Include/polybuild.h)
19-
#ENDIF(POLYCODE_BUILD_SHARED)
20-
21-
#IF(POLYCODE_BUILD_STATIC)
22-
ADD_EXECUTABLE(polybuild ${minizip_SRCS} Source/polybuild.cpp Include/polybuild.h)
11+
ADD_EXECUTABLE(polybuild Source/polybuild.cpp Include/polybuild.h)
2312
IF(MSVC OR MINGW)
24-
TARGET_LINK_LIBRARIES(polybuild Polycore ${LUA_LIBRARIES} ${PHYSFS_LIBRARY} ${ZLIB_LIBRARIES})
13+
TARGET_LINK_LIBRARIES(polybuild Polycore ${LUA_LIBRARIES} ${PHYSFS_LIBRARY} ${LIBARCHIVE_LIBRARY} ${ZLIB_LIBRARIES})
2514
ELSEIF(APPLE)
26-
TARGET_LINK_LIBRARIES(polybuild Polycore ${LUA_LIBRARIES} ${PHYSFS_LIBRARY} ${ZLIB_LIBRARIES} "-framework IOKit" "-framework Cocoa")
15+
TARGET_LINK_LIBRARIES(polybuild Polycore ${LUA_LIBRARIES} ${PHYSFS_LIBRARY} ${LIBARCHIVE_LIBRARY} ${ZLIB_LIBRARIES} "-framework IOKit" "-framework Cocoa")
2716
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pagezero_size 10000 -image_base 100000000" )
2817
ELSE(MSVC OR MINGW)
29-
TARGET_LINK_LIBRARIES(polybuild Polycore ${LUA_LIBRARIES} ${PHYSFS_LIBRARY} ${ZLIB_LIBRARIES} dl)
18+
TARGET_LINK_LIBRARIES(polybuild Polycore ${LUA_LIBRARIES} ${PHYSFS_LIBRARY} ${LIBARCHIVE_LIBRARY} ${ZLIB_LIBRARIES} dl)
3019
ENDIF(MSVC OR MINGW)
31-
#ENDIF(POLYCODE_BUILD_STATIC)
3220

3321
IF(POLYCODE_INSTALL_FRAMEWORK)
34-
35-
# install exes
36-
# IF(POLYCODE_BUILD_SHARED)
37-
# INSTALL(TARGETS polybuild_dynamic DESTINATION ${POLYCODE_RELEASE_DIR}/Framework/Tools)
38-
# ENDIF(POLYCODE_BUILD_SHARED)
39-
40-
# IF(POLYCODE_BUILD_STATIC)
4122
INSTALL(TARGETS polybuild DESTINATION Tools)
42-
# ENDIF(POLYCODE_BUILD_STATIC)
43-
4423
ENDIF(POLYCODE_INSTALL_FRAMEWORK)

0 commit comments

Comments
 (0)