made new docker file to build mpy files
This commit is contained in:
parent
a90d569690
commit
f65f436273
25
.github/workflows/build.yml
vendored
Normal file
25
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: build_mpy
|
||||
on: [push]
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: docker-compose up
|
||||
|
||||
- name: Sleep
|
||||
uses: jakejarvis/wait-action@master
|
||||
with:
|
||||
time: '60s'
|
||||
|
||||
- name: Archive
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mpy
|
||||
path: compiled
|
59
Dockerfile
59
Dockerfile
@ -1,39 +1,20 @@
|
||||
FROM python:3.9-slim-buster
|
||||
|
||||
ARG KMKPY_REF
|
||||
ARG KMKPY_URL
|
||||
|
||||
ENV KMKPY_REF ${KMKPY_REF}
|
||||
ENV KMKPY_URL ${KMKPY_URL}
|
||||
|
||||
RUN mkdir -p /app /dist
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y build-essential curl gettext git git-lfs rsync wget zip lbzip2
|
||||
RUN pip install pipenv
|
||||
|
||||
# Pull CircuitPython-designated ARM GCC to avoid mismatches/weird
|
||||
# inconsistencies with upstream
|
||||
RUN curl -L -o /tmp/gcc-arm.tar.bz2 https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 && \
|
||||
tar -C /usr --strip-components=1 -xaf /tmp/gcc-arm.tar.bz2 && \
|
||||
rm -rf /tmp/gcc-arm.tar.bz2
|
||||
|
||||
# Get a local copy of KMKPython and its dependencies. We don't provide MPY
|
||||
# builds for kmkpython anymore, so we can get away with being opinionated
|
||||
# here.
|
||||
RUN git init /opt/kmkpython && \
|
||||
git -C /opt/kmkpython remote add origin ${KMKPY_URL} && \
|
||||
git -C /opt/kmkpython fetch --depth 1 origin ${KMKPY_REF} && \
|
||||
git -C /opt/kmkpython checkout FETCH_HEAD && \
|
||||
git -C /opt/kmkpython submodule update --init --recursive
|
||||
|
||||
# Build the MPY compiler
|
||||
RUN make -C /opt/kmkpython/mpy-cross
|
||||
|
||||
ENV PATH=/opt/kmkpython/mpy-cross:${PATH}
|
||||
|
||||
RUN mkdir -p /opt/kmkpython/frozen/kmk/kmk
|
||||
COPY ./build_kmkpython_release.sh /app/
|
||||
COPY ./kmk /opt/kmkpython/frozen/kmk/kmk
|
||||
|
||||
CMD /app/build_kmkpython_release.sh
|
||||
FROM python:3.9-slim-buster
|
||||
|
||||
RUN mkdir -p /app /dist
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y curl
|
||||
|
||||
RUN curl https://adafruit-circuit-python.s3.amazonaws.com/bin/mpy-cross/linux-amd64/mpy-cross.static-amd64-linux-8.0.0 --output mpy-cross-8
|
||||
RUN curl https://adafruit-circuit-python.s3.amazonaws.com/bin/mpy-cross/linux-amd64/mpy-cross.static-amd64-linux-7.0.0 --output mpy-cross-7
|
||||
|
||||
|
||||
RUN chmod +x mpy-cross-8
|
||||
|
||||
RUN chmod +x mpy-cross-7
|
||||
|
||||
|
||||
COPY ./docker_mpy_build.sh /app/build.sh
|
||||
# COPY ./kmk /app/kmk/
|
||||
|
||||
CMD ["bash", "build.sh"]
|
||||
|
0
compiled/.gitkeep
Normal file
0
compiled/.gitkeep
Normal file
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
@ -0,0 +1,7 @@
|
||||
version: "0.1"
|
||||
services:
|
||||
mpy_kmk:
|
||||
build: .
|
||||
volumes:
|
||||
- ./kmk:/app/kmk
|
||||
- ./.compiled:/app/compiled
|
33
dockerMakeFile
Normal file
33
dockerMakeFile
Normal file
@ -0,0 +1,33 @@
|
||||
.SILENT:
|
||||
|
||||
.PHONY: \
|
||||
clean-dist \
|
||||
devdeps \
|
||||
dist \
|
||||
dockerbase \
|
||||
lint
|
||||
|
||||
.DEFAULT: all
|
||||
|
||||
MPY_CROSS ?= $(shell which mpy-cross 2>/dev/null)
|
||||
MPY_FLAGS ?= '-O2'
|
||||
MPY_SOURCES ?= 'kmk/'
|
||||
MPY_TARGET_DIR ?= compiled
|
||||
PY_KMK_TREE = $(shell find $(MPY_SOURCES) -name "*.py")
|
||||
DIST_DESCRIBE = $(shell $(DIST_DESCRIBE_CMD))
|
||||
|
||||
TIMESTAMP := $(shell date +%s)
|
||||
|
||||
compile: $(MPY_TARGET_DIR)/.mpy.compiled
|
||||
$(MPY_TARGET_DIR)/.mpy.compiled: $(PY_KMK_TREE)
|
||||
@mkdir -p $(MPY_TARGET_DIR)/8
|
||||
@echo "KMK_RELEASE = '$(DIST_DESCRIBE)'" > $(MPY_SOURCES)/release_info.py
|
||||
@find $(MPY_SOURCES) -name "*.py" -exec sh -c 'mkdir -p $(MPY_TARGET_DIR)/$$(dirname {}) && ./mpy-cross-8 $(MPY_FLAGS) {} -o $(MPY_TARGET_DIR)/8/$$(dirname {})/$$(basename -s .py {}).mpy' \;
|
||||
@rm -rf $(MPY_SOURCES)/release_info.py
|
||||
@touch $(MPY_TARGET_DIR)/.mpy.compileds
|
||||
|
||||
|
||||
|
||||
|
||||
find ./kmk/ -name "*.py" -exec sh -c 'mkdir -p ./compile/8/$dirname {} &&\
|
||||
./mpy-cross-8 -O2 {} -o ./compile/8/$$(dirname {})/$$(basename -s .py {}).mpy' \;
|
9
docker_mpy_build.sh
Normal file
9
docker_mpy_build.sh
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
#!/bin/sh
|
||||
|
||||
find kmk/ -name "*.py" -exec sh -c 'mkdir -p compiled/8/$(dirname {}) &&\
|
||||
./mpy-cross-8 -O2 {} -o compiled/8/$(dirname {})/$(basename -s .py {}).mpy' \;
|
||||
|
||||
|
||||
find kmk/ -name "*.py" -exec sh -c 'mkdir -p compiled/7/$(dirname {}) &&\
|
||||
./mpy-cross-7 -O2 {} -o compiled/7/$(dirname {})/$(basename -s .py {}).mpy' \;
|
39
kmk_python_Dockerfile
Normal file
39
kmk_python_Dockerfile
Normal file
@ -0,0 +1,39 @@
|
||||
FROM python:3.9-slim-buster
|
||||
|
||||
ARG KMKPY_REF
|
||||
ARG KMKPY_URL
|
||||
|
||||
ENV KMKPY_REF ${KMKPY_REF}
|
||||
ENV KMKPY_URL ${KMKPY_URL}
|
||||
|
||||
RUN mkdir -p /app /dist
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y build-essential curl gettext git git-lfs rsync wget zip lbzip2
|
||||
RUN pip install pipenv
|
||||
|
||||
# Pull CircuitPython-designated ARM GCC to avoid mismatches/weird
|
||||
# inconsistencies with upstream
|
||||
RUN curl -L -o /tmp/gcc-arm.tar.bz2 https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 && \
|
||||
tar -C /usr --strip-components=1 -xaf /tmp/gcc-arm.tar.bz2 && \
|
||||
rm -rf /tmp/gcc-arm.tar.bz2
|
||||
|
||||
# Get a local copy of KMKPython and its dependencies. We don't provide MPY
|
||||
# builds for kmkpython anymore, so we can get away with being opinionated
|
||||
# here.
|
||||
RUN git init /opt/kmkpython && \
|
||||
git -C /opt/kmkpython remote add origin ${KMKPY_URL} && \
|
||||
git -C /opt/kmkpython fetch --depth 1 origin ${KMKPY_REF} && \
|
||||
git -C /opt/kmkpython checkout FETCH_HEAD && \
|
||||
git -C /opt/kmkpython submodule update --init --recursive
|
||||
|
||||
# Build the MPY compiler
|
||||
RUN make -C /opt/kmkpython/mpy-cross
|
||||
|
||||
ENV PATH=/opt/kmkpython/mpy-cross:${PATH}
|
||||
|
||||
RUN mkdir -p /opt/kmkpython/frozen/kmk/kmk
|
||||
COPY ./build_kmkpython_release.sh /app/
|
||||
COPY ./kmk /opt/kmkpython/frozen/kmk/kmk
|
||||
|
||||
CMD /app/build_kmkpython_release.sh
|
Loading…
Reference in New Issue
Block a user