[llvm] 4ce375a - [gn build] minor tweaks to sync script

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 19:09:23 PDT 2020


Author: Nico Weber
Date: 2020-03-30T22:07:23-04:00
New Revision: 4ce375a8f2eed73832b6384cd1ea0b33606db6fe

URL: https://github.com/llvm/llvm-project/commit/4ce375a8f2eed73832b6384cd1ea0b33606db6fe
DIFF: https://github.com/llvm/llvm-project/commit/4ce375a8f2eed73832b6384cd1ea0b33606db6fe.diff

LOG: [gn build] minor tweaks to sync script

- only complain about duplicate 'sources' lines if they contain
  more than 1 elements each (before, 0 and 1 element lists were
  counted too). In practice, this only has an effect for
  clang/lib/Headers/BUILD.gn

- make the '# NOSORT' diag actually work. This too only affects
  clang/lib/Headers/BUILD.gn.

In aggregate, changes to clang/lib/Headers/BUILD.gn still can't
be auto-merged, but for a slighly better reason.

Added: 
    

Modified: 
    llvm/utils/gn/build/sync_source_lists_from_cmake.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/build/sync_source_lists_from_cmake.py b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
index 0b13a8afc716..46a779ef376c 100755
--- a/llvm/utils/gn/build/sync_source_lists_from_cmake.py
+++ b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
@@ -27,13 +27,13 @@ def patch_gn_file(gn_file, add, remove):
     with open(gn_file) as f:
         gn_contents = f.read()
 
-    srcs_tok = 'sources = ['
+    srcs_tok = 'sources = [\n'
     tokloc = gn_contents.find(srcs_tok)
 
     if tokloc == -1: raise ValueError(gn_file + ': Failed to find source list')
     if gn_contents.find(srcs_tok, tokloc + 1) != -1:
         raise ValueError(gn_file + ': Multiple source lists')
-    if gn_file.find('# NOSORT', 0, tokloc) != -1:
+    if gn_contents.find('# NOSORT', 0, tokloc) != -1:
         raise ValueError(gn_file + ': Found # NOSORT, needs manual merge')
 
     tokloc += len(srcs_tok)


        


More information about the llvm-commits mailing list