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.
This commit is contained in:
@@ -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",
|
||||
)
|
||||
|
@@ -525,6 +525,52 @@ set(ICON_NAMES
|
||||
imagefile
|
||||
)
|
||||
|
||||
# This section is maintained by the updating script, keep BEGIN/END comments.
|
||||
set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
|
||||
# BEGIN ICON_GEOM_NAMES
|
||||
ops.armature.extrude.cursor
|
||||
ops.armature.extrude
|
||||
ops.generic.cursor
|
||||
ops.generic.select_border
|
||||
ops.generic.select_circle
|
||||
ops.generic.select_lasso
|
||||
ops.gpencil.draw
|
||||
ops.gpencil.draw.eraser
|
||||
ops.gpencil.draw.line
|
||||
ops.gpencil.draw.poly
|
||||
ops.mesh.bisect
|
||||
ops.mesh.inset
|
||||
ops.mesh.knife_tool
|
||||
ops.mesh.loopcut_slide
|
||||
ops.mesh.offset_edge_loops_slide
|
||||
ops.mesh.polybuild_hover
|
||||
ops.mesh.rip
|
||||
ops.mesh.rip_edge
|
||||
ops.mesh.spin
|
||||
ops.mesh.spin.duplicate
|
||||
ops.mesh.vertices_smooth
|
||||
ops.particle.brush_edit.add
|
||||
ops.particle.brush_edit.comb
|
||||
ops.particle.brush_edit.comb.weight
|
||||
ops.particle.brush_edit.cut
|
||||
ops.particle.brush_edit.length
|
||||
ops.particle.brush_edit.puff
|
||||
ops.particle.brush_edit.smooth
|
||||
ops.transform.edge_slide
|
||||
ops.transform.push_pull
|
||||
ops.transform.resize.cage
|
||||
ops.transform.resize
|
||||
ops.transform.rotate
|
||||
ops.transform.shrink_fatten
|
||||
ops.transform.translate
|
||||
ops.transform.vert_slide
|
||||
ops.transform.vertex_random
|
||||
ops.view3d.edit_mesh_extrude
|
||||
ops.view3d.edit_mesh_extrude_individual
|
||||
ops.view3d.ruler
|
||||
# END ICON_GEOM_NAMES
|
||||
)
|
||||
|
||||
data_to_c_simple(../../../../release/datafiles/bfont.pfb SRC)
|
||||
data_to_c_simple(../../../../release/datafiles/bfont.ttf SRC)
|
||||
data_to_c_simple(../../../../release/datafiles/bmonofont.ttf SRC)
|
||||
|
@@ -958,12 +958,27 @@ delayed_do_install(${TARGETDIR_VER})
|
||||
unset(BLENDER_TEXT_FILES)
|
||||
unset(BLENDER_TEXT_FILES_DESTINATION)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Geometry Icons
|
||||
|
||||
# Geometry icons.
|
||||
install(
|
||||
DIRECTORY
|
||||
${CMAKE_SOURCE_DIR}/release/datafiles/icons
|
||||
DESTINATION ${TARGETDIR_VER}/datafiles
|
||||
get_property(_icon_names GLOBAL PROPERTY ICON_GEOM_NAMES)
|
||||
set(_icon_files)
|
||||
foreach(_f ${_icon_names})
|
||||
list(APPEND _icon_files
|
||||
"${CMAKE_SOURCE_DIR}/release/datafiles/icons/${_f}.dat"
|
||||
)
|
||||
endforeach()
|
||||
install(
|
||||
FILES ${_icon_files}
|
||||
DESTINATION ${TARGETDIR_VER}/datafiles/icons
|
||||
)
|
||||
|
||||
unset(_icon_names)
|
||||
unset(_icon_files)
|
||||
unset(_f)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Setup link libs
|
||||
|
Reference in New Issue
Block a user