浏览代码

deploy-ng: fixes for FreeBSD

rdb 8 年之前
父节点
当前提交
1c018f5bdb
共有 3 个文件被更改,包括 21 次插入4 次删除
  1. 6 3
      direct/src/showutil/FreezeTool.py
  2. 1 1
      direct/src/showutil/dist.py
  3. 14 0
      pandatool/src/deploy-stub/deploy-stub.c

+ 6 - 3
direct/src/showutil/FreezeTool.py

@@ -750,9 +750,12 @@ class Freezer:
                     ('.abi{0}.so'.format(sys.version_info[0]), 'rb', 3),
                     ('.so', 'rb', 3),
                 ]
-            else:
-                print("Unknown platform %s" % (self.platform))
-                self.moduleSuffixes = imp.get_suffixes()
+            else: # FreeBSD et al.
+                self.moduleSuffixes += [
+                    ('.cpython-{0}{1}m.so'.format(*sys.version_info), 'rb', 3),
+                    ('.abi{0}.so'.format(*sys.version_info), 'rb', 3),
+                    ('.so', 'rb', 3),
+                ]
 
     def excludeFrom(self, freezer):
         """ Excludes all modules that have already been processed by

+ 1 - 1
direct/src/showutil/dist.py

@@ -78,7 +78,7 @@ class build_apps(distutils.core.Command):
         whldir = os.path.join(self.build_base, '__whl_cache__')
         abi_tag = pip.pep425tags.get_abi_tag()
 
-        if 'u' in abi_tag and not platform.startswith('manylinux'):
+        if 'u' in abi_tag and (platform.startswith('win') or platform.startswith('macosx')):
             abi_tag = abi_tag.replace('u', '')
 
         pip_args = [

+ 14 - 0
pandatool/src/deploy-stub/deploy-stub.c

@@ -3,6 +3,9 @@
 #include "Python.h"
 #ifdef _WIN32
 #include "malloc.h"
+
+#ifdef __FreeBSD__
+#include <sys/sysctl.h>
 #endif
 
 #include <stdio.h>
@@ -165,7 +168,18 @@ int main(int argc, char *argv[]) {
   wchar_t buffer[2048];
   GetModuleFileNameW(NULL, buffer, 2048);
   runtime = _wfopen(buffer, L"rb");
+#elif defined(__FreeBSD__)
+  size_t bufsize = 4096;
+  char buffer[4096];
+  int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
+  mib[3] = getpid();
+  if (sysctl(mib, 4, (void *)buffer, &bufsize, NULL, 0) == -1) {
+    perror("sysctl");
+    return 1;
+  }
+  runtime = fopen(buffer, "rb");
 #else
+  // Let's hope that it was invoked with the executable name as first arg.
   runtime = fopen(argv[0], "rb");
 #endif