Skip to content

Commit

Permalink
[vcpkg] Add Forward Declarations (originally by @cngzhnp) (microsoft#…
Browse files Browse the repository at this point in the history
…12985)

Co-authored-by: cngzhnp <[email protected]>
  • Loading branch information
strega-nil and cngzhnp authored Aug 19, 2020
1 parent c8b5803 commit ed78528
Show file tree
Hide file tree
Showing 57 changed files with 172 additions and 67 deletions.
10 changes: 6 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ IncludeCategories:
Priority: -1
- Regex: '^<catch2/catch\.hpp>$'
Priority: 1
- Regex: '^<vcpkg/base/.*\.h>$'
- Regex: '^<vcpkg/fwd/.*\.h>$'
Priority: 2
- Regex: '^<vcpkg/.*\.h>$'
- Regex: '^<vcpkg/base/.*\.h>$'
Priority: 3
- Regex: '^<[a-z0-9_]*\.h>$'
- Regex: '^<vcpkg/.*\.h>$'
Priority: 4
- Regex: '^<[a-z0-9_]*>$' # C++ standard library
- Regex: '^<[a-z0-9_]*\.h>$'
Priority: 5
- Regex: '^<[a-z0-9_]*>$' # C++ standard library
Priority: 6
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ if(CLANG_FORMAT)
add_custom_target(format COMMAND ${CLANG_FORMAT} -i -verbose
${CMAKE_CURRENT_SOURCE_DIR}/src/pch.cpp
${VCPKGLIB_BASE_SOURCES}
${VCPKGLIB_NON_PCH_SOURCES}
${VCPKGLIB_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/include/pch.h
${VCPKGLIB_BASE_INCLUDES}
${VCPKGLIB_NON_PCH_INCLUDES}
${VCPKGLIB_INCLUDES}

${VCPKG_SOURCES}
${VCPKGMETRICSUPLOADER_SOURCES}
Expand Down
2 changes: 1 addition & 1 deletion include/vcpkg-test/mockcmakevarprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace vcpkg::Test
{
for (auto&& spec : specs)
tag_vars[spec.package_spec] = {};
Util::unused(port_provider);
(void)(port_provider);
}

Optional<const std::unordered_map<std::string, std::string>&> get_generic_triplet_vars(
Expand Down
4 changes: 2 additions & 2 deletions include/vcpkg/archives.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <vcpkg/base/files.h>
#include <vcpkg/fwd/vcpkgpaths.h>

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

namespace vcpkg::Archives
{
Expand Down
11 changes: 0 additions & 11 deletions include/vcpkg/base/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,4 @@ namespace vcpkg::Util
return e == E::YES;
}
}

template<class... Ts>
void unused(const Ts&...)
{
}

template<class T>
T copy(const T& t)
{
return t;
}
}
6 changes: 4 additions & 2 deletions include/vcpkg/buildenvironment.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <vcpkg/base/system.process.h>
#pragma once

#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/vcpkgpaths.h>
#include <vcpkg/base/system.process.h>

#include <string>
#include <vector>
Expand Down
3 changes: 2 additions & 1 deletion include/vcpkg/cmakevars.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once

#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/base/optional.h>

#include <vcpkg/portfileprovider.h>
#include <vcpkg/vcpkgpaths.h>

namespace vcpkg::Dependencies
{
Expand Down
6 changes: 0 additions & 6 deletions include/vcpkg/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

#include <vcpkg/build.h>
#include <vcpkg/commands.interface.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/statusparagraphs.h>

#include <array>
#include <map>
#include <vector>

namespace vcpkg::Commands
{
Expand Down
8 changes: 6 additions & 2 deletions include/vcpkg/commands.interface.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#pragma once

#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkgpaths.h>
#include <vcpkg/fwd/vcpkgcmdarguments.h>
#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/base/files.h>

#include <vcpkg/triplet.h>

namespace vcpkg::Commands
{
Expand Down
1 change: 1 addition & 0 deletions include/vcpkg/commands.owns.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <vcpkg/commands.interface.h>
#include <vcpkg/vcpkgcmdarguments.h>

namespace vcpkg::Commands::Owns
{
Expand Down
1 change: 1 addition & 0 deletions include/vcpkg/commands.search.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <vcpkg/commands.interface.h>
#include <vcpkg/vcpkgcmdarguments.h>

namespace vcpkg::Commands::Search
{
Expand Down
19 changes: 15 additions & 4 deletions include/vcpkg/dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
#include <vcpkg/base/util.h>

#include <vcpkg/build.h>
#include <vcpkg/cmakevars.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/portfileprovider.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkgpaths.h>

#include <functional>
#include <map>
Expand All @@ -19,6 +15,21 @@ namespace vcpkg::Graphs
struct Randomizer;
}

namespace vcpkg::CMakeVars
{
struct CMakeVarProvider;
}

namespace vcpkg::PortFileProvider
{
struct PortFileProvider;
}

namespace vcpkg
{
struct StatusParagraphs;
}

namespace vcpkg::Dependencies
{
enum class RequestType
Expand Down
3 changes: 2 additions & 1 deletion include/vcpkg/export.ifw.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgpaths.h>

#include <string>
#include <vector>
Expand Down
6 changes: 6 additions & 0 deletions include/vcpkg/fwd/registries.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

namespace vcpkg
{
struct Registry;
}
13 changes: 13 additions & 0 deletions include/vcpkg/fwd/vcpkgcmdarguments.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

namespace vcpkg
{
struct ParsedArguments;
struct CommandSwitch;
struct CommandSetting;
struct CommandMultiSetting;
struct CommandOptionsStructure;
struct CommandStructure;
struct HelpTableFormatter;
struct VcpkgCmdArguments;
}
8 changes: 8 additions & 0 deletions include/vcpkg/fwd/vcpkgpaths.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

namespace vcpkg
{
struct ToolsetArchOption;
struct Toolset;
struct VcpkgPaths;
}
32 changes: 32 additions & 0 deletions include/vcpkg/registries.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <vcpkg/base/files.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/
#include <vcpkg/fwd/registries.h>

#include <memory>
#include <string>
#include <system_error>
#include <vector>

namespace vcpkg
{
struct RegistryImpl
{
virtual void update(std::error_code&) = 0;
virtual Optional<fs::path> find_port(StringView name) const = 0;

virtual ~RegistryImpl() = default;
};

struct Registry
{
std::string name;
std::vector<std::string> packages;

std::unique_ptr<RegistryImpl> underlying;
};

}
4 changes: 3 additions & 1 deletion include/vcpkg/statusparagraph.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/binaryparagraph.h>

#include <map>
Expand Down Expand Up @@ -62,5 +64,5 @@ namespace vcpkg
std::vector<const StatusParagraph*> features;
};

Json::Value serialize_ipv(const InstalledPackageView& ipv, const struct VcpkgPaths& paths);
Json::Value serialize_ipv(const InstalledPackageView& ipv, const VcpkgPaths& paths);
}
4 changes: 2 additions & 2 deletions include/vcpkg/tools.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/base/files.h>

#include <string>
#include <utility>

namespace vcpkg
{
struct VcpkgPaths;

namespace Tools
{
static const std::string SEVEN_ZIP = "7zip";
Expand Down
5 changes: 3 additions & 2 deletions include/vcpkg/vcpkgcmdarguments.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

#include <vcpkg/fwd/vcpkgcmdarguments.h>
#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/base/files.h>
#include <vcpkg/base/optional.h>
#include <vcpkg/base/span.h>
Expand All @@ -19,8 +22,6 @@ namespace vcpkg
std::unordered_map<std::string, std::vector<std::string>> multisettings;
};

struct VcpkgPaths;

struct CommandSwitch
{
constexpr CommandSwitch(const StringLiteral& name, const StringLiteral& short_help_text)
Expand Down
2 changes: 2 additions & 0 deletions include/vcpkg/vcpkgpaths.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/base/cache.h>
#include <vcpkg/base/files.h>
#include <vcpkg/base/lazy.h>
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg-test/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ namespace vcpkg::Test
ec.assign(errno, std::system_category());
}
#else
Util::unused(target, file, ec);
(void)(target, file, ec);
vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message);
#endif
}
Expand All @@ -217,7 +217,7 @@ namespace vcpkg::Test
#elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX
::vcpkg::Test::create_symlink(target, file, ec);
#else
Util::unused(target, file, ec);
(void)(target, file, ec);
vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message);
#endif
}
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/archives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <vcpkg/archives.h>
#include <vcpkg/commands.h>
#include <vcpkg/tools.h>
#include <vcpkg/vcpkgpaths.h>

namespace vcpkg::Archives
{
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/base/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ namespace vcpkg::Files
std::error_code& ec) override
{
this->rename(oldpath, newpath, ec);
Util::unused(temp_suffix);
(void)(temp_suffix);
#if !defined(_WIN32)
if (ec)
{
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/base/system.print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace vcpkg::System
#else
// TODO: add color handling code
// it should probably use VT-220 codes
Util::unused(c);
(void)(c);
System::print2(message);
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ namespace vcpkg::Build
#if !defined(_WIN32)
// TODO: remove when vcpkg.exe is in charge for acquiring tools. Change introduced in vcpkg v0.0.107.
// bootstrap should have already downloaded ninja, but making sure it is present in case it was deleted.
vcpkg::Util::unused(paths.get_tool_exe(Tools::NINJA));
(void)(paths.get_tool_exe(Tools::NINJA));
#endif
std::vector<System::CMakeVariable> cmake_args{
{"CURRENT_PORT_DIR", paths.scripts / "detect_compiler"},
Expand Down Expand Up @@ -539,7 +539,7 @@ namespace vcpkg::Build
#if !defined(_WIN32)
// TODO: remove when vcpkg.exe is in charge for acquiring tools. Change introduced in vcpkg v0.0.107.
// bootstrap should have already downloaded ninja, but making sure it is present in case it was deleted.
vcpkg::Util::unused(paths.get_tool_exe(Tools::NINJA));
(void)(paths.get_tool_exe(Tools::NINJA));
#endif
auto& scfl = action.source_control_file_location.value_or_exit(VCPKG_LINE_INFO);
auto& scf = *scfl.source_control_file;
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/buildenvironment.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <vcpkg/buildenvironment.h>
#include <vcpkg/tools.h>
#include <vcpkg/vcpkgpaths.h>

namespace vcpkg
{
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/commands.autocomplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <vcpkg/metrics.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/remove.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkglib.h>

namespace vcpkg::Commands::Autocomplete
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/commands.buildexternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <vcpkg/commands.buildexternal.h>
#include <vcpkg/help.h>
#include <vcpkg/input.h>
#include <vcpkg/vcpkgcmdarguments.h>

namespace vcpkg::Commands::BuildExternal
{
Expand Down
3 changes: 2 additions & 1 deletion src/vcpkg/commands.cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <vcpkg/commands.cache.h>
#include <vcpkg/help.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/vcpkgcmdarguments.h>

namespace vcpkg::Commands::Cache
{
Expand Down Expand Up @@ -36,7 +37,7 @@ namespace vcpkg::Commands::Cache

void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
Util::unused(args.parse_arguments(COMMAND_STRUCTURE));
(void)(args.parse_arguments(COMMAND_STRUCTURE));

const std::vector<BinaryParagraph> binary_paragraphs = read_all_binary_paragraphs(paths);
if (binary_paragraphs.empty())
Expand Down
Loading

0 comments on commit ed78528

Please sign in to comment.