distrib > Mageia > 6 > x86_64 > by-pkgid > 3dd7afb0e73ef085f903dd0db1dc8c8f > files > 7


<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="rustdoc">
    <title>External tools</title>

    <link rel="stylesheet" type="text/css" href="stylesheets/normalize.css">
<link rel="stylesheet" type="text/css" href="stylesheets/all.css">
<link rel="stylesheet" type="text/css" href="stylesheets/prism.css">

    <script src=""></script>
<link rel="icon" type="image/x-icon" href="favicon.ico">

<body class="rustdoc">
    <!--[if lte IE 8]>
    <div class="warning">
        This old browser is unsupported and will most likely display funky

    <a href='' class='fork-me'>
  <img src='images/forkme.png'/>

<div id="header">
    <a href='' class='logo'>
        <img id="logo" height=100 width=100 src='images/Cargo-Logo-Small.png'/>
    <a href="index.html">

    <div class="search">
        <form action=""
            <input name="q" class="search" placeholder="Search crates" type="text"/>

    <div class="nav">
        <a href=''>Browse All Crates</a>

        <span class='sep'>|</span>

        <div class="dropdown-container">
            <button class="dropdown">
                <span class="arrow"></span>
            <!-- Sync this list with
                 and with in this repository -->
            <ul id="current-user-links" class="dropdown" data-bindattr-503="503">
                <li><a href='index.html'>Getting Started</a></li>
                <li><a href='guide.html'>Guide</a></li>
                <li><a href='specifying-dependencies.html'>Specifying Dependencies</a></li>
                <li><a href='crates-io.html'>Publishing on</a></li>
                <li><a href='faq.html'>FAQ</a></li>
                <li><a href='manifest.html'>Cargo.toml Format</a></li>
                <li><a href='build-script.html'>Build Scripts</a></li>
                <li><a href='config.html'>Configuration</a></li>
                <li><a href='pkgid-spec.html'>Package ID specs</a></li>
                <li><a href='environment-variables.html'>Environment Variables</a></li>
                <li><a href='source-replacement.html'>Source Replacement</a></li>
                <li><a href='external-tools.html'>External Tools</a></li>
                <li><a href='policies.html'>Policies</a></li>


    <h1 class="title">External tools</h1>
    <p>One of the goals of Cargo is simple integration with third-party tools, like
IDEs and other build systems. To make integration easier, Cargo has several

<li><p><code>cargo metadata</code> command, which outputs project structure and dependencies
information in JSON,</p></li>
<li><p><code>--message-format</code> flag, which outputs information about a particular build,</p></li>
<li><p>support for custom subcommands.</p></li>

<h1 id='information-about-project-structure' class='section-header'><a href='#information-about-project-structure'>Information about project structure</a></h1>
<p>You can use <code>cargo metadata</code> command to get information about project structure
and dependencies. The output of the command looks like this:</p>

<pre><code class="language-text">{
  // Integer version number of the format.
  &quot;version&quot;: integer,

  // List of packages for this workspace, including dependencies.
  &quot;packages&quot;: [
      // Opaque package identifier.
      &quot;id&quot;: PackageId,

      &quot;name&quot;: string,

      &quot;version&quot;: string,

      &quot;source&quot;: SourceId,

      // A list of declared dependencies, see `resolve` field for actual dependencies.
      &quot;dependencies&quot;: [ Dependency ],

      &quot;targets: [ Target ],

      // Path to Cargo.toml
      &quot;manifest_path&quot;: string,

  &quot;workspace_members&quot;: [ PackageId ],

  // Dependencies graph.
  &quot;resolve&quot;: {
     &quot;nodes&quot;: [
         &quot;id&quot;: PackageId,
         &quot;dependencies&quot;: [ PackageId ]

<p>The format is stable and versioned. When calling <code>cargo metadata</code>, you should
pass <code>--format-version</code> flag explicitly to avoid forward incompatibility

<p>If you are using Rust, there is <a href="">cargo_metadata</a> crate.</p>

<h1 id='information-about-build' class='section-header'><a href='#information-about-build'>Information about build</a></h1>
<p>When passing <code>--message-format=json</code>, Cargo will output the following
information during the build:</p>

<li><p>compiler errors and warnings,</p></li>
<li><p>produced artifacts,</p></li>
<li><p>results of the build scripts (for example, native dependencies).</p></li>

<p>The output goes to stdout in the JSON object per line format. The <code>reason</code> field
distinguishes different kinds of messages.</p>

<p>Information about dependencies in the Makefile-compatible format is stored in
the <code>.d</code> files alongside the artifacts.</p>

<h1 id='custom-subcommands' class='section-header'><a href='#custom-subcommands'>Custom subcommands.</a></h1>
<p>Cargo is designed to be extensible with new subcommands without having to modify
Cargo itself. This is achieved by translating a cargo invocation of the form
cargo <code>(?&lt;command&gt;[^ ]+)</code> into an invocation of an external tool
<code>cargo-${command}</code> that then needs to be present in one of the user&#39;s <code>$PATH</code>

<p>Custom subcommand may use <code>CARGO</code> environment variable to call back to
Cargo. Alternatively, it can link to <code>cargo</code> crate as a library, but this
approach has drawbacks:</p>

<li><p>Cargo as a library is unstable, API changes without deprecation,</p></li>
<li><p>versions of Cargo library and Cargo binary may be different.</p></li>

<a href='index.html'>Install</a>
<span class='sep'>|</span>
<a href='index.html'>Getting Started</a>
<span class='sep'>|</span>
<a href='guide.html'>Guide</a>

<script type='text/javascript' src='javascripts/prism.js'></script>
<script type='text/javascript' src='javascripts/all.js'></script>