Channels ▼
RSS

Open Source

A Build System for Complex Projects: Part 3


Project Metadata Files

Make files are okay (I wouldn't say great) for running a build, but they are not very easy to parse and modify. NetBeans uses two XML files to maintain the project information and dynamically generates the make files from these files.

configurations.xml

This is the file. It contains most of the project information used for generating the make files as well as some GUI information such as the logical folders displayed in the IDE for each project and what files reside in them. It is a typical XML file. The root element is called configurationDescriptor and it contains a logicalFolder element called "root that contains nested logicalFolder elements for "HeaderFiles", "ResourceFiles", "SourceFiles" and "ExternalFiles". Each logicalFolder element may contain itemPath elements for the files in this folder. Here is the logical folders of the testPunctuator project:


<?xml version="1.0" encoding="UTF-8"?>
  <configurationDescriptor version="45">
    <logicalFolder name="root" displayName="root" projectFiles="true">
    <logicalFolder name="HeaderFiles"
             displayName="Header Files"
             projectFiles="true">
    </logicalFolder>
    <logicalFolder name="ResourceFiles"
             displayName="Resource Files"
             projectFiles="true">
    </logicalFolder>
    <logicalFolder name="SourceFiles"
             displayName="Source Files"
             projectFiles="true">
      <itemPath>main.cpp</itemPath>
    </logicalFolder>
    <logicalFolder name="ExternalFiles"
             displayName="Important Files"
             projectFiles="false">
      <itemPath>Makefile</itemPath>
    </logicalFolder>
    </logicalFolder>

The configurations.xml file also contains elements for the encoding the make file for the project (in case you want to change its name for some reason):


  <sourceEncoding>UTF-8</sourceEncoding>
  <projectmakefile>Makefile</projectmakefile>

Then comes the all important "confs" elements that contains "conf" elements for each configuration. Each "conf" elements contains a "toolset" element and a "compileType" elements that contains various tools. Each tool has its own set of elements and attribute that translate directly to make file tool settings:


<confs>
    <conf name="Debug" type="1">
      <toolsSet>
        <compilerSet>GNU|GNU</compilerSet>
        <platform>4</platform>
      </toolsSet>
      <compileType>
        <ccCompilerTool>
          <includeDirectories>
            <directoryPath>../..</directoryPath>
          </includeDirectories>
        </ccCompilerTool>
        <linkerTool>
          <linkerLibItems>
            <linkerLibProjectItem>
              <makeArtifact PL="../../hw/utils"
                            CT="3"
                            CN="Debug"
                            AC="true"
                            BL="true"
                            WD="../../hw/utils"
                            BC="${MAKE}  -f Makefile CONF=Debug"
                            CC="${MAKE}  -f Makefile CONF=Debug clean"
                            OP="dist/Debug/GNU-MacOSX/libutils.a">
              </makeArtifact>
            </linkerLibProjectItem>
          </linkerLibItems>
        </linkerTool>
      </compileType>
      <item path="main.cpp">
        <itemTool>1</itemTool>
      </item>
    </conf>
    <conf name="Release" type="1">
      <toolsSet>
        <compilerSet>GNU|GNU</compilerSet>
        <platform>4</platform>
      </toolsSet>
      <compileType>
        <cCompilerTool>
          <developmentMode>5</developmentMode>
        </cCompilerTool>
        <ccCompilerTool>
          <developmentMode>5</developmentMode>
          <includeDirectories>
            <directoryPath>../..</directoryPath>
          </includeDirectories>
        </ccCompilerTool>
        <fortranCompilerTool>
          <developmentMode>5</developmentMode>
        </fortranCompilerTool>
        <linkerTool>
          <linkerLibItems>
            <linkerLibProjectItem>
              <makeArtifact PL="../../hw/utils"
                            CT="3"
                            CN="Release"
                            AC="false"
                            BL="true"
                            WD="../../hw/utils"
                            BC="${MAKE}  -f Makefile CONF=Release"
                            CC="${MAKE}  -f Makefile CONF=Release clean"
                            OP="dist/Release/GNU-MacOSX/libutils.a">
              </makeArtifact>
            </linkerLibProjectItem>
          </linkerLibItems>
        </linkerTool>
      </compileType>
      <item path="main.cpp">
        <itemTool>1</itemTool>
      </item>
    </conf>
  </confs>

There is one "conf" element for each configuration (in this case Debug and Release).

project.xml

The project.xml file holds additional information like the project type, project dependencies and the file extensions of different file types. I'm not sure why this information should go in a separate file, but that's how it is. Here is the project.xml file of the hello_world application project itself:


  <?xml version="1.0" encoding="UTF-8"?>
  <project xmlns="http://www.netbeans.org/ns/project/1">
    <type>org.netbeans.modules.cnd.makeproject</type>
    <configuration>
      <data xmlns="http://www.netbeans.org/ns/make-project/1">
        <name>hello_world</name>
        <make-project-type>0</make-project-type>
        <make-dep-projects>
          <make-dep-project>../../hw/hello</make-dep-project>
          <make-dep-project>../../hw/utils</make-dep-project>
          <make-dep-project>../../hw/world</make-dep-project>
        </make-dep-projects>
        <c-extensions/>
        <cpp-extensions>cpp</cpp-extensions>
        <header-extensions>hpp</header-extensions>
      </data>
    </configuration>
  </project>

Project Group

In addition to the individual project files NetBeans support a higher level of organization called a project group. A project group is simply a collection of projects that can be loaded together into the NetBeans IDE. The hello world system is also a project group that contains many projects. The ibs can generate such a project group on behalf of the user and update it automatically when new projects are added or removed.

NetBeans keeps a lot of information in the user's home directory in a hidden directory called ".netbeans". The project groups are stored in the following directory:


~/.netbeans/6.7/config/Preferences/org/netbeans/modules/projectui/groups

Note the 6.7 version number following the .netbeans directory. You may have multiple versions of NetBeans installed on your machine and their preferences are stored separately. Each project group has a file under the projectui sub-directory called <project group name>.properties. There are three kinds of projects groups: free group, master + dependencies and folder group (all projects under a root directory). The hello_world project group is a folder group. Here is the hello_world.properties file:


name=hello_world
kind=directory
path=file\:/Users/gsayfan/Documents/Invisible.Build.System/src

Pretty simple, really. In addition there is another important file called:


~/.netbeans/6.7/config/Preferences/org/netbeans/modules/projectui/groups.properties. 

This file determines the active project group if there are multiple project groups. Its format is very simple too and to make a group active you just need to have this line in the file:


active=<project group name>

In case of the hello_world project group it is:


active=hello_world


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video