#makefile #generate #generator #directory #link

bin+lib makewiz

MakeWiz 是一个命令行工具,可以根据您目录中的文件生成 Makefile

3 个版本 (重大更改)

0.8.0 2023年10月8日
0.7.0 2023年9月3日
0.6.1 2023年8月27日
0.6.0 2023年8月26日

#1704 in 开发工具

Download history 69/week @ 2024-07-27

每月69 次下载

MIT/Apache

42KB
771

MakeWiz

MakeWiz 是一款方便的命令行工具,旨在使处理 Makefile 变得更容易。只需一个简单的命令,MakeWiz 就会为您创建一个整洁的 Makefile,它完全符合您目录中的文件。它可以生成 C、C++ 和 Java 的 Makefile。它适用于所有主要的 Linux 发行版。

Build status Crates.io

🔐 MakeWiz 同时受 MIT 或 Apache 2.0 许可。

📺MakeWiz 动作演示

假设您有一个包含以下文件的目录

  • Bike.cpp Bike.hpp
  • Car.cpp Car.hpp
  • Vehicle.hpp
  • main.cpp 和可执行文件 main

运行 makewiz 后(对于 Java 项目使用 makewiz java),将创建一个类似的 Makefile

# Compiler and flags
CC = g++
FLAGS = -g -c -Wall
LFLAGS =

# Source files and object files
OBJS = Bike.o Car.o main.o
SOURCE = Bike.cpp Car.cpp main.cpp
HEADER = Bike.hpp Car.hpp Vehicle.hpp
OUT = main

# Libraries
LDLIBS =

# Default target
all: $(OUT)

# Linking rules
$(OUT): $(OBJS)
    $(CC) -g $(OBJS) -o $(OUT) $(LFLAGS) $(LDLIBS)

# Compilation rules
%.o: %.cpp $(HEADER)
    $(CC) $(FLAGS) -o $@ $<

# Clean rule
clean:
    rm -f $(OBJS) $(OUT)

所有扩展名不是 .cpp.hpp.c.h 的文件将被 makewiz 自动忽略

🚀安装

Arch Linux

如果您是 Arch Linux 用户(或任何基于 Arch 的发行版,如 Manjaro),您可以使用 yayparu 等工具从 AUR 安装 MakeWiz

yay -S makewiz

Debian

如果您是 Debian 用户(或任何基于 Debian 的发行版,如 Ubuntu),您可以使用 .deb 文件安装 MakeWiz

sudo curl -LO https://github.com/kallazz/MakeWiz/releases/download/v0.8.0/makewiz_0.8.0_amd64.deb
sudo dpkg -i makewiz_0.8.0_amd64.deb

RedHat/Fedora

如果您使用的是 RedHat-based Linux distribution(如 FedoraCentOS),您可以使用 .rpm 文件安装 MakeWiz

sudo curl -LO https://github.com/kallazz/MakeWiz/releases/download/v0.8.0/makewiz-0.8.0-1.x86_64.rpm
sudo rpm -i makewiz-0.8.0-1.x86_64.rpm

Cargo

如果您已安装 Rust,可以使用 cargo 下载 MakeWiz

cargo install makewiz

💡Shell 自动补全

MakeWiz 支持 Bash、Fish 和 Zsh 的 Shell 自动补全。

您可以从 MakeWiz 二进制版本发布 中找到 Shell 补全脚本,从 v0.7.0 开始。您也可以使用以下命令下载它们

Bash

sudo curl -LO https://github.com/kallazz/MakeWiz/releases/download/v0.8.0/makewiz.bash

Fish

sudo curl -LO https://github.com/kallazz/MakeWiz/releases/download/v0.8.0/makewiz.fish

Zsh

sudo curl -LO https://github.com/kallazz/MakeWiz/releases/download/v0.8.0/_makewiz

下载您首选 Shell 的脚本后,按照以下步骤启用自动补全

对于 Bash:makewiz.bash 移动到 $XDG_CONFIG_HOME/bash_completion//etc/bash_completion.d/ 中。

对于 Fish:makewiz.fish 移动到 $HOME/.config/fish/completions/

对于 Zsh:_makewiz 移动到您的 $fpath 目录之一。如果您不确定如何操作

  • _makewiz 放在您选择的目录中,例如 ~/.zsh/completions/
  • fpath=(~/.zsh/completions $fpath) 添加到您的 ~/.zshrc 中,将 ~/.zsh/completions 替换为您选择的目录。

打开新的终端窗口后,一切应该都能正常工作。

📖用户指南

要使用 MakeWiz 生成 Makefile,只需在终端中输入 makewiz 命令(用于 C/C++ 项目)。对于 Java 项目输入 makewiz java

默认情况下,对于 C/C++,MakeWiz 将创建一个名为 main 的可执行文件和编译器 g++ 的 Makefile。您可以通过以下命令和选项更改此行为。如果您不确定默认的编译器和可执行文件值,可以运行 makewiz default

MakeWiz is a command line tool that generates a Makefile based on the files in your directory

Usage: makewiz [OPTIONS] [COMMAND]

Commands:
  java            Generate a Java Makefile
  set-compiler    Set the default C/C++ compiler name
  set-executable  Set the default C/C++ executable name
  default         Show default values
  help            Print this message or the help of the given subcommand(s)

Options:
  -c, --compiler <COMPILER_NAME>      Set the C/C++ compiler name for this Makefile
  -e, --executable <EXECUTABLE_NAME>  Set the C/C++ executable name for this Makefile
  -m, --math                          Add the math library(-lm) to this Makefile
  -t, --thread                        Add the thread library(-lpthread) to this Makefile
  -r, --crypto                        Add the crypto library(-lcrypto) to this Makefile
      --cunit                         Add the CUnit library(-lcunit) to this Makefile
      --cppunit                       Add the CPPUnit library(-lcppunit) to this Makefile
  -h, --help                          Print help
  -V, --version                       Print version

📣您的反馈

如果您有任何问题、建议或遇到任何问题,请随时访问 问题 选项卡。您的反馈对我来说非常重要。

依赖项

~2–12MB
~91K SLoC