Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions scripts/azure-pipelines/windows/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ jobs:
condition: always()
inputs:
filePath: 'scripts/azure-pipelines/windows/disk-space.ps1'
- task: Powershell@2
displayName: 'Check C++ Formatting'
condition: eq('${{ parameters.triplet }}', 'x86-windows')
inputs:
filePath: 'scripts/azure-pipelines/windows/check-formatting.ps1'
arguments: '-Toolsrc ./toolsrc'
# Note: D: is the Azure machines' temporary disk.
- task: CmdLine@2
displayName: 'Build vcpkg'
Expand Down
54 changes: 54 additions & 0 deletions scripts/azure-pipelines/windows/check-formatting.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$Toolsrc,
[Parameter()]
[switch]$IgnoreErrors # allows one to just format
)

$clangFormat = 'C:\Program Files\LLVM\bin\clang-format.exe'
if (-not (Test-Path $clangFormat))
{
Write-Error "clang-format not found; is it installed in the CI machines?"
throw
}

$Toolsrc = Get-Item $Toolsrc
Push-Location $Toolsrc

try
{
$files = Get-ChildItem -Recurse -LiteralPath "$Toolsrc/src" -Filter '*.cpp'
$files += Get-ChildItem -Recurse -LiteralPath "$Toolsrc/include/vcpkg" -Filter '*.h'
$files += Get-ChildItem -Recurse -LiteralPath "$Toolsrc/include/vcpkg-test" -Filter '*.h'
$files += Get-Item "$Toolsrc/include/pch.h"
$fileNames = $files.FullName

& $clangFormat -style=file -i @fileNames

$changedFiles = git status --porcelain $Toolsrc | ForEach-Object {
(-split $_)[1]
}

if (-not $IgnoreErrors -and $null -ne $changedFiles)
{
$msg = @(
"",
"The formatting of the C++ files didn't match our expectation.",
"If your build fails here, you need to format the following files with:"
)
$msg += " $(& $clangFormat -version)"
$msg += " $changedFiles"
$msg += ""

$msg += "clang-format should produce the following diff:"
$msg += git diff $Toolsrc

Write-Error ($msg -join "`n")
throw
}
}
finally
{
Pop-Location
}
24 changes: 24 additions & 0 deletions scripts/azure-pipelines/windows/provision-image.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,30 @@ Function InstallLLVM {
}
}

<#
.SYNOPSIS
Installs LLVM.

.DESCRIPTION
InstallLLVM installs LLVM from the supplied URL.

.PARAMETER Url
The URL of the LLVM installer.
#>
Function InstallLLVM {
try {
Write-Host 'Downloading LLVM...'
[string]$installerPath = Get-TempFilePath -Extension 'exe'
curl.exe -L -o $installerPath -s -S $Url
Write-Host 'Installing LLVM...'
$proc = Start-Process -FilePath $installerPath -ArgumentList @('/S') -NoNewWindow -Wait -PassThru
PrintMsiExitCodeMessage $proc.ExitCode
}
catch {
Write-Error "Failed to install LLVM! $($_.Exception.Message)"
}
}

<#
.SYNOPSIS
Installs MPI
Expand Down
18 changes: 15 additions & 3 deletions toolsrc/.clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
BasedOnStyle: WebKit
Language: Cpp
Standard: Cpp11
Expand Down Expand Up @@ -32,6 +31,19 @@ ForEachMacros: [TEST_CASE, SECTION]
PenaltyReturnTypeOnItsOwnLine: 1000
SpaceAfterTemplateKeyword: false
SpaceBeforeCpp11BracedList: false
UseCRLF: false

IncludeBlocks: Preserve
SortIncludes: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^(<vcpkg/base/system_headers\.h>|"pch\.h")$'
Priority: -1
- Regex: '^<catch2/catch\.hpp>$'
Priority: 1
- Regex: '^<vcpkg/base/*\.h>$'
Priority: 2
- Regex: '^<vcpkg/*\.h>$'
Priority: 3
- Regex: '^<[a-z0-9_]*\.h>$'
Priority: 4
- Regex: '^<[a-z0-9_]*>$' # C++ standard library
Priority: 5
6 changes: 4 additions & 2 deletions toolsrc/include/pch.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include <vcpkg/base/pragmas.h>
#include <vcpkg/base/system_headers.h>

#include <vcpkg/base/pragmas.h>

#if defined(_WIN32)
#include <process.h>
#include <shellapi.h>
Expand Down Expand Up @@ -49,9 +50,10 @@
#include <sys/time.h>
#endif

#include <time.h>

#include <system_error>
#include <thread>
#include <time.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
Expand Down
12 changes: 6 additions & 6 deletions toolsrc/include/vcpkg-test/util.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <vcpkg/base/system_headers.h>

#include <catch2/catch.hpp>
#include <vcpkg/base/pragmas.h>

#include <memory>

#include <vcpkg/base/files.h>
#include <vcpkg/base/pragmas.h>
#include <vcpkg/statusparagraph.h>

#include <memory>

#define CHECK_EC(ec) \
do \
{ \
Expand Down Expand Up @@ -54,7 +54,7 @@ namespace vcpkg::Test
{
std::unordered_map<std::string, SourceControlFileLocation> map;
Triplet triplet;
PackageSpecMap(Triplet t = Triplet::X86_WINDOWS) noexcept : triplet(t) {}
PackageSpecMap(Triplet t = Triplet::X86_WINDOWS) noexcept : triplet(t) { }

PackageSpec emplace(const char* name,
const char* depends = "",
Expand Down Expand Up @@ -86,9 +86,9 @@ namespace vcpkg::Test
Yes = true,
} tag;

constexpr AllowSymlinks(Tag tag) noexcept : tag(tag) {}
constexpr AllowSymlinks(Tag tag) noexcept : tag(tag) { }

constexpr explicit AllowSymlinks(bool b) noexcept : tag(b ? Yes : No) {}
constexpr explicit AllowSymlinks(bool b) noexcept : tag(b ? Yes : No) { }

constexpr operator bool() const noexcept { return tag == Yes; }
};
Expand Down
16 changes: 8 additions & 8 deletions toolsrc/include/vcpkg/base/chrono.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#pragma once

#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/optional.h>

#include <chrono>
#include <string>

#include <vcpkg/base/cstringview.h>
#include <vcpkg/base/optional.h>

namespace vcpkg::Chrono
{
class ElapsedTime
{
using duration = std::chrono::high_resolution_clock::time_point::duration;

public:
constexpr ElapsedTime() noexcept : m_duration() {}
constexpr ElapsedTime(duration d) noexcept : m_duration(d) {}
constexpr ElapsedTime() noexcept : m_duration() { }
constexpr ElapsedTime(duration d) noexcept : m_duration(d) { }

template<class TimeUnit>
TimeUnit as() const
Expand All @@ -34,7 +34,7 @@ namespace vcpkg::Chrono
public:
static ElapsedTimer create_started();

constexpr ElapsedTimer() noexcept : m_start_tick() {}
constexpr ElapsedTimer() noexcept : m_start_tick() { }

ElapsedTime elapsed() const
{
Expand All @@ -56,8 +56,8 @@ namespace vcpkg::Chrono
static Optional<CTime> get_current_date_time();
static Optional<CTime> parse(CStringView str);

constexpr CTime() noexcept : m_tm{} {}
explicit constexpr CTime(tm t) noexcept : m_tm{t} {}
constexpr CTime() noexcept : m_tm{} { }
explicit constexpr CTime(tm t) noexcept : m_tm{t} { }

CTime add_hours(const int hours) const;

Expand Down
4 changes: 2 additions & 2 deletions toolsrc/include/vcpkg/base/cofffilereader.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include <vector>

#include <vcpkg/base/files.h>
#include <vcpkg/base/machinetype.h>

#include <vector>

namespace vcpkg::CoffFileReader
{
struct DllInfo
Expand Down
6 changes: 3 additions & 3 deletions toolsrc/include/vcpkg/base/cstringview.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ namespace vcpkg
{
struct CStringView
{
constexpr CStringView() noexcept : cstr(nullptr) {}
constexpr CStringView(const char* cstr) : cstr(cstr) {}
constexpr CStringView() noexcept : cstr(nullptr) { }
constexpr CStringView(const char* cstr) : cstr(cstr) { }
constexpr CStringView(const CStringView&) = default;
CStringView(const std::string& str) : cstr(str.c_str()) {}
CStringView(const std::string& str) : cstr(str.c_str()) { }

constexpr const char* c_str() const { return cstr; }

Expand Down
4 changes: 2 additions & 2 deletions toolsrc/include/vcpkg/base/enums.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <vcpkg/base/lineinfo.h>

#include <string>

#include <vcpkg/base/lineinfo.h>

namespace vcpkg::Enums
{
std::string nullvalue_to_string(const CStringView enum_name);
Expand Down
6 changes: 3 additions & 3 deletions toolsrc/include/vcpkg/base/expected.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#pragma once

#include <system_error>

#include <vcpkg/base/checks.h>
#include <vcpkg/base/stringliteral.h>

#include <system_error>

namespace vcpkg
{
template<class Err>
struct ErrorHolder
{
ErrorHolder() : m_is_error(false), m_err{} {}
ErrorHolder() : m_is_error(false), m_err{} { }
template<class U>
ErrorHolder(U&& err) : m_is_error(true), m_err(std::forward<U>(err))
{
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/include/vcpkg/base/graphs.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace vcpkg::Graphs
virtual int random(int max_exclusive) = 0;

protected:
~Randomizer() {}
~Randomizer() { }
};

namespace details
Expand Down
4 changes: 2 additions & 2 deletions toolsrc/include/vcpkg/base/hash.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <vcpkg/base/files.h>

#include <string>

#include <vcpkg/base/files.h>

namespace vcpkg::Hash
{
enum class Algorithm
Expand Down
11 changes: 6 additions & 5 deletions toolsrc/include/vcpkg/base/json.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#pragma once

#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/parse.h>
#include <vcpkg/base/stringview.h>

#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <string>
#include <utility>
#include <vector>

#include <vcpkg/base/expected.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/parse.h>
#include <vcpkg/base/stringview.h>

namespace vcpkg::Json
{
struct JsonStyle
Expand Down
2 changes: 1 addition & 1 deletion toolsrc/include/vcpkg/base/lazy.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace vcpkg
class Lazy
{
public:
Lazy() : value(T()), initialized(false) {}
Lazy() : value(T()), initialized(false) { }

template<class F>
T const& get_lazy(const F& f) const
Expand Down
4 changes: 2 additions & 2 deletions toolsrc/include/vcpkg/base/lineinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace vcpkg
{
struct LineInfo
{
constexpr LineInfo() noexcept : m_line_number(0), m_file_name("") {}
constexpr LineInfo(const int lineno, const char* filename) : m_line_number(lineno), m_file_name(filename) {}
constexpr LineInfo() noexcept : m_line_number(0), m_file_name("") { }
constexpr LineInfo(const int lineno, const char* filename) : m_line_number(lineno), m_file_name(filename) { }

std::string to_string() const;
void to_string(std::string& out) const;
Expand Down
Loading