forked from blender/blender
Sergey Sharybin
03806d0b67
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
87 lines
2.0 KiB
Python
Executable File
87 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import os
|
|
from os.path import join
|
|
|
|
from trailing_space_clean_config import PATHS
|
|
|
|
SOURCE_EXT = (
|
|
# C/C++
|
|
".c", ".h", ".cpp", ".hpp", ".cc", ".hh", ".cxx", ".hxx", ".inl",
|
|
# Objective C
|
|
".m", ".mm",
|
|
# GLSL
|
|
".glsl",
|
|
# Python
|
|
".py",
|
|
# Text (also CMake)
|
|
".txt", ".cmake", ".rst",
|
|
# MS-Windows Scripts.
|
|
".bat", ".cmd",
|
|
)
|
|
|
|
|
|
def is_source(filename):
|
|
return filename.endswith(SOURCE_EXT)
|
|
|
|
|
|
def path_iter(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:
|
|
if filename.startswith("."):
|
|
continue
|
|
filepath = join(dirpath, filename)
|
|
if filename_check is None or filename_check(filepath):
|
|
yield filepath
|
|
|
|
|
|
def path_expand(paths, filename_check=None):
|
|
for f in paths:
|
|
if not os.path.exists(f):
|
|
print("Missing:", f)
|
|
elif os.path.isdir(f):
|
|
yield from path_iter(f, filename_check)
|
|
else:
|
|
yield f
|
|
|
|
|
|
def rstrip_file(filename):
|
|
reports = []
|
|
with open(filename, "r", encoding="utf-8") as fh:
|
|
data_src = fh.read()
|
|
|
|
# Strip trailing space.
|
|
data_dst = []
|
|
for l in data_src.rstrip().splitlines(True):
|
|
data_dst.append(l.rstrip() + "\n")
|
|
|
|
data_dst = "".join(data_dst)
|
|
|
|
# Remove BOM.
|
|
if data_dst and (data_dst[0] == '\ufeff'):
|
|
data_dst = data_dst[1:]
|
|
|
|
len_strip = len(data_src) - len(data_dst)
|
|
if len_strip != 0:
|
|
reports.append("STRIP=%d" % len_strip)
|
|
|
|
if len_strip:
|
|
with open(filename, "w", encoding="utf-8") as fh:
|
|
fh.write(data_dst)
|
|
return tuple(reports)
|
|
|
|
|
|
def main():
|
|
for f in path_expand(PATHS, is_source):
|
|
report = rstrip_file(f)
|
|
if report:
|
|
print("Strip (%s): %s" % (', '.join(report), f))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|