Skip to content

Commit 764f0c3

Browse files
committed
restructured cmake
1 parent eda6439 commit 764f0c3

File tree

8 files changed

+56
-127
lines changed

8 files changed

+56
-127
lines changed

.github/workflows/pyjs_builder.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ on:
1919
py_version:
2020
type: choice
2121
description: Please select a python version
22-
default: '3.11'
22+
default: '3.13'
2323
required: true
2424
options:
2525
- '3.7'
2626
- '3.8'
2727
- '3.9'
2828
- '3.10'
2929
- '3.11'
30+
- '3.12'
31+
- '3.13'
3032

3133
env:
3234
arch: darwin-x86

.github/workflows/pyjs_matrix_os.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: setup python
3434
uses: actions/setup-python@v4
3535
with:
36-
python-version: '3.11'
36+
python-version: '3.13'
3737
cache: 'pip' # caching pip dependencies
3838

3939
- name: install python requirements

.github/workflows/pyjs_matrix_variants.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
# runs-on: macos-11 # requires changes
1010
strategy:
1111
matrix:
12-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
12+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
1313
variant:
1414
- default
1515
- shared-pkg

.github/workflows/python_builder.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ on:
2222
py_version:
2323
type: choice
2424
description: Please select a python version
25-
default: '3.11'
25+
default: '3.13'
2626
required: true
2727
options:
2828
- '3.7'
2929
- '3.8'
3030
- '3.9'
3131
- '3.10'
3232
- '3.11'
33+
- '3.12'
34+
- '3.13'
3335

3436
env:
3537
arch: darwin-x86

CMakeLists.txt

+20-96
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,13 @@ option(BUILD_THIRDPARTY_EXTERNALS "Enable building third-party externals" OFF)
1414
option(BUILD_NET_EXTERNALS "Enable building networking externals" OFF)
1515
option(BUILD_DEMO_EXTERNALS "Enable demo (scratch) externals" OFF)
1616

17-
# individual build options
18-
option(BUILD_PY_EXTERNAL "Build the py external" OFF)
19-
option(BUILD_PYJS_EXTERNAL "Build the pyjs external" OFF)
20-
option(BUILD_COBRA_EXTERNAL "Build the cobra external" OFF)
21-
option(BUILD_KRAIT_EXTERNAL "Build the krait external" OFF)
22-
option(BUILD_MAMBA_EXTERNAL "Build the mamba external" OFF)
23-
option(BUILD_MXPY_EXTERNAL "Build the mxpy external" OFF)
24-
option(BUILD_PKTPY_EXTERNAL "Build the pktpy external" OFF)
25-
option(BUILD_PKTPY2_EXTERNAL "Build the pktpy2 external" OFF)
26-
option(BUILD_ZEDIT_EXTERNAL "Build the zedit external" OFF)
27-
option(BUILD_ZPY_EXTERNAL "Build the zpy external" OFF)
28-
option(BUILD_ZTHREAD_EXTERNAL "Build the zthread external" OFF)
29-
option(BUILD_JMX_EXTERNAL "Build the jmx external" OFF)
30-
3117
# micropython external build options
3218
option(FETCH_MICROPYTHON "Download latest micropython and use that to build external" OFF)
3319
option(BUILD_MICROPYTHON_EXTERNAL "Build the micropython external" OFF)
3420

3521
# string options
3622
set(BUILD_VARIANT "" CACHE STRING "specify build variant")
37-
23+
set(BUILD_TARGETS "" CACHE STRING "specify build targets")
3824

3925
# use ccache if available
4026
find_program(CCACHE_PROGRAM ccache)
@@ -88,103 +74,41 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
8874
endif()
8975
endif()
9076

91-
92-
# python3 externals
93-
9477
if(BUILD_PYTHON3_CORE_EXTERNALS)
95-
set(BUILD_PY_EXTERNAL ON)
96-
set(BUILD_PYJS_EXTERNAL ON)
78+
list(APPEND BUILD_TARGETS py pyjs)
9779
endif()
9880

9981
if(BUILD_PYTHON3_EXPERIMENTAL_EXTERNALS)
100-
set(BUILD_COBRA_EXTERNAL ON)
101-
set(BUILD_KRAIT_EXTERNAL ON)
102-
set(BUILD_MAMBA_EXTERNAL ON)
103-
set(BUILD_MXPY_EXTERNAL ON)
82+
list(APPEND BUILD_TARGETS cobra krait mamba mxpy)
10483
endif()
10584

106-
# python variants
10785
if(BUILD_POCKETPY_EXTERNALS)
108-
set(BUILD_PKTPY_EXTERNAL ON)
109-
set(BUILD_PKTPY2_EXTERNAL ON)
86+
list(APPEND BUILD_TARGETS pktpy pktpy2)
11087
endif()
11188

112-
113-
# networking externals
11489
if(BUILD_NET_EXTERNALS)
115-
set(BUILD_ZEDIT_EXTERNAL ON)
116-
set(BUILD_ZPY_EXTERNAL ON)
117-
set(BUILD_ZTHREAD_EXTERNAL ON)
118-
set(BUILD_JMX_EXTERNAL ON)
119-
endif()
120-
121-
122-
# demo externals
123-
if(BUILD_DEMO_EXTERNALS)
124-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/demos/cmx)
125-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/demos/demo)
126-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/demos/mx)
127-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/demos/jw)
90+
list(APPEND BUILD_TARGETS zedit zpy zthread jmx)
12891
endif()
12992

130-
# thirdparty externals
93+
set(THIRDPARTY_EXTERNALS shell jit.fill2 jit.foo)
13194
if(BUILD_THIRDPARTY_EXTERNALS)
132-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/thirdparty/jit.foo)
133-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/thirdparty/jit.fill2)
134-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/thirdparty/shell)
135-
endif()
136-
137-
# single-build-options
138-
139-
if(BUILD_PY_EXTERNAL)
140-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/py)
141-
endif()
142-
143-
if(BUILD_PYJS_EXTERNAL)
144-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/pyjs)
145-
endif()
146-
147-
if(BUILD_COBRA_EXTERNAL)
148-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/cobra)
149-
endif()
150-
151-
if(BUILD_KRAIT_EXTERNAL)
152-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/krait)
95+
list(APPEND BUILD_TARGETS ${THIRDPARTY_EXTERNALS})
15396
endif()
15497

155-
if(BUILD_MAMBA_EXTERNAL)
156-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/mamba)
157-
endif()
158-
159-
if(BUILD_MXPY_EXTERNAL)
160-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/mxpy)
161-
endif()
162-
163-
if(BUILD_PKTPY_EXTERNAL)
164-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/pktpy)
165-
endif()
166-
167-
if(BUILD_PKTPY2_EXTERNAL)
168-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/pktpy2)
169-
endif()
170-
171-
if(BUILD_MICROPYTHON_EXTERNAL)
172-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/mpy)
173-
endif()
174-
175-
if(BUILD_ZEDIT_EXTERNAL)
176-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/zedit)
177-
endif()
178-
179-
if(BUILD_ZPY_EXTERNAL)
180-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/zpy)
98+
set(DEMO_EXTERNALS mx cmx demo)
99+
if(BUILD_DEMO_EXTERNALS)
100+
list(APPEND BUILD_TARGETS ${DEMO_EXTERNALS})
181101
endif()
182102

183-
if(BUILD_ZTHREAD_EXTERNAL)
184-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/zthread)
185-
endif()
103+
foreach(proj ${BUILD_TARGETS})
104+
message(STATUS "to build: ${proj}")
105+
if(proj IN_LIST THIRDPARTY_EXTERNALS)
106+
add_subdirectory(${CMAKE_SOURCE_DIR}/source/thirdparty/${proj})
107+
elseif(proj IN_LIST DEMO_EXTERNALS)
108+
add_subdirectory(${CMAKE_SOURCE_DIR}/source/demos/${proj})
109+
else()
110+
add_subdirectory(${CMAKE_SOURCE_DIR}/source/projects/${proj})
111+
endif()
112+
endforeach()
186113

187-
if(BUILD_JMX_EXTERNAL)
188-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/jmx)
189-
endif()
190114

Makefile

+27-22
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,21 @@ HOMEBREW_DEPENDENCIES = "python cmake zmq czmq"
7171
# $(call section,string)
7272
section = @echo ${COLOR_BOLD_CYAN}">>> ${1}"${COLOR_RESET}
7373

74-
# $(call pybuild,name)
74+
# $(call call-builder,name,etc.)
7575
define call-builder
7676
$(call section,"builder $1 $2 $3 $4 $5 $6")
7777
@cd '$(PYDIR)' && $(PYTHON) -m builder $1 $2 $3 $4 $5 $6
7878
endef
7979

80-
# $(call xbuild,name)
80+
# $(call xbuild-targets,name)
8181
define xbuild-targets
8282
$(call section,"build $1")
8383
@for target in $(TARGETS); do \
8484
xcodebuild -project targets/'$1'/py-js.xcodeproj -target $$target ; \
8585
done
8686
endef
8787

88-
# $(call xbuild,name,flags)
88+
# $(call xbuild-targets-flags,name,flags)
8989
define xbuild-targets-flags
9090
$(call section,"build $1 with flags: $2")
9191
@for target in $(TARGETS); do \
@@ -94,14 +94,14 @@ $(call section,"build $1 with flags: $2")
9494
endef
9595

9696

97-
# $(call xclean,name)
97+
# $(call xclean-target,name)
9898
define xclean-target
9999
$(call section,"cleaning build artifacts from $1 target")
100100
@rm -rf '$(PYDIR)'/targets/$1/build
101101
endef
102102

103103

104-
# $(call xclean,name)
104+
# $(call xcleanlib,name)
105105
define xcleanlib
106106
$(call section,"cleaning build product from python build $1")
107107
@rm -rf '$(PYDIR)'/targets/build/lib/$1
@@ -189,7 +189,7 @@ net: clean-build-dir clean-externals
189189
@mkdir -p build && \
190190
cd build && \
191191
cmake -GXcode .. \
192-
-DBUILD_ZMQ_EXTERNALS=ON \
192+
-DBUILD_NET_EXTERNALS=ON \
193193
&& \
194194
cmake --build . --config Release
195195

@@ -272,27 +272,23 @@ beeware-ext: clean-externals
272272
krait krait-static krait-shared \
273273
krait-framework krait-framework-pkg
274274

275-
276-
277-
278275
mamba: clean-externals
279276
$(call section,"building mamba")
280277
@mkdir -p build && \
281278
cd build && \
282279
cmake -GXcode .. \
283-
-DBUILD_MAMBA_EXTERNAL=ON \
280+
-DBUILD_TARGETS=mamba \
284281
-DBUILD_VARIANT=local \
285282
&& \
286283
cmake --build . --config Release
287284

288-
289285
mamba-static: clean-externals
290286
$(call section,"building mamba-static")
291287
@./source/scripts/buildpy.py -c static-mid
292288
@mkdir -p build && \
293289
cd build && \
294290
cmake -GXcode .. \
295-
-DBUILD_MAMBA_EXTERNAL=ON \
291+
-DBUILD_TARGETS=mamba \
296292
-DBUILD_VARIANT=static-ext \
297293
&& \
298294
cmake --build . --config Release
@@ -303,7 +299,7 @@ mamba-shared: clean-externals
303299
@mkdir -p build && \
304300
cd build && \
305301
cmake -GXcode .. \
306-
-DBUILD_MAMBA_EXTERNAL=ON \
302+
-DBUILD_TARGETS=mamba \
307303
-DBUILD_VARIANT=shared-ext \
308304
&& \
309305
cmake --build . --config Release
@@ -314,7 +310,7 @@ mamba-framework: clean-externals
314310
@mkdir -p build && \
315311
cd build && \
316312
cmake -GXcode .. \
317-
-DBUILD_MAMBA_EXTERNAL=ON \
313+
-DBUILD_TARGETS=mamba \
318314
-DBUILD_VARIANT=framework-ext \
319315
&& \
320316
cmake --build . --config Release
@@ -325,7 +321,7 @@ mamba-framework-pkg: clean-externals
325321
@mkdir -p build && \
326322
cd build && \
327323
cmake -GXcode .. \
328-
-DBUILD_MAMBA_EXTERNAL=ON \
324+
-DBUILD_TARGETS=mamba \
329325
-DBUILD_VARIANT=framework-pkg \
330326
&& \
331327
cmake --build . --config Release
@@ -335,7 +331,7 @@ krait: clean-externals
335331
@mkdir -p build && \
336332
cd build && \
337333
cmake -GXcode .. \
338-
-DBUILD_KRAIT_EXTERNAL=ON \
334+
-DBUILD_TARGETS=krait \
339335
-DBUILD_VARIANT=local \
340336
&& \
341337
cmake --build . --config Release
@@ -346,7 +342,7 @@ krait-static: clean-externals
346342
@mkdir -p build && \
347343
cd build && \
348344
cmake -GXcode .. \
349-
-DBUILD_KRAIT_EXTERNAL=ON \
345+
-DBUILD_TARGETS=krait \
350346
-DBUILD_VARIANT=static-ext \
351347
&& \
352348
cmake --build . --config Release
@@ -357,7 +353,7 @@ krait-shared: clean-externals
357353
@mkdir -p build && \
358354
cd build && \
359355
cmake -GXcode .. \
360-
-DBUILD_KRAIT_EXTERNAL=ON \
356+
-DBUILD_TARGETS=krait \
361357
-DBUILD_VARIANT=shared-ext \
362358
&& \
363359
cmake --build . --config Release
@@ -368,7 +364,7 @@ krait-framework: clean-externals
368364
@mkdir -p build && \
369365
cd build && \
370366
cmake -GXcode .. \
371-
-DBUILD_KRAIT_EXTERNAL=ON \
367+
-DBUILD_TARGETS=krait \
372368
-DBUILD_VARIANT=framework-ext \
373369
&& \
374370
cmake --build . --config Release
@@ -379,7 +375,7 @@ krait-framework-pkg: clean-externals
379375
@mkdir -p build && \
380376
cd build && \
381377
cmake -GXcode .. \
382-
-DBUILD_KRAIT_EXTERNAL=ON \
378+
-DBUILD_TARGETS=krait \
383379
-DBUILD_VARIANT=framework-pkg \
384380
&& \
385381
cmake --build . --config Release
@@ -389,7 +385,7 @@ jmx: clean-build-dir clean-externals
389385
@mkdir -p build && \
390386
cd build && \
391387
cmake -GXcode .. \
392-
-DBUILD_JMX_EXTERNAL=ON \
388+
-DBUILD_TARGETS=jmx \
393389
&& \
394390
cmake --build . --config Release
395391

@@ -398,7 +394,16 @@ zthread: clean-build-dir clean-externals
398394
@mkdir -p build && \
399395
cd build && \
400396
cmake -GXcode .. \
401-
-DBUILD_ZTHREAD_EXTERNAL=ON \
397+
-DBUILD_TARGETS=zthread \
398+
&& \
399+
cmake --build . --config Release
400+
401+
zpy: clean-build-dir clean-externals
402+
$(call section,"building zpy")
403+
@mkdir -p build && \
404+
cd build && \
405+
cmake -GXcode .. \
406+
-DBUILD_TARGETS=zpy \
402407
&& \
403408
cmake --build . --config Release
404409

TODO.md

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# TODO
22

3-
- [x] Create project-level userguide (in-progress in `pyjs/source/docs`)
4-
5-
- [ ] Move `builder` to `py-js/source/scripts/builder`
6-
73
- [ ] Alternatively, use [buildpy](https://github.com/shakfu/buildpy) and
84
[xcodegen](https://github.com/yonaskolb/XcodeGen) to build relocatable
95
python builds, generate xccongfig and xcode projects

0 commit comments

Comments
 (0)