Skip to content

Commit 4c6a6c7

Browse files
tmediccicederom
authored andcommitted
interpreters/python: create Python's config files dynamically
The `Setup.local` and the `config.site` files are used by Python's build system to, respectively, enable or disable Python's modules and set/unset available functions in the target system. These files are now set according to NuttX's configs, enabling or disabling Python's features according to the configs set on NuttX.
1 parent 5a7661a commit 4c6a6c7

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

interpreters/python/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/Python/
55
/romfs_cpython_modules.h
66
/romfs_cpython_modules.img
7+
/config.site
8+
/Setup.local

interpreters/python/Makefile

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ UNPACK ?= unzip -q -o
3232

3333
MACHDEP=nuttx
3434
CONFIG_SITE=${CURDIR}/config.site
35+
SETUP_LOCAL=${CURDIR}/Setup.local
3536
CPYTHON_PATH=$(CURDIR)/$(CPYTHON_UNPACKNAME)
3637

3738
BUILDIR=$(CURDIR)/build
@@ -92,6 +93,35 @@ $(HOSTPYTHON):
9293
)
9394
$(MAKE) -C $(HOSTBUILD) install
9495

96+
# The `config.site` file contains settings that override the configuration
97+
# settings provided by the `configure` script. Depending on the features
98+
# enabled on NuttX, this file may need to be adjusted.
99+
100+
$(CONFIG_SITE):
101+
$(Q) ( cp $(CONFIG_SITE).in $(CONFIG_SITE))
102+
ifeq ($(CONFIG_ARCH_HAVE_FORK),y)
103+
@echo "export ac_cv_func_fork=\"yes\"" >> $@
104+
else
105+
@echo "export ac_cv_func_fork=\"no\"" >> $@
106+
endif
107+
ifeq ($(CONFIG_SYSTEM_SYSTEM),y)
108+
@echo "export ac_cv_func_system=\"yes\"" >> $@
109+
else
110+
@echo "export ac_cv_func_system=\"no\"" >> $@
111+
endif
112+
113+
# The `Setup.local` file enables or disables Python modules.
114+
# Depending on the features enabled on NuttX, this file may need to be
115+
# adjusted. Please note that the base `Setup.local.in` file only contains
116+
# a section to disable Python modules. Inserting lines to it will disable
117+
# such modules.
118+
119+
$(SETUP_LOCAL):
120+
$(Q) ( cp $(SETUP_LOCAL).in $(SETUP_LOCAL))
121+
ifneq ($(CONFIG_ARCH_HAVE_FORK),y)
122+
@echo "_posixsubprocess" >> $@
123+
endif
124+
95125
# For the Python's `configure` script, please consider the following
96126
# when building for NuttX:
97127
#
@@ -103,7 +133,7 @@ $(HOSTPYTHON):
103133
# Python/Modules/getpath.c (issue will be filed soon to track this
104134
# problem).
105135

106-
$(TARGETBUILD)/Makefile: $(HOSTPYTHON)
136+
$(TARGETBUILD)/Makefile: $(HOSTPYTHON) $(CONFIG_SITE) $(SETUP_LOCAL)
107137
$(Q) mkdir -p $(TARGETBUILD)/Modules
108138
$(Q) mkdir -p $(TARGETMODULES)/python$(CPYTHON_VERSION_MINOR)
109139
$(Q) ( cp Setup.local $(TARGETBUILD)/Modules/Setup.local )
@@ -177,5 +207,7 @@ distclean::
177207
$(call DELFILE, $(CPYTHON_ZIP))
178208
$(call DELFILE, romfs_cpython_modules.img)
179209
$(call DELFILE, romfs_cpython_modules.h)
210+
$(call DELFILE, config.site)
211+
$(call DELFILE, Setup.local)
180212

181213
include $(APPDIR)/Application.mk
File renamed without changes.

interpreters/python/config.site renamed to interpreters/python/config.site.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export MODULE_BUILDTYPE="static"
12
export ac_cv_file__dev_ptmx="no"
23
export ac_cv_file__dev_ptc="no"
34
export ac_cv_buggy_getaddrinfo="no"
@@ -15,10 +16,9 @@ export ac_cv_func_clock_gettime="yes"
1516
export ac_cv_header_sys_syscall_h="no"
1617
export ac_cv_func_timegm="yes"
1718
export ac_cv_func_clock="yes"
18-
export ac_cv_func_fork="yes"
1919
export ac_cv_func_waitpid="yes"
2020
export ac_cv_func_pipe="yes"
2121
export ac_cv_enable_strict_prototypes_warning="no"
2222
export ac_cv_func_getnameinfo="yes"
2323
export ac_cv_func_poll="yes"
24-
export MODULE_BUILDTYPE="static"
24+
export ac_cv_func_gethostname="yes"

0 commit comments

Comments
 (0)