Last active
August 29, 2015 14:06
-
-
Save MikaelSmith/d885c72dd87e61e3f969 to your computer and use it in GitHub Desktop.
Build script that downloads dependencies and builds puppetlabs/cfacter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Starting from a base Windows Server 2008r2 or 2012r2 installation, install required tools, setup the PATH, and download and build software. | |
# This script can be run directly from the web using "iex ((new-object net.webclient).DownloadString('<url_to_raw>'))" | |
### Configuration | |
## Setup the working directory | |
$sourceDir=$pwd | |
## Set the number of cores to use for parallel builds | |
$cores=2 | |
## Choose whether to download pre-built libraries or build from source | |
$buildSource=$FALSE | |
## Choose 32 or 64-bit build | |
$arch=64 | |
$mingwVerNum = "4.8.3" | |
$mingwVerChoco = "${mingwVerNum}.20141208" | |
$mingwThreads = "posix" | |
if ($arch -eq 64) { | |
$mingwExceptions = "seh" | |
$mingwArch = "x86_64" | |
} else { | |
$mingwExceptions = "dwarf" | |
$mingwArch = "i686" | |
} | |
$mingwVer = "${mingwArch}_mingw-w64_${mingwVerNum}_${mingwThreads}_${mingwExceptions}" | |
$boostVerNum = "1.55.0" | |
$boostVer = "boost_$(${boostVerNum}.Replace('.', '_'))" | |
$boostPkg = "${boostVer}-${mingwVer}" | |
$yamlCppVerNum = "0.5.1" | |
$yamlCppVer = "yaml-cpp-${yamlCppVerNum}" | |
$yamlPkg = "${yamlCppVer}-${mingwVer}" | |
### Setup, build, and install | |
## Install Chocolatey, then use it to install required tools. | |
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) | |
choco install 7zip.commandline cmake git ruby python doxygen.install | |
choco install mingw -Version "${mingwVerChoco}" | |
$env:PATH = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") | |
cd $sourceDir | |
## Download cfacter and setup build directories | |
git clone --recursive https://github.com/puppetlabs/cfacter | |
mkdir -Force cfacter\release\ext | |
cd cfacter\release | |
$buildDir=$pwd | |
cd ext | |
$toolsDir=$pwd | |
if ($buildSource) { | |
## Download, build, and install Boost | |
(New-Object net.webclient).DownloadFile("http://iweb.dl.sourceforge.net/project/boost/boost/$boostVerNum/$boostVer.7z", "$toolsDir\$boostVer.7z") | |
& 7za x "${boostVer}.7z" | FIND /V "ing " | |
cd $boostVer | |
.\bootstrap mingw | |
$args = @( | |
'toolset=gcc', | |
"--build-type=minimal", | |
"install", | |
"--with-program_options", | |
"--with-system", | |
"--with-filesystem", | |
"--with-date_time", | |
"--with-thread", | |
"--with-regex", | |
"--with-log", | |
"--with-locale", | |
"--prefix=`"$toolsDir\$boostPkg`"", | |
"boost.locale.iconv=off" | |
"-j$cores" | |
) | |
.\b2 $args | |
cd $toolsDir | |
## Download, build, and install yaml-cpp | |
(New-Object net.webclient).DownloadFile("https://yaml-cpp.googlecode.com/files/${yamlCppVer}.tar.gz", "$toolsDir\${yamlCppVer}.tar.gz") | |
& 7za x "${yamlCppVer}.tar.gz" | |
& 7za x "${yamlCppVer}.tar" | FIND /V "ing " | |
cd $yamlCppVer | |
mkdir build | |
cd build | |
$args = @( | |
'-G', | |
"MinGW Makefiles", | |
"-DBOOST_ROOT=`"$toolsDir\$boostPkg`"", | |
"-DCMAKE_INSTALL_PREFIX=`"$toolsDir\$yamlPkg`"", | |
".." | |
) | |
cmake $args | |
mingw32-make install -j $cores | |
cd $toolsDir | |
} else { | |
## Download and unpack Boost from a pre-built package in S3 | |
(New-Object net.webclient).DownloadFile("https://s3.amazonaws.com/kylo-pl-bucket/${boostPkg}.7z", "$toolsDir\${boostPkg}.7z") | |
& 7za x "${boostPkg}.7z" | FIND /V "ing " | |
## Download and unpack yaml-cpp from a pre-built package in S3 | |
(New-Object net.webclient).DownloadFile("https://s3.amazonaws.com/kylo-pl-bucket/${yamlPkg}.7z", "$toolsDir\${yamlPkg}.7z") | |
& 7za x "${yamlPkg}.7z" | FIND /V "ing " | |
} | |
## Build CFacter | |
cd $buildDir | |
$args = @( | |
'-G', | |
"MinGW Makefiles", | |
"-DBOOST_ROOT=`"$toolsDir\$boostPkg`"", | |
"-DYAMLCPP_ROOT=`"$toolsDir\$yamlPkg`"", | |
"-DBOOST_STATIC=ON", | |
".." | |
) | |
cmake $args | |
mingw32-make -j $cores |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should be retired in favor of using https://github.com/puppetlabs/cfacter/blob/master/contrib/cfacter.ps1