Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: Makefile

Issue 5986495445860352: 1377-Blacklist_dependencies (Closed)
Patch Set: Created Sept. 29, 2014, 11:41 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « .travis.yml ('k') | ensure_dependencies.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/make -f
2 # -------------------------------------------------------------------------
3 # This Makefile is destined to ease the work with the infrastructure repo,
4 # especially when working with Vagrant: It contains wildcard targets for the
5 # most common Vagrant commands ($box.$operation) that ensure each operation
6 # is logged properly. This eases reporting, reproducing and debugging any
7 # issues that may arise.
8 # In addition, there are a set of additional targets that perform actions
9 # specific to the repo, such as invocation of the ensure_dependencies.py
10 # script and the creation of the modules/private resource when necessary.
11 # -------------------------------------------------------------------------
12
13 # Phony targets are always considered out-of-date.
14 .PHONY: ensure_dependencies.py prepare clean distclean
15
16 # The first target is also the default one.
17 .DEFAULT_GOAL = prepare
18
19 # -------------------------------------------------------------------------
20 # Recognized environment variables and their defaults
21 # -------------------------------------------------------------------------
22
23 # The python(1) executable to use. Note that it must be Python version 2!
24 PYTHON ?= python
25
26 # The Vagrant executable to use.
27 VAGRANT ?= vagrant
28
29 # -------------------------------------------------------------------------
30 # Common targets or "commands"
31 # -------------------------------------------------------------------------
32
33 # The prepare target is also the default goal. It ensures all prerequisites
34 # for development and testing are fulfilled.
35 prepare: \
36 ensure_dependencies.py \
37 modules/private
38
39 ##
40 # The clean target removes any logs written so far.
41 clean:
42 rm -rf "$(VAGRANT_LOG_PATH)"
43
44 ##
45 # The obligatoric distclean target implies clean and, in addition, removes
46 # all submodules as well as the modules/private stub, if any.
47 distclean: clean
48 $(MAKE) list-dependencies | while read module; do rm -rf "$$module"; don e
49 if [ -L "modules/private" ]; then rm "modules/private"; fi
50
51 # -------------------------------------------------------------------------
52 # Vagrant-specific utilities
53 # -------------------------------------------------------------------------
54
55 # The following variables are local to the Makefile and meant to decrease
56 # the amount of code being repeated in the %.command targets.
57 VAGRANT_LOG_PATH = .vagrant/logs
58 VAGRANT_LOG_APPEND = tee -a "$(VAGRANT_LOG_PATH)/$*.log"
59 VAGRANT_LOG_STANZA = echo "[`date` $@]" | $(VAGRANT_LOG_APPEND)
60
61 %.back: $(VAGRANT_LOG_PATH)
62 @$(VAGRANT_LOG_STANZA)
63 @$(VAGRANT) snapshot back "$*" 2>&1 | $(VAGRANT_LOG_APPEND)
64
65 %.destroy: $(VAGRANT_LOG_PATH)
66 @$(VAGRANT_LOG_STANZA)
67 @$(VAGRANT) destroy -f "$*" 2>&1 | $(VAGRANT_LOG_APPEND)
68
69 %.halt: $(VAGRANT_LOG_PATH)
70 @$(VAGRANT_LOG_STANZA)
71 @$(VAGRANT) halt "$*" 2>&1 | $(VAGRANT_LOG_APPEND)
72
73 %.provision: $(VAGRANT_LOG_PATH)
74 @$(VAGRANT_LOG_STANZA)
75 @$(VAGRANT) provision "$*" 2>&1 | $(VAGRANT_LOG_APPEND)
76
77 %.snapshot: $(VAGRANT_LOG_PATH)
78 @$(VAGRANT_LOG_STANZA)
79 @$(VAGRANT) snapshot take "$*" 2>&1 | $(VAGRANT_LOG_APPEND)
80
81 %.ssh: $(VAGRANT_LOG_PATH)
82 @$(VAGRANT_LOG_STANZA)
83 @$(VAGRANT) ssh "$*"
84
85 %.up: $(VAGRANT_LOG_PATH)
86 @$(VAGRANT_LOG_STANZA)
87 @$(VAGRANT) up "$*" 2>&1 | $(VAGRANT_LOG_APPEND)
88
89 # -------------------------------------------------------------------------
90 # Fragmental dependencies of other targets
91 # -------------------------------------------------------------------------
92
93 ##
94 # The list-dependencies target is used internally to accumulate a newline-
95 # separated list of all external modules referenced in the dependencies file.
96 list-dependencies:
97 @sed -n 's/^\s*\([a-z0-9][^ ]\+\)\s*=.*/\1/p' dependencies
98
99 # The ensure_dependencies.py target invokes the accompanying $(PYTHON)
100 # script of the same name for each dependency module not found in the local
101 # repository clone.
102 ensure_dependencies.py:
103 $(MAKE) list-dependencies \
104 | while read line; do \
105 if [ ! -e "$$line" ]; then \
106 $(PYTHON) "$@"; \
107 break; \
108 fi; \
109 done
110
111 # The modules/private target ensures the private setup module being present.
112 # By default, it's using the development stub that ships with the repository.
113 # Please refer to the accompanying README.md file for more information.
114 modules/private:
115 if [ ! -e "$@" ]; then ln -s private-stub "$@"; fi
116
117 # The $(VAGRANT_LOG_PATH) target ensures the destination for log files
118 # being present.
119 $(VAGRANT_LOG_PATH):
120 mkdir -p "$@"
121
122 # -------------------------------------------------------------------------
123 # Miscellaneous targets
124 # -------------------------------------------------------------------------
125
126 # The Makefile target is an empty stub required when the Makefile is invoked
127 # as an executable script in another directory (see also the #!shebang line
128 # at the top).
129 Makefile:
130
OLDNEW
« no previous file with comments | « .travis.yml ('k') | ensure_dependencies.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld