Kaynağa Gözat

Makefile: Add removed target

Lets you list out what files were removed from OLD to NEW generations. Note
automatically done to remove files as I consider that the job of the user.

While here, added a function check_defined to let me check if a variable is
defined or not and if not bail.

Updated the option target to use this function as well as the removed target
where I needed it for.
master
Mitch Tishmack 8 yıl önce
ebeveyn
işleme
5ff14c8d3f
2 değiştirilmiş dosya ile 52 ekleme ve 10 silme
  1. +27
    -7
      Makefile
  2. +25
    -3
      readme.org

+ 27
- 7
Makefile Dosyayı Görüntüle

@@ -1,19 +1,31 @@
# Makefile is here to make it possible to use this whole shebang
# outside of emacs.
#
# TODO: wrap this stuff into a script maybe?
DEST:=$(HOME)
LAST:=$(shell cat .last || echo 0)
NEXT:=$(shell l=$(LAST); ((l=l+1)); echo $$l)
LAST!=cat .last || echo 0
NEXT!=l=$(LAST); ((l=l+1)); echo $$l
NEXTGEN:=$(PWD)/generation/$(NEXT)
LASTGEN:=$(PWD)/generation/$(LAST)
TANGLERS:=$(shell ls -d *.org)
TANGLERS:=$(wildcard *.org)
GEN:=$(LAST)
OPTS:=
# OSX uses scutil --get ComputerName
# uname -n && hostname -s can return dhcp addresses
# which aren't stable.
HOST=$(shell echo "$$(scutil --get ComputerName || uname -n)")
HOST!=scutil --get ComputerName || uname -n
USEROPTS:=$(OPTS):$(HOST)
NAME:=default

# Make it easier to check if a variable is defined or not
# params:
# variable name
# optional message to print if variable is not set
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined variable $1$(if $2, ($2))))

INSTALLDIRS=tmp $(NEXTGEN) $(LASTGEN) generation/$(GEN)

@@ -25,8 +37,6 @@ $(INSTALLDIRS):
generation: $(NEXTGEN) $(LASTGEN) tmp
cd tmp && cp -av . $(NEXTGEN)

check:

diff: generation/$(GEN)
./ddiff $(PWD)/generation/$(GEN) $(DEST)

@@ -50,6 +60,15 @@ copy:
tangle: tmp
USEROPTS=$(USEROPTS) /usr/bin/env emacs --script ./etangle $(TANGLERS)

# TODO: is this gnu diff output... only or not? note: wip until i've
# tested on bsd make etc...

.PHONY: removed
removed:
$(call check_defined, OLD, generation to compare removed files against)
$(call check_defined, NEW, generation to compare removed files to)
@diff -bur generation/$(OLD) generation/$(NEW) 2>&1 | grep 'Only in generation/'$(OLD) | sed -e 's|Only in ||' -e 's|.*[:] ||'

clean:
-rm -fr tmp

@@ -58,5 +77,6 @@ nuke: clean

.PHONY: option
option:
$(call check_defined, NAME, predicate NAME to define in option files. Note: without -p i.e. NAME-p = t and no-NAME-p = nil)
echo "(setq $(NAME)-p t)" > options/$(NAME).el
echo "(setq $(NAME)-p nil)" > options/no-$(NAME).el

+ 25
- 3
readme.org Dosyayı Görüntüle

@@ -155,9 +155,31 @@ This isn't intended to cover everything. This could be considered a template for
how you could setup your files in a similar way. Look at this org mode file for
details.

NOTE: Removal of files is YOUR job, not this tools. One could theoretically look
at what changed between two generations and remove that way. BUT that sounds
janky and error prone. Removal of files is the users job, not this setup.
** Removal of files between generations

Removal of files is ultimately *YOUR* job. However... to make it possible to
remove things if desired a bit easier you can run this makefile target with the
*OLD* and *NEW* variables set:

#+BEGIN_SRC sh :tangle no
make removed OLD=generation NEW=generation
#+END_SRC

This will list all the files/directories recursively not in *OLD* compared to *NEW*.

Example:

#+BEGIN_SRC sh :tangle no
$ make removed OLD=40 NEW=470
.Xdefaults
.Xresources
.ghc.hs
escp
essh
flushdns
tomod
towip
#+END_SRC

** Explanation of what is happening



Yükleniyor…
İptal
Kaydet