Difference between revisions of "Autobuild Shell Functions"

From Second Life Wiki
Jump to navigation Jump to search
(Update instructions about autobuild source_environment with AUTOBUILD vs. autobuild warning)
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Autobuild offers a set of shell functions for use in <tt>build-cmd.sh</tt> scripts which can be added to the environment by inserting the following line into any build script:
{{Autobuild Nav}}


  eval "$("$AUTOBUILD" source_environment)"
{{Warning|This page describes autobuild 1.0. As of 2015-03-20, autobuild 1.0 can be found in [https://bitbucket.org/lindenlab/autobuild-1.0/ this repository]; as of this date, [https://bitbucket.org/lindenlab/autobuild/ the official repository] and [https://pypi.python.org/pypi/autobuild the PyPI package] are still at autobuild 0.8.}}


The exact shell code that is injected into your environment upon execution of this command [https://bitbucket.org/lindenlab/autobuild/src/tip/autobuild/autobuild_tool_source_environment.py is here].
You can install autobuild 1.0 (e.g. into a [http://docs.python-guide.org/en/latest/dev/virtualenvs/ virtualenv]) from the alternate repository using a command such as (bash):


pip install 'hg+http://bitbucket.org/lindenlab/autobuild-1.0#egg=autobuild'
or (Windows command prompt):
pip install  hg+http://bitbucket.org/lindenlab/autobuild-1.0#egg=autobuild
Autobuild offers a set of shell functions for use in <code>build-cmd.sh</code> scripts which can be added to the environment by inserting lines such as the following into your build script:
<br clear=all/>
<source lang="bash">
if [ "$OSTYPE" == "cygwin" ]
then autobuild="$(cygpath -u "$AUTOBUILD")"
else autobuild="$AUTOBUILD"
fi
eval "$("$autobuild" source_environment)"
</source>
{{Warning|The AUTOBUILD environment variable is passed through a number of different programs written in different languages. On Windows, it is essential that AUTOBUILD be a pathname in native syntax (e.g. <tt>c:\Users\Joe\autobuild.exe</tt> or <tt>c:/Users/Joe/autobuild.exe</tt>) rather than cygwin syntax (e.g. <tt>/cygdrive/c/Users/Joe/autobuild.exe</tt>).}}
When invoking autobuild from within your <tt>build-cmd.sh</tt>, you must convert it to cygwin syntax so that cygwin bash doesn't get confused. However, it is '''essential''' to avoid overwriting the AUTOBUILD environment variable itself, or various child programs will, in turn, be confused. Capture the converted autobuild pathname in a ''different'' environment variable local to your script. Since bash environment variables are case-sensitive, it works to use <tt>autobuild</tt> for the cygwin-form path, leaving <tt>AUTOBUILD</tt> for the native-form path.
The exact shell code that is injected into your environment upon execution of this command [https://bitbucket.org/lindenlab/autobuild-1.0/src/tip/autobuild/autobuild_tool_source_environment.py?at=default#cl-161 is here], with (for Windows) additional functions [https://bitbucket.org/lindenlab/autobuild-1.0/src/tip/autobuild/autobuild_tool_source_environment.py?at=default#cl-250 here].
== General functions ==
Shell functions provided by autobuild:
Shell functions provided by autobuild:
:{|border="0" cellpadding="5" style="border-collapse: collapse; border-style: none;"
{| border="1" class=lltable
 
|-
! Function
! Description
|- style="vertical-align: top;"
|- style="vertical-align: top;"
|<nowiki>pass</nowiki>
| pass
|<nowiki>Indicates build has succeeded</nowiki>
| Indicates build has succeeded


|- style="vertical-align: top;"
|- style="vertical-align: top;"
|<nowiki>fail $comment</nowiki>
| fail $comment
|<nowiki>Indicates build has failed, citing $comment in the output</nowiki>
| Indicates build has failed, citing $comment in the output


|- style="vertical-align: top;"
|- style="vertical-align: top;"
|<nowiki>fetch_archive $url $archive $md5</nowiki>
| fetch_archive $url $archive $md5
|<nowiki>Uses curl to download $archive from the $url and checks the downloaded file hash against the $md5 provided.</nowiki>
| Uses curl to download $archive from the $url and checks the downloaded file hash against the $md5 provided.


|- style="vertical-align: top;"
|- style="vertical-align: top;"
|<nowiki>extract $file</nowiki>
| extract $file
| <nowiki>Extracts contents of an archive appropriate for the tar extension of $file.</nowiki>
| Extracts contents of an archive appropriate for the tar extension of $file.


|- style="vertical-align: top;"
|- style="vertical-align: top;"
|<nowiki>calc_md5 $file</nowiki>
| calc_md5 $file
|<nowiki>Calculate the md5 of $file</nowiki>
| Calculate the md5 of $file


|}
|}


 
== Windows-only commands ==
Windows-only shell commands (Cygwin):
Windows-only shell commands (Cygwin):
:{|border="0" cellpadding="5" style="border-collapse: collapse; border-style: none;"


{| border="1" class=lltable
|-
! Function
! Description
|- style="vertical-align: top;"
|- style="vertical-align: top;"
|<nowiki>build_vcproj $vcproj $config</nowiki>
|width=200| build_vcproj $vcproj $config
|<nowiki>Launches a Visual Studio build of $vcproj, building configuration $config. If $USE_INCREDIBUILD is set, the same build is launched via BuildConsole, Incredibuild's command-line launcher.</nowiki>
| Launches a Visual Studio build of $vcproj, building configuration $config.  
If $USE_INCREDIBUILD is set, the same build is launched via BuildConsole, Incredibuild's command-line launcher.


|- style="vertical-align: top;"
|- style="vertical-align: top;"
|<nowiki>build_sln $sln $config $project</nowiki>
| build_sln $sln $config $project
|<nowiki>Launches a Visual Studio build using the solution file $sln, configuration $config, and specifying project $project.</nowiki>
| Launches a Visual Studio build using the solution file $sln, configuration $config, and specifying project $project.
If $project is omitted, then the entire solution will be built.


|- style="vertical-align: top;"
|- style="vertical-align: top;"
|<nowiki>load_vsvars</nowiki>
| load_vsvars
|<nowiki>Import Visual Studio paths, includes and libs into the shell environment</nowiki>
| Import Visual Studio paths, includes and libs into the shell environment


|}
|}
[[Category:Autobuild]]

Latest revision as of 12:03, 20 March 2015


Warning!

This page describes autobuild 1.0. As of 2015-03-20, autobuild 1.0 can be found in this repository; as of this date, the official repository and the PyPI package are still at autobuild 0.8.


You can install autobuild 1.0 (e.g. into a virtualenv) from the alternate repository using a command such as (bash):

pip install 'hg+http://bitbucket.org/lindenlab/autobuild-1.0#egg=autobuild'

or (Windows command prompt):

pip install  hg+http://bitbucket.org/lindenlab/autobuild-1.0#egg=autobuild

Autobuild offers a set of shell functions for use in build-cmd.sh scripts which can be added to the environment by inserting lines such as the following into your build script:

if [ "$OSTYPE" == "cygwin" ]
then autobuild="$(cygpath -u "$AUTOBUILD")"
else autobuild="$AUTOBUILD"
fi
eval "$("$autobuild" source_environment)"
Warning!

The AUTOBUILD environment variable is passed through a number of different programs written in different languages. On Windows, it is essential that AUTOBUILD be a pathname in native syntax (e.g. c:\Users\Joe\autobuild.exe or c:/Users/Joe/autobuild.exe) rather than cygwin syntax (e.g. /cygdrive/c/Users/Joe/autobuild.exe).


When invoking autobuild from within your build-cmd.sh, you must convert it to cygwin syntax so that cygwin bash doesn't get confused. However, it is essential to avoid overwriting the AUTOBUILD environment variable itself, or various child programs will, in turn, be confused. Capture the converted autobuild pathname in a different environment variable local to your script. Since bash environment variables are case-sensitive, it works to use autobuild for the cygwin-form path, leaving AUTOBUILD for the native-form path.

The exact shell code that is injected into your environment upon execution of this command is here, with (for Windows) additional functions here.

General functions

Shell functions provided by autobuild:

Function Description
pass Indicates build has succeeded
fail $comment Indicates build has failed, citing $comment in the output
fetch_archive $url $archive $md5 Uses curl to download $archive from the $url and checks the downloaded file hash against the $md5 provided.
extract $file Extracts contents of an archive appropriate for the tar extension of $file.
calc_md5 $file Calculate the md5 of $file

Windows-only commands

Windows-only shell commands (Cygwin):

Function Description
build_vcproj $vcproj $config Launches a Visual Studio build of $vcproj, building configuration $config.

If $USE_INCREDIBUILD is set, the same build is launched via BuildConsole, Incredibuild's command-line launcher.

build_sln $sln $config $project Launches a Visual Studio build using the solution file $sln, configuration $config, and specifying project $project.

If $project is omitted, then the entire solution will be built.

load_vsvars Import Visual Studio paths, includes and libs into the shell environment