瀏覽代碼

deploy-stub: Add flag for enabling verbose mode in Python

rdb 1 月之前
父節點
當前提交
325727ef2f
共有 2 個文件被更改,包括 17 次插入0 次删除
  1. 12 0
      pandatool/src/deploy-stub/android_main.cxx
  2. 5 0
      pandatool/src/deploy-stub/deploy-stub.c

+ 12 - 0
pandatool/src/deploy-stub/android_main.cxx

@@ -32,6 +32,14 @@
 // Leave room for future expansion.
 #define MAX_NUM_POINTERS 24
 
+/* Stored in the flags field of the blobinfo structure below. */
+enum Flags {
+  F_log_append = 1,
+  F_log_filename_strftime = 2,
+  F_keep_docstrings = 4,
+  F_python_verbose = 8,
+};
+
 // Define an exposed symbol where we store the offset to the module data.
 extern "C" {
   __attribute__((__visibility__("default"), used))
@@ -283,6 +291,10 @@ void android_main(struct android_app *app) {
   PyConfig_SetBytesString(&config, &config.platlibdir, libdir);
   env->ReleaseStringUTFChars(libdir_jstr, libdir);
 
+  if (blobinfo.flags & F_python_verbose) {
+    config.verbose = 1;
+  }
+
   status = Py_InitializeFromConfig(&config);
   PyConfig_Clear(&config);
   if (PyStatus_Exception(status)) {

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

@@ -35,6 +35,7 @@ enum Flags {
   F_log_append = 1,
   F_log_filename_strftime = 2,
   F_keep_docstrings = 4,
+  F_python_verbose = 8,
 };
 
 /* Define an exposed symbol where we store the offset to the module data. */
@@ -416,6 +417,10 @@ int Py_FrozenMain(int argc, char **argv)
     }
 #endif
 
+    if (blobinfo.flags & F_python_verbose) {
+      Py_VerboseFlag = 1;
+    }
+
 #ifndef NDEBUG
     if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0')
         inspect = 1;