Skip to content
Permalink
Browse files
Now compiles everything whether we need it or not, removing whole fil…
…es with

 #ifdefs...this will make it easier to "embed" this library in other projects
 or use a different build system: just push everything through the compiler
 with preprocessor defines for the parts you want/need...platform modules are
 determined automatically without the build system needing to intervene, so
 you just have to #define the archivers, etc that you want.
  • Loading branch information
icculus committed Mar 11, 2007
1 parent 839f733 commit 69598e49ab5ec55e9d96ce99f206aa15bfd559e5
Showing with 144 additions and 65 deletions.
  1. +7 −0 CHANGELOG.txt
  2. +42 −20 CMakeLists.txt
  3. +38 −0 physfs_platforms.h
  4. +5 −3 platform/beos.cpp
  5. +7 −12 platform/macclassic.c
  6. +5 −3 platform/os2.c
  7. +7 −1 platform/pocketpc.c
  8. +5 −3 platform/posix.c
  9. +8 −3 platform/skeleton.c
  10. +14 −17 platform/unix.c
  11. +6 −3 platform/windows.c
@@ -6,6 +6,13 @@
branch for history's sake. Added shared and static build options
to CMakeLists.txt, and the expected "make install" target.
Renamed some FILENAME files to FILENAME.txt, removed physfs.rc.
Now compiles everything whether we need it or not, removing whole
files with #ifdefs...this will make it easier to "embed" this
library in other projects or use a different build system: just
push everything through the compiler with preprocessor defines for
the parts you want/need...platform modules are determined
automatically without the build system needing to intervene, so you
just have to #define the archivers, etc that you want.
03082007 - Fixed a comment in physfs.h. Renamed win32.c to windows.c.
Cleaned up whitespace/formatting in pocketpc.c. Updated PocketPC
code to expect UTF-8 strings from the higher level. Changed
@@ -6,7 +6,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)

PROJECT(PhysicsFS)
SET(PHYSFS_VERSION 1.1.2)
SET(PHYSFS_VERSION 1.1.1)
SET(PHYSFS_SOVERSION 1)

# I hate that they define "WIN32" ... we're about to move to Win64...I hope!
@@ -88,23 +88,46 @@ SET(LZMA_SRCS
lzma/LzmaStateDecode.c
)

IF(BEOS)
# We add this explicitly, since we don't want CMake to think this
# is a C++ project unless we're on BeOS.
SET(PHYSFS_BEOS_SRCS platform/beos.cpp)
ENDIF(BEOS)

# Almost everything is "compiled" here, but things that don't apply to the
# build are #ifdef'd out. This is to make it easy to embed PhysicsFS into
# another project or bring up a new build system: just compile all the source
# code and #define the things you want.
SET(PHYSFS_SRCS
physfs.c
physfs_byteorder.c
physfs_unicode.c
platform/macclassic.c
platform/os2.c
platform/pocketpc.c
platform/posix.c
platform/unix.c
platform/windows.c
archivers/dir.c
archivers/grp.c
archivers/hog.c
archivers/lzma.c
archivers/mvl.c
archivers/qpak.c
archivers/wad.c
archivers/zip.c
${PHYSFS_BEOS_SRCS}
)


# platform layers ...

IF(UNIX)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} platform/posix.c)
IF(BEOS)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} platform/beos.cpp)
SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
SET(HAVE_PTHREAD_H TRUE)
ELSE(BEOS)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} platform/unix.c)
# !!! FIXME
# AC_DEFINE([PHYSFS_HAVE_LLSEEK], 1, [define if we have llseek])
CHECK_INCLUDE_FILE(sys/ucred.h HAVE_UCRED_H)
@@ -118,21 +141,19 @@ IF(UNIX)
ADD_DEFINITIONS(-DPHYSFS_HAVE_MNTENT_H=1)
SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
ENDIF(HAVE_MNTENT_H)
ENDIF(BEOS)

CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
IF(HAVE_PTHREAD_H)
SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
ELSE(HAVE_PTHREAD_H)
ADD_DEFINITIONS(-DPHYSFS_NO_PTHREADS_SUPPORT=1)
ENDIF(HAVE_PTHREAD_H)
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
IF(HAVE_PTHREAD_H)
SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
ELSE(HAVE_PTHREAD_H)
ADD_DEFINITIONS(-DPHYSFS_NO_PTHREADS_SUPPORT=1)
ENDIF(HAVE_PTHREAD_H)
ENDIF(BEOS)
ENDIF(UNIX)

IF(WINDOWS)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} platform/windows.c)
SET(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
SET(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
# !!! FIXME: platform/pocketpc.c ... ?
ENDIF(WINDOWS)

IF(NOT PHYSFS_HAVE_CDROM_SUPPORT)
@@ -158,20 +179,26 @@ ELSE(PHYSFS_HAVE_THREAD_SUPPORT)
MESSAGE(WARNING " ***")
ENDIF(PHYSFS_HAVE_THREAD_SUPPORT)

CHECK_INCLUDE_FILE(assert.h HAVE_ASSERT_H)
IF(HAVE_ASSERT_H)
ADD_DEFINITIONS(-DHAVE_ASSERT_H=1)
ENDIF(HAVE_ASSERT_H)



# Archivers ...

OPTION(PHYSFS_ARCHIVE_ZIP "Enable ZIP support" TRUE)
IF(PHYSFS_ARCHIVE_ZIP)
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_ZIP=1)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} archivers/zip.c)
SET(PHYSFS_NEED_ZLIB TRUE)
ENDIF(PHYSFS_ARCHIVE_ZIP)

OPTION(PHYSFS_ARCHIVE_7Z "Enable 7zip support" TRUE)
IF(PHYSFS_ARCHIVE_7Z)
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_7Z=1)
# !!! FIXME: rename to 7z.c?
SET(PHYSFS_SRCS ${PHYSFS_SRCS} ${LZMA_SRCS} archivers/lzma.c)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} ${LZMA_SRCS})
INCLUDE_DIRECTORIES(lzma)
ADD_DEFINITIONS(-D_LZMA_IN_CB=1)
ADD_DEFINITIONS(-D_LZMA_PROB32=1)
@@ -182,31 +209,26 @@ ENDIF(PHYSFS_ARCHIVE_7Z)
OPTION(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
IF(PHYSFS_ARCHIVE_GRP)
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_GRP=1)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} archivers/grp.c)
ENDIF(PHYSFS_ARCHIVE_GRP)

OPTION(PHYSFS_ARCHIVE_WAD "Enable Doom WAD support" TRUE)
IF(PHYSFS_ARCHIVE_WAD)
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_WAD=1)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} archivers/wad.c)
ENDIF(PHYSFS_ARCHIVE_WAD)

OPTION(PHYSFS_ARCHIVE_HOG "Enable Descent I/II HOG support" TRUE)
IF(PHYSFS_ARCHIVE_HOG)
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_HOG=1)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} archivers/hog.c)
ENDIF(PHYSFS_ARCHIVE_HOG)

OPTION(PHYSFS_ARCHIVE_MVL "Enable Descent I/II MVL support" TRUE)
IF(PHYSFS_ARCHIVE_MVL)
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_MVL=1)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} archivers/mvl.c)
ENDIF(PHYSFS_ARCHIVE_MVL)

OPTION(PHYSFS_ARCHIVE_QPAK "Enable Quake I/II QPAK support" TRUE)
IF(PHYSFS_ARCHIVE_QPAK)
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_QPAK=1)
SET(PHYSFS_SRCS ${PHYSFS_SRCS} archivers/qpak.c)
ENDIF(PHYSFS_ARCHIVE_QPAK)


@@ -0,0 +1,38 @@
#ifndef _INCL_PHYSFS_PLATFORMS
#define _INCL_PHYSFS_PLATFORMS

#ifndef __PHYSICSFS_INTERNAL__
#error Do not include this header from your applications.
#endif

/*
* These only define the platforms to determine which files in the platforms
* directory should be compiled. For example, technically BeOS can be called
* a "unix" system, but since it doesn't use unix.c, we don't define
* PHYSFS_PLATFORM_UNIX on that system.
*/

#if ((defined __BEOS__) || (defined __beos__))
# define PHYSFS_PLATFORM_BEOS
# define PHYSFS_PLATFORM_POSIX
#elif (defined _WIN32_WCE) || (defined _WIN64_WCE)
# define PHYSFS_PLATFORM_POCKETPC
#elif (((defined _WIN32) || (defined _WIN64)) && (!defined __CYGWIN__))
# define PHYSFS_PLATFORM_WINDOWS
#elif (defined OS2)
# define PHYSFS_PLATFORM_OS2
#elif ((defined __MACH__) && (defined __APPLE__))
# define PHYSFS_PLATFORM_MACOSX
# define PHYSFS_PLATFORM_UNIX
# define PHYSFS_PLATFORM_POSIX
#elif defined(macintosh)
# define PHYSFS_PLATFORM_MACCLASSIC
#elif defined(unix)
# define PHYSFS_PLATFORM_UNIX
# define PHYSFS_PLATFORM_POSIX
#else
# error Unknown platform.
#endif

#endif /* include-once blocker. */

@@ -6,7 +6,10 @@
* This file written by Ryan C. Gordon.
*/

#ifdef __BEOS__
#define __PHYSICSFS_INTERNAL__
#include "physfs_platforms.h"

#ifdef PHYSFS_PLATFORM_BEOS

#include <be/kernel/OS.h>
#include <be/app/Roster.h>
@@ -24,7 +27,6 @@
#include <errno.h>
#include <unistd.h>

#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"


@@ -244,7 +246,7 @@ void __PHYSFS_platformReleaseMutex(void *mutex)
release_sem(*((sem_id *) mutex));
} /* __PHYSFS_platformReleaseMutex */

#endif
#endif /* PHYSFS_PLATFORM_BEOS */

/* end of beos.cpp ... */

@@ -6,6 +6,11 @@
* This file written by Ryan C. Gordon.
*/

#define __PHYSICSFS_INTERNAL__
#include "physfs_platforms.h"

#ifdef PHYSFS_PLATFORM_MACCLASSIC

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -31,15 +36,6 @@
*/


/*
* Please note that I haven't tried this code with CarbonLib or under
* Mac OS X at all. The code in unix.c is known to work with Darwin,
* and you may or may not be better off using that, especially since
* mutexes are no-ops in this file. Patches welcome.
*/
#ifdef __PHYSFS_CARBONIZED__ /* this is currently not defined anywhere. */
#include <Carbon.h>
#else
#include <OSUtils.h>
#include <Processes.h>
#include <Files.h>
@@ -49,12 +45,9 @@
#include <Events.h>
#include <DriverGestalt.h>
#include <Aliases.h>
#endif

#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"


const char *__PHYSFS_platformDirSeparator = ":";


@@ -960,5 +953,7 @@ void __PHYSFS_platformAllocatorFree(void *ptr)
free(ptr);
} /* __PHYSFS_platformAllocatorFree */

#endif /* PHYSFS_PLATFORM_MACCLASSIC */

/* end of macclassic.c ... */

@@ -6,7 +6,10 @@
* This file written by Ryan C. Gordon.
*/

#if (defined OS2)
#define __PHYSICSFS_INTERNAL__
#include "physfs_platforms.h"

#ifdef PHYSFS_PLATFORM_OS2

#define INCL_DOSSEMAPHORES
#define INCL_DOSDATETIME
@@ -26,7 +29,6 @@
#include <time.h>
#include <ctype.h>

#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"

const char *__PHYSFS_platformDirSeparator = "\\";
@@ -773,7 +775,7 @@ void __PHYSFS_platformAllocatorFree(void *ptr)
free(ptr);
} /* __PHYSFS_platformAllocatorFree */

#endif /* defined OS2 */
#endif /* PHYSFS_PLATFORM_OS2 */

/* end of os2.c ... */

@@ -6,10 +6,14 @@
* This file written by Ryan C. Gordon.
*/

#define __PHYSICSFS_INTERNAL__
#include "physfs_platforms.h"

#ifdef PHYSFS_PLATFORM_POCKETPC

#include <stdio.h>
#include <windows.h>

#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"

#define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF
@@ -624,5 +628,7 @@ void __PHYSFS_platformAllocatorFree(void *ptr)
free(ptr);
} /* __PHYSFS_platformAllocatorFree */

#endif /* PHYSFS_PLATFORM_POCKETPC */

/* end of pocketpc.c ... */

@@ -6,7 +6,10 @@
* This file written by Ryan C. Gordon.
*/

#if ((!defined WIN32) && (!defined OS2))
#define __PHYSICSFS_INTERNAL__
#include "physfs_platforms.h"

#ifdef PHYSFS_PLATFORM_POSIX

#if (defined __STRICT_ANSI__)
#define __PHYSFS_DOING_STRICT_ANSI__
@@ -44,7 +47,6 @@
#include <linux/unistd.h>
#endif

#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"


@@ -533,7 +535,7 @@ void __PHYSFS_platformAllocatorFree(void *ptr)
free(ptr);
} /* __PHYSFS_platformAllocatorFree */

#endif /* !defined WIN32 */
#endif /* PHYSFS_PLATFORM_POSIX */

/* end of posix.c ... */

@@ -6,12 +6,14 @@
* This file written by Ryan C. Gordon.
*/

#define __PHYSICSFS_INTERNAL__
#include "physfs_internal.h"
#error DO NOT COMPILE THIS. IT IS JUST A SKELETON EXAMPLE FILE.

#define __PHYSICSFS_INTERNAL__
#include "physfs_platforms.h"

#error DO NOT COMPILE THIS. IT IS JUST A SKELETON EXAMPLE FILE.
#ifdef PHYSFS_PLATFORM_SKELETON

#include "physfs_internal.h"

const char *__PHYSFS_platformDirSeparator = ":";

@@ -265,5 +267,8 @@ void __PHYSFS_platformAllocatorFree(void *ptr)
free(ptr);
} /* __PHYSFS_platformAllocatorFree */

#endif /* PHYSFS_PLATFORM_SKELETON */


/* end of skeleton.c ... */

0 comments on commit 69598e4

Please sign in to comment.