Skip to content

Commit 5caa4be

Browse files
committed
git subrepo clone https://github.com/carstene1ns/physfs-switch repo/physfs
subrepo: subdir: "repo/physfs" merged: "676b8bb0f" upstream: origin: "https://github.com/carstene1ns/physfs-switch" branch: "master" commit: "676b8bb0f" git-subrepo: version: "0.4.0" origin: "https://github.com/ingydotnet/git-subrepo" commit: "5d6aba9"
1 parent 8dec237 commit 5caa4be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+32600
-0
lines changed

repo/physfs/.gitrepo

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; DO NOT EDIT (unless you know what you are doing)
2+
;
3+
; This subdirectory is a git "subrepo", and this file is maintained by the
4+
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
5+
;
6+
[subrepo]
7+
remote = https://github.com/carstene1ns/physfs-switch
8+
branch = master
9+
commit = 676b8bb0f78410ad6b3dd7abc610387d848976ad
10+
parent = 8dec2372b11c1359513f52a0a36ac7aee097a24d
11+
method = merge
12+
cmdver = 0.4.0

repo/physfs/CMakeLists.txt

Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
# PhysicsFS; a portable, flexible file i/o abstraction.
2+
#
3+
# Please see the file LICENSE.txt in the source's root directory.
4+
5+
# The CMake project file is meant to get this compiling on all sorts of
6+
# platforms quickly, and serve as the way Unix platforms and Linux distros
7+
# package up official builds, but you don't _need_ to use this; we have
8+
# built PhysicsFS to (hopefully) be able to drop into your project and
9+
# compile, using preprocessor checks for platform-specific bits instead of
10+
# testing in here.
11+
12+
cmake_minimum_required(VERSION 2.8.4)
13+
14+
project(PhysicsFS)
15+
set(PHYSFS_VERSION 3.0.1)
16+
17+
# Increment this if/when we break backwards compatibility.
18+
set(PHYSFS_SOVERSION 1)
19+
20+
# I hate that they define "WIN32" ... we're about to move to Win64...I hope!
21+
if(WIN32 AND NOT WINDOWS)
22+
set(WINDOWS TRUE)
23+
endif()
24+
25+
include_directories(./src)
26+
27+
if(APPLE)
28+
set(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework IOKit -framework Foundation")
29+
set(PHYSFS_M_SRCS src/physfs_platform_apple.m)
30+
endif()
31+
32+
if(CMAKE_COMPILER_IS_GNUCC)
33+
# Don't use -rpath.
34+
set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
35+
endif()
36+
37+
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
38+
add_definitions(-erroff=E_EMPTY_TRANSLATION_UNIT)
39+
add_definitions(-xldscope=hidden)
40+
endif()
41+
42+
if(HAIKU)
43+
# We add this explicitly, since we don't want CMake to think this
44+
# is a C++ project unless we're on Haiku.
45+
set(PHYSFS_CPP_SRCS src/physfs_platform_haiku.cpp)
46+
find_library(BE_LIBRARY be)
47+
find_library(ROOT_LIBRARY root)
48+
set(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
49+
endif()
50+
51+
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
52+
set(WINRT TRUE)
53+
endif()
54+
55+
if(WINRT)
56+
set(PHYSFS_CPP_SRCS src/physfs_platform_winrt.cpp)
57+
endif()
58+
59+
if(UNIX AND NOT WINDOWS AND NOT APPLE) # (MingW and such might be UNIX _and_ WINDOWS!)
60+
find_library(PTHREAD_LIBRARY pthread)
61+
if(PTHREAD_LIBRARY)
62+
set(OPTIONAL_LIBRARY_LIBS ${OPTIONAL_LIBRARY_LIBS} ${PTHREAD_LIBRARY})
63+
endif()
64+
endif()
65+
66+
# Almost everything is "compiled" here, but things that don't apply to the
67+
# build are #ifdef'd out. This is to make it easy to embed PhysicsFS into
68+
# another project or bring up a new build system: just compile all the source
69+
# code and #define the things you want.
70+
set(PHYSFS_SRCS
71+
src/physfs.c
72+
src/physfs_byteorder.c
73+
src/physfs_unicode.c
74+
src/physfs_platform_posix.c
75+
src/physfs_platform_unix.c
76+
src/physfs_platform_windows.c
77+
src/physfs_platform_os2.c
78+
src/physfs_platform_qnx.c
79+
src/physfs_archiver_dir.c
80+
src/physfs_archiver_unpacked.c
81+
src/physfs_archiver_grp.c
82+
src/physfs_archiver_hog.c
83+
src/physfs_archiver_7z.c
84+
src/physfs_archiver_mvl.c
85+
src/physfs_archiver_qpak.c
86+
src/physfs_archiver_wad.c
87+
src/physfs_archiver_zip.c
88+
src/physfs_archiver_slb.c
89+
src/physfs_archiver_iso9660.c
90+
src/physfs_archiver_vdf.c
91+
${PHYSFS_CPP_SRCS}
92+
${PHYSFS_M_SRCS}
93+
)
94+
95+
96+
# Archivers ...
97+
# These are (mostly) on by default now, so these options are only useful for
98+
# disabling them.
99+
100+
option(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE)
101+
if(NOT PHYSFS_ARCHIVE_ZIP)
102+
add_definitions(-DPHYSFS_SUPPORTS_ZIP=0)
103+
endif()
104+
105+
option(PHYSFS_ARCHIVE_7Z "Enable 7zip support" TRUE)
106+
if(NOT PHYSFS_ARCHIVE_7Z)
107+
add_definitions(-DPHYSFS_SUPPORTS_7Z=0)
108+
endif()
109+
110+
option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
111+
if(NOT PHYSFS_ARCHIVE_GRP)
112+
add_definitions(-DPHYSFS_SUPPORTS_GRP=0)
113+
endif()
114+
115+
option(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE)
116+
if(NOT PHYSFS_ARCHIVE_WAD)
117+
add_definitions(-DPHYSFS_SUPPORTS_WAD=0)
118+
endif()
119+
120+
option(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE)
121+
if(NOT PHYSFS_ARCHIVE_HOG)
122+
add_definitions(-DPHYSFS_SUPPORTS_HOG=0)
123+
endif()
124+
125+
option(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE)
126+
if(NOT PHYSFS_ARCHIVE_MVL)
127+
add_definitions(-DPHYSFS_SUPPORTS_MVL=0)
128+
endif()
129+
130+
option(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE)
131+
if(NOT PHYSFS_ARCHIVE_QPAK)
132+
add_definitions(-DPHYSFS_SUPPORTS_QPAK=0)
133+
endif()
134+
135+
option(PHYSFS_ARCHIVE_SLB "Enable I-War / Independence War SLB support" TRUE)
136+
if(NOT PHYSFS_ARCHIVE_SLB)
137+
add_definitions(-DPHYSFS_SUPPORTS_SLB=0)
138+
endif()
139+
140+
option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE)
141+
if(NOT PHYSFS_ARCHIVE_ISO9660)
142+
add_definitions(-DPHYSFS_SUPPORTS_ISO9660=0)
143+
endif()
144+
145+
option(PHYSFS_ARCHIVE_VDF "Enable Gothic I/II VDF archive support" TRUE)
146+
if(NOT PHYSFS_ARCHIVE_VDF)
147+
add_definitions(-DPHYSFS_SUPPORTS_VDF=0)
148+
endif()
149+
150+
151+
option(PHYSFS_BUILD_STATIC "Build static library" TRUE)
152+
if(PHYSFS_BUILD_STATIC)
153+
add_library(physfs-static STATIC ${PHYSFS_SRCS})
154+
# Don't rename this on Windows, since DLLs will also produce an import
155+
# library named "physfs.lib" which would conflict; Unix tend to like the
156+
# same library name with a different extension for static libs, but
157+
# Windows can just have a separate name.
158+
if(NOT MSVC)
159+
set_target_properties(physfs-static PROPERTIES OUTPUT_NAME "physfs")
160+
endif()
161+
if(WINRT)
162+
# Ignore LNK4264 warnings; we don't author any WinRT components, just consume them, so we're okay in a static library.
163+
set_target_properties(physfs-static PROPERTIES VS_WINRT_COMPONENT True)
164+
set_target_properties(physfs-static PROPERTIES STATIC_LIBRARY_FLAGS "/ignore:4264")
165+
endif()
166+
167+
set(PHYSFS_LIB_TARGET physfs-static)
168+
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs-static")
169+
endif()
170+
171+
option(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
172+
if(PHYSFS_BUILD_SHARED)
173+
add_library(physfs SHARED ${PHYSFS_SRCS})
174+
set_target_properties(physfs PROPERTIES MACOSX_RPATH 1)
175+
set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
176+
set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
177+
if(WINRT)
178+
set_target_properties(physfs PROPERTIES VS_WINRT_COMPONENT True)
179+
endif()
180+
target_link_libraries(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS})
181+
set(PHYSFS_LIB_TARGET physfs)
182+
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs")
183+
endif()
184+
185+
if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
186+
message(FATAL "Both shared and static libraries are disabled!")
187+
endif()
188+
189+
# CMake FAQ says I need this...
190+
if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC AND NOT WINDOWS)
191+
set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
192+
set_target_properties(physfs-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
193+
endif()
194+
195+
option(PHYSFS_BUILD_TEST "Build stdio test program." TRUE)
196+
mark_as_advanced(PHYSFS_BUILD_TEST)
197+
if(PHYSFS_BUILD_TEST)
198+
find_path(READLINE_H readline/readline.h)
199+
find_path(HISTORY_H readline/history.h)
200+
if(READLINE_H AND HISTORY_H)
201+
find_library(CURSES_LIBRARY NAMES curses ncurses)
202+
set(CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY})
203+
find_library(READLINE_LIBRARY readline)
204+
if(READLINE_LIBRARY)
205+
set(HAVE_SYSTEM_READLINE TRUE)
206+
set(TEST_PHYSFS_LIBS ${TEST_PHYSFS_LIBS} ${READLINE_LIBRARY} ${CURSES_LIBRARY})
207+
include_directories(SYSTEM ${READLINE_H} ${HISTORY_H})
208+
add_definitions(-DPHYSFS_HAVE_READLINE=1)
209+
endif()
210+
endif()
211+
add_executable(test_physfs test/test_physfs.c)
212+
target_link_libraries(test_physfs ${PHYSFS_LIB_TARGET} ${TEST_PHYSFS_LIBS} ${OTHER_LDFLAGS})
213+
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";test_physfs")
214+
endif()
215+
216+
install(TARGETS ${PHYSFS_INSTALL_TARGETS}
217+
RUNTIME DESTINATION bin
218+
LIBRARY DESTINATION lib${LIB_SUFFIX}
219+
ARCHIVE DESTINATION lib${LIB_SUFFIX})
220+
install(FILES src/physfs.h DESTINATION include)
221+
222+
find_package(Doxygen)
223+
if(DOXYGEN_FOUND)
224+
set(PHYSFS_OUTPUT_DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
225+
configure_file(
226+
"${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile"
227+
"${PHYSFS_OUTPUT_DOXYFILE}"
228+
COPYONLY
229+
)
230+
file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n\n# Below auto-generated by cmake...\n\n")
231+
file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "PROJECT_NUMBER = \"${PHYSFS_VERSION}\"\n")
232+
file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "OUTPUT_DIRECTORY = \"${CMAKE_CURRENT_BINARY_DIR}/docs\"\n")
233+
file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n# End auto-generated section.\n\n")
234+
235+
add_custom_target(
236+
docs
237+
${DOXYGEN_EXECUTABLE} "${PHYSFS_OUTPUT_DOXYFILE}"
238+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
239+
COMMENT "Building documentation in 'docs' directory..."
240+
)
241+
else()
242+
message(STATUS "Doxygen not found. You won't be able to build documentation.")
243+
endif()
244+
245+
if(UNIX)
246+
set(PHYSFS_TARBALL "${CMAKE_CURRENT_SOURCE_DIR}/../physfs-${PHYSFS_VERSION}.tar.bz2")
247+
add_custom_target(
248+
dist
249+
hg archive -t tbz2 "${PHYSFS_TARBALL}"
250+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
251+
COMMENT "Building source tarball '${PHYSFS_TARBALL}'..."
252+
)
253+
add_custom_target(
254+
uninstall
255+
"${CMAKE_CURRENT_SOURCE_DIR}/extras/uninstall.sh"
256+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
257+
COMMENT "Uninstall the project..."
258+
)
259+
endif()
260+
261+
if(NOT MSVC)
262+
configure_file(
263+
"extras/physfs.pc.in"
264+
"extras/physfs.pc"
265+
@ONLY
266+
)
267+
install(
268+
FILES "${CMAKE_CURRENT_BINARY_DIR}/extras/physfs.pc"
269+
DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
270+
)
271+
endif()
272+
273+
macro(message_bool_option _NAME _VALUE)
274+
if(${_VALUE})
275+
message(STATUS " ${_NAME}: enabled")
276+
else()
277+
message(STATUS " ${_NAME}: disabled")
278+
endif()
279+
endmacro()
280+
281+
message(STATUS "PhysicsFS will build with the following options:")
282+
message_bool_option("ZIP support" PHYSFS_ARCHIVE_ZIP)
283+
message_bool_option("7zip support" PHYSFS_ARCHIVE_7Z)
284+
message_bool_option("GRP support" PHYSFS_ARCHIVE_GRP)
285+
message_bool_option("WAD support" PHYSFS_ARCHIVE_WAD)
286+
message_bool_option("HOG support" PHYSFS_ARCHIVE_HOG)
287+
message_bool_option("MVL support" PHYSFS_ARCHIVE_MVL)
288+
message_bool_option("QPAK support" PHYSFS_ARCHIVE_QPAK)
289+
message_bool_option("SLB support" PHYSFS_ARCHIVE_SLB)
290+
message_bool_option("VDF support" PHYSFS_ARCHIVE_VDF)
291+
message_bool_option("ISO9660 support" PHYSFS_ARCHIVE_ISO9660)
292+
message_bool_option("Build static library" PHYSFS_BUILD_STATIC)
293+
message_bool_option("Build shared library" PHYSFS_BUILD_SHARED)
294+
message_bool_option("Build stdio test program" PHYSFS_BUILD_TEST)
295+
if(PHYSFS_BUILD_TEST)
296+
message_bool_option(" Use readline in test program" HAVE_SYSTEM_READLINE)
297+
endif()
298+
299+
# end of CMakeLists.txt ...
300+

repo/physfs/LICENSE.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
Copyright (c) 2001-2017 Ryan C. Gordon and others.
3+
4+
This software is provided 'as-is', without any express or implied warranty.
5+
In no event will the authors be held liable for any damages arising from
6+
the use of this software.
7+
8+
Permission is granted to anyone to use this software for any purpose,
9+
including commercial applications, and to alter it and redistribute it
10+
freely, subject to the following restrictions:
11+
12+
1. The origin of this software must not be misrepresented; you must not
13+
claim that you wrote the original software. If you use this software in a
14+
product, an acknowledgment in the product documentation would be
15+
appreciated but is not required.
16+
17+
2. Altered source versions must be plainly marked as such, and must not be
18+
misrepresented as being the original software.
19+
20+
3. This notice may not be removed or altered from any source distribution.
21+
22+
Ryan C. Gordon <icculus@icculus.org>
23+

repo/physfs/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# PhysicsFS - https://icculus.org/physfs/
2+
3+
A portable, flexible file i/o abstraction.
4+
5+
Version 3.0.1 for Nintendo Switch Homebrew (using libnx)
6+
7+
## Building for Switch
8+
9+
```bash
10+
rm -rf build
11+
mkdir build
12+
cd build
13+
cmake .. -DCMAKE_TOOLCHAIN_FILE=../Toolchain.cmake -DCMAKE_BUILD_TYPE=Release \
14+
-DCMAKE_INSTALL_PREFIX=$DEVKITPRO/portlibs/switch \
15+
-DPHYSFS_BUILD_SHARED=OFF -DPHYSFS_BUILD_TEST=OFF
16+
make
17+
sudo make install
18+
19+
```
20+
21+
Please see the [docs](docs/) directory for documentation.
22+
Please see [LICENSE.txt](LICENSE.txt) for licensing information.

repo/physfs/README.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
PhysicsFS; a portable, flexible file i/o abstraction.
3+
4+
https://icculus.org/physfs/
5+
6+
Please see the docs directory for documentation.
7+
8+
Please see LICENSE.txt for licensing information.
9+

repo/physfs/Toolchain.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
set(DEVKITPRO $ENV{DEVKITPRO})
2+
set(NX 1)
3+
4+
set(CMAKE_SYSTEM_NAME "Generic")
5+
set(CMAKE_C_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc")
6+
set(CMAKE_CXX_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++")
7+
set(CMAKE_AR "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ar" CACHE STRING "")
8+
set(CMAKE_RANLIB "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ranlib" CACHE STRING "")
9+
10+
set(PKG_CONFIG "${DEVKITPRO}/portlibs/bin/aarch64-none-elf-pkg-config" CACHE STRING "")
11+
set(CPPFLAGS "-D__SWITCH__ -I${DEVKITPRO}/libnx/include -I${DEVKITPRO}/portlibs/switch/include")
12+
set(CMAKE_C_FLAGS "${CPPFLAGS} -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ffunction-sections" CACHE STRING "C flags")
13+
set(CMAKE_CXX_FLAGS "${CPPFLAGS} ${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions -std=gnu++11" CACHE STRING "C++ flags")
14+
15+
set(CMAKE_FIND_ROOT_PATH ${DEVKITPRO}/devkitA64 ${DEVKITPRO}/libnx ${DEVKITPRO}/portlibs/switch)
16+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
17+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
18+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
19+
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
20+
21+
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available")
22+
link_directories(${DEVKITPRO}/libnx/lib ${DEVKITPRO}/portlibs/switch/lib)

0 commit comments

Comments
 (0)