<Hermetic> Implement CPython2 Launcher in C++.
The launcher is actually a wrapper which will statically link Python
interpreter within the .par file. It is used to bootstrap embedded
interpreter.
The next step is to change/integrate with Soong to make this hermetic .par
generation process more automatic.
Bug: b/62380596
Test: The launcher has been tested using real files:
zip -r hermetic.zip entry_point.txt Stdlib/ runfiles/
cat launcher | cat - hermetic.zip > executable && chmod u+x executable
Change-Id: I293cae2fe74d46766044f3e3c4b654a54d319b67
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index 1691773..0a7cd0f 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -43,9 +43,11 @@
static PyObject *ZipImportError;
static PyObject *zip_directory_cache = NULL;
+// GOOGLE(nanzhang): Changed two functions below to be visible to launcher so
+// that launcher can access the zip metadata section.
/* forward decls */
-static PyObject *read_directory(const char *archive);
-static PyObject *get_data(const char *archive, PyObject *toc_entry);
+PyObject *read_directory(const char *archive);
+PyObject *get_data(const char *archive, PyObject *toc_entry);
static PyObject *get_module_code(ZipImporter *self, char *fullname,
int *p_ispackage, char **p_modpath);
@@ -702,7 +704,7 @@
Directories can be recognized by the trailing SEP in the name,
data_size and file_offset are 0.
*/
-static PyObject *
+PyObject *
read_directory(const char *archive)
{
PyObject *files = NULL;
@@ -912,7 +914,7 @@
/* Given a path to a Zip file and a toc_entry, return the (uncompressed)
data as a new reference. */
-static PyObject *
+PyObject *
get_data(const char *archive, PyObject *toc_entry)
{
PyObject *raw_data = NULL, *data, *decompress;