Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-04-25 10:24:54 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-04-25 10:24:54 +0300
commit2fe35914e17d6173925be06c61974479666b9ef7 (patch)
tree418463b00ca4dcb2465329a8283fe85090a19c27 /release/datafiles/blender_icons_geom_update.py
parent4d6cdb8b897861679e94aa28e9b193255e2c3f5a (diff)
CMake: generate icon list for installation
MSVC users weren't getting icons installed, since glob isn't reliable, list all files in a section which the update script maintains.
Diffstat (limited to 'release/datafiles/blender_icons_geom_update.py')
-rwxr-xr-xrelease/datafiles/blender_icons_geom_update.py54
1 files changed, 52 insertions, 2 deletions
diff --git a/release/datafiles/blender_icons_geom_update.py b/release/datafiles/blender_icons_geom_update.py
index 1671067664e..fac45c77b89 100755
--- a/release/datafiles/blender_icons_geom_update.py
+++ b/release/datafiles/blender_icons_geom_update.py
@@ -4,9 +4,32 @@
import os
import subprocess
+
def run(cmd):
print(" ", " ".join(cmd))
- subprocess.check_call(cmd)
+ # Don't use check_call because asan causes nonzero exitcode :S
+ subprocess.call(cmd)
+
+
+def edit_text_file(filename, marker_begin, marker_end, content):
+ with open(filename, 'r', encoding='utf-8') as f:
+ data = f.read()
+ marker_begin_index = data.find(marker_begin)
+ marker_end_index = data.find(marker_end, marker_begin_index)
+ # include indentation of marker
+ while data[marker_end_index - 1] in {'\t', ' '}:
+ marker_end_index -= 1
+ if marker_begin_index == -1:
+ print('Error: {!r} not found'.format(marker_begin))
+ return
+ if marker_end_index == -1:
+ print('Error: {!r} not found'.format(marker_end))
+ return
+ marker_begin_index += len(marker_begin) + 1
+ data_update = data[:marker_begin_index] + content + data[marker_end_index:]
+ with open(filename, 'w', encoding='utf-8') as f:
+ f.write(data_update)
+
BASEDIR = os.path.abspath(os.path.dirname(__file__))
ROOTDIR = os.path.normpath(os.path.join(BASEDIR, "..", ".."))
@@ -19,14 +42,41 @@ icons_blend = (
os.path.join(ROOTDIR, "..", "lib", "resources", "icon_geom.blend"),
)
+
+def names_and_time_from_path(path):
+ for entry in os.scandir(path):
+ name = entry.name
+ if name.endswith(".dat"):
+ yield (name, entry.stat().st_mtime)
+
+
+# Collect icons files and update CMake.
+icon_files = []
+
# create .dat geometry (which are stored in git)
for blend in icons_blend:
+ output_dir = os.path.join(BASEDIR, "icons")
+ files_old = set(names_and_time_from_path(output_dir))
cmd = (
blender_bin, "--background", "--factory-startup", "-noaudio",
blend,
"--python", os.path.join(BASEDIR, "blender_icons_geom.py"),
"--",
"--group", "Export",
- "--output-dir", os.path.join(BASEDIR, "icons"),
+ "--output-dir", output_dir,
)
run(cmd)
+ files_new = set(names_and_time_from_path(output_dir))
+
+ icon_files.extend([
+ name[:-4] # no .dat
+ for (name, _) in sorted((files_new - files_old))
+ ])
+
+
+edit_text_file(
+ os.path.join(ROOTDIR, "source", "blender", "editors", "datafiles", "CMakeLists.txt"),
+ "# BEGIN ICON_GEOM_NAMES",
+ "# END ICON_GEOM_NAMES",
+ "\t" + "\n\t".join(icon_files) + "\n",
+)