]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - utils/sync-source/README.txt
Vendor import of lldb trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / utils / sync-source / README.txt
1 syncsource.py
2
3 OVERVIEW
4
5 The syncsource.py utility transfers groups of files between
6 computers. The primary use case is to enable developing LLVM project
7 software on one machine, transfer it efficiently to other machines ---
8 possibly of other architectures --- and test it there. syncsource.py
9 supports configurable, named source-to-destination mappings and has a
10 transfer agent plug-in architecture. The current distribution provides
11 an rsync-over-ssh transfer agent.
12
13 The primary benefits of using syncsource.py are:
14
15 * Provides a simple, reliable way to get a mirror copy of primary-
16   machine files onto several different destinations without concern
17   of compromising the patch during testing on different machines.
18
19 * Handles directory-mapping differences between two machines.  For
20   LLDB, this is helpful when going between OS X and any other non-OS X
21   target system.
22
23 EXAMPLE WORKFLOW
24
25 This utility was developed in the context of working on the LLDB
26 project.  Below we show the transfers we'd like to have happen,
27 and the configuration that supports it.
28
29 Workflow Example:
30
31 * Develop on OS X (primary machine)
32 * Test candidate changes on OS X.
33 * Test candidate changes on a Linux machine (machine-name: lldb-linux).
34 * Test candidate changes on a FreeBSD machine (machine-name: lldb-freebsd).
35 * Do check-ins from OS X machine.
36
37 Requirements:
38
39 * OS X machine requires the lldb source layout: lldb, lldb/llvm,
40   lldb/llvm/tools/clang. Note this is different than the canonical
41   llvm, llvm/tools/clang, llvm/tools/lldb layout that we'll want on
42   the Linux and FreeBSD test machines.
43
44 * Linux machine requires the llvm, llvm/tools/clang and
45   llvm/tools/lldb layout.
46
47 * FreeBSD machine requires the same layout as the llvm machine.
48
49 syncsource.py configuration in ~/.syncsourcerc:
50
51 # This is my configuration with a comment.  Configuration
52 # files are JSON-based.
53 { "configurations": [
54     # Here we have a collection of named configuration blocks.
55     # Configuration blocks can chain back to a parent by name.
56     {
57         # Every block has a name so it can be referenced from
58         # the command line or chained back to by a child block
59         # for sharing.
60         "name": "base_tot_settings",
61
62         # This directive lists the "directory ids" that we'll care
63         # about.  If your local repository has additional directories
64         # for other projects that need to ride along, add them here.
65         # For defaulting purposes, it makes sense to name the
66         # directory IDs as the most likely name for the directory
67         # itself.  For stock LLDB from top of tree, we generally only
68         # care about lldb, llvm and clang.
69         "dir_names": [ "llvm", "clang", "lldb" ],
70
71         # This section describes where the source files live on
72         # the primary machine.  There should always be a base_dir
73         # entry, which indicates where in the local filesystem the
74         # projects are rooted.  For each dir in dir_names, there
75         # should be either:
76         # 1. an entry named {dir-id}_dir (e.g. llvm_dir), which
77         #    specifies the source directory for the given dir id
78         #    relative to the base_dir entry, OR
79         # 2. no entry, in which case the directory is assumed to
80         #    be the same as {dir-id}.  In the example below, the
81         #    base_dir-relative directory for the "lldb" dir-id is
82         #    defaulted to being "lldb".  That's exactly what
83         #    we need in an OS X-style lldb dir layout.
84         "source": {
85             "base_dir": "~/work/lldb-tot",
86             "llvm_dir": "lldb/llvm",
87             "clang_dir": "lldb/llvm/tools/clang"
88         },
89
90         # source_excludes covers any exclusions that:
91         # * should be applied when copying files from the source
92         # * should be excluded from deletion on the destination
93         #
94         # By default, ".git", ".svn" and ".pyc" are added to
95         # all dir-id exclusions.  The default excludes can be
96         # controlled by the syncsource.py --default-excludes
97         # option.
98         #
99         # Below, I have transfer of the lldb dir skip everything
100         # rooted at "/llvm" below the lldb dir.  This is
101         # because we want the source OS X lldb to move to
102         # a destination of {some-dest-root}/llvm/tools/lldb, and
103         # not have the OS-X-inverted llvm copy over with the lldb
104         # transfer portion.  We'll see the complete picture of
105         # how this works when we get to specifying destinations
106         # later on in the config.
107         #
108         # We also exclude the "/build" and "/llvm-build" dir rooted in
109         # the OS X-side sources.  The Xcode configuration on this
110         # OS X machine will dump lldb builds in the /build directory
111         # relative to the lldb dir, and it will build llvm+clang in
112         # the /llvm-build dir relative to the lldb dir.
113         #
114         # Note the first forward slash in "/build" indicates to the
115         # transfer agent that we only want to exclude the
116         # ~/work/lldb-tot/lldb/build dir, not just any file or
117         # directory named "build" somewhere underneath the lldb
118         # directory.  Without the leading forward slash, any file
119         # or directory called build anywhere underneath the lldb dir
120         # will be excluded, which is definitely not what we want here.
121         #
122         # For the llvm dir, we do a source-side exclude for
123         # "/tools/clang".  We manage the clang transfer as a separate
124         # entity, so we don't want the movement of llvm to also move
125         # clang.
126         #
127         # The llvm_dir exclusion of "/tools/lldb" is the first example
128         # of an exclude targeting a requirement of the destination
129         # side.  Normally the transfer agent will delete anything on
130         # the destination that is not present on the source.  It is
131         # trying to mirror, and ensure both sides have the same
132         # content.  The source side of llvm on OS X does not have a
133         # "/tools/lldb", so at first this exclude looks non-sensical.
134         # But on the canonical destination layout, lldb lives in
135         # {some-dest-root}/llvm/tools/lldb.  Without this exclude,
136         # the transfer agent would blow away the tools/lldb directory
137         # on the destination every time we transfer, and then have to
138         # copy the lldb dir all over again.  For rsync+ssh, that
139         # totally would defeat the huge transfer efficiencies gained
140         # by using rsync in the first place.
141         #
142         # Note the overloading of both source and dest style excludes
143         # ultimately comes from the rsync-style exclude mechanism.
144         # If it wasn't for that, I would have separated source and
145         # dest excludes out better.
146         "source_excludes": {
147             "lldb_dir": ["/llvm", "/build", "/llvm-build"],
148             "llvm_dir": ["/tools/lldb", "/tools/clang"]
149         }
150     },
151
152     # Top of tree public, common settings for all destinations.
153     {
154         # The name for this config block.
155         "name": "common_tot",
156
157         # Here is our first chaining back to a parent config block.
158         # Any settings in "common_tot" not specified here are going
159         # to be retrieved from the parent.
160         "parent": "base_tot_settings",
161
162         # The transfer agent class to use.  Right now, the only one
163         # available is this one here that uses rsync over ssh.
164         # If some other mechanism is needed to reach this destination,
165         # it can be specified here in full [[package.]module.]class form.
166         "transfer_class": "transfer.rsync.RsyncOverSsh",
167
168         # Specifies the destination-root-relative directories.
169         # Here our desination is rooted at:
170         # {some-yet-to-be-specified-destination-root} + "base_dir".
171         # In other words, each destination will have some kind of root
172         # for all relative file placement.  We'll see those defined
173         # later, as they can change per destination machine.
174         # The block below describes the settings relative to that
175         # destination root.
176         #
177         # As before, each dir-id used in this configuration is
178         # expected to have either:
179         # 1. an entry named {dir-id}_dir (e.g. llvm_dir), which
180         #    specifies the destination directory for the given dir id
181         #    relative to the dest_root+base_dir entries, OR
182         # 2. no entry, in which case the directory is assumed to
183         #    be the same as {dir-id}.  In the example below, the
184         #    dest_root+base_dir-relative directory for the "llvm" dir-id is
185         #    defaulted to being "llvm".  That's exactly what
186         #    we need in a canonical llvm/clang/lldb setup on
187         #    Linux/FreeBSD.
188         #
189         #    Note we see the untangling of the OS X lldb-centric
190         #    directory structure to the canonical llvm,
191         #    llvm/tools/clang, llvm/tools/lldb structure below.
192         #    We are mapping lldb into a subdirectory of the llvm
193         #    directory.
194         #
195         #    The transfer logic figures out which directories to copy
196         #    first by finding the shortest destination absolute path
197         #    and doing them in that order.  For our case, this ensures
198         #    llvm is copied over before lldb or clang.
199         "dest": {
200             "base_dir": "work/mirror/git",
201             "lldb_dir": "llvm/tools/lldb",
202             "clang_dir": "llvm/tools/clang"
203         }
204     },
205
206     # Describe the lldb-linux destination.  With this,
207     # we're done with the mapping for transfer setup
208     # for the lldb-linux box.  This configuration can
209     # be used either by:
210     # 1. having a parent "default" blockthat points to this one,
211     #    which then gets used by default, or
212     # 2. using the --configuration/-c CONFIG option to
213     #    specify using this name on the syncsource.py command line.
214     {
215         "name": "lldb-linux"
216         "parent": "common_tot",
217
218         # The ssh block is understood by the rsync+ssh transfer
219         # agent.  Other agents would probably require different
220         # agent-specific details that they could read from
221         # other blocks.
222         "ssh": {
223             # This specifies the host name (or IP address) as would
224             # be used as the target for an ssh command.
225             "dest_host": "lldb-linux.example.com",
226
227             # root_dir specifies the global root directory for
228             # this destination.  All destinations on this target
229             # will be in a directory that is built from
230             # root_dir + base_dir + {dir_id}_dir.
231             "root_dir" : "/home/tfiala",
232
233             # The ssh user is specified here.
234             "user": "tfiala",
235
236             # The ssh port is specified here.
237             "port": 22
238         }
239     },
240
241     # Describe the lldb-freebsd destination.
242     # Very similar to the lldb-linux one.
243     {
244         "name": "lldb-freebsd"
245         "parent": "common_tot",
246         "ssh": {
247             "dest_host": "lldb-freebsd.example.com",
248             # Specify a different destination-specific root dir here.
249             "root_dir" : "/mnt/ssd02/fialato",
250             "user": "fialato",
251             # The ssh port is specified here.
252             "port": 2022
253         }
254     },
255
256     # If a block named "default" exists, and if no configuration
257     # is specified on the command line, then the default block
258     # will be used.  Use this block to point to the most common
259     # transfer destination you would use.
260     {
261         "name": "default",
262         "parent": "lldb-linux"
263     }
264 ]
265 }
266
267 Using it
268
269 Now that we have a .syncsourcerc file set up, we can do a transfer.
270 The .syncsourcerc file will be searched for as follows, using the
271 first one that is found:
272
273 * First check the --rc-file RCFILE option.  If this is specified
274   and doesn't exist, it will raise an error and quit.
275
276 * Check if the current directory has a .syncsourcerc file.  If so,
277   use that.
278
279 * Use the .syncsourcerc file from the user's home directory.
280
281 Run the command:
282 python /path/to/syncsource.rc -c {configuration-name}
283
284 The -c {configuration-name} can be left off, in which case a
285 configuration with the name 'default' will be used.
286
287 After that, the transfer will occur.  With the rsync-over-ssh
288 transfer agent, one rsync per dir-id will be used.  rsync output
289 is redirected to the console.
290
291 FEEDBACK
292
293 Feel free to pass feedback along to Todd Fiala (todd.fiala@gmail.com).