Eliminate dependency on ‘paste’ and ‘parallel’
This commit is contained in:
		
							parent
							
								
									bb8118c771
								
							
						
					
					
						commit
						4a32ebf8b5
					
				| @ -1,30 +1,34 @@ | |||||||
| 
 | # Setting the number of job runners like this in the makefile only works in
 | ||||||
| .PHONY: command-options clean | # GNU Make 4.3 or later. Older versions will require that either an env
 | ||||||
|  | # variable be set before running or command line flag be passed at runtime to
 | ||||||
|  | # get parallel jobs.
 | ||||||
|  | MAKEFLAGS += --jobs=$(shell nproc 2>/dev/null || printf 8) | ||||||
| 
 | 
 | ||||||
| all: hledger-completion.bash | all: hledger-completion.bash | ||||||
| 
 | 
 | ||||||
| hledger-completion.bash: hledger-completion.bash.m4 commands-list.txt query-filters.txt generic-options.txt command-options | COMMANDS := $(sort $(shell hledger | ./output-commands.sh | grep -v ^hledger | sort -u) ui web api) | ||||||
|  | CMDOPTFILES := $(foreach CMD,$(COMMANDS),options-$(CMD).txt) | ||||||
|  | 
 | ||||||
|  | hledger-completion.bash: hledger-completion.bash.m4 commands.txt commands-list.txt query-filters.txt generic-options.txt $(CMDOPTFILES) | ||||||
| 	m4 hledger-completion.bash.m4 > $@ | 	m4 hledger-completion.bash.m4 > $@ | ||||||
| 
 | 
 | ||||||
| generic-options.txt: | generic-options.txt: | ||||||
| 	hledger -h | ./output-options.sh | sort -u > $@ | 	hledger -h | ./output-options.sh | sort -u > $@ | ||||||
| 
 | 
 | ||||||
| commands.txt: | commands.txt: | ||||||
| 	hledger | ./output-commands.sh | grep -v ^hledger | sort -u > $@ | 	printf "%s\n" $(COMMANDS) > $@ | ||||||
| 	echo ui  >> $@ |  | ||||||
| 	echo web >> $@ |  | ||||||
| 	echo api >> $@ |  | ||||||
| 
 | 
 | ||||||
| commands-list.txt: commands.txt | commands-list.txt: | ||||||
| 	paste -sd, $^ | tr -d '\n' > $@ | 	printf "%s,"  $(COMMANDS) | sed 's/,$$//' > $@ | ||||||
| 
 | 
 | ||||||
| #query-filters.txt:
 | #query-filters.txt:
 | ||||||
| 	# The query filters are hard to extract! | 	# The query filters are hard to extract! | ||||||
| 	# hledger help --cat hledger | sed -n '/^QUERIES/,/^[A-Z]/p' | 	# hledger help --cat hledger | sed -n '/^QUERIES/,/^[A-Z]/p' | ||||||
| 
 | 
 | ||||||
| command-options: commands.txt | options-%.txt: | ||||||
| 	parallel -j8 'hledger {} -h | ./output-options.sh {} | sort -u > options-{}.txt' < commands.txt | 	hledger $* -h | ./output-options.sh $* | sort -u > $@ | ||||||
| 
 | 
 | ||||||
|  | .PHONY: clean | ||||||
| clean: | clean: | ||||||
| 	rm -f commands*.txt generic-options.txt options-*.txt | 	rm -f commands*.txt generic-options.txt options-*.txt | ||||||
| 	rm -f hledger-completion.bash | 	rm -f hledger-completion.bash | ||||||
|  | |||||||
| @ -69,8 +69,10 @@ cd shell-completion/ | |||||||
| make | make | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| Hint: GNU make, GNU m4, and GNU parallel must be installed to call `make`. | Hint: GNU make and  GNU m4 must be installed to call `make`. | ||||||
| The first two usually are. | These are present on most systems anyway. | ||||||
|  | Additionally the build will run a lot faster with parallell jobs. | ||||||
|  | Use `make -j$(nproc)` for best effect. | ||||||
| 
 | 
 | ||||||
| The generated completion script must be installed. The package maintainer for | The generated completion script must be installed. The package maintainer for | ||||||
| your distribution should be responsible for this. | your distribution should be responsible for this. | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user