This commit implements described in the #104573. The goal is to fix the confusion of the submodule hashes change, which are not ideal for any of the supported git-module configuration (they are either always visible causing confusion, or silently staged and committed, also causing confusion). This commit replaces submodules with a checkout of addons and addons_contrib, covered by the .gitignore, and locale and developer tools are moved to the main repository. This also changes the paths: - /release/scripts are moved to the /scripts - /source/tools are moved to the /tools - /release/datafiles/locale is moved to /locale This is done to avoid conflicts when using bisect, and also allow buildbot to automatically "recover" wgen building older or newer branches/patches. Running `make update` will initialize the local checkout to the changed repository configuration. Another aspect of the change is that the make update will support Github style of remote organization (origin remote pointing to thy fork, upstream remote pointing to the upstream blender/blender.git). Pull Request #104755
89 lines
2.0 KiB
Python
Executable File
89 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
"""
|
|
Run this script to check if headers are included multiple times.
|
|
|
|
python3 check_header_duplicate.py ../../
|
|
|
|
Now build the code to find duplicate errors, resolve them manually.
|
|
|
|
Then restore the headers to their original state:
|
|
|
|
python3 check_header_duplicate.py --restore ../../
|
|
"""
|
|
|
|
# Use GCC's __INCLUDE_LEVEL__ to find direct duplicate includes
|
|
|
|
UUID = 0
|
|
|
|
|
|
def source_filepath_guard(filepath):
|
|
global UUID
|
|
|
|
footer = """
|
|
#if __INCLUDE_LEVEL__ == 1
|
|
# ifdef _DOUBLEHEADERGUARD_%d
|
|
# error "duplicate header!"
|
|
# endif
|
|
#endif
|
|
|
|
#if __INCLUDE_LEVEL__ == 1
|
|
# define _DOUBLEHEADERGUARD_%d
|
|
#endif
|
|
""" % (UUID, UUID)
|
|
UUID += 1
|
|
|
|
with open(filepath, 'a', encoding='utf-8') as f:
|
|
f.write(footer)
|
|
|
|
|
|
def source_filepath_restore(filepath):
|
|
import os
|
|
os.system("git co %s" % filepath)
|
|
|
|
|
|
def scan_source_recursive(dirpath, is_restore):
|
|
import os
|
|
from os.path import join, splitext
|
|
|
|
# ensure git working dir is ok
|
|
os.chdir(dirpath)
|
|
|
|
def source_list(path, filename_check=None):
|
|
for dirpath, dirnames, filenames in os.walk(path):
|
|
# skip '.git'
|
|
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
|
|
|
|
for filename in filenames:
|
|
filepath = join(dirpath, filename)
|
|
if filename_check is None or filename_check(filepath):
|
|
yield filepath
|
|
|
|
def is_source(filename):
|
|
ext = splitext(filename)[1]
|
|
return (ext in {".hpp", ".hxx", ".h", ".hh"})
|
|
|
|
def is_ignore(filename):
|
|
pass
|
|
|
|
for filepath in sorted(source_list(dirpath, is_source)):
|
|
print("file:", filepath)
|
|
if is_ignore(filepath):
|
|
continue
|
|
|
|
if is_restore:
|
|
source_filepath_restore(filepath)
|
|
else:
|
|
source_filepath_guard(filepath)
|
|
|
|
|
|
def main():
|
|
import sys
|
|
is_restore = ("--restore" in sys.argv[1:])
|
|
scan_source_recursive(sys.argv[-1], is_restore)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|