make的purePython实现。
almost-make的Python项目详细描述
阿尔莫斯马克
一个纯粹的python,不太符合POSIX的make实现。在
支持的生成文件示例
这个例子包含了一组来自AlmostMake测试的文件。在
宏定义.mk
# Use the mini-shell built into AlmostMakeexport _BUILTIN_SHELL:=1export _CUSTOM_BASE_COMMANDS:=1CC= clang CFLAGS=TEST_MACRO=Testing1234=:= := This **should ** work! # A comment!EXEC_PROGRAM=SEND_MACROS:=EXEC_PROGRAM=$(EXEC_PROGRAM)CC=$(CC)CFLAGS=$(CFLAGS)TEST_MACRO="$(TEST_MACRO)"# Note: '=' defers expansion. ':=' does not.export MAKEFLAGS:=$(MAKEFLAGS)$(SEND_MACROS)
Makefile
^{pr2}$testSimple/Makefile
.POSIX:all:# Note: As of v0.0.19, chmod is not built-in.check:all chmod u+x main $(EXEC_PROGRAM) ./main | grep PASS all:mainclean: -rm -f main.o -rm -f main main:main.o$(CC) main.c -o main .SUFFIXES: .c .o.c.o:$(CC)$(CFLAGS) -c $< -o $@
使用
AlmostMake附带了almake
和almake_shell
命令行实用程序。让我们看看如何使用它们!在
almake
在一个名为Makefile
的目录中运行almake
会使almake
满足该文件中定义的第一个目标。在
例如,假设Makefile
包含以下内容:
# A makefile!# This is the first target.# (Pretend `echo 'Hello, world'`# is indented with a single tab)firstTarget:echo'Hello, world'# firstTarget isn't the name of a real file!# Mark it as PHONY. We need this because if # firstTarget were to be a file in the same# folder as Makefile, its existence (and lack# of newer dependencies) would cause `almake`# to do nothing!.PHONY:firstTarget
almake
然后运行与firstTarget关联的命令。每一行都有自己的外壳。在
其他选项通过almake
的帮助文本记录:
$ almake --help Help: Summary: Satisfy dependencies of a target in a makefile. This parser is not quite POSIX-compliant, but should be able to parse simple makefiles. Usage: almake [targets...][options] where each target in targets is a valid target and options include: -h, --help Print this message. --version Print version and licensing information. --file File to parse (default is Makefile). -k Keep going if errors are encountered. -n, --just-print Just print commands to be run, without evaluating (print commands, don't send them to the shell). Be aware that $(shell ...) macros are still evaluated. This option only applies to individual commands. -p Rather than finding targets, print the makefile, with top-level targets expanded. -C dir Switch to directory, dir, before running make. -w, --print-directory Print the current directory before and after running make. -j, --jobs Maximum number of jobs (e.g. almake -j 8). -s, --silent In most cases, don't print output. -b, --built-in-shell Use the built-in shell for commands in the makefile. This can also be enabled as follows: export _BUILTIN_SHELL :=1# Use the built-in shell instead of the system shell.export _CUSTOM_BASE_COMMANDS :=1# Enable built-in overrides for several commands like ls, echo, cat, grep, and pwd.export _SYSTEM_SHELL_PIPES :=1# Send commands that seem related to pipes (e.g. ls | less) directly to the system's shell. Note: AlmostMake's built-in shell is currently very limited. Note: Macro definitions that override those from the environment can be provided in addition to targets and options. For example, make target1 target2 target3 CC=gcc CFLAGS=-O3 should make target1, target2, and target3 with the macros CC and CFLAGS by default set to gcc and -O3, respectively. Note: Options can also be given to almake through the environment. This is done through the MAKEFLAGS variable. For example, setting MAKEFLAGS to --built-in-shell causes almake to always use its built-in shell, rather than the system shell.
almake_shell
除了almake
命令外,almake_shell
命令也可用。此命令允许访问AlmostMake中内置的shell的交互式版本(非常有限)。在
与almake
一样,我们可以获得如下使用信息:
$ almake_shell --help Help: Summary: Run an interactive version of the shell built into almake. This is a POSIX-like shell. It is not POSIX-compliant. Usage: almake_shell [options][files...] ...where each filename in [files...] is an optional file to interpret. If files are given, interpret them before opening the shell. Options include: -h, --help Print this message. --version Print version and licensing information. -B, --without-builtins Do not (re)define built-in commands (like echo). By default, echo, ls, dir, pwd, and perhaps other commands, are defined and override any commands with the same name already present in the system. -p, --system-pipe Rather than attempting to pipe output between commands (e.g. in ls | grep foo), send piped portions of the input to the system's shell.
almost_make
Python模块
AlmostMake还提供almost_make
模块!关于这方面的文档即将发布,但是现在,请查看GitHub上的源代码!在
安装
来自PyPI…
AlmostMake在Python包索引上!要安装它,请运行:
$ python3 -m pip install almost-make
要更新它
$ python3 -m pip install --upgrade almost-make
从GitHub…
由于AlmostMake
托管在GitHub上,因此可以通过克隆来安装它:
$ git clone https://github.com/personalizedrefrigerator/AlmostMake.git
$ cd AlmostMake
$ make install
您可能还需要安装setuptools
、wheel
和{
$ python3 -m pip install --user --upgrade setuptools wheel twine
显著缺失的功能
目前,AlmostMake
不支持以下值得注意的特性。在
在almake
中:
$(shell ...)
可以使用almake_shell
- BSDMake样式条件语句
- BSDMake样式
.include < ... >
包括 - 通过
a:: b
和a! b
定义配方。在 - 预定义配方(例如
.o
来自.c
)
在almake_shell
/内置shell中:
if
语句、循环、函数。在- 内置
chmod
测试
要测试AlmostMake,运行
$ make test
但是请注意,make test
依赖于make install
。在
支持的平台
目前,已经在以下平台上进行了测试:
- Ubuntu和Python3.8,AlmostmakeV0.2.0。所有测试都通过了。在
- Debian与Python3.7,较旧的AlmostMake。所有测试都通过了。在
- iOS通过a-Shell,AlmostMake v0.19.0。测试失败。在
如果您发现AlmostMake在未列出的平台上工作,请考虑creating an issue and/or submitting a pull request to update the list of supported platforms and versions of Python!在
如果AlmostMake不适合您,您可以尝试PyMake。这个包似乎支持范围更广的Python版本和平台,但可能具有较少的特性。在
- 项目
标签: