Skip to main content

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.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

make0-0.2.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file make0-0.2.1.tar.gz.

File metadata

  • Download URL: make0-0.2.1.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

Hashes for make0-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7d53e9e0be66caec86f78c87f98ba64789f394ab429cdc316924f3107a14943a
MD5 ba1263a836201b4f22a8c80891acd7d2
BLAKE2b-256 2cda2e87536576452807b573b5d4e18786d62ebfdc8851b942260d23fa5b6f6a

See more details on using hashes here.

File details

Details for the file make0-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: make0-0.2.1-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

Hashes for make0-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6d26f4cdab49915aa4d13c598b6fdae58cc66c061ee33175d46ba22cea42ae6
MD5 877b7028be54b681bf826cca968e4af3
BLAKE2b-256 27820b767feae26a72a9efd299ce3b4de9ed7442afeaec76b86073fae4aa1d21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page