maketools

package module
v0.0.0-...-8f69eaf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

Make Tools

Tools to pimp your Makefiles.

Installation

Unix users (Linux, BSDs and MacOSX)

Unix users may download and install latest make-tools release with command:

sh -c "$(curl https://sweetohm.net/dist/make-tools/install)"

If curl is not installed on you system, you might run:

sh -c "$(wget -O - https://sweetohm.net/dist/make-tools/install)"

Note: Some directories are protected, even as root, on MacOSX (since El Capitan release), thus you can't install project in /usr/bin for instance.

Binary package

Otherwise, you can download latest binary archive at https://github.com/c4s4/make-tools/releases. Unzip the archive, put the binary of your platform somewhere in your PATH and rename it project.

Usage

There are two tools in this toolbox:

make-targets

This tool lists targets available in current makefile and included ones recursively. This is called to perform Bash completion.

To enable Bash target completion on make, source following file:

complete -W "\`make-targets\`" make
make-help

This tool prints help on targets in current makefile and included ones recursively. Thus to get help about makefile in current directory, you might type:

$ make-help
build   Build binary [clean]
clean   Clean generated files and test cache
fmt     Format Go source code
help    Print help on Makefile
install [build]
run     Run make help [build]

You might also print help calling following target help:

.PHONY: help
help: # Print help on Makefile
	@make-help

To get help on targets in root makefile only (without parsing included ones), you can pass -root option on command line. To skip help on targets without comment, you can pass -mute on command line.

make-desc

Describe given target. If makefile defines a build target, you might describe it with:

$ make-desc build
Build binary

This prints the target description on command line. In a makefile, you can get current target name with $@ and thus get its description calling make-desc $@.

Enjoy!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Filenames = []string{"GNUmakefile", "makefile", "Makefile"}

Filenames is ordered list of makefile names

View Source
var HelpLineRegexp = regexp.MustCompile(`(?m)^([\w-]+):[\t ]*([^#\n]+)?[\t ]*(#[\t ]*(.*))?$`)

HelpLineRegexp is the regexp to catch target lines

View Source
var IncludedRegexp = regexp.MustCompile(`(?m)^-?include\s+(.*)$`)

IncludedRegexp is the regexp to catch included makefiles

Functions

func ExpandUserHome

func ExpandUserHome(path string) string

ExpandUserHome expand path starting with "~/": - path: the path to expand Return: expanded path

func FileExists

func FileExists(file string) bool

FileExists tells if given file exists: - file: the name of the file to test Return: a boolean that tells if file exists

func FindMakefile

func FindMakefile() string

FindMakefile looks for makefile in current directory Return: found makefile name

func IncludedFiles

func IncludedFiles(source string) ([]string, error)

IncludedFiles extracts included makefiles - source: makefile source Return: included makefiles

func ReadFile

func ReadFile(filename string) string

ReadFile and exit on error - filename: name of the file to read Return: file content as a string

Types

type HelpLine

type HelpLine struct {
	Name         string
	Description  string
	Dependencies []string
}

HelpLine holds information about a line of help

func ParseMakefile

func ParseMakefile(source string, recursive bool) ([]HelpLine, error)

ParseMakefile parses passed makefile - source: the makefile source - recursive: tells if we should parse recursively (defaults to true) Return: HelpLine list and error if any

type HelpLineSorter

type HelpLineSorter []HelpLine

HelpLineSorter sorts HelpLine by name

func (HelpLineSorter) Len

func (a HelpLineSorter) Len() int

func (HelpLineSorter) Less

func (a HelpLineSorter) Less(i, j int) bool

func (HelpLineSorter) Swap

func (a HelpLineSorter) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL