Slicer3:SBuild

From Slicer Wiki
Revision as of 19:33, 26 October 2009 by Hayes (talk | contribs) (Created page with '= SBuild = SBuild is a new, experimental build system for Slicer. It is based on getbuildtest2.tcl and genlib2.tcl, but rather than try to hid the gory details of building Slice…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home < Slicer3:SBuild

SBuild

SBuild is a new, experimental build system for Slicer. It is based on getbuildtest2.tcl and genlib2.tcl, but rather than try to hid the gory details of building Slicer, SBuild attempts to expose a reasonable amount to the developer. The interface should be reasonably intuitive, but a brief walk through is useful. Click on the thumbnails for larger views. SBuild allows you to update and build just the portions of Slicer that you may require or want to build. Any of the required libraries may be specified to be build by SBuild, or to use an existing build. Existing libraries are not controlled by SBuild. Under the hood, SBuild calls CMake to do the heavy lifting, just like getbuildtest2.tcl.

Screenshots

SBuild screenshots
Main SBuild Window
Required libraries
SBuild configured for all external builds


  1. Configure the "Slicer Source Directory" by clicking on the "..." button, or typing a path to where you would like Slicer source saved
    1. Configure the "Slicer Build Directory" and "Slicer Library Directory" in the same fashion
  2. (Optional:) Switch to the "Required Libs" tab
    1. Configure any of the external builds that you may have by clicking on the checkbox next to the "Use external build" label
    2. When prompted, find the external build directory
    3. Note: SBuild looks for specific files inside the directory you choose, if not found you will be warned. In this case, choose better.
    4. Any of the required libraries may be Updated, Configured, or Built from this tab.
  3. To build everything, go to the Slicer3 tab and click "All"
    1. Output of the build process should fly by.

Binary downloads

Adding new Libraries to SBuild

The default package of SBuild contains the minimal number of required libraries to build Slicer. Currently no optional libraries are installed. The procedure for providing an SBuild plugin is modestly complicated, but several good examples exist. All plugins go in SBuild.vfs/lib/SBuildPlugins. As an example, let's create a plugin called Mythical, contained in SBuild.vfs/lib/SBuildPlugins/Mythical.tcl.

In the Slicer3/Scripts/SBuild directory, run ./bootstrap run to run SBuild, and ./bootstrap build to build the Tcl Starkits.

The first section of Mythical.tcl provides some housekeeping details:

package provide SBuildPlugins 1.0 

lappend ::SBuild(Plugins) Mythical 

set ::Plugin(Mythical,Type) "optional"
set ::Plugin(Mythical,Order) 100
set ::Plugin(Mythical,CanUseUserBuild) 1

The Mythical plugin must append itself to ::SBuild(Plugins) to register, and declares itself optional, builds in order 100, and can use user provided builds.

Each plugin must provide several Tcl procs to do various functions. The naming convention is PluginName-Function-Architecture. In this example PluginName is Mythical. SBuild first looks for the -Architecture variant, and failing, calls the PluginName-Function. For instance, Mythical-Update is the Tcl proc that updates the source for Mythical, while Mythical-Build-Windows is a specialization for Windows. The important functions are: Update, Configure, Build, and ConfigureSlicer. The ConfigureSlicer function may append a CMake argument to be used when Slicer is configured. If external packages are allowed, the ConfigureExternal function is called. ConfigureExternal usually looks for libraries and sets a LibPath to be used to configure Slicer. Examples of these functions are shown below.

# Here is where we would add lines to the main Slicer3 configuration
proc Mythical-Setup {} {
  global SBuild
}

# How do we setup for an external build
proc Mythical-ConfigureExternal {} {
  global SBuild
  set SBuild(Mythical,LibPath) [file dirname [FindFile $::SBuild(Mythical,ExternalBuildPath) [list libMythicalCommon* MythicalCommon*.lib MythicalCommon*.dll]]]
}

# Add a line to Slicer's CMake command
proc Mythical-ConfigureSlicer {} {
  global Plugin SBuild Slicer
  set dir [file join $SBuild(SlicerLibDir) Insight-build]
  if { $SBuild(Mythical,UseExternalBuild) } {
    set dir $SBuild(Mythical,ExternalBuildPath)
  }
  Debug "setting Mythical_DIR to $dir"
  lappend Slicer(CMakeArguments) -DMythical_DIR:FILEPATH=$dir
}

# How do we update Mythical?
proc Mythical-Update {} {
  Debug "Checking out Mythical"
  global SBuild Plugin
  file mkdir Insight
  ExecuteCommand $SBuild(SVNCommand) co http://www.mythical.org/svn/Mythical/trunk Mythical
}

# Configure to build
proc Mythical-Configure {} {
  Debug "Configure Mythical"
  global SBuild Plugin
  file mkdir Mythical-build
  cd Mythical-build
  ExecuteCommand $SBuild(CMake) \
    -G$SBuild(Generator) \
    -DCMAKE_CXX_COMPILER:STRING=$::SBuild(CompilerPath)/$SBuild(Compiler) \
    -DCMAKE_CXX_COMPILER_FULLPATH:FILEPATH=$::SBuild(CompilerPath)/$SBuild(Compiler) \
    -DBUILD_SHARED_LIBS:BOOL=ON \
    -DCMAKE_SKIP_RPATH:BOOL=ON \
    -DBUILD_EXAMPLES:BOOL=OFF \
    -DBUILD_TESTING:BOOL=OFF \
    -DCMAKE_BUILD_TYPE:STRING=$::SBuild(BuildType) \
    -DCMAKE_CXX_FLAGS_DEBUG:STRING=$::SBuild(CMakeCXXFlagsDebug) \
    ../Insight
}

# How do we build on windows?
proc Mythical-Build-Windows {} {
  global SBuild
  cd Insight-build
  ExecuteCommand $SBuild(Make) Mythical.SLN /build  $SBuild(BuildType)
}

# How do we build on other Makefile-based systems?
proc Mythical-Build {} {
  Debug "Building Mythical"
  global SBuild
  cd Insight-build
  eval ExecuteCommand $SBuild(Make) $SBuild(ParallelMake)
}

# Clean up Mythical (nothing for the moment).
proc Mythical-Clean {} {
  Debug "Cleaning Mythical"
}

Links

Information on Free Microsoft C++ Compiler on Windows

To build with the free version of the windows compiler (Developer Studio 9.0 2008 Visual C++ Express), it is important that you follow the instructions on this page.

As of April 11, 2008, this works with the slicer3 svn trunk. You will need to manually install a newer version of cmake as part of the process described in the link above.