From d9844d3ca751e390863332411c1567155cae4cf3 Mon Sep 17 00:00:00 2001 From: Paul deGrandis Date: Mon, 22 Feb 2016 08:11:14 -0500 Subject: [PATCH 1/7] Parallel jobs should default to the number of available, logical CPU cores. --- mk.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mk.go b/mk.go index 915429a..95f7de8 100644 --- a/mk.go +++ b/mk.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "runtime" "flag" "fmt" "io/ioutil" @@ -311,7 +312,7 @@ func main() { flag.BoolVar(&dryrun, "n", false, "print commands without actually executing") flag.BoolVar(&shallowrebuild, "r", false, "force building of just targets") flag.BoolVar(&rebuildall, "a", false, "force building of all dependencies") - flag.IntVar(&subprocsAllowed, "p", 4, "maximum number of jobs to execute in parallel") + flag.IntVar(&subprocsAllowed, "p", runtime.NumCPU(), "maximum number of jobs to execute in parallel") flag.BoolVar(&interactive, "i", false, "prompt before executing rules") flag.BoolVar(&quiet, "q", false, "don't print recipes before executing them") flag.Parse() From 10cfccda21c6fe6cc9dd71eb50999f14bc4545ee Mon Sep 17 00:00:00 2001 From: Paul deGrandis Date: Mon, 22 Feb 2016 08:12:49 -0500 Subject: [PATCH 2/7] Adjust README headers to be more 'semantic' --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index de3f380..1197026 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ Mk is a reboot of the Plan 9 mk command, which itself is [a successor to make](http://www.cs.tufts.edu/~nr/cs257/archive/andrew-hume/mk.pdf). This tool is for anyone who loves make, but hates all its stupid bullshit. -# Installation +## Installation 1. Install Go. 2. Run `go get github.com/dcjones/mk` 3. Make sure `$GOPATH/bin` is in your `PATH`. -# Why Plan 9 mk is better than make +## Why Plan 9 mk is better than make Way back in the 90s, some smart guys at Bell Labs got together and decided to write new operating system to replace Unix. The idea was to keep everything that @@ -43,13 +43,14 @@ elegant, and powerful. To name a few specifics: `<|sh config.sh`. 1. A generalized mechanism to determine if a target is out of date, for when timestamps won't cut it. - 1. Variables are expanded in recipes only if they are defined. They way you + 1. Variables are expanded in recipes only if they are defined. That way you usually don't have to escape `$`. -And much more! Read [Maintaining Files on Plan 9 with -Mk](http://doc.cat-v.org/plan_9/4th_edition/papers/mk) for good overview. +And much more! +Read [Maintaining Files on Plan 9 with Mk](http://doc.cat-v.org/plan_9/4th_edition/papers/mk) +for good overview. -# Improvements over Plan 9 mk +## Improvements over Plan 9 mk This mk stays mostly faithful to Plan 9, but makes a few (in my opinion) improvements. @@ -72,21 +73,21 @@ improvements. 1. Pretty colors. -# Usage +## Usage `mk [options] [target] ...` -## Options +### Options * `-f filename` Use the given file as the mkfile. * `-n` Dry run, print commands without actually executing. * `-r` Force building of the immediate targets. * `-a` Force building the targets and of all their dependencies. - * `-p` Maximum number of jobs to execute in parallel (default: 8) + * `-p` Maximum number of jobs to execute in parallel (default: # CPU cores) * `-i` Show rules that will execute and prompt before executing. -# Non-shell recipes +## Non-shell recipes Non-shell recipes are a major addition over Plan 9 mk. They can be used with the `S[command]` attribute, where `command` is an arbitrary command that the recipe @@ -100,7 +101,7 @@ mean.txt:Sjulia: input.txt mean(map(parseint, eachline(open("$prereq"))))) ``` -# Current State +## Current State Functional, but with some bugs and some unimplemented minor features. Give it a try and see what you think! From 60817ccb46fe09ba6b05f193c97bcee236793b1d Mon Sep 17 00:00:00 2001 From: Paul deGrandis Date: Mon, 22 Feb 2016 08:18:52 -0500 Subject: [PATCH 3/7] Add a gitignore --- .gitignore | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ecb64f --- /dev/null +++ b/.gitignore @@ -0,0 +1,46 @@ +# Project related +mk + +# Go related + +# Java related +pom.xml +*.class + +# Python +*.pyc +*.pyo +/__pycache__/ + +# Ruby +#Gemfile.lock +.sass-cache/ + +# Temp Files +*.orig +*~ +.*.swp +.*.swo +*.tmp +*.bak + +# Editors (IntelliJ / Eclipse) +*/.idea +.idea +*/.classpath +.classpath +*/.project +.project +*/.settings +.settings + +# OS X +.DS_Store + +# Logging +*.log +/logs/ + +# Builds +*.o +out/ From a9197527a297ac2ae0ada3c86513b5f2d238e0f4 Mon Sep 17 00:00:00 2001 From: Paul deGrandis Date: Mon, 22 Feb 2016 08:27:26 -0500 Subject: [PATCH 4/7] Add license information to the README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 1197026..b40eed4 100644 --- a/README.md +++ b/README.md @@ -106,4 +106,10 @@ mean.txt:Sjulia: input.txt Functional, but with some bugs and some unimplemented minor features. Give it a try and see what you think! +## License + +This work is provided under the [BSD 2-clause](https://opensource.org/licenses/BSD-2-Clause) license. + +Copyright (c) 2013, [Daniel C. Jones](https://github.com/dcjones) - All rights reserved. +Updates made by [Paul deGrandis](https://github.com/ohpauleez) Feb 2016. From 5772eba1cb228953ef1a78f860a02441bf5c05d0 Mon Sep 17 00:00:00 2001 From: Paul deGrandis Date: Mon, 22 Feb 2016 08:44:23 -0500 Subject: [PATCH 5/7] Disable color if the output stream is not a terminal; Fixes #4 --- mk.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mk.go b/mk.go index 95f7de8..df11f21 100644 --- a/mk.go +++ b/mk.go @@ -1,19 +1,21 @@ package main import ( - "bufio" + "bufio" "runtime" - "flag" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strings" - "sync" + "flag" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strings" + "sync" + "github.com/mattn/go-isatty" ) // True if messages should be printed without fancy colors. -var nocolor bool = false +// - By default, if the output stream is not the terminal, colors are disabled +var nocolor bool = !isatty.IsTerminal(os.Stdout.Fd()) // True if we are ignoring timestamps and rebuilding everything. var rebuildall bool = false From f01bbbc2b4635cb1466727007109071b940409cc Mon Sep 17 00:00:00 2001 From: Paul deGrandis Date: Mon, 1 Aug 2016 08:57:50 -0400 Subject: [PATCH 6/7] Build from source tips for those new to Go --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index b40eed4..9b2cad0 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,11 @@ is for anyone who loves make, but hates all its stupid bullshit. 2. Run `go get github.com/dcjones/mk` 3. Make sure `$GOPATH/bin` is in your `PATH`. +### Building/installing from source + + 1. `git clone` the repo + 2. `go build` + ## Why Plan 9 mk is better than make Way back in the 90s, some smart guys at Bell Labs got together and decided to @@ -106,6 +111,12 @@ mean.txt:Sjulia: input.txt Functional, but with some bugs and some unimplemented minor features. Give it a try and see what you think! +## Building and installing from source + + * clone the repo + * `go build` - build the executable + * `go test` - run the tests + ## License This work is provided under the [BSD 2-clause](https://opensource.org/licenses/BSD-2-Clause) license. From d6534b7e8d6e16f57187b471f4bdd1b8044fea79 Mon Sep 17 00:00:00 2001 From: NDensity compute Date: Fri, 2 Sep 2016 13:51:40 +0000 Subject: [PATCH 7/7] Building tweaks --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b2cad0..7f2a357 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ is for anyone who loves make, but hates all its stupid bullshit. ### Building/installing from source 1. `git clone` the repo - 2. `go build` + 2. `go get` + 3. `go build` ## Why Plan 9 mk is better than make