Skip to content

Commit cabc6e5

Browse files
authored
Add MicroPython Standard Library Packages (#125)
1 parent 20c6e70 commit cabc6e5

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

micropython/build.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ set -ex
44
source common.sh
55

66
VERSION=$1
7+
VARIANT=standard
78

89
URL=https://github.com/micropython/micropython.git
9-
REPO=micropython
10+
REPO=/tmp/micropython
1011

1112
LAST_REVISION="${3:-}"
1213

@@ -18,6 +19,7 @@ fi;
1819

1920
FULLNAME="${REVISION}.tar.xz"
2021
OUTPUT="$2/${FULLNAME}"
22+
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2123

2224
DEST="/opt/compiler-explorer/${REVISION}"
2325

@@ -29,16 +31,35 @@ else
2931
git clone --depth 1 "${URL}" -b "v${VERSION}" "${REPO}"
3032
fi;
3133

34+
make -C "${REPO}/ports/unix" submodules
35+
make -C "${REPO}/ports/unix" deplibs
36+
37+
for patch in "${SCRIPT_DIR}"/patches/*.patch; do
38+
patch --unified --strip=1 --dir="${REPO}" --input="${patch}" || true
39+
done
40+
3241
(
3342
cd "${REPO}"
3443
set +u
3544
source tools/ci.sh
36-
ci_unix_standard_build
45+
46+
make ${MAKEOPTS} -C mpy-cross
47+
make ${MAKEOPTS} -C ports/unix VARIANT=${VARIANT}
48+
49+
ci_unix_build_ffi_lib_helper gcc
50+
)
51+
52+
(
53+
cd "${REPO}/lib/micropython-lib/"
54+
set +u
55+
source tools/ci.sh
56+
57+
PACKAGE_INDEX_PATH="${DEST}/mip" ci_build_packages_compile_index
3758
)
3859

3960
mkdir -p "${DEST}" "${DEST}/bin" "${DEST}/tools" "${DEST}/py" "${DEST}/lib"
4061
cp "${REPO}/mpy-cross/build/mpy-cross" "${DEST}/bin/mpy-cross"
41-
cp "${REPO}/ports/unix/build-standard/micropython" "${DEST}/bin/micropython"
62+
cp "${REPO}/ports/unix/build-${VARIANT}/micropython" "${DEST}/bin/micropython"
4263
cp "${REPO}/tools/mpy-tool.py" "${DEST}/tools/mpy-tool.py"
4364
cp "${REPO}/py/makeqstrdata.py" "${DEST}/py/makeqstrdata.py"
4465

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--- a/lib/micropython-lib/micropython/mip/mip/__init__.py
2+
+++ b/lib/micropython-lib/micropython/mip/mip/__init__.py
3+
@@ -6 +6,19 @@
4+
-import requests
5+
+class _offline:
6+
+ @classmethod
7+
+ def get(cls, url):
8+
+ return cls(url)
9+
+ def __init__(self, url):
10+
+ import sys
11+
+ path = url.replace(_PACKAGE_INDEX, sys.executable.replace("bin/micropython", "mip"))
12+
+ try:
13+
+ self.raw = open(path, "rb")
14+
+ self.status_code = 200
15+
+ except OSError:
16+
+ self.raw = None
17+
+ self.status_code = 404
18+
+ def json(self):
19+
+ import json
20+
+ return json.load(self.raw)
21+
+ def close(self):
22+
+ return self.raw and self.raw.close()
23+
+requests = _offline

0 commit comments

Comments
 (0)