/usr/share/doc/racket/raco/c-mods.html is in racket-doc 6.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>12.2 Embedding Modules via C</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">►</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco</span>:<span class="mywbr"> </span> Racket Command-<wbr></wbr>Line Tools</a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="make.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco make</span>:<span class="mywbr"> </span> Compiling Source to Bytecode</a></td></tr><tr><td align="right">2 </td><td><a href="exe.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco exe</span>:<span class="mywbr"> </span> Creating Stand-<wbr></wbr>Alone Executables</a></td></tr><tr><td align="right">3 </td><td><a href="exe-dist.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco distribute</span>:<span class="mywbr"> </span> Sharing Stand-<wbr></wbr>Alone Executables</a></td></tr><tr><td align="right">4 </td><td><a href="planet.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco planet</span>:<span class="mywbr"> </span> Automatic Package Distribution</a></td></tr><tr><td align="right">5 </td><td><a href="pkg.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco pkg</span>:<span class="mywbr"> </span> Package Management</a></td></tr><tr><td align="right">6 </td><td><a href="setup.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco setup</span>:<span class="mywbr"> </span> Installation Management</a></td></tr><tr><td align="right">7 </td><td><a href="decompile.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco decompile</span>:<span class="mywbr"> </span> Decompiling Bytecode</a></td></tr><tr><td align="right">8 </td><td><a href="demod.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco demod</span>:<span class="mywbr"> </span> Demodularizing Programs</a></td></tr><tr><td align="right">9 </td><td><a href="link.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco link</span>:<span class="mywbr"> </span> Library Collection Links</a></td></tr><tr><td align="right">10 </td><td><a href="plt.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco pack</span>:<span class="mywbr"> </span> Packing Library Collections</a></td></tr><tr><td align="right">11 </td><td><a href="unpack.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco unpack</span>:<span class="mywbr"> </span> Unpacking Library Collections</a></td></tr><tr><td align="right">12 </td><td><a href="ctool.html" class="tocviewselflink" data-pltdoc="x"><span class="stt">raco ctool</span>:<span class="mywbr"> </span> Working with C Code</a></td></tr><tr><td align="right">13 </td><td><a href="test.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco test</span>:<span class="mywbr"> </span> Run tests</a></td></tr><tr><td align="right">14 </td><td><a href="docs.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco docs</span>:<span class="mywbr"> </span> Documentation Search</a></td></tr><tr><td align="right">15 </td><td><a href="expand.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco expand</span>:<span class="mywbr"> </span> Macro Expansion</a></td></tr><tr><td align="right">16 </td><td><a href="read.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco read</span>:<span class="mywbr"> </span> Reading and Pretty-<wbr></wbr>Printing</a></td></tr><tr><td align="right">17 </td><td><a href="scribble.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco scribble</span>:<span class="mywbr"> </span> Building Documentation</a></td></tr><tr><td align="right">18 </td><td><a href="command.html" class="tocviewlink" data-pltdoc="x">Adding a <span class="stt">raco</span> Command</a></td></tr><tr><td align="right">19 </td><td><a href="config-file.html" class="tocviewlink" data-pltdoc="x">Installation Configuration and Search Paths</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_1");">▼</a></td><td>12 </td><td><a href="ctool.html" class="tocviewlink" data-pltdoc="x"><span class="stt">raco ctool</span>:<span class="mywbr"> </span> Working with C Code</a></td></tr></table><div class="tocviewsublistbottom" style="display: block;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">12.1 </td><td><a href="cc.html" class="tocviewlink" data-pltdoc="x">Compiling and Linking C Extensions</a></td></tr><tr><td align="right">12.2 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Embedding Modules via C</a></td></tr></table></div></div></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <a href="cc.html" title="backward to "12.1 Compiling and Linking C Extensions"" data-pltdoc="x">← prev</a> <a href="ctool.html" title="up to "12 raco ctool: Working with C Code"" data-pltdoc="x">up</a> <a href="test.html" title="forward to "13 raco test: Run tests"" data-pltdoc="x">next →</a></span> </div><h4 x-source-module="(lib "scribblings/raco/raco.scrbl")" x-source-pkg="racket-doc" x-part-tag=""c-mods"">12.2<tt> </tt><a name="(part._c-mods)"></a>Embedding Modules via C</h4><p>The <span class="nobreak"><span class="stt">--c-mods</span></span> mode for <span class="stt">raco ctool</span> takes a set of Racket
modules and generates a C source file that can be used as part of
program that embeds the Racket run-time system. See <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=inside&rel=embedding.html&version=6.7" class="Sq" data-pltdoc="x">Embedding into a Program</a> in <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=inside&rel=index.html&version=6.7" class="Sq" data-pltdoc="x">Inside: Racket C API</a> for an
explanation of embedding programs.</p><p>The generated source file embeds the specified modules, and it defines
a <span class="stt">declare_modules</span> function that puts the module declarations into
a namespace. Thus, using the output of <span class="stt">raco ctool --c-mods</span>, a
program can embed Racket with a set of modules so that it does not
need a <span class="stt">"collects"</span> directory to load modules at run time.</p><p>If the embedded modules refer to runtime files, the files can be
gathers by supplying the <span class="nobreak"><span class="stt">--runtime</span></span> argument to <span class="stt">raco ctool
--cmods</span>, specifying a directory <span class="sroman">‹<span style="font-style: italic">dir</span>›</span> to hold the files.
Normally, <span class="sroman">‹<span style="font-style: italic">dir</span>›</span> is a relative path, and files are found at run
time in <span class="sroman">‹<span style="font-style: italic">dir</span>›</span> relative to the executable, but a separate path
(usually relative) for run time can be specified with
<span class="nobreak"><span class="stt">--runtime-access</span></span>.</p><p>Typically, <span class="stt">raco ctool --c-mods</span> is used with <span class="nobreak"><span class="stt">++lib</span></span> to
specify a collection-based module path. For example,</p><p><span class="hspace"> </span><span class="stt">raco ctool --c-mods base.c ++lib racket/base</span></p><p>generates a <span class="stt">"base.c"</span> whose <span class="stt">declare_modules</span> function
makes <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=reference&rel=index.html&version=6.7" class="RktModLink Sq" data-pltdoc="x"><span class="RktSym">racket/base</span></a> available for use via the
<span class="stt">scheme_namespace_require</span> or <span class="stt">scheme_dynamic_require</span> functions
within the embedding application.</p><p>When a module file is provided to <span class="stt">raco ctool --c-mods</span>, then
<span class="stt">declare_modules</span> declares a module with the symbolic name of the
module file. For example,</p><p><span class="hspace"> </span><span class="stt">raco ctool --c-mods base.c hello.rkt</span></p><p>creates a <span class="stt">declare_modules</span> that defines the module
<span class="RktVal">'</span><span class="RktVal">hello</span>, which could be required into the current namespace
with <span class="RktPn">(</span><span class="RktSym">namespace-require</span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">'</span><span class="RktVal">hello</span><span class="RktPn">)</span> or similarly at the C level:</p><p><table cellspacing="0" cellpadding="0"><tr><td><p><span class="hspace"> </span><span class="stt">p = scheme_make_pair(scheme_intern_symbol("quote"),</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">scheme_make_pair(scheme_intern_symbol("hello"),</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt"></span><span class="hspace"> </span><span class="stt">scheme_make_null()));</span></p></td></tr><tr><td><p><span class="hspace"> </span><span class="stt">scheme_namespace_require(p);</span></p></td></tr></table></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <a href="cc.html" title="backward to "12.1 Compiling and Linking C Extensions"" data-pltdoc="x">← prev</a> <a href="ctool.html" title="up to "12 raco ctool: Working with C Code"" data-pltdoc="x">up</a> <a href="test.html" title="forward to "13 raco test: Run tests"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|