Skip to content

Commit 4f343c7

Browse files
committed
_bootstrap.py can bootstrap other than "main"
1 parent ffcd9d4 commit 4f343c7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

bootstrap/minimal/assets/_bootstrap.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,8 @@ def load_module(self, fullname):
120120
# Step 4: bootstrap the application !
121121
#
122122

123+
main_module = sys.argv[1]
124+
print 'Bootstrapping module: "%s"' % main_module
125+
123126
import runpy
124-
runpy._run_module_as_main("main", False)
127+
runpy._run_module_as_main(main_module, False)

bootstrap/minimal/jni/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ void android_main(struct android_app* state) {
6666
return;
6767
}
6868

69+
// pass a module name as argument: _bootstrap.py use it as the main module
70+
int argc;
71+
char * argv[2];
72+
argc = 2;
73+
argv[0] = "_bootstrap.py";
74+
argv[1] = "main";
75+
76+
PySys_SetArgv(argc, argv);
77+
6978
// run the python bootstrap
7079
LOGI("Run _bootstrap.py >>>");
7180
FILE *fhd = fopen(bootstrap_fn, "rb");

0 commit comments

Comments
 (0)