msxbuild/lib/make/ᐊᑐᕐᓗᒍ/mb_os.mk

111 lines
3.8 KiB
Makefile
Raw Normal View History

2024-07-05 22:11:54 +00:00
# OS cmds
MB_OS_RM ?= rm -f
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable_rock,MB_OS_RM,"Native OS delete command.")
MB_OS_RMDIR ?= rm -rf
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable_rock,MB_OS_RMDIR,"Native OS remove folder command.")
MB_OS_MKDIR ?= mkdir -p
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable_rock,MB_OS_MKDIR,"Native OS create folder command.")
MB_OS_COPY ?= cp
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable_rock,MB_OS_COPY,"Native OS copy command.")
MB_OS_STDOUT_IGNORE ?= >/dev/null
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable_rock,MB_OS_STDOUT_IGNORE,"Native OS ignore stdout.")
MB_OS_STDERR_IGNORE ?= 2>/dev/null
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable_rock,MB_OS_STDERR_IGNORE,"Native OS ignore stderr.")
MB_OS_SEP ?=/
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable_rock,MB_OS_SEP,"Native OS path seperator.")
MB_OS_CACHE ?= ~/.cache
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_variable_rock,MB_OS_CACHE,"Native OS application cache folder.")
2024-07-10 14:24:46 +00:00
MB_OS_TERM_COLORS ?= $(shell tput colors 2> /dev/null;test $$? -eq 0 || echo "-1")
$(call mb_make_call,mb_doc_variable_rock,MB_OS_TERM_COLORS,"Native OS terminal color count support.")
2024-07-05 22:11:54 +00:00
ifdef OS
ifeq ($(OS),Windows_NT)
$(MB__    )MB_OS_RM ?= del /F /Q
$(MB__    )MB_OS_RMDIR ?= RMDIR /S /Q
$(MB__    )MB_OS_MKDIR ?= mkdir
$(MB__    )MB_OS_COPY ?= copy
$(MB__    )MB_OS_STDOUT_IGNORE ?= >NUL
$(MB__    )MB_OS_STDERR_IGNORE ?= 2>NUL || true
$(MB__    )MB_OS_SEP ?=\
$(MB__    )MB_OS_CACHE ?= %LOCALAPPDATA%
$(MB__    )MB_OS_TERM_COLORS ?= -1
endif
endif
define mb_os_dir_delete
$(MB__    )$(MB_OS_RMDIR) $(1)
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_os_dir_delete,"Delete the full folder.","<dir>")
define mb_os_dir_create
$(MB__    )$(MB_OS_MKDIR) $(1)
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_os_dir_create,"Creates an folder.","<dir>")
define mb_os_file_delete
$(MB__    )$(MB_OS_RM) $(1)
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_os_file_delete,"Deletes an file.","<file>")
define mb_os_file_copy
$(MB__    )$(MB_OS_COPY) $(1) $(2)
endef
2024-07-07 18:53:06 +00:00
$(call mb_make_call,mb_doc_function,mb_os_file_copy,"Copy an file.","<in> <out>")
2024-07-10 14:24:46 +00:00
define mb_os_crayon_tagged_echo
$(MB__    )$(if $(filter -1,$(MB_OS_TERM_COLORS)),@echo $(MB_I18N_OS_CRAYON_TAG) $(2),@echo -e "\x1B[$(1)m$(MB_I18N_OS_CRAYON_TAG)\x1B[39m $(2)")
endef
2024-07-10 14:24:46 +00:00
$(call mb_make_call,mb_doc_function_deep,mb_os_crayon_tagged_echo,"Echo's an prefixed message to stdout with ansi color code.","<color-code> <message>")
define mb_os_echo_fail
2024-07-10 14:24:46 +00:00
$(MB__    )$(call mb_make_call,mb_os_crayon_tagged_echo,31,$(1))
endef
$(call mb_make_call,mb_doc_function_deep,mb_os_echo_fail,"Echo's an message to stdout with 'red' crayon.","<message>")
define mb_os_echo_good
2024-07-10 14:24:46 +00:00
$(MB__    )$(call mb_make_call,mb_os_crayon_tagged_echo,32,$(1))
endef
$(call mb_make_call,mb_doc_function_deep,mb_os_echo_good,"Echo's an message to stdout with 'green' crayon.","<message>")
define mb_os_echo_assert
2024-07-10 14:24:46 +00:00
$(MB__    )$(call mb_make_call,mb_os_crayon_tagged_echo,33,$(1))
endef
$(call mb_make_call,mb_doc_function_deep,mb_os_echo_assert,"Echo's an message to stdout with 'yellow' crayon.","<message>")
define mb_os_echo_command
2024-07-10 14:24:46 +00:00
$(MB__    )$(call mb_make_call,mb_os_crayon_tagged_echo,34,$(1))
endef
$(call mb_make_call,mb_doc_function_deep,mb_os_echo_command,"Echo's an message to stdout with 'blue' crayon.","<message>")
define mb_os_echo_phase
2024-07-10 14:24:46 +00:00
$(MB__    )$(call mb_make_call,mb_os_crayon_tagged_echo,35,$(1))
endef
$(call mb_make_call,mb_doc_function_deep,mb_os_echo_phase,"Echo's an message to stdout with 'magenta' crayon.","<message>")
define mb_os_echo_alert
2024-07-10 14:24:46 +00:00
$(MB__    )$(call mb_make_call,mb_os_crayon_tagged_echo,36,$(1))
endef
2024-07-10 14:10:18 +00:00
$(call mb_make_call,mb_doc_function_deep,mb_os_echo_alert,"Echo's an message to stdout with 'cyan' crayon.","<message>")