Mercurial > molko
changeset 305:3675021fa6e5
make: add fakeroot support
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 27 Jun 2021 17:07:37 +0200 |
parents | 3ccf841ca1fe |
children | 6a7bca547f9a |
files | .hgignore GNUmakefile INSTALL.md doc/scripts/cmake-extract.sh libmlk-data/CMakeLists.txt |
diffstat | 5 files changed, 60 insertions(+), 156 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Thu Jun 24 22:35:02 2021 +0200 +++ b/.hgignore Sun Jun 27 17:07:37 2021 +0200 @@ -7,10 +7,14 @@ assets/.*\.h$ ^config\.h$ +# fakeroot directory. +^fakeroot + # vim/emacs specific. ^tags$ -^tags.lock$ -^tags.temp$ +^tags\.lock$ +^tags\.temp$ +^cscope\.out$ \.swp$ \.swo$
--- a/GNUmakefile Thu Jun 24 22:35:02 2021 +0200 +++ b/GNUmakefile Sun Jun 27 17:07:37 2021 +0200 @@ -202,16 +202,20 @@ tests/test-tileset \ tests/test-util -TARGETS= ${LIBMLK_ADVENTURE} \ +LIBRARIES= ${LIBMLK_ADVENTURE} \ ${LIBMLK_CORE} \ ${LIBMLK_RPG} \ ${LIBMLK_SQLITE} \ - ${LIBMLK_UI} \ - ${MLK_ADVENTURE} \ - ${MLK_BCC} \ + ${LIBMLK_UI} + +TOOLS= ${MLK_BCC} \ ${MLK_MAP} \ ${MLK_TILESET} +PROGS= ${MLK_ADVENTURE} + +TARGETS:= ${LIBRARIES} ${PROGS} + SDL2_INCS:= $(shell pkg-config --cflags sdl2 SDL2_mixer SDL2_ttf SDL2_image) SDL2_LIBS:= $(shell pkg-config --libs sdl2 SDL2_mixer SDL2_ttf SDL2_image) @@ -438,4 +442,24 @@ # }}} -.PHONY: all clean examples tests +# {{{ fakeroot + +fakeroot: + mkdir -p fakeroot + mkdir -p fakeroot/bin + mkdir -p fakeroot/share/mlk-adventure + cp ${PROGS} fakeroot/bin + for e in ${EXAMPLES}; do cp $$e fakeroot/bin/$$(basename $$(dirname $$e)); done + rsync -a libmlk-data/ fakeroot/share/mlk-adventure + +# }}} + +# {{{ meta targets + +tools: ${TOOLS} + +everything: ${TARGETS} ${TESTS} ${EXAMPLES} + +# }}} + +.PHONY: all clean examples everything fakeroot tests tools
--- a/INSTALL.md Thu Jun 24 22:35:02 2021 +0200 +++ b/INSTALL.md Sun Jun 27 17:07:37 2021 +0200 @@ -28,10 +28,31 @@ Available general make targets: -- `all`: (default): build only molko, -- `tools`: build tools (e.g. molko-map), -- `tests`: build tests and run them, +- `all`: (default): build only molko. +- `tools`: build tools (e.g. molko-map). +- `tests`: build tests and run them. - `everything`: build molko, tools and tests without running them. +- `fakeroot`: create a runnable local directory. + +Direct use in source tree +------------------------- + +Examples and `mlk-adventure` executable searches for data into a specific +directory, when building those are not already discoverable because targets are +not already installed. + +It's still possible to build a fakeroot directory to run examples and +`mlk-adventure` without installing. To do this you simply need to use `fakeroot` +target. + +Note: you need rsync installed, in contrast to `install` with a `DESTDIR` + macro it only copies runtime data and avoid re-copying what didn't + change for a faster experience. + + $ make all examples + $ ./fakeroot/bin/mlk-adventure + (or) + $ ./fakeroot/bin/example-action Platform: Windows ----------------- @@ -51,7 +72,7 @@ - *mingw-w64-x86_64-SDL2_image* - *mingw-w64-x86_64-SDL2_mixer* - *mingw-w64-x86_64-SDL2_ttf* -- *mingw-w64-x86_64-jansson* (only for molko-map tool) +- *mingw-w64-x86_64-jansson* (only for mlk-map/mlk-tileset tools) Note: replace `x86_64` with `i686` if you have a deprecated system or if you have issues while debugging (MinGW-w64 and/or gdb have known issues in
--- a/doc/scripts/cmake-extract.sh Thu Jun 24 22:35:02 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -#!/bin/sh -# -# cmake-extract.sh -- extract documentation from CMake headers -# -# CMakeLists.txt -- CMake build system for molko -# -# Copyright (c) 2020 David Demelier <markand@malikania.fr> -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -prog=$(basename $0) - -usage() -{ - printf "usage: $prog cmake-file\n" 1>&2 - exit 1 -} - -if [ $# -ne 1 ]; then - usage -fi - -# -# Remove ISC license header then every grep every lines that start with a # -# and finally remove them. -# - -sed -e "1,19d" "$1" | grep '^#' | sed -e "s/^# *//"
--- a/libmlk-data/CMakeLists.txt Thu Jun 24 22:35:02 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -# -# CMakeLists.txt -- CMake build system for molko -# -# Copyright (c) 2020 David Demelier <markand@malikania.fr> -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# - -project(libmlk-data) - -# -# The following projects use the data: -# -# - examples, -# - libmlk-adventure (implies mlk-adventure), -# - tests. -# - -set( - DIRECTORIES - fonts - images - maps - music - sounds - sprites -) - -# Directories to not link but create instead (for converting files). -set(NO_LINK maps) - -set( - MAPS - ${libmlk-data_SOURCE_DIR}/maps/map-world.json -) - -set( - TILESETS - ${libmlk-data_SOURCE_DIR}/maps/tileset-world.json -) - -if (NOT IS_ABSOLUTE ${CMAKE_INSTALL_DATADIR}) - set(directories) - - foreach (d ${DIRECTORIES}) - set(outputdir ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CMAKE_INSTALL_DATADIR}/mlk-adventure) - - # If no link, copy the whole directory instead. - if (${d} IN_LIST NO_LINK) - add_custom_command( - OUTPUT ${outputdir}/${d} - COMMENT "Copying data ${d} to binary directory ${outputdir}" - VERBATIM - DEPENDS ${libmlk-data_SOURCE_DIR}/${d} - COMMAND - ${CMAKE_COMMAND} -E copy_directory ${libmlk-data_SOURCE_DIR}/${d} ${outputdir}/${d} - ) - else () - - add_custom_command( - OUTPUT ${outputdir}/${d} - COMMENT "Linking data ${d} to binary directory ${outputdir}" - VERBATIM - DEPENDS ${libmlk-data_SOURCE_DIR}/${d} - COMMAND - ${CMAKE_COMMAND} -E make_directory ${outputdir} - COMMAND - ${CMAKE_COMMAND} -E create_symlink ${libmlk-data_SOURCE_DIR}/${d} ${outputdir}/${d} - ) - endif () - - list(APPEND directories ${outputdir}/${d}) - endforeach () -endif () - -foreach (d ${DIRECTORIES}) - install( - DIRECTORY ${libmlk-data_SOURCE_DIR}/${d} - DESTINATION ${CMAKE_INSTALL_DATADIR}/mlk-adventure - PATTERN REGEX "\\.(json|xcf)$" EXCLUDE - ) -endforeach () - -# Convert maps and tilesets too. -molko_build_maps( - OUTPUT_DIR mlk-adventure/maps - OUTPUTS objects - MAPS ${MAPS} - TILESETS ${TILESETS} -) - -molko_define_library( - TARGET libmlk-data - TYPE INTERFACE - SOURCES ${directories} ${objects} -)