diff options
author | Richard Carlsson <[email protected]> | 2016-12-06 12:14:18 +0100 |
---|---|---|
committer | Richard Carlsson <[email protected]> | 2017-02-06 15:36:20 +0100 |
commit | 0eb45e21d406539caaad98bfc1740f9a11e32565 (patch) | |
tree | e7254e79a17efe61e25ecc4f6efbea4c919c0340 /lib/stdlib/doc/src/c.xml | |
parent | eab4b024957a27be018f8bc155bdd1dc05ec7969 (diff) | |
download | otp-0eb45e21d406539caaad98bfc1740f9a11e32565.tar.gz otp-0eb45e21d406539caaad98bfc1740f9a11e32565.tar.bz2 otp-0eb45e21d406539caaad98bfc1740f9a11e32565.zip |
Add shell shortcut for recompiling existing modules
This extends the shell function c/1 and c/2 so that if the argument is a
module name instead of a file name, it automatically locates the .beam file
and the corresponding source file, and then recompiles the module using the
same compiler options (plus any options passed to c/2). If compilation
fails, the old beam file is preserved. Also adds c(Mod, Opts, Filter),
where the Filter argument allows you to remove old compiler options before
the new options are added.
Diffstat (limited to 'lib/stdlib/doc/src/c.xml')
-rw-r--r-- | lib/stdlib/doc/src/c.xml | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/stdlib/doc/src/c.xml b/lib/stdlib/doc/src/c.xml index 55a77d1bc5..7666699183 100644 --- a/lib/stdlib/doc/src/c.xml +++ b/lib/stdlib/doc/src/c.xml @@ -52,13 +52,27 @@ <func> <name name="c" arity="1"/> <name name="c" arity="2"/> - <fsummary>Compile and load code in a file.</fsummary> + <name name="c" arity="3"/> + <fsummary>Compile and load a file or module.</fsummary> <desc> - <p>Compiles and then purges and loads the code for a file. - <c><anno>Options</anno></c> defaults to <c>[]</c>. Compilation is - equivalent to:</p> - <code type="none"> -compile:file(<anno>File</anno>, <anno>Options</anno> ++ [report_errors, report_warnings])</code> + <p>Compiles and then purges and loads the code for a module. + <c><anno>Module</anno></c> can be either a module name or a source + file path, with or without <c>.erl</c> extension. + <c><anno>Options</anno></c> defaults to <c>[]</c>.</p> + <p>If <c><anno>Module</anno></c> is an atom and is not the path of a + source file, then the code path is searched to locate the object + file for the module and extract its original compiler options and + source path. If the source file is not found in the original + location, <seealso + marker="filelib#find_source/1"><c>filelib:find_source/1</c></seealso> + is used to search for it relative to the directory of the object + file.</p> + <p>The source file is compiled with the the original + options appended to the given <c><anno>Options</anno></c>, the + output replacing the old object file if and only if compilation + succeeds. A function <c><anno>Filter</anno></c> can be specified + for removing elements from from the original compiler options + before the new options are added.</p> <p>Notice that purging the code means that any processes lingering in old code for the module are killed without warning. For more information, see <c>code/3</c>.</p> |