mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
Build: Embed application icons directly in the executables.
New serenity_app() targets can be defined which allows application icons to be emedded directly into the executable. The embedded icons will then be used when creating an icon for that file in LibGUI.
This commit is contained in:
parent
d16eabed06
commit
39364bdda4
Notes:
sideshowbarker
2024-07-19 17:30:55 +09:00
Author: https://github.com/lux01 Commit: https://github.com/SerenityOS/serenity/commit/39364bdda43 Pull-request: https://github.com/SerenityOS/serenity/pull/4470
39 changed files with 94 additions and 37 deletions
|
@ -15,5 +15,5 @@ set(SOURCES
|
|||
TabGML.h
|
||||
)
|
||||
|
||||
serenity_bin(Browser)
|
||||
serenity_app(Browser ICON app-browser)
|
||||
target_link_libraries(Browser LibWeb LibProtocol LibGUI LibDesktop)
|
||||
|
|
|
@ -5,5 +5,5 @@ set(SOURCES
|
|||
Keypad.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Calculator)
|
||||
serenity_app(Calculator ICON app-calculator)
|
||||
target_link_libraries(Calculator LibGUI)
|
||||
|
|
|
@ -3,5 +3,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Calendar)
|
||||
serenity_app(Calendar ICON app-calendar)
|
||||
target_link_libraries(Calendar LibGUI)
|
||||
|
|
|
@ -4,5 +4,5 @@ set(SOURCES
|
|||
MonitorWidget.cpp
|
||||
)
|
||||
|
||||
serenity_bin(DisplaySettings)
|
||||
serenity_app(DisplaySettings ICON app-display-settings)
|
||||
target_link_libraries(DisplaySettings LibGUI)
|
||||
|
|
|
@ -9,5 +9,5 @@ set(SOURCES
|
|||
PropertiesDialog.cpp
|
||||
)
|
||||
|
||||
serenity_bin(FileManager)
|
||||
serenity_app(FileManager ICON filetype-folder)
|
||||
target_link_libraries(FileManager LibGUI LibDesktop)
|
||||
|
|
|
@ -7,5 +7,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(FontEditor)
|
||||
serenity_app(FontEditor ICON app-font-editor)
|
||||
target_link_libraries(FontEditor LibGUI LibGfx)
|
||||
|
|
|
@ -6,5 +6,5 @@ set(SOURCES
|
|||
ManualSectionNode.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Help)
|
||||
serenity_app(Help ICON app-help)
|
||||
target_link_libraries(Help LibWeb LibMarkdown LibGUI LibDesktop)
|
||||
|
|
|
@ -4,5 +4,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(HexEditor)
|
||||
serenity_app(HexEditor ICON app-hexeditor)
|
||||
target_link_libraries(HexEditor LibGUI)
|
||||
|
|
|
@ -10,5 +10,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(IRCClient)
|
||||
serenity_app(IRCClient ICON app-irc-client)
|
||||
target_link_libraries(IRCClient LibWeb LibGUI)
|
||||
|
|
|
@ -2,5 +2,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(KeyboardSettings)
|
||||
serenity_app(KeyboardSettings ICON app-keyboard-settings)
|
||||
target_link_libraries(KeyboardSettings LibGUI LibKeyboard)
|
||||
|
|
|
@ -10,5 +10,5 @@ set(SOURCES
|
|||
WaveWidget.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Piano)
|
||||
serenity_app(Piano ICON app-piano)
|
||||
target_link_libraries(Piano LibAudio LibGUI)
|
||||
|
|
|
@ -23,5 +23,5 @@ set(SOURCES
|
|||
Tool.cpp
|
||||
)
|
||||
|
||||
serenity_bin(PixelPaint)
|
||||
serenity_app(PixelPaint ICON app-pixel-paint)
|
||||
target_link_libraries(PixelPaint LibGUI LibGfx)
|
||||
|
|
|
@ -3,5 +3,5 @@ set(SOURCES
|
|||
QSWidget.cpp
|
||||
)
|
||||
|
||||
serenity_bin(QuickShow)
|
||||
serenity_app(QuickShow ICON filetype-image)
|
||||
target_link_libraries(QuickShow LibGUI LibGfx)
|
||||
|
|
|
@ -5,5 +5,5 @@ set(SOURCES
|
|||
SoundPlayerWidget.cpp
|
||||
)
|
||||
|
||||
serenity_bin(SoundPlayer)
|
||||
serenity_app(SoundPlayer ICON app-sound-player)
|
||||
target_link_libraries(SoundPlayer LibAudio LibGUI)
|
||||
|
|
|
@ -24,5 +24,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Spreadsheet)
|
||||
serenity_app(Spreadsheet ICON app-spreadsheet)
|
||||
target_link_libraries(Spreadsheet LibGUI LibJS LibWeb)
|
||||
|
|
|
@ -12,5 +12,5 @@ set(SOURCES
|
|||
ThreadStackWidget.cpp
|
||||
)
|
||||
|
||||
serenity_bin(SystemMonitor)
|
||||
serenity_app(SystemMonitor ICON app-system-monitor)
|
||||
target_link_libraries(SystemMonitor LibGUI LibPCIDB)
|
||||
|
|
|
@ -2,5 +2,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Terminal)
|
||||
serenity_app(Terminal ICON app-terminal)
|
||||
target_link_libraries(Terminal LibGUI LibVT)
|
||||
|
|
|
@ -6,5 +6,5 @@ set(SOURCES
|
|||
MainWindowGML.h
|
||||
)
|
||||
|
||||
serenity_bin(TextEditor)
|
||||
serenity_app(TextEditor ICON app-text-editor)
|
||||
target_link_libraries(TextEditor LibWeb LibMarkdown LibGUI LibShell LibRegex LibDesktop)
|
||||
|
|
|
@ -3,5 +3,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(ThemeEditor)
|
||||
serenity_app(ThemeEditor ICON app-theme-editor)
|
||||
target_link_libraries(ThemeEditor LibGUI)
|
||||
|
|
|
@ -164,6 +164,23 @@ function(serenity_bin target_name)
|
|||
serenity_generated_sources(${target_name})
|
||||
endfunction()
|
||||
|
||||
function(serenity_app target_name)
|
||||
cmake_parse_arguments(SERENITY_APP "" "ICON" "" ${ARGN})
|
||||
|
||||
serenity_bin("${target_name}")
|
||||
set(small_icon "${CMAKE_SOURCE_DIR}/Base/res/icons/16x16/${SERENITY_APP_ICON}.png")
|
||||
set(medium_icon "${CMAKE_SOURCE_DIR}/Base/res/icons/32x32/${SERENITY_APP_ICON}.png")
|
||||
|
||||
if (EXISTS "${small_icon}")
|
||||
embed_resource("${target_name}" serenity_icon_s "${small_icon}")
|
||||
endif()
|
||||
if (EXISTS "${medium_icon}")
|
||||
embed_resource("${target_name}" serenity_icon_m "${medium_icon}")
|
||||
endif()
|
||||
|
||||
# TODO: Issue warnings if the app icons don't exist
|
||||
endfunction()
|
||||
|
||||
function(compile_gml source output string_name)
|
||||
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
|
||||
add_custom_command(
|
||||
|
@ -191,6 +208,19 @@ function(compile_ipc source output)
|
|||
add_custom_target(generate_${output_name} DEPENDS ${output})
|
||||
endfunction()
|
||||
|
||||
function(embed_resource target section file)
|
||||
get_filename_component(asm_file "${file}" NAME)
|
||||
set(asm_file "${CMAKE_CURRENT_BINARY_DIR}/${target}-${section}.s")
|
||||
get_filename_component(input_file "${file}" ABSOLUTE)
|
||||
add_custom_command(
|
||||
OUTPUT "${asm_file}"
|
||||
COMMAND "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh" "${asm_file}" "${section}" "${input_file}"
|
||||
DEPENDS "${input_file}" "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh"
|
||||
COMMENT "Generating ${asm_file}"
|
||||
)
|
||||
target_sources("${target}" PRIVATE "${asm_file}")
|
||||
endfunction()
|
||||
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if(CCACHE_PROGRAM)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
|
||||
|
|
|
@ -2,5 +2,5 @@ set(SOURCES
|
|||
Cube.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Cube)
|
||||
serenity_app(Cube ICON app-cube)
|
||||
target_link_libraries(Cube LibGUI)
|
||||
|
|
|
@ -3,5 +3,5 @@ set(SOURCES
|
|||
EyesWidget.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Eyes)
|
||||
serenity_app(Eyes ICON app-eyes)
|
||||
target_link_libraries(Eyes LibGUI LibGfx)
|
||||
|
|
|
@ -2,5 +2,5 @@ set(SOURCES
|
|||
Fire.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Fire)
|
||||
serenity_app(Fire ICON app-fire)
|
||||
target_link_libraries(Fire LibGUI LibCore LibGfx)
|
||||
|
|
|
@ -2,5 +2,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(HelloWorld)
|
||||
serenity_app(HelloWorld ICON app-hello-world)
|
||||
target_link_libraries(HelloWorld LibGUI)
|
||||
|
|
|
@ -2,5 +2,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(LibGfxDemo)
|
||||
serenity_app(LibGfxDemo ICON app-libgfx-demo)
|
||||
target_link_libraries(LibGfxDemo LibGUI LibIPC LibGfx LibCore)
|
||||
|
|
|
@ -2,5 +2,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Mouse)
|
||||
serenity_app(Mouse ICON app-mouse)
|
||||
target_link_libraries(Mouse LibGUI LibGfx)
|
||||
|
|
|
@ -2,5 +2,5 @@ set(SOURCES
|
|||
Screensaver.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Screensaver)
|
||||
serenity_app(Screensaver ICON app-screensaver)
|
||||
target_link_libraries(Screensaver LibGUI LibCore LibGfx)
|
||||
|
|
|
@ -2,5 +2,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(WidgetGallery)
|
||||
serenity_app(WidgetGallery ICON app-widget-gallery)
|
||||
target_link_libraries(WidgetGallery LibGUI)
|
||||
|
|
|
@ -33,6 +33,6 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(HackStudio)
|
||||
serenity_app(HackStudio ICON app-hack-studio)
|
||||
target_link_libraries(HackStudio LibWeb LibMarkdown LibGUI LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell)
|
||||
add_dependencies(HackStudio CppLanguageServer)
|
||||
|
|
|
@ -6,5 +6,5 @@ set(SOURCES
|
|||
RemoteProcess.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Inspector)
|
||||
serenity_app(Inspector ICON app-inspector)
|
||||
target_link_libraries(Inspector LibGUI)
|
||||
|
|
|
@ -6,5 +6,5 @@ set(SOURCES
|
|||
ProfileTimelineWidget.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Profiler)
|
||||
serenity_app(Profiler ICON app-profiler)
|
||||
target_link_libraries(Profiler LibGUI LibX86 LibCoreDump)
|
||||
|
|
|
@ -5,5 +5,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(2048)
|
||||
serenity_app(2048 ICON app-2048)
|
||||
target_link_libraries(2048 LibGUI)
|
||||
|
|
|
@ -4,5 +4,5 @@ set(SOURCES
|
|||
LevelSelectDialog.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Breakout)
|
||||
serenity_app(Breakout ICON app-breakout)
|
||||
target_link_libraries(Breakout LibGUI)
|
||||
|
|
|
@ -5,5 +5,5 @@ set(SOURCES
|
|||
Engine.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Chess)
|
||||
serenity_app(Chess ICON app-chess)
|
||||
target_link_libraries(Chess LibChess LibGUI LibCore)
|
||||
|
|
|
@ -3,5 +3,5 @@ set(SOURCES
|
|||
main.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Minesweeper)
|
||||
serenity_app(Minesweeper ICON app-minesweeper)
|
||||
target_link_libraries(Minesweeper LibGUI)
|
||||
|
|
|
@ -3,5 +3,5 @@ set(SOURCES
|
|||
Game.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Pong)
|
||||
serenity_app(Pong ICON app-pong)
|
||||
target_link_libraries(Pong LibGUI)
|
||||
|
|
|
@ -3,5 +3,5 @@ set(SOURCES
|
|||
SnakeGame.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Snake)
|
||||
serenity_app(Snake ICON app-snake)
|
||||
target_link_libraries(Snake LibGUI)
|
||||
|
|
|
@ -5,5 +5,5 @@ set(SOURCES
|
|||
SolitaireWidget.cpp
|
||||
)
|
||||
|
||||
serenity_bin(Solitaire)
|
||||
serenity_app(Solitaire ICON app-solitaire)
|
||||
target_link_libraries(Solitaire LibGUI LibGfx LibCore)
|
||||
|
|
27
Meta/generate-embedded-resource-assembly.sh
Executable file
27
Meta/generate-embedded-resource-assembly.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "ERROR: No output file specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OUTPUT_FILE="$1"
|
||||
shift
|
||||
|
||||
rm -f "${OUTPUT_FILE}"
|
||||
|
||||
while (( "$#" >= 2)); do
|
||||
SECTION_NAME="$1"
|
||||
INPUT_FILE="$2"
|
||||
|
||||
{
|
||||
printf ' .section %s\n' "${SECTION_NAME}"
|
||||
printf ' .type %s, @object\n' "${SECTION_NAME}"
|
||||
printf ' .align 4\n'
|
||||
printf ' .incbin "%s"\n' "${INPUT_FILE}"
|
||||
printf '\n'
|
||||
} >> "${OUTPUT_FILE}"
|
||||
shift 2
|
||||
done
|
Loading…
Reference in a new issue