From ec618c98e8afdf2e5083a8dd045953cdc43781e1 Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 5 Dec 2018 00:49:28 -0500 Subject: project: pycompile: extend to allow .pyc generation of all pydist scripts. --- config/x86_64-linux-musl/config.c | 4 ++++ config/x86_64-nt64-midipix/config.c | 4 ++++ profiles/linkage/inittab.h | 4 ++++ profiles/linkage/pycompile.h | 26 ++++++++++++++++++++++++++ project/pycompile.mk | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 profiles/linkage/pycompile.h diff --git a/config/x86_64-linux-musl/config.c b/config/x86_64-linux-musl/config.c index a4ec971..d4d2384 100644 --- a/config/x86_64-linux-musl/config.c +++ b/config/x86_64-linux-musl/config.c @@ -11,5 +11,9 @@ struct _inittab _PyImport_Inittab[] = { PY_IMPORT_INITTAB_LINUX_AUDIO, #endif +#ifdef PY_FOR_PYCOMPILE + PY_IMPORT_INITTAB_PYCOMPILE_CORE, +#endif + {0, 0} }; diff --git a/config/x86_64-nt64-midipix/config.c b/config/x86_64-nt64-midipix/config.c index f0fb3bf..0304e40 100644 --- a/config/x86_64-nt64-midipix/config.c +++ b/config/x86_64-nt64-midipix/config.c @@ -9,5 +9,9 @@ struct _inittab _PyImport_Inittab[] = { PY_IMPORT_INITTAB_ANYOS_CORE, #endif +#ifdef PY_FOR_PYCOMPILE + PY_IMPORT_INITTAB_PYCOMPILE_CORE, +#endif + {0, 0} }; diff --git a/profiles/linkage/inittab.h b/profiles/linkage/inittab.h index 94474c8..86d3ea9 100644 --- a/profiles/linkage/inittab.h +++ b/profiles/linkage/inittab.h @@ -8,6 +8,10 @@ #include "static.h" #endif +#ifdef PY_FOR_PYCOMPILE +#include "pycompile.h" +#endif + struct _inittab { char * name; PY_INIT_PTR(initfunc); diff --git a/profiles/linkage/pycompile.h b/profiles/linkage/pycompile.h new file mode 100644 index 0000000..9cdd7ac --- /dev/null +++ b/profiles/linkage/pycompile.h @@ -0,0 +1,26 @@ +#ifndef PY_LINKAGE_PYCOMPILE_H +#define PY_LINKAGE_PYCOMPILE_H + +PY_INIT_FUNC(init_collections); +PY_INIT_FUNC(init_functools); +PY_INIT_FUNC(init_heapq); +PY_INIT_FUNC(init_locale); + +PY_INIT_FUNC(inititertools); +PY_INIT_FUNC(initoperator); +PY_INIT_FUNC(initreadline); +PY_INIT_FUNC(initstrop); +PY_INIT_FUNC(initunicodedata); + +#define PY_IMPORT_INITTAB_PYCOMPILE_CORE \ + {"_collections", init_collections}, \ + {"_functools", init_functools}, \ + {"_heapq", init_heapq}, \ + {"_locale", init_locale}, \ + {"itertools", inititertools}, \ + {"operator", initoperator}, \ + {"readline", initreadline}, \ + {"strop", initstrop}, \ + {"unicodedata", initunicodedata} + +#endif diff --git a/project/pycompile.mk b/project/pycompile.mk index 6bb61dc..6568792 100644 --- a/project/pycompile.mk +++ b/project/pycompile.mk @@ -15,6 +15,7 @@ PYCOMPILE_TAGS += $(PYCOMPILE_DIR)/config.tag PYCOMPILE_CFLAGS += -I$(PYCOMPILE_DIR)/build PYCOMPILE_CFLAGS += -I$(PROJECT_DIR)/profiles PYCOMPILE_CFLAGS += -I$(SOURCE_DIR)/Include +PYCOMPILE_CFLAGS += -DPY_FOR_PYCOMPILE PYCOMPILE_CFLAGS += -DVPATH=\"$(SOURCE_DIR)\" PYCOMPILE_CFLAGS += -DVERSION=\"$(PYTHON_VER)\" PYCOMPILE_CFLAGS += -DPLATFORM=\"$(NATIVE_OS)\" @@ -22,9 +23,15 @@ PYCOMPILE_CFLAGS += -DPREFIX=\"$(PYCOMPILE_PREFIX)\" PYCOMPILE_CFLAGS += -DEXEC_PREFIX=\"$(PYCOMPILE_PREFIX)\" PYCOMPILE_CFLAGS += -DPYTHONPATH=\"$(PYCOMPILE_PATH)\" +PYCOMPILE_LDFLAGS += -lreadline +PYCOMPILE_LDFLAGS += $(LDFLAGS_NCURSES_STATIC) + $(PYCOMPILE_DIR)/tree.tag: mkdir -p $(PYCOMPILE_DIR)/bin mkdir -p $(PYCOMPILE_DIR)/lib + mkdir -p $(PYCOMPILE_DIR)/lib/$(NICKNAME) + mkdir -p $(PYCOMPILE_DIR)/lib/$(NICKNAME)/encodings + mkdir -p $(PYCOMPILE_DIR)/lib/$(NICKNAME)/lib-dynload mkdir -p $(PYCOMPILE_DIR)/build mkdir -p $(PYCOMPILE_DIR)/Modules mkdir -p $(PYCOMPILE_DIR)/Objects @@ -68,8 +75,21 @@ $(PYCOMPILE_DIR)/Python/%.o: $(SOURCE_DIR)/Python/%.c $(ALL_HEADERS) $(PYCOMPILE $(NATIVE_CC) -c -o $@ $< $(PYCOMPILE_CFLAGS) +PYCOMPILE_PYEXT_SRCS = \ + $(PYEXT_COLLECTIONS_SRCS) \ + $(PYEXT_FUNCTOOLS_SRCS) \ + $(PYEXT_HEAPQ_SRCS) \ + $(PYEXT_LOCALE_SRCS) \ + $(PYEXT_ITERTOOLS_SRCS) \ + $(PYEXT_OPERATOR_SRCS) \ + $(PYEXT_READLINE_SRCS) \ + $(PYEXT_STROP_SRCS) \ + $(PYEXT_UNICODEDATA_SRCS) \ + + PYCOMPILE_APP_OBJS = $(PYCOMPILE_APP_SRCS:Modules/%.c=$(PYCOMPILE_DIR)/Modules/%.o) PYCOMPILE_CONFIG_OBJS = $(PYCOMPILE_CONFIG_SRCS:Modules/%.c=$(PYCOMPILE_DIR)/Modules/%.o) +PYCOMPILE_PYEXT_OBJS = $(PYCOMPILE_PYEXT_SRCS:Modules/%.c=$(PYCOMPILE_DIR)/Modules/%.o) PYCOMPILE_MODULE_OBJS = $(MODULE_SRCS:Modules/%.c=$(PYCOMPILE_DIR)/Modules/%.o) PYCOMPILE_OBJECT_OBJS = $(OBJECT_SRCS:Objects/%.c=$(PYCOMPILE_DIR)/Objects/%.o) PYCOMPILE_PARSER_OBJS = $(PARSER_SRCS:Parser/%.c=$(PYCOMPILE_DIR)/Parser/%.o) @@ -82,10 +102,24 @@ PYCOMPILE_OBJS = \ $(PYCOMPILE_OBJECT_OBJS) \ $(PYCOMPILE_PARSER_OBJS) \ $(PYCOMPILE_PYTHON_OBJS) \ + $(PYCOMPILE_PYEXT_OBJS) \ + + +ifeq ($(PYCOMPILE_CFGSTEP),) + +$(PYCOMPILE): $(PYCOMPILE_OBJS) + $(MAKE) PYCOMPILE_CFGSTEP=yes \ + PYCOMPILE_CFGHOST=$(PYCOMPILE_CFGHOST) \ + CFGHOST=$(PYCOMPILE_CFGHOST) \ + pycompile +else $(PYCOMPILE): $(PYCOMPILE_OBJS) $(NATIVE_CC) -o $@ $^ $(PYCOMPILE_LDFLAGS) +endif + + pycompile: $(PYCOMPILE) pycompile-objs: $(PYCOMPILE_OBJS) -- cgit v1.2.3