Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KGB99 committed Aug 2, 2024
1 parent 1f292b5 commit 8ad3e96
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions recipes/recipes_emscripten/python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,31 @@ LIBFFI_COMMIT=f08493d249d2067c8b3207ba46693dd858f95db3

all: $(INSTALL)/lib/$(LIB) $(INSTALL)/lib/libffi.a

.PHONY=sysconfigdata
sysconfigdata:
# Generate sysconfigdata. It outputs into a subfolder of build/, and
# the subfolder is written to pybuilddir.txt.
cd $(BUILD) && _PYTHON_SYSCONFIGDATA_NAME=$(SYSCONFIG_NAME) _PYTHON_PROJECT_BASE=$(BUILD) $(HOSTPYTHON) -m sysconfig --generate-posix-vars
$(eval PYBUILDDIR=$(BUILD)/`cat $(BUILD)/builddir.txt`)
ROOT=$(ROOT) PYTHONPATH=$(PYBUILDDIR) python$(PYMAJOR).$(PYMINOR) adjust_sysconfig.py
mkdir -p $(PREFIX)/lib/python$(PYMAJOR).$(PYMINOR)/
mkdir -p $(SYSCONFIGDATA_DIR)
cp $(PYBUILDDIR)/$(SYSCONFIG_NAME).py $(PREFIX)/lib/python$(PYMAJOR).$(PYMINOR)/
cp $(PYBUILDDIR)/$(SYSCONFIG_NAME).py $(SYSCONFIGDATA_DIR)

LIBPYTHON_EXTRA_OBJECTS=$$(LIBMPDEC_OBJS) $$(LIBEXPAT_OBJS) $$(LIBHACL_SHA2_OBJS)

$(PYBUILD)/.patched_makefile:
# Clear out libinstall deps (we build what we want explicitly first)
cd $(PYBUILD) && sed -i -e 's/libinstall:.*/libinstall:/' Makefile;
# Inject extra objects into libpython3.12.a so we don't have to link them
# separately
cd $(PYBUILD) && sed -i '/MODOBJS=/s/$$/ $(LIBPYTHON_EXTRA_OBJECTS)/' Makefile
touch $(PYBUILD)/.patched_makefile

$(INSTALL)/lib/$(LIB): $(BUILD)/$(LIB)
$(INSTALL)/lib/$(LIB): $(BUILD)/$(LIB) sysconfigdata $(BUILD)/.patched_makefile
( \
cd $(BUILD); \
sed -i -e 's/libinstall:.*/libinstall:/' Makefile; \
sed -i '/MODOBJS=/s/$$/ $$(LIBMPDEC_OBJS) $$(LIBEXPAT_OBJS) /' Makefile; \
touch $(BUILD)/$(LIB) ; \
emmake make PYTHON_FOR_BUILD=$(HOSTPYTHON) CROSS_COMPILE=yes inclinstall libinstall $(LIB) -j${CPU_COUNT} && \
cp $(LIB) $(INSTALL)/lib/ \
Expand All @@ -28,7 +47,7 @@ $(INSTALL)/lib/$(LIB): $(BUILD)/$(LIB)
# the subfolder is written to pybuilddir.txt.
_PYTHON_SYSCONFIGDATA_NAME=$(SYSCONFIG_NAME) _PYTHON_PROJECT_BASE=$(BUILD) $(HOSTPYTHON) -m sysconfig --generate-posix-vars

$(eval PYBUILDDIR=`cat pybuilddir.txt`)
$(eval BUILDDIR=`cat builddir.txt`)
PYTHONPATH=$(PYBUILDDIR) python adjust_sysconfig.py
cp $(PYBUILDDIR)/$(SYSCONFIG_NAME).py $(INSTALL)/lib/python$(PYMAJOR).$(PYMINOR)/
mkdir -p $(SYSCONFIGDATA_DIR)
Expand Down

0 comments on commit 8ad3e96

Please sign in to comment.