|
| 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