File: appveyor_ci_build.ps1

package info (click to toggle)
cpputest 4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,688 kB
  • sloc: cpp: 31,212; sh: 4,978; ansic: 1,360; makefile: 775; ruby: 676; xml: 8; sed: 1
file content (116 lines) | stat: -rw-r--r-- 3,477 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

# Load functions from the helper file
. (Join-Path (Split-Path $MyInvocation.MyCommand.Path) 'appveyor_helpers.ps1')

function Invoke-BuildCommand($command, $directory = '.')
{
    $command_wrapped = "$command;`$err = `$?"
    Write-Host $command

    Push-Location $directory
    Invoke-Expression $command_wrapped

    if ($LASTEXITCODE -ne 0)
    {
        Pop-Location
        Write-Host "Command Returned error: $LASTEXITCODE"
        Exit $LASTEXITCODE
    }

    Pop-Location
}

function Invoke-CygwinCommand($command, $directory = '.')
{
    # Assume cygwin is located at C:\cygwin on x86 and C:\cygwin64 on x64 for now
    $cygwin_bin = Get-CygwinBin

    $cygwin_directory = (. "${cygwin_bin}\cygpath.exe" (Resolve-Path $directory))
    $command_wrapped = "${cygwin_bin}\bash.exe --login -c 'cd $cygwin_directory ; $command'"

    Write-Host "Executing <$command> in <$cygwin_directory>"
    Invoke-Expression $command_wrapped

    if ($LASTEXITCODE -ne 0)
    {
        Write-Host "Command Returned error: $LASTEXITCODE"
        Exit $LASTEXITCODE
    }
}

# The project files that will get built
$VS2008ProjectFiles = @( 'CppUTest.vcproj' , 'tests\AllTests.vcproj'  )
$VS2010ProjectFiles = @( 'CppUTest.vcxproj', 'tests\AllTests.vcxproj' )

if ($env:APPVEYOR)
{
    $logger_arg = '/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"'
}
else
{
    $logger_arg = ''
}

# Clean up some paths for any configuration
Remove-PathFolder "C:\MinGW\bin"
Remove-PathFolder "C:\Program Files\Git\bin"
Remove-PathFolder "C:\Program Files\Git\cmd"
Remove-PathFolder "C:\Program Files\Git\usr\bin"
Remove-PathFolder "C:\Program Files (x86)\Git\bin"
Remove-PathFolder "C:\Program Files (x86)\Git\cmd"
Remove-PathFolder "C:\Program Files (x86)\Git\usr\bin"

switch -Wildcard ($env:Platform)
{
    'Cygwin*'
    {
        Invoke-CygwinCommand "autoreconf -i .." "cpputest_build"
        Invoke-CygwinCommand "../configure" "cpputest_build"
        Invoke-CygwinCommand "make CppUTestTests.exe CppUTestExtTests.exe" "cpputest_build"
    }

    'MinGW*'
    {
        $mingw_path = Get-MinGWBin

        if ($env:Platform -like 'MinGWClang*')
        {
            $toolchain_filename = Get-ClangToolchainFilename
            $toolchain_path = (Join-Path (Split-Path $MyInvocation.MyCommand.Path) "..\cmake\$toolchain_filename")
            $toolchain = "-DCMAKE_TOOLCHAIN_FILE=$toolchain_path"
        }

        # Add mingw to the path
        Add-PathFolder $mingw_path

        Invoke-BuildCommand "cmake --version"
        Invoke-BuildCommand "cmake -G 'MinGW Makefiles' -DCMAKE_CXX_STANDARD=17 $toolchain .." 'cpputest_build'
        Invoke-BuildCommand "mingw32-make all" 'cpputest_build'

        Remove-PathFolder $mingw_path
    }

    default   # Assume that anything else uses Visual C++
    {
        if ($env:PlatformToolset -eq 'v90')
        {
            # Load environment variables from vsvars32.bat
            $vsvarspath = Join-Path $env:VS90COMNTOOLS vsvars32.bat
            Get-BatchFile($vsvarspath)

            $VS2008ProjectFiles | foreach {
                Invoke-BuildCommand "vcbuild /upgrade $_"
            }

            $VS2008ProjectFiles | foreach {
                Invoke-BuildCommand "vcbuild $_ $env:CONFIGURATION"
            }
        }
        else
        {
            $VS2010ProjectFiles | foreach {
                Invoke-BuildCommand "msbuild /ToolsVersion:14.0 $logger_arg $_"
            }
        }
    }
}