Skip to content

Commit 90270b0

Browse files
committed
✨ feat(repo/packages/m/micropython): add micropython
1 parent b2c3b8d commit 90270b0

3 files changed

Lines changed: 125 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h
2+
index 8eafb6119..04d284e8f 100644
3+
--- a/ports/unix/mpconfigport.h
4+
+++ b/ports/unix/mpconfigport.h
5+
@@ -43,7 +43,7 @@
6+
#if defined(__APPLE__) && defined(__MACH__)
7+
#define MICROPY_PY_SYS_PLATFORM "darwin"
8+
#else
9+
- #define MICROPY_PY_SYS_PLATFORM "linux"
10+
+ #define MICROPY_PY_SYS_PLATFORM "rt-smart"
11+
#endif
12+
#endif
13+
14+
diff --git a/ports/unix/mpconfigport.mk b/ports/unix/mpconfigport.mk
15+
index ce6183c13..f98769960 100644
16+
--- a/ports/unix/mpconfigport.mk
17+
+++ b/ports/unix/mpconfigport.mk
18+
@@ -9,7 +9,7 @@ MICROPY_FORCE_32BIT = 0
19+
MICROPY_USE_READLINE = 1
20+
21+
# btree module using Berkeley DB 1.xx
22+
-MICROPY_PY_BTREE = 1
23+
+MICROPY_PY_BTREE = 0
24+
25+
# _thread module using pthreads
26+
MICROPY_PY_THREAD = 1
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- Licensed under the Apache License, Version 2.0 (the "License");
2+
-- You may not use this file except in compliance with the License.
3+
-- You may obtain a copy of the License at
4+
--
5+
-- http://www.apache.org/licenses/LICENSE-2.0
6+
--
7+
-- Unless required by applicable law or agreed to in writing, software
8+
-- distributed under the License is distributed on an "AS IS" BASIS,
9+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
-- See the License for the specific language governing permissions and
11+
-- limitations under the License.
12+
--
13+
-- Copyright (C) 2023-2023 RT-Thread Development Team
14+
--
15+
-- @author zhouquan
16+
-- @file deploy.lua
17+
--
18+
-- Change Logs:
19+
-- Date Author Notes
20+
-- ------------ ---------- -----------------------------------------------
21+
-- 2023-05-09 zhouquan initial version
22+
--
23+
import("rt.rt_utils")
24+
25+
function main(rootfs, installdir)
26+
for _, filepath in ipairs(os.files(path.join(installdir, "bin") .. "/*")) do
27+
local filename = path.filename(filepath)
28+
rt_utils.cp_with_symlink(filepath, path.join(rootfs, "bin", filename))
29+
end
30+
end
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
-- Licensed under the Apache License, Version 2.0 (the "License");
2+
-- You may not use this file except in compliance with the License.
3+
-- You may obtain a copy of the License at
4+
--
5+
-- http://www.apache.org/licenses/LICENSE-2.0
6+
--
7+
-- Unless required by applicable law or agreed to in writing, software
8+
-- distributed under the License is distributed on an "AS IS" BASIS,
9+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
-- See the License for the specific language governing permissions and
11+
-- limitations under the License.
12+
--
13+
-- Copyright (C) 2023-2023 RT-Thread Development Team
14+
--
15+
-- @author zhouquan
16+
-- @file xmake.lua
17+
--
18+
-- Change Logs:
19+
-- Date Author Notes
20+
-- ------------ ---------- -----------------------------------------------
21+
-- 2023-06-25 zhouquan initial version
22+
--
23+
package("micropython")
24+
do
25+
set_homepage("https://micropython.org/")
26+
set_description("MicroPython is a lean and efficient implementation of the Python 3 programming language.")
27+
28+
add_urls("https://github.com/micropython/micropython/releases/download/v$(version)/micropython-$(version).tar.xz")
29+
30+
add_versions("1.20.0", "098ef8e40abdc62551b5460d0ffe9489074240c0cb5589ca3c3a425551beb9bf")
31+
32+
add_patches("1.20.0", path.join(os.scriptdir(), "patches", "1.20.0", "01_adapt_smart.diff"),
33+
"d0eb05d02339977f9c5771dcc81d2a616962ec57cb4d272fe8da3b8b22cc830c")
34+
35+
add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"})
36+
37+
on_load(function(package)
38+
package:add("deps", "libffi", {debug = package:config("debug"), configs = {shared = package:config("shared")}})
39+
end)
40+
41+
on_install("cross@linux", function(package)
42+
import("rt.private.build.rtflags")
43+
local info = rtflags.get_package_info(package)
44+
local version = info.version
45+
local host = info.host
46+
local cc = info.cc
47+
local configs = {host = ""}
48+
local cxflags = {}
49+
local packagedeps = {}
50+
51+
table.insert(cxflags, "-DMICROPY_FORCE_PLAT_ALLOC_EXEC=0")
52+
table.insert(packagedeps, "libffi")
53+
54+
os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH"))
55+
56+
local buildenvs = import("package.tools.autoconf").buildenvs(package,
57+
{cxflags = cxflags, packagedeps = packagedeps})
58+
59+
import("package.tools.make").build(package, {"-C", "mpy-cross"}, {envs = {}})
60+
import("package.tools.make").build(package, {"-C", "ports/unix", "VARIANT=standard"}, {
61+
envs = {CROSS_COMPILE = host .. "-", LDFLAGS = buildenvs.LDFLAGS, CFLAGS_EXTRA = buildenvs.CFLAGS}
62+
})
63+
os.vcp("ports/unix/build-standard/micropython", package:installdir("bin"))
64+
end)
65+
66+
on_test(function(package)
67+
assert(os.isfile(path.join(package:installdir("bin"), "micropython")))
68+
end)
69+
end

0 commit comments

Comments
 (0)