Code Monkey home page Code Monkey logo

mmake's Introduction

Modern Make

About

Mmake is a small program which wraps make to provide additional functionality, such as user-friendly help output, remote includes, and eventually more. It otherwise acts as a pass-through to standard make.

Installation

Via gobinaries.com:

$ curl -sf https://gobinaries.com/tj/mmake/cmd/mmake | sudo sh

Build from source:

$ go get github.com/tj/mmake/cmd/mmake

Homebrew:

$ brew tap tj/mmake https://github.com/tj/mmake.git
$ brew install tj/mmake/mmake

Next add the following alias to your profile:

alias make=mmake

Features

Help output

Make's primary function is not to serve as a "task runner", however it's often used for that scenario due to its ubiquitous nature, and if you're already using it, why not! Make is however lacking a built-in mechanism for displaying help information.

Here's an example Makefile:

# Start the dev server.
#
# Note that the API server must
# also be running.
start:
	@gopherjs -m -v serve --http :3000 github.com/tj/docs/client
.PHONY: start

# Start the API server.
api:
	@go run server/cmd/api/api.go
.PHONY: api

# Display dependency graph.
deps:
	@godepgraph github.com/tj/docs/client | dot -Tsvg | browser
.PHONY: deps

# Display size of dependencies.
#- Any comment preceded by a dash is omitted.
size:
	@gopherjs build client/*.go -m -o /tmp/out.js
	@du -h /tmp/out.js
	@gopher-count /tmp/out.js | sort -nr
.PHONY: size

Mmake provides a help command to display all target comments in short form:

$ alias make=mmake
$ make help

  start      Start the dev server.
  api        Start the API server.
  deps       Display dependency graph.
  size       Display size of dependencies.

You can optionally filter which commands to view the help dialogue for (this supports standard Unix glob patterns):

$ make help start

  start   Start the dev server.

$ make help s*

  size    Display size of dependencies.
  start   Start the dev server.

The help command also supports displaying longer output with the verbose flag (-v / --verbose):

$ make help -v start

  Start the dev server.

  Note that the API server must
  also be running.

$ make help -v

  start:
    Start the dev server.

    Note that the API server must
    also be running.

  api:    
    Start the API server.

  deps:       
    Display dependency graph.

  size:
    Display size of dependencies.
    

The default behaviour of Make is of course preserved:

$ make
serving at http://localhost:3000 and on port 3000 of any available addresses

$ make size
...

Remote includes

Includes may specify a URL (http, https, or github shortcut) for inclusion, which are automatically downloaded to /usr/local/include and become available to Make. Note that make resolves includes to this directory by default, so the Makefile will still work for regular users.

Includes are resolved recursively. For example you may have a standard set of includes for your team to run tests, lint, and deploy:

include github.com/apex/make/deploy
include github.com/apex/make/lint
include github.com/apex/make/test
include https://github.com/apex/make/test/Makefile
include https://github.com/apex/make/test/make.mk

This can be a lot to remember, so you could also provide a file which includes the others:

include github.com/apex/make/all

If the given repository contains an index.mk file, you can just declare:

include github.com/apex/make

Or perhaps one per dev environment such as Node or Golang:

include github.com/apex/make/node
include github.com/apex/make/golang

If you're worried about arbitrary code execution, then simply fork a project and maintain control over it.

Update

Once the remote includes are downloaded to /usr/local/include, mmake will not try to fetch them again. In order to get an updated copy of the remote includes, mmake provides an update target that will download them again:

$ make update

Registry

If you're looking to find or share makefiles check out the Wiki, and feel free to add a category if it is missing.

Links

Badges

GoDoc


tjholowaychuk.com  ·  GitHub @tj  ·  Twitter @tjholowaychuk

mmake's People

Contributors

a8m avatar codekoala avatar goreleaserbot avatar gtramontina avatar kashav avatar rabingaire avatar tj avatar tryzniak avatar zph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mmake's Issues

Local includes are not working as intended

Consider two local files Makefile and foo.mk

Makefile:

include foo.mk

foo.mk

foo:
	@echo "foo"

make allows including the local file, but mmake seems to think it's a remote include.

$ make foo
foo
$ mmake foo
   ⨯ installing                error=installing "foo.mk": only github.com is currently supported

Verbose flag for `help` command

Might be cool to have, for a quick glance at what the makefile does instead of going through every command :)

$ make help -v

  start:
    Start the dev server.

    Note that the API server must
    also be running.

  api:    
    Start the API server.

  deps:       
    Display dependency graph.

  size:
    Display size of dependencies.

mmake help doesn't output comments from include targets

@tj , thanks for this awesome tooling.
I'm not sure if this was ever possible. But in 1.3.0 mmake help does not output any help data for a simple included common makefile.

Makefile

include ../common.mk

common.mk

# example command help string
start:
  @echo test
.PHONY: start

Ignore .PHONY line

Many style guides suggest putting the .PHONY before the target.
This is also my preferred style.

# Remove all build artifacts and dependencies
.PHONY: clean
clean:
	-rm -r build

This, however, leads to a not very helpful help output

$ make help

  .PHONY                        Remove all build artifacts and dependencies

I think mmake should ignore the .PHONY line.

Ability to generate Makefiles and/or update targets

I was thinking about how to use mmake with projects where potential contributors may or may not have it, and asking them to install it is another step that doesn't feel totally necessary. The idea I came up with is to have a secondary MMakefile (or similar) that contains remote includes, and can (optionally) be used to generate a Makefile with the remote includes inlined.

For instance:

# MMakefile

include github.com/foo/make/bar

$ mmake gen

# Makefile

bar:
    // Contents of github.com/foo/make/bar

Basically mmake would check for MMakefile before Makefile when executing a target, so you could have either a MMakefile, Makefile, or both.

Alternatively, it could suffice to support overwriting a target in a Makefile with the latest version of a remote. For example, the sanity and precommit targets here are actually copy+pasted from what would have been remote includes if I were to enforce mmake being installed, which isn't ideal because there are already hurdles to contributing to that project. What would be nice is to be able to update these targets inline with the latest contents of the remote targets, something like:

$ mmake update sanity github.com/KyleBanks/make/go/sanity

After this the Makefile would contain the latest version of sanity.

permission denied

This was installed using homebrew.

$ cat Makefile | head -1
include https://gitlab.com/REDACTED/make-templates.git
$ make
   ⨯ installing                error=installing "https://gitlab.com/REDACTED/make-templates.git": mkdir: mkdir /usr/local/include: permission denied

I'm thinking this is an issue with M1 Mac's and how homebrew changed the install directory: /usr/local vs /opt/homebrew

Also tried installing with curl:

$ curl -sf https://gobinaries.com/tj/mmake/cmd/mmake | sudo sh
Password:

  ==> Downloading github.com/tj/mmake/cmd/mmake@master
  ==> Resolved version master to v1.4.0
  ==> Downloading binary for darwin arm64

  Error downloading, got 500 response from server
$ sw_vers
ProductName:	macOS
ProductVersion:	12.4
BuildVersion:	21F79

Wiki registry

Somewhere I have code to parse the wiki pages for listing/search etc via CLI.

CI

my lazy tree commands appear to be failing, the output looks like it's matching just fine but something is going on there

Publish Homebrew Formula

In your .goreleaser configuration you have homebrew configured, but you haven't yet published the formula. I would love to be able to install mmake via brew. Could you publish your formula?

Resolve in local includes

Currently just ignoring them entirely, but ideally we traverse those as well and pick up any local includes / comments.

Contributing back from a fork

Hi @tj,

I like the concept of this project and looked through forks and PRs to bring it current and extend it for a few desired features. Repo: https://github.com/zph/mmake

  • Allow direct http/s based includes via new resolver
  • Support standard makefile names (per GNUMake, ie GNUmakefile, makefile, or Makefile) #33 (though I rewrote this one myself)
  • Allow custom include paths #25
  • Highlight default target #29
  • Fixed tests broken by custom include path.
  • Use goreleaser
  • Setup a brew recipe for installation on mac/linux
  • Use golang modules for dependency tracking/download
  • Implements #3 tag/commit/sha support for github based resolver

I want to make sure to contribute back and am happy to do any of the following:

  • Merge this back into your repo and optionally get a commit bit to tidy up the issues/PRs
  • Maintain my own copy indefinitely
  • Or another combination of these :).

Thanks for putting this project together and if any of these outcomes sound good, great! If not, I'm quite happy to have my own repo for it too 👍.

Cheers,
ZPH

Show/confirm dependency tree

Looks like the parser might need more complexity for this, but just wanted to throw out a vote for displaying a build dependency tree.

I use make for a number of ETL tasks, and it would be nice to easily see what files/targets might be touched before I do something that will take a long time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.