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 覆蓋特定變數

範例

pip install --upgrade make0

# 建置預設 target
make

# 建置多個 targets
make all clean

# 使用指定 Makefile
make -f Makefile.demo greet

# Dry-run
make -n all

# 列出所有 target
make -l

# 印出解析的資料庫
make -p

# 覆蓋變數
make --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.3.0.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.3.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

Hashes for make0-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0efce61a26daa077b4e394e58632d689e06911412aa27d56cafa29a00186331d
MD5 68d93e8099a225d85308dcc6fa256823
BLAKE2b-256 f03af22f3849688fbaa17b9f7de9ad2d12eeba26db6b4a54cdec47ddea4ac388

See more details on using hashes here.

File details

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

File metadata

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

Hashes for make0-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 313f265f8245e43caf441ec19f8dfe8d58f4fdb76ffd6fdc9322d41224b15c08
MD5 313ccf388ea4e279999ebbddb752e0f3
BLAKE2b-256 49469f250937d984c7c827479eb214119b30576d906725bb217ead975d8a0dc9

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