Skip to content

Commit

Permalink
Merge pull request #87 from dpogue/linux
Browse files Browse the repository at this point in the history
Make plPythonPack work on Linux
  • Loading branch information
Hoikas committed Oct 30, 2011
2 parents fa6c547 + f6b1ee4 commit a7dbe3f
Show file tree
Hide file tree
Showing 105 changed files with 580 additions and 293 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ find_package(OpenAL REQUIRED)
find_package(PythonLibs REQUIRED)
find_package(EXPAT REQUIRED)
find_package(ZLIB REQUIRED)
find_package(PhysX REQUIRED) #TODO: Not required if we aren't building the client
find_package(PNG REQUIRED)
find_package(Ogg REQUIRED) #TODO: Not required if we aren't building the client
find_package(Vorbis REQUIRED) #TODO: Not required if we aren't building the client
find_package(Speex REQUIRED) #TODO: Not required if we aren't building the client
find_package(DirectX REQUIRED)
find_package(CURL REQUIRED)

if(WIN32)
find_package(PhysX REQUIRED) #TODO: Not required if we aren't building the client
find_package(DirectX REQUIRED)
endif(WIN32)

find_package(MaxSDK) #TODO: Only find this if we are building PlasmaMax
find_package(Bink) #TODO: Find Bink, but don't require it if plPipeline isn't built...
# Or better yet, just eliminate bink altogether
Expand Down
1 change: 1 addition & 0 deletions Sources/Plasma/Apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ add_subdirectory(plUruLauncher)
add_subdirectory(plFileSecure)
add_subdirectory(plFileEncrypt)
add_subdirectory(plLogDecrypt)
add_subdirectory(plPageInfo)
2 changes: 1 addition & 1 deletion Sources/Plasma/Apps/plClient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ target_link_libraries(plClient plStreamLogger)
target_link_libraries(plClient plSurface)
target_link_libraries(plClient plTransform)
target_link_libraries(plClient plUnifiedTime)
target_link_libraries(plClient plUUID)
target_link_libraries(plClient plVault)
target_link_libraries(plClient pnAddrInfo)
target_link_libraries(plClient pnAsyncCore)
Expand All @@ -161,6 +160,7 @@ target_link_libraries(plClient pnSimpleNet)
target_link_libraries(plClient pnTimer)
target_link_libraries(plClient pnUtils)
target_link_libraries(plClient pnUtilsExe)
target_link_libraries(plClient pnUUID)

if(PYTHON_DEBUG_LIBRARY)
target_link_libraries(plClient debug ${PYTHON_DEBUG_LIBRARY})
Expand Down
3 changes: 1 addition & 2 deletions Sources/Plasma/Apps/plFileEncrypt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ set(plFileEncrypt_SOURCES
)

add_executable(plFileEncrypt ${plFileEncrypt_SOURCES})
target_link_libraries(plFileEncrypt CoreLib CoreLibExe plFile plUnifiedTime pnProduct pnUtils)
target_link_libraries(plFileEncrypt Rpcrt4)
target_link_libraries(plFileEncrypt CoreLib CoreLibExe pnProduct plFile)

source_group("Source Files" FILES ${plFileEncrypt_SOURCES})
1 change: 0 additions & 1 deletion Sources/Plasma/Apps/plFileEncrypt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "plFile/hsFiles.h"
#include "plFile/plEncryptedStream.h"
#include "pnUtils/pnUtils.h"
#include "pnProduct/pnProduct.h"
#include "hsUtils.h"

Expand Down
3 changes: 1 addition & 2 deletions Sources/Plasma/Apps/plFileSecure/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ set(plFileSecure_SOURCES
)

add_executable(plFileSecure ${plFileSecure_SOURCES})
target_link_libraries(plFileSecure CoreLib CoreLibExe plFile plUnifiedTime pnProduct pnUtils)
target_link_libraries(plFileSecure Rpcrt4)
target_link_libraries(plFileSecure CoreLib CoreLibExe pnProduct plFile)

source_group("Source Files" FILES ${plFileSecure_SOURCES})
1 change: 0 additions & 1 deletion Sources/Plasma/Apps/plFileSecure/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plFile/plSecureStream.h"
#include "pnUtils/pnUtils.h"
#include "pnProduct/pnProduct.h"
#include "hsUtils.h"

Expand Down
3 changes: 1 addition & 2 deletions Sources/Plasma/Apps/plLogDecrypt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ set(plLogDecrypt_SOURCES
)

add_executable(plLogDecrypt ${plLogDecrypt_SOURCES})
target_link_libraries(plLogDecrypt CoreLib CoreLibExe plFile plUnifiedTime plStatusLog pnProduct pnUtils)
target_link_libraries(plLogDecrypt Rpcrt4)
target_link_libraries(plLogDecrypt CoreLib CoreLibExe plStatusLog pnProduct)

source_group("Source Files" FILES ${plLogDecrypt_SOURCES})
4 changes: 3 additions & 1 deletion Sources/Plasma/Apps/plLogDecrypt/plLogDecrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
***/

#include <stdio.h>
#include <cstdio>
#include <cstring>
#include "hsTypes.h"
#include "hsUtils.h"
#include "plStatusLog/plEncryptLogLine.h"

void IProcessFile(const char *path)
Expand Down
18 changes: 18 additions & 0 deletions Sources/Plasma/Apps/plPageInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
include_directories("../../Apps")
include_directories("../../CoreLib")
include_directories("../../FeatureLib/inc")
include_directories("../../FeatureLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib/inc")
include_directories("../../PubUtilLib")

set(plPageInfo_SOURCES
plAllCreatables.cpp
plPageInfo.cpp
)

add_executable(plPageInfo ${plPageInfo_SOURCES})
target_link_libraries(plPageInfo CoreLib CoreLibExe pnProduct plResMgr plAudioCore)

source_group("Source Files" FILES ${plPageInfo_SOURCES})
20 changes: 10 additions & 10 deletions Sources/Plasma/Apps/plPageInfo/plAllCreatables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "hsTypes.h"

#include "../pnFactory/plCreator.h"
#include "pnFactory/plCreator.h"

#include "plAudible.h"
REGISTER_NONCREATABLE( plAudible );
Expand All @@ -55,16 +55,16 @@ REGISTER_NONCREATABLE( plPhysical );
#include "plgDispatch.h"
REGISTER_NONCREATABLE( plDispatchBase );

#include "../pnDispatch/pnDispatchCreatable.h"
#include "../pnKeyedObject/pnKeyedObjectCreatable.h"
#include "../pnMessage/pnMessageCreatable.h"
#include "../pnModifier/pnModifierCreatable.h"
#include "../pnNetCommon/pnNetCommonCreatable.h"
#include "../pnTimer/pnTimerCreatable.h"
#include "pnDispatch/pnDispatchCreatable.h"
#include "pnKeyedObject/pnKeyedObjectCreatable.h"
#include "pnMessage/pnMessageCreatable.h"
#include "pnModifier/pnModifierCreatable.h"
#include "pnNetCommon/pnNetCommonCreatable.h"
#include "pnTimer/pnTimerCreatable.h"

#include "../plResMgr/plResMgrCreatable.h"
#include "plResMgr/plResMgrCreatable.h"

#include "../plMessage/plResMgrHelperMsg.h"
#include "plMessage/plResMgrHelperMsg.h"
REGISTER_CREATABLE(plResMgrHelperMsg);

#include "../plAudioCore/plAudioCoreCreatable.h"
#include "plAudioCore/plAudioCoreCreatable.h"
23 changes: 11 additions & 12 deletions Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,20 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "hsUtils.h"
#include "hsTimer.h"
#include "../plFile/hsFiles.h"
#include "../plFile/plFileUtils.h"
#include "../plResMgr/plResManager.h"
#include "../plResMgr/plResMgrSettings.h"
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plResMgr/plResManager.h"
#include "plResMgr/plResMgrSettings.h"

#include "../plAgeDescription/plAgeManifest.h"
#include "plAgeDescription/plAgeManifest.h"

#include "../plResMgr/plRegistryHelpers.h"
#include "../plResMgr/plRegistryNode.h"
#include "plResMgr/plRegistryHelpers.h"
#include "plResMgr/plRegistryNode.h"

#include "../plAudioCore/plSoundBuffer.h"
#include "plAudioCore/plSoundBuffer.h"
#include "hsStream.h"

#include "../pnUtils/pnUtils.h"
#include "../pnProduct/pnProduct.h"
#include "pnProduct/pnProduct.h"


//// Globals /////////////////////////////////////////////////////////////////
Expand All @@ -70,7 +69,7 @@ void PrintVersion()
{
wchar productString[256];
ProductString(productString, arrsize(productString));
_putws(productString);
printf("%S\n\n", productString);
}

//// PrintHelp ///////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -267,4 +266,4 @@ bool DumpStats(const char* patchDir)
plStatDumpIterator statDump(patchDir);
gResMgr->IterateAllPages(&statDump);
return true;
}
}
56 changes: 43 additions & 13 deletions Sources/Plasma/Apps/plPythonPack/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,26 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <string>
#include <algorithm>

#include <direct.h>
#if HS_BUILD_FOR_WIN32
# include <direct.h>

# define getcwd _getcwd
# define chdir _chdir

# ifndef MAXPATHLEN
# define MAXPATHLEN MAX_PATH
# endif
#elif HS_BUILD_FOR_UNIX
# include <unistd.h>
# include <sys/param.h>
#endif

static const char* kPackFileName = "python.pak";
static const char* kGlueFile = ".\\plasma\\glue.py";
#if HS_BUILD_FOR_WIN32
static const char* kGlueFile = ".\\plasma\\glue.py";
#else
static const char* kGlueFile = "./plasma/glue.py";
#endif
static char* glueFile = (char*)kGlueFile;

void WritePythonFile(std::string fileName, std::string path, hsStream *s)
Expand Down Expand Up @@ -267,16 +283,22 @@ void FindSubDirs(std::vector<std::string> &dirnames, const char *path)
// adds or removes the ending slash in a path as necessary
std::string AdjustEndingSlash(std::string path, bool endingSlash = false)
{
#if HS_BUILD_FOR_WIN32
char slash = '\\';
#else
char slash = '/';
#endif

std::string retVal = path;
bool endSlashExists = false;
char temp = path[path.length()-1];
if (temp == '\\')
if (temp == slash)
endSlashExists = true;

if (endingSlash)
{
if (!endSlashExists)
retVal += "\\";
retVal += slash;
}
else
{
Expand All @@ -294,17 +316,23 @@ std::string AdjustEndingSlash(std::string path, bool endingSlash = false)
// appends partialPath onto the end of fullPath, inserting or removing slashes as necesssary
std::string ConcatDirs(std::string fullPath, std::string partialPath)
{
#if HS_BUILD_FOR_WIN32
char slash = '\\';
#else
char slash = '/';
#endif

bool fullSlash = false, partialSlash = false;
char temp = fullPath[fullPath.length()-1];
if (temp == '\\')
if (temp == slash)
fullSlash = true;
temp = partialPath[0];
if (temp == '\\')
if (temp == slash)
partialSlash = true;

std::string retVal = "";
if (!fullSlash)
retVal = fullPath + "\\";
retVal = fullPath + slash;
if (partialSlash)
{
std::string temp = "";
Expand Down Expand Up @@ -346,7 +374,7 @@ void PackDirectory(std::string dir, std::string rootPath, std::string pakName, s

printf("\nCreating %s using the contents of %s\n",pakName.c_str(),dir.c_str());
printf("Changing working directory to %s\n",rootPath.c_str());
if (_chdir(rootPath.c_str()))
if (chdir(rootPath.c_str()))
{
printf("ERROR: Directory change to %s failed for some reason\n",rootPath.c_str());
printf("Unable to continue with the packing of this directory, aborting...\n");
Expand Down Expand Up @@ -428,12 +456,12 @@ void PrintUsage()
printf(" must be a relative path to the current working directory\n");
}

void main(int argc, char *argv[])
int main(int argc, char *argv[])
{
printf("The Python Pack Utility\n");

char buffer[_MAX_PATH];
_getcwd(buffer,_MAX_PATH);
char buffer[MAXPATHLEN];
getcwd(buffer, MAXPATHLEN);
std::string baseWorkingDir = buffer;

// are they asking for usage?
Expand All @@ -445,14 +473,14 @@ void main(int argc, char *argv[])
|| (temp == "-h") || (temp == "/h"))
{
PrintUsage();
return;
return -1;
}
}
// wrong number of args, print usage
if (argc > 2)
{
PrintUsage();
return;
return -1;
}

std::vector<std::string> dirNames;
Expand All @@ -476,4 +504,6 @@ void main(int argc, char *argv[])
{
PackDirectory(dirNames[i],rootPath,rootPath+dirNames[i]+".pak",dirNames);
}

return 0;
}
3 changes: 3 additions & 0 deletions Sources/Plasma/CoreLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ set(CoreLib_HEADERS
)

add_library(CoreLib STATIC ${CoreLib_SOURCES} ${CoreLib_HEADERS})
if(UNIX)
target_link_libraries(CoreLib pthread)
endif(UNIX)

source_group("Source Files" FILES ${CoreLib_SOURCES})
source_group("Header Files" FILES ${CoreLib_HEADERS})
19 changes: 19 additions & 0 deletions Sources/Plasma/CoreLib/hsCritSect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,23 @@ void CCritSect::Enter () {
void CCritSect::Leave () {
LeaveCriticalSection(&m_handle);
}
#elif HS_BUILD_FOR_UNIX
//===========================================================================
CCritSect::CCritSect () {
m_handle = PTHREAD_MUTEX_INITIALIZER;
}

//===========================================================================
CCritSect::~CCritSect () {
}

//===========================================================================
void CCritSect::Enter () {
pthread_mutex_lock(&m_handle);
}

//===========================================================================
void CCritSect::Leave () {
pthread_mutex_unlock(&m_handle);
}
#endif
3 changes: 3 additions & 0 deletions Sources/Plasma/CoreLib/hsCritSect.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com

#ifdef HS_BUILD_FOR_WIN32
typedef CRITICAL_SECTION CritSectHandle;
#elif HS_BUILD_FOR_UNIX
# include <pthread.h>
typedef pthread_mutex_t CritSectHandle;
#else
# error "CCritSect: Not implemented on this platform"
#endif
Expand Down
6 changes: 4 additions & 2 deletions Sources/Plasma/CoreLib/hsMatrix44.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ void hsMatrix44::MakeZRotation(hsScalar radians)
//
hsMatrix44& hsMatrix44::Make(const hsPoint3* f, const hsPoint3* at, const hsVector3* up)
{
MakeTranslateMat(&hsVector3(f->fX, f->fY, f->fZ));
hsVector3 trans(f->fX, f->fY, f->fZ);
MakeTranslateMat(&trans);

hsVector3 back (f,at); // Z
back.Normalize();
Expand Down Expand Up @@ -435,7 +436,8 @@ hsMatrix44& hsMatrix44::Make(const hsPoint3* f, const hsPoint3* at, const hsVect
//
hsMatrix44& hsMatrix44::MakeUpPreserving(const hsPoint3* f, const hsPoint3* at, const hsVector3* up)
{
MakeTranslateMat(&hsVector3(f->fX, f->fY, f->fZ));
hsVector3 trans(f->fX, f->fY, f->fZ);
MakeTranslateMat(&trans);

hsVector3 topHead = *up;
topHead.Normalize();
Expand Down

0 comments on commit a7dbe3f

Please sign in to comment.