1#!/usr/bin/env omake 2#---------------------------------------------------------------------------- 3# Project: Horizon 4# File: commondefs.archiver.om 5# 6# Copyright 2007-2009 Nintendo. All rights reserved. 7# 8# These coded instructions, statements, and computer programs contain 9# proprietary information of Nintendo of America Inc. and/or Nintendo 10# Company Ltd., and are protected by Federal copyright law. They may 11# not be disclosed to third parties or copied or duplicated in any form, 12# in whole or in part, without the prior written consent of Nintendo. 13# 14# $Date:: 2010-04-07#$ 15# $Rev: 13736 $ 16# $Author: hatamoto_minoru $ 17#---------------------------------------------------------------------------- 18 19declare public.UNZIP 20declare public.7ZIP 21declare public.RUBY 22 23.STATIC: 24 7ZIP = 25 try 26 7ZIP = $(get-registry HKEY_LOCAL_MACHINE, SOFTWARE\\7-Zip, Path)$(DIRSEP)7z.exe 27 export 28 default 29 30.STATIC: 31 UNZIP = 32 if $(CheckProg_ unzip) 33 UNZIP = $(nth 0,$(where unzip)) 34 export 35 36.STATIC: 37 RUBY = 38 if $(CheckProg_ ruby) 39 RUBY = $(nth 0,$(where ruby)) 40 export 41 42.STATIC: 43 RUBY_VERSION = 44 if $(defined RUBY) 45 RUBY_VERSION = $(string $(shell $(RUBY) --version)) 46 export 47 48Unzip(archive, destination) = 49 if $(defined 7ZIP) 50 # Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...] 51 # [<@listfiles...>] 52 # 53 # <Commands> 54 # a: Add files to archive 55 # b: Benchmark 56 # d: Delete files from archive 57 # e : Extract files from archive (without using directory names) 58 # l: List contents of archive 59 # t: Test integrity of archive 60 # u: Update files to archive 61 # x: eXtract files with full paths 62 # <Switches> 63 # -ai[r[-|0]]{@listfile|!wildcard}: Include archives 64 # -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives 65 # -bd: Disable percentage indicator 66 # -i[r[-|0]]{@listfile|!wildcard}: Include filenames 67 # -m{Parameters}: set compression Method 68 # -o{Directory}: set Output directory 69 # -p{Password}: set Password 70 # -r[-|0]: Recurse subdirectories 71 # -scs{UTF-8 | WIN | DOS}: set charset for list files 72 # -sfx[{name}]: Create SFX archive 73 # -si[{name}]: read data from stdin 74 # -slt: show technical information for l (List) command 75 # -so: write data to stdout 76 # -ssc[-]: set sensitive case mode 77 # -ssw: compress shared files 78 # -t{Type}: Set type of archive 79 # -v{Size}[b|k|m|g]: Create volumes 80 # -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options 81 # -w[{path}]: assign Work directory. Empty path means a temporary directory 82 # -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames 83 # -y: assume Yes on all queries 84 elseif $(defined UNZIP) 85 # Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir] 86 # Default action is to extract files in list, except those in xlist, to exdir; 87 # file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage). 88 # 89 # -p extract files to pipe, no messages -l list files (short format) 90 # -f freshen existing files, create none -t test compressed archive data 91 # -u update files, create if necessary -z display archive comment 92 # -x exclude files that follow (in xlist) -d extract files into exdir 93 # 94 # modifiers: -q quiet mode (-qq => quieter) 95 # -n never overwrite existing files -a auto-convert any text files 96 # -o overwrite files WITHOUT prompting -aa treat ALL files as text 97 # -j junk paths (do not make directories) -v be verbose/print version info 98 # -C match filenames case-insensitively -L make (some) names lowercase 99 # -X restore UID/GID info -V retain VMS version numbers 100 # -K keep setuid/setgid/tacky permissions -M pipe through "more" pager 101 # Examples (see unzip.txt for more info): 102 # unzip data1 -x joe => extract all files except joe from zipfile data1.zip 103 # unzip -p foo | more => send contents of foo.zip via pipe into program more 104 # unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer 105 else 106 eprintln($"Cannot find archiver. Install unzip or 7zip.") 107 eprintln($"If this message appears even if it is installed, search for the tool again using omake --configure.") 108 exit(1) 109 110ASTYLE = $(ROOT_TOOLS)/_private/AStyle.exe 111ASTYLE_FLAGS = --indent=spaces=4 --brackets=break --indent-preprocessor \ 112 --max-instatement-indent=40 --min-conditional-indent=0 \ 113 --pad-oper --unpad-paren --keep-one-line-statements --keep-one-line-blocks 114 115UNCRUSTIFY = $(file $(ROOT_TOOLS)/_private/Uncrustify.exe) 116UNCRUSTIFY_CONFIG = $(file $(dirname $(UNCRUSTIFY))/nintendo.cfg) 117 118IndentWithUncrustify(sources) = 119 SUBDIR_OUTPUT = indented/ 120 121 INDENTED_SOURCES = 122 export INDENTED_SOURCES 123 foreach(SOURCE, $(sources)) 124 INDENTED_SOURCE = $(file $(dirname $(SOURCE))/$(SUBDIR_OUTPUT)$(basename $(SOURCE))) 125 $(INDENTED_SOURCE): $(SOURCE) 126 $(UNCRUSTIFY) -c $(UNCRUSTIFY_CONFIG) -f $< -o $@ 127 128 INDENTED_SOURCES += $(INDENTED_SOURCE) 129 130 $(INDENTED_SOURCES): $(UNCRUSTIFY_CONFIG) $(UNCRUSTIFY) 131 return $(INDENTED_SOURCES) 132 133Indent(sources) = 134 return $(IndentWithUncrustify $(sources)) 135