EXAMPLE - Complete MSI Script |
The following 3 line script builds a complete MSI:
#include "dennis.mmh" ;;Include MAKEMSI support and define my macro! <$DirFiles Dir="c:\tmp\aaaa" "a*.dll;a*.exe"> <$DirFiles Dir="c:\tmp\aaaa\bbbb" "a*.ocx">
EXAMPLE - Macro (defined in DENNIS.MMH) |
You would generally define a macro in a single place and a common header file such as "DENNIS.MMH" would be ideal.
This macro started out very simple but to handle all sorts of user type interactions (reduce restrictions on how it should be used) it snowballed :-)
The macro takes these parameters:
#NextId #define? OPTION_DIRFILES_FIRST_USE_SETS_ROOT_FEATURE_DIRECTORY Y ;;Y/N #define? OPTION_DIRFILES_FIRST_DIRKEY DIRFILES #define? OPTION_DIRFILES_OTHER_DIRKEYS <$OPTION_DIRFILES_FIRST_DIRKEY>_{$Cnt} #define? OPTION_DIRFILES_DEFAULT_Options4Files #RexxVar @@DirFilesCnt = 0 #( '' #define DirFiles ;--- Some Parameter Validations ------------------------------------------ {$!KEYWORDS} ;;Don't accept/use keyword parameters #( '' ;--- Check passed parameter names against this list ------------------ {$!:#1, ;;List of one or more file masks (normally must be at least one file matching mask) Dir, ;;Destination dir (first one usually configurable via root feature). Can also be a Directory key such as "INSTALLDIR" Options4Files ;;A mechanism to supply "FILES" command options } #) ;--- Create the MSI directory key if not seen before --------------------- #DefineRexx '' @@Dir = '{$Dir}'; if pos(@@Dir, '\') = 0 then; @@DirKey = @@Dir; else @@DirKey = DataGet(translate('{$Dir}')) ;;Returns '' if not seen #DefineRexx #if [@@DirKey = ''] ;--- Have not seen before so what do we wish to call this directory? --- #RexxVar @@DirFilesCnt + 1 #if [@@DirFilesCnt = 1] #RexxVar @@DirKey = "<$OPTION_DIRFILES_FIRST_DIRKEY>" #elseif #RexxVar @@DirKey = "<$OPTION_DIRFILES_OTHER_DIRKEYS Cnt=^<??@@DirFilesCnt>^>" #endif ;--- Save this info away --------------------------------------------- #DefineRexx '' call DataSave translate('{$Dir}'),, @@DirKey #DefineRexx ;--- Create the directory -------------------------------------------- #RexxVar @@FeatureDir = 'N' #if [@@DirFilesCnt = 1] #if ['<$OPTION_DIRFILES_FIRST_USE_SETS_ROOT_FEATURE_DIRECTORY $$UPPER>' = 'Y'] #RexxVar @@FeatureDir = 'Y' #endif #endif #if [@@FeatureDir = 'N'] <$DirectoryTree Key="<??@@DirKey>" Dir="{$Dir}"> #elseif <$DirectoryTree Key="<??@@DirKey>" Dir="{$Dir}" CHANGE='\'> #endif #endif ;--- Add the Files to the MSI -------------------------------------------- #if ['{$Options4Files=^^ $$IsPassed}' = 'Y'] <$Files "{$#1}" DestDir="<??@@DirKey>" {$Options4Files}> #elseif ;--- Bit trickier ---------------------------------------------------- #DefineRexx '' @@Options4Files = MacroGet('OPTION_DIRFILES_DEFAULT_Options4Files'); @@FilesCmd = '<' || '$Files "{$#1}" DestDir="' || @@DirKey || '" ' || @@Options4Files || '>' #DefineRexx <??@@FilesCmd><?RestartLine> #endif #)