1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2009-2017. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19 20-define(APPLICATION, reltool). 21-define(MISSING_APP_NAME, '*MISSING*'). 22-define(MISSING_APP_TEXT, "*MISSING*"). 23 24-type file() :: file:filename(). 25-type dir() :: file:filename(). 26%% app - Include all modules in app file 27%% ebin - Include all modules on ebin directory 28%% derived - Include only those modules that others are dependent on 29-type mod_cond() :: all | app | ebin | derived | none. 30-type incl_cond() :: include | exclude | derived. 31-type debug_info() :: keep | strip. 32-type app_file() :: keep | strip | all. 33-type re_regexp() :: string(). % re:regexp() 34-type regexps() :: [re_regexp()] | 35 {add, [re_regexp()]} | 36 {del, [re_regexp()]} . 37-type incl_sys_filters() :: regexps(). 38-type excl_sys_filters() :: regexps(). 39-type incl_app_filters() :: regexps(). 40-type excl_app_filters() :: regexps(). 41-type incl_archive_filters() :: regexps(). 42-type excl_archive_filters() :: regexps(). 43-type archive_opt() :: term(). % zip:create() 44-type root_dir() :: dir(). 45-type lib_dir() :: dir(). 46-type profile() :: development | embedded | standalone. 47-type relocatable() :: boolean(). 48-type escript_file() :: file(). 49-type escript_app_name() :: app_name(). 50-type mod_name() :: atom(). 51-type app_name() :: atom(). 52-type app_vsn() :: string(). % e.g. "4.7" 53-type app_label() :: string(). % e.g. "mnesia" or "mnesia-4.7" 54-type app_type() :: permanent | transient | temporary | load | none. 55-type incl_app() :: app_name(). 56-type emu_name() :: string(). 57-type rel_name() :: string(). 58-type rel_vsn() :: string(). 59-type boot_rel() :: rel_name(). 60-type rel_app() :: app_name() 61 | {app_name(), app_type()} 62 | {app_name(), [incl_app()]} 63 | {app_name(), app_type(), [incl_app()]}. 64-type rel_opt() :: {load_dot_erlang, boolean()}. 65-type mod() :: {incl_cond, incl_cond()} 66 | {debug_info, debug_info()}. 67-type app() :: {vsn, app_vsn()} 68 | {lib_dir, lib_dir()} 69 | {mod, mod_name(), [mod()]} 70 | {mod_cond, mod_cond()} 71 | {incl_cond, incl_cond()} 72 | {app_file, app_file()} 73 | {debug_info, debug_info()} 74 | {incl_app_filters, incl_app_filters()} 75 | {excl_app_filters, excl_app_filters()} 76 | {incl_archive_filters, incl_archive_filters()} 77 | {excl_archive_filters, excl_archive_filters()}. 78-type escript() :: {incl_cond, incl_cond()}. 79-type sys() :: {mod_cond, mod_cond()} 80 | {incl_cond, incl_cond()} 81 | {debug_info, debug_info()} 82 | {app_file, app_file()} 83 | {profile, profile()} 84 | {excl_lib, excl_lib()} 85 | {incl_sys_filters, incl_sys_filters()} 86 | {excl_sys_filters, excl_sys_filters()} 87 | {incl_app_filters, incl_app_filters()} 88 | {excl_app_filters, excl_app_filters()} 89 | {incl_archive_filters, incl_archive_filters()} 90 | {excl_archive_filters, excl_archive_filters()} 91 | {archive_opts, [archive_opt()]} 92 | {root_dir, root_dir()} 93 | {lib_dirs, [lib_dir()]} 94 | {boot_rel, boot_rel()} 95 | {rel, rel_name(), rel_vsn(), [rel_app()]} 96 | {rel, rel_name(), rel_vsn(), 97 [rel_app()], [rel_opt()]} 98 | {relocatable, relocatable()} 99 | {erts, app()} 100 | {escript, escript_file(), [escript()]} 101 | {app, app_name(), [app()]}. 102-type config() :: {sys, [sys()]}. 103-type option() :: {wx_debug, term()} 104 | {trap_exit, boolean()} 105 | config() 106 | {config, config() | file()}. 107-type options() :: [option()]. 108-type server_pid() :: pid(). 109-type window_pid() :: pid(). 110-type server() :: server_pid() | options(). 111-type rel_file() :: term(). 112-type script_file() :: term(). 113-type reason() :: string(). 114 115-type base_dir() :: dir(). 116-type base_file() :: file(). 117-type top_dir() :: file(). 118-type top_file() :: file(). 119-type target_spec() :: [target_spec()] 120 | {create_dir, base_dir(), [target_spec()]} 121 | {create_dir, base_dir(), top_dir(), [target_spec()]} 122 | {archive, base_file(), [archive_opt()], [target_spec()]} 123 | {copy_file, base_file()} 124 | {copy_file, base_file(), top_file()} 125 | {write_file, base_file(), binary()} 126 | {strip_beam_file, base_file()}. 127-type target_dir() :: dir(). 128-type incl_defaults() :: boolean(). 129-type incl_derived() :: boolean(). 130-type status() :: missing | ok. 131-type excl_lib() :: otp_root. 132 133-record(common, 134 { 135 sys_debug :: term(), 136 wx_debug :: term(), 137 trap_exit :: boolean() 138 }). 139 140%% Types '$1','$2' and '_' are needed for match specs to ets:select 141-record(mod, 142 { %% Static 143 name :: '$1' | mod_name(), 144 app_name :: '_' | app_name(), 145 incl_cond :: '_' | incl_cond() | undefined, 146 debug_info :: '_' | debug_info() | undefined, 147 is_app_mod :: '_' | boolean() | undefined, 148 is_ebin_mod :: '_' | boolean() | undefined, 149 uses_mods :: '$2' | [mod_name()] | undefined, 150 exists :: '_' | boolean() | undefined, 151 %% Dynamic 152 status = ok :: '_' | status(), 153 used_by_mods = [] :: '_' | [mod_name()], 154 is_pre_included :: '_' | boolean() | undefined, 155 is_included :: '_' | boolean() | undefined 156 }). 157 158-record(app_info, 159 { 160 description = "" :: '_' | string(), 161 id = "" :: '_' | string(), 162 vsn = "" :: '_' | app_vsn(), 163 modules = [] :: '_' | [mod_name()], 164 maxP = infinity :: '_' | integer() | infinity, 165 maxT = infinity :: '_' | integer() | infinity, 166 registered = [] :: '_' | [atom()], 167 incl_apps = [] :: '_' | '$3' | [app_name()], 168 applications = [] :: '_' | '$2' | [app_name()], 169 env = [] :: '_' | [{atom(), term()}], 170 mod = undefined :: '_' | {mod_name(), [term()]} | undefined, 171 start_phases = undefined :: '_' | [{atom(), term()}] | undefined, 172 runtime_dependencies = [] :: '_' | [string()] 173 }). 174 175-record(regexp, {source, compiled}). 176 177%% Types '$1','$2' and '_' are needed for match specs to ets:select 178-record(app, 179 { %% Static info 180 name :: '_' | app_name(), 181 is_escript :: '_' | boolean() | {inlined, escript_app_name()}, 182 use_selected_vsn :: '_' | vsn | dir | undefined, 183 active_dir :: '_' | dir() | undefined, 184 sorted_dirs :: '_' | [dir()], 185 vsn :: '_' | app_vsn() | undefined, 186 label :: '_' | app_label() | undefined, 187 info :: '_' | #app_info{} | undefined, 188 mods :: '_' | [#mod{}], 189 190 %% Static source cond 191 mod_cond :: '_' | mod_cond() | undefined, 192 incl_cond :: '_' | incl_cond() | undefined, 193 194 %% Static target cond 195 debug_info :: '_' | debug_info() | undefined, 196 app_file :: '_' | app_file() | undefined, 197 app_type :: '_' | app_type() | undefined, 198 incl_app_filters :: '_' | [#regexp{}] | undefined, 199 excl_app_filters :: '_' | [#regexp{}] | undefined, 200 incl_archive_filters :: '_' | [#regexp{}] | undefined, 201 excl_archive_filters :: '_' | [#regexp{}] | undefined, 202 archive_opts :: '_' | [archive_opt()] | undefined, 203 204 %% Dynamic 205 status :: '_' | status(), 206 uses_mods :: '_' | [mod_name()] | undefined, 207 used_by_mods :: '_' | [mod_name()] | undefined, 208 uses_apps :: '_' | [app_name()] | undefined, 209 used_by_apps :: '_' | [app_name()] | undefined, 210 is_pre_included :: '_' | '$2' | boolean() | undefined, 211 is_included :: '_' | '$1' | boolean() | undefined, 212 rels :: '_' | [rel_name()] | undefined 213 }). 214 215-record(rel_app, 216 { 217 name :: app_name(), 218 app_type :: app_type() | undefined, 219 incl_apps :: [incl_app()] | undefined 220 }). 221 222-record(rel, 223 { 224 name :: rel_name(), 225 vsn :: rel_vsn(), 226 rel_apps :: [#rel_app{}], 227 load_dot_erlang = true :: boolean() 228 }). 229 230-record(sys, 231 { %% Sources 232 root_dir :: dir(), 233 lib_dirs :: [dir()], 234 escripts :: [file()], 235 mod_cond :: mod_cond(), 236 incl_cond :: incl_cond(), 237 apps :: [#app{}] | undefined, 238 239 %% Target cond 240 boot_rel :: boot_rel(), 241 rels :: [#rel{}], 242 emu_name :: emu_name(), 243 profile :: profile(), 244 excl_lib :: excl_lib() | undefined, 245 incl_sys_filters :: [#regexp{}], 246 excl_sys_filters :: [#regexp{}], 247 incl_app_filters :: [#regexp{}], 248 excl_app_filters :: [#regexp{}], 249 incl_archive_filters :: [#regexp{}], 250 excl_archive_filters :: [#regexp{}], 251 archive_opts :: [archive_opt()], 252 relocatable :: boolean(), 253 rel_app_type :: app_type(), 254 embedded_app_type :: app_type() | undefined, 255 app_file :: app_file(), 256 debug_info :: debug_info() 257 }). 258 259-define(ERR_IMAGE, 0). 260-define(WARN_IMAGE, 1). 261-define(QUEST_IMAGE, 2). 262-define(TICK_IMAGE, 3). 263-define(CROSS_IMAGE, 4). 264-define(SOURCE_IMAGE, 5). 265 266-define(KEYSEARCH(Key, Pos, List), 267 reltool_utils:safe_keysearch(Key, Pos, List, ?MODULE, ?LINE)). 268 269-define(DEFAULT_LIBS, []). 270-define(DEFAULT_APPS, []). 271-define(DEFAULT_INCL_COND, derived). 272-define(DEFAULT_MOD_COND, all). 273-define(DEFAULT_REL_NAME, "start_clean"). 274-define(DEFAULT_EMU_NAME, "beam"). 275-define(DEFAULT_PROFILE, development). 276-define(DEFAULT_RELOCATABLE, true). 277-define(DEFAULT_REL_APP_TYPE, permanent). 278-define(DEFAULT_EMBEDDED_APP_TYPE, undefined). 279-define(DEFAULT_APP_FILE, keep). 280-define(DEFAULT_DEBUG_INFO, keep). 281 282-define(DEFAULT_INCL_ARCHIVE_FILTERS, [".*"]). 283-define(DEFAULT_EXCL_ARCHIVE_FILTERS, ["^include\$", "^priv\$"]). 284-define(DEFAULT_ARCHIVE_OPTS, []). 285 286-define(DEFAULT_INCL_SYS_FILTERS, [".*"]). 287-define(DEFAULT_EXCL_SYS_FILTERS, []). 288-define(DEFAULT_INCL_APP_FILTERS, [".*"]). 289-define(DEFAULT_EXCL_APP_FILTERS, []). 290 291-define(EMBEDDED_INCL_SYS_FILTERS, ["^bin", 292 "^erts", 293 "^lib", 294 "^releases"]). 295-define(EMBEDDED_EXCL_SYS_FILTERS, 296 ["^bin/(erlc|dialyzer|typer)(|\\.exe)\$", 297 "^erts.*/bin/(erlc|dialyzer|typer)(|\\.exe)\$", 298 "^erts.*/bin/.*(debug|pdb)"]). 299-define(EMBEDDED_INCL_APP_FILTERS, ["^ebin", 300 "^include", 301 "^priv"]). 302-define(EMBEDDED_EXCL_APP_FILTERS, []). 303-define(EMBEDDED_APP_TYPE, load). 304 305-define(STANDALONE_INCL_SYS_FILTERS, ["^bin/(erl|epmd)(|\\.exe|\\.ini)\$", 306 "^bin/start(|_clean).boot\$", 307 "^bin/no_dot_erlang\\.boot\$", 308 "^erts.*/bin", 309 "^lib\$"]). 310-define(STANDALONE_EXCL_SYS_FILTERS, 311 ["^erts.*/bin/(erlc|dialyzer|typer)(|\\.exe)\$", 312 "^erts.*/bin/(start|escript|to_erl|run_erl)(|\\.exe)\$", 313 "^erts.*/bin/.*(debug|pdb)"]). 314-define(STANDALONE_INCL_APP_FILTERS, ["^ebin", 315 "^priv"]). 316-define(STANDALONE_EXCL_APP_FILTERS, ["^ebin/.*\\.appup\$"]). 317