From 9908148679eb72659bd2a6510e9facc103c07c9a Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 3 Aug 2009 18:51:54 +0000 Subject: [PATCH] add dtool_platform --- dtool/Config.pp | 6 +++ dtool/LocalSetup.pp | 1 + dtool/src/dtoolbase/Sources.pp | 5 ++- dtool/src/dtoolbase/dtool_platform.h | 55 ++++++++++++++++++++++++++++ dtool/src/dtoolutil/pandaSystem.cxx | 14 +++++++ dtool/src/dtoolutil/pandaSystem.h | 2 + 6 files changed, 82 insertions(+), 1 deletion(-) create mode 100755 dtool/src/dtoolbase/dtool_platform.h diff --git a/dtool/Config.pp b/dtool/Config.pp index d1398eb5e3..7cba9fb0a9 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -956,6 +956,12 @@ #define ARTOOLKIT_LIBS $[if $[WINDOWS_PLATFORM],libAR.lib,AR] #defer HAVE_ARTOOLKIT $[libtest $[ARTOOLKIT_LPATH],$[ARTOOLKIT_LIBS]] +// Define this to explicitly indicate the given platform string within +// the resulting Panda runtime. Normally it is best to leave this +// undefined, in which case Panda will determine the best value +// automatically. +#define DTOOL_PLATFORM + // Define this to generate static libraries and executables, rather than // dynamic libraries. //#define LINK_ALL_STATIC yes diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index accce517a5..a4f69d74e7 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -686,5 +686,6 @@ $[cdefine IS_OSX] $[cdefine IS_LINUX] $[cdefine IS_FREEBSD] $[cdefine BUILD_IPHONE] +$[cdefine DTOOL_PLATFORM] #end dtool_config.h diff --git a/dtool/src/dtoolbase/Sources.pp b/dtool/src/dtoolbase/Sources.pp index 7dafe631f1..2697507ba5 100644 --- a/dtool/src/dtoolbase/Sources.pp +++ b/dtool/src/dtoolbase/Sources.pp @@ -17,6 +17,7 @@ deletedBufferChain.h deletedBufferChain.I \ deletedChain.h deletedChain.T \ dtoolbase.h dtoolbase_cc.h dtoolsymbols.h \ + dtool_platform.h \ fakestringstream.h \ indent.I indent.h indent.cxx \ memoryBase.h \ @@ -73,7 +74,9 @@ cmath.I cmath.h \ deletedBufferChain.h deletedBufferChain.I \ deletedChain.h deletedChain.T \ - dtoolbase.h dtoolbase_cc.h dtoolsymbols.h fakestringstream.h \ + dtoolbase.h dtoolbase_cc.h dtoolsymbols.h \ + dtool_platform.h \ + fakestringstream.h \ indent.I indent.h \ memoryBase.h \ memoryHook.h memoryHook.I \ diff --git a/dtool/src/dtoolbase/dtool_platform.h b/dtool/src/dtoolbase/dtool_platform.h new file mode 100755 index 0000000000..8f0d9fb65c --- /dev/null +++ b/dtool/src/dtoolbase/dtool_platform.h @@ -0,0 +1,55 @@ +/* Filename: dtool_platform.h + * Created by: drose (03Aug09) + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef DTOOL_PLATFORM_H +#define DTOOL_PLATFORM_H + +/* This file defines the macro DTOOL_PLATFORM, which is used in + PandaSystem and a few other places to report the current platform + string. In practice, this string is primarily useful for the + packaged runtime system. */ + +#include "dtool_config.h" + +#if defined(DTOOL_PLATFORM) +// This has already been defined explicitly by the Config.pp file. + +#elif defined(_WIN32) +#define DTOOL_PLATFORM "win32" + +#elif defined(_WIN64) +#define DTOOL_PLATFORM "win64" + +#elif defined(__APPLE__) +#if defined(BUILD_IPHONE) +#define DTOOL_PLATFORM "iphone" +#elif defined(__ppc__) +#define DTOOL_PLATFORM "osx.ppc" +#else +#define DTOOL_PLATFORM "osx.i386" +#endif + +#elif defined(__x86_64) +#define DTOOL_PLATFORM "linux.amd64" + +#elif defined(__i386) +#define DTOOL_PLATFORM "linux.i386" + +#else +#error Can't determine platform; please define DTOOL_PLATFORM in Config.pp file. + +#endif + +#endif + diff --git a/dtool/src/dtoolutil/pandaSystem.cxx b/dtool/src/dtoolutil/pandaSystem.cxx index ae145a0ef5..3337cb96dc 100644 --- a/dtool/src/dtoolutil/pandaSystem.cxx +++ b/dtool/src/dtoolutil/pandaSystem.cxx @@ -14,6 +14,7 @@ #include "pandaSystem.h" #include "pandaVersion.h" +#include "dtool_platform.h" PandaSystem *PandaSystem::_global_ptr = NULL; TypeHandle PandaSystem::_type_handle; @@ -182,6 +183,19 @@ string PandaSystem:: get_build_date() { return __DATE__ " " __TIME__; } + +//////////////////////////////////////////////////////////////////// +// Function: PandaSystem::get_platform +// Access: Published, Static +// Description: Returns a string representing the runtime platform +// that we are currently running on. This will be +// something like "win32" or "osx.i386" or +// "linux.amd64". +//////////////////////////////////////////////////////////////////// +string PandaSystem:: +get_platform() { + return DTOOL_PLATFORM; +} //////////////////////////////////////////////////////////////////// // Function: PandaSystem::has_system diff --git a/dtool/src/dtoolutil/pandaSystem.h b/dtool/src/dtoolutil/pandaSystem.h index d851c31f9d..af4d081c3f 100644 --- a/dtool/src/dtoolutil/pandaSystem.h +++ b/dtool/src/dtoolutil/pandaSystem.h @@ -43,6 +43,8 @@ PUBLISHED: static string get_compiler(); static string get_build_date(); + static string get_platform(); + bool has_system(const string &system) const; int get_num_systems() const; string get_system(int n) const;