A lightweight cross-platform C/C++ build system written in Python.
Project description
make0
make0 是一個純 Python 實作的 Makefile 建置工具,完全不依賴系統的 make,透過直接呼叫 shell 來執行 recipe。
特色
- ✅ 解析標準 Makefile 語法
- ✅ 變數展開(
=,:=,?=,+=,!=) - ✅ 自動變數:
$@,$<,$^,$?,$*,$+ - ✅
.PHONY偽目標 - ✅ 檔案時間戳記比較(判斷是否需要重建)
- ✅ Recipe 前綴:
@(靜音)、-(忽略錯誤)、+(強制執行) - ✅ 內建函式:
wildcard,shell,notdir,dir,basename,suffix,subst,patsubst,filter,strip,word,words,firstword,lastword - ✅
include指令 - ✅ Dry-run 模式 (
-n) - ✅ 彩色輸出
安裝
chmod +x make0.py
# 或直接用 python3 執行
python3 make0.py
用法
make0 [選項] [target ...]
選項:
-f FILE 指定 Makefile(預設: Makefile)
-n Dry-run,只印出命令不執行
-s 靜音模式,不印出 recipe 命令
-p 印出解析後的變數與規則資料庫
-l 列出所有 target
-C DIR 切換至 DIR 目錄後再執行
-e 環境變數覆蓋 Makefile 變數
--var VAR=VAL 覆蓋特定變數
範例
# 建置預設 target
python3 make0.py
# 建置多個 targets
python3 make0.py all clean
# 使用指定 Makefile
python3 make0.py -f Makefile.demo greet
# Dry-run
python3 make0.py -n all
# 列出所有 target
python3 make0.py -l
# 印出解析的資料庫
python3 make0.py -p
# 覆蓋變數
python3 make0.py --var CC=clang all
Makefile 語法支援
| 語法 | 說明 |
|---|---|
VAR = val |
遞迴展開(lazy) |
VAR := val |
立即展開 |
VAR ?= val |
僅在未定義時設定 |
VAR += val |
附加 |
VAR != cmd |
Shell 命令輸出 |
$(VAR) |
變數引用 |
$(shell cmd) |
執行 shell |
$(wildcard *.c) |
萬用字元 |
.PHONY: t |
宣告偽目標 |
$@ |
目標名稱 |
$< |
第一個 prerequisite |
$^ |
所有 prerequisites(去重) |
$? |
比目標新的 prerequisites |
@cmd |
靜音執行 |
-cmd |
忽略錯誤 |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
make0-0.2.0.tar.gz
(8.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
make0-0.2.0-py3-none-any.whl
(7.6 kB
view details)
File details
Details for the file make0-0.2.0.tar.gz.
File metadata
- Download URL: make0-0.2.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9471762735933b36ae654afaf6f53d33fff447bcc2d901a61ee075867e59fa93
|
|
| MD5 |
5038b64d5c3af7d8ecbf2b4946e237a4
|
|
| BLAKE2b-256 |
05f4ccebd7e2febd40de1865fd955226c77749f2c4763353d2d0705fce851606
|
File details
Details for the file make0-0.2.0-py3-none-any.whl.
File metadata
- Download URL: make0-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12240151d430808db006ceb3ec3c1ca3fbc61029ba3ee6ebf27834f2973fd963
|
|
| MD5 |
ca5d704b7ab584d5025aee9a47b32151
|
|
| BLAKE2b-256 |
b1febf30837a92adab71bd961edca5d9be8f4fe6146a778e5a9046e71901d1cd
|