The script build/clobber.py tried to parse the build.ninja when
clobbering a directory and use it as a template, however if the
parsing failed, it generated a broken build.ninja file.
The script ios/build/tools/setup-gn.py would create multiple
empty build directory with just args.gn and a build.ninja file
that would result in invoking `gn gen` as a first step.
However, the build.ninja created by setup-gn.py could not be
parsed by clobber.py since it did not include minimum required
version of ninja command. Also, setup-gn.py did not recreate
the file if they existed, even if they were incorrect.
All this caused build/clobber.py to sometimes leave a build
directory in an unbuildable state requiring the developer to
run `gn gen` manually.
To fix this, change setup-gn.py to always overwrite build.ninja
file, to use a format that can be parsed by clobber.py and fix
clobber.py to write a build.ninja file that is valid if parsing
fails.
Always overwrite the build.ninja file to ensure that `--check`
is added to `gn gen` invocation (as locally running `gn gen`
without `--check` even once would disable the local check of the
deps and later be reported by Chrome iOS developers as a bug).
Bug: 1102331
Change-Id: Iabe906ac5f676f1b837c6ebb03ee32d73c7b6cf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283143
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Olivier Robin <olivierrobin@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786208}
GitOrigin-RevId: 75bb49ad3432cb331ae13058d2029ac060ab3543
The build.ninja file generated by ninja has changed and now
include a "ninja_required_version" statement. To keep the
rule to generate the build.ninja file, all the line up to
the third blank line should be kept (this is what "gn clean"
does).
Bug: 830627
Change-Id: I493cc39f484c6da8a0784d9cf2b45337cb4672d3
Reviewed-on: https://chromium-review.googlesource.com/1001902
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#549181}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: dfbbade3b1b603083944c0fe1945ff3842526a1d
Background: in order to use multiple build directories without the
cognitive or scripting overhead of figuring out which one is currently
in use, I keep a symlink "out/cur" pointing to the current one.
When the clobber script runs, it detects that out/cur is a build
directory (because out/cur/args.gn exists) but shutil.rmtree() fails
when applied to a symlink. This change skips the clobber when a link is
detected and leaves out/cur pointing to the real build dir. There's no
need to remove the symlink, since the original has been clobbered.
Review-Url: https://codereview.chromium.org/2642833002
Cr-Original-Commit-Position: refs/heads/master@{#444777}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 29acddfbe7b3c92cd85d99e416f920849d011ec1
If delete_dir or os.mkdir throw an exception then the code to restore
args.gn, build.ninja, and build.ninja.d will not run. This breaks a
design goal of gn which is that the args.gn files should not be
deleted.
The fix is to catch the exception and raise it after the files have
been restored.
To test the code leave chrome.exe or base_unittests.exe running in one
window and run this in another:
python build\clobber.py d:\src\chromium\src\out
Note that if you do this without the patch applied then all args.gn
files may be deleted, so consider backing them up. Also note that
args.gn files won't be restored unless build.ninja and build.ninja.d
files are also present, so back them up.
Just apply the patch first - it's easier.
BUG=612940
Review-Url: https://codereview.chromium.org/1996833002
Cr-Original-Commit-Position: refs/heads/master@{#395177}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 562df4f33e0a29669b83d451d33c81648a9e023e
For unknown reasons (Windows!) shutil.rmtree has been failing frequently
when the landmines change due to a toolchain change. This avoids the
the problem. This is necessary because manually deleting the 'out'
directory causes args.gn to get lost, which is a hassle.
This was noticed because the VS 2015 toolchain upgrades kept failing
to clobber the out directory on multiple machines.
Review URL: https://codereview.chromium.org/1812673003
Cr-Original-Commit-Position: refs/heads/master@{#382140}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b0e768eae38f683886600ba869e31054273ebeab
This patch factors clobbering functionality from build/landmines.py
into build/clobber.py (new file). This will allow us to reuse existing
code in the cr tool.
BUG=493023
Review URL: https://codereview.chromium.org/1199933004
Cr-Original-Commit-Position: refs/heads/master@{#335491}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: af7f4c0efa1389e3989041b3f50a9f647fe2d478