浏览代码

add dtool_platform

David Rose 16 年之前
父节点
当前提交
9908148679

+ 6 - 0
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

+ 1 - 0
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

+ 4 - 1
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 \

+ 55 - 0
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
+

+ 14 - 0
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

+ 2 - 0
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;