2022-09-06 19:14:07 -04:00
|
|
|
|
// Copyright 2014 The Crashpad Authors
|
2014-08-20 15:18:55 -04:00
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
#ifndef CRASHPAD_TOOLS_TOOL_SUPPORT_H_
|
|
|
|
|
#define CRASHPAD_TOOLS_TOOL_SUPPORT_H_
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2015-05-06 10:28:07 -07:00
|
|
|
|
#include "base/files/file_path.h"
|
2015-05-06 11:09:31 -07:00
|
|
|
|
#include "base/strings/string_piece.h"
|
2015-05-06 10:28:07 -07:00
|
|
|
|
#include "build/build_config.h"
|
2014-08-20 15:18:55 -04:00
|
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
|
|
|
|
|
|
//! \brief Common functions used by command line tools.
|
|
|
|
|
class ToolSupport {
|
|
|
|
|
public:
|
2021-09-20 12:55:12 -07:00
|
|
|
|
ToolSupport() = delete;
|
|
|
|
|
ToolSupport(const ToolSupport&) = delete;
|
|
|
|
|
ToolSupport& operator=(const ToolSupport&) = delete;
|
|
|
|
|
|
2014-08-20 15:18:55 -04:00
|
|
|
|
//! \brief Handles `--version`.
|
|
|
|
|
//!
|
|
|
|
|
//! \param[in] me The tool’s name, the basename of `argv[0]`.
|
2015-05-06 10:28:07 -07:00
|
|
|
|
static void Version(const base::FilePath& me);
|
2014-08-20 15:18:55 -04:00
|
|
|
|
|
|
|
|
|
//! \brief Prints the footer for `--help`.
|
|
|
|
|
//!
|
|
|
|
|
//! \param[in] me The tool’s name, the basename of `argv[0]`.
|
2015-05-06 10:28:07 -07:00
|
|
|
|
static void UsageTail(const base::FilePath& me);
|
2014-08-20 15:18:55 -04:00
|
|
|
|
|
|
|
|
|
//! \brief Suggests using `--help` when a command line tool can’t make sense
|
|
|
|
|
//! of its arguments.
|
|
|
|
|
//!
|
|
|
|
|
//! \param[in] me The tool’s name, the basename of `argv[0]`.
|
doc: Fix all Doxygen warnings, cleaning up some generated documentation
This makes Doxygen’s output more actionable by setting QUIET = YES to
suppress verbose progress spew, and WARN_IF_UNDOCUMENTED = NO to prevent
warnings for undocumented classes and members from being generated. The
latter is too noisy, producing 721 warnings in the current codebase.
The remaining warnings produced by Doxygen were useful and actionable.
They fell into two categories: abuses of Doxygen’s markup syntax, and
missing (or misspelled) parameter documentation. In a small number of
cases, pass-through parameters had intentionally been left undocumented.
In these cases, they are now given blank \param descriptions. This is
not optimal, but there doesn’t appear to be any other way to tell
Doxygen to allow a single parameter to be undocumented.
Some tricky Doxygen errors were resolved by asking it to not enter
directiores that we do not provide documentation in (such as the
“on-platform” compat directories, compat/mac and compat/win, as well as
compat/non_cxx11_lib) while allowing it to enter the
“off-platform” directories that we do document (compat/non_mac and
compat/non_win).
A Doxygen run (doc/support/generate_doxygen.sh) now produces no output
at all. It would produce warnings if any were triggered.
Not directly related, but still relevant to documentation,
doc/support/generate.sh is updated to remove temporary removals of
now-extinct files and directories. doc/appengine/README is updated so
that a consistent path to “goapp” is used throughout the file.
Change-Id: I300730c04de4d3340551ea3086ca70cc5ff862d1
Reviewed-on: https://chromium-review.googlesource.com/408812
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-08 14:23:09 -05:00
|
|
|
|
//! \param[in] hint A hint to display before the suggestion to try `--help`.
|
|
|
|
|
//! Optional, may be `nullptr`, in which case no hint will be presented.
|
2015-05-06 10:28:07 -07:00
|
|
|
|
static void UsageHint(const base::FilePath& me, const char* hint);
|
|
|
|
|
|
2022-01-19 15:00:24 -05:00
|
|
|
|
#if BUILDFLAG(IS_POSIX) || DOXYGEN
|
2015-05-06 10:28:07 -07:00
|
|
|
|
//! \copydoc Version
|
|
|
|
|
static void Version(const std::string& me);
|
|
|
|
|
|
|
|
|
|
//! \copydoc UsageTail
|
|
|
|
|
static void UsageTail(const std::string& me);
|
|
|
|
|
|
|
|
|
|
//! \copydoc UsageHint
|
2014-08-20 15:18:55 -04:00
|
|
|
|
static void UsageHint(const std::string& me, const char* hint);
|
2022-01-19 15:00:24 -05:00
|
|
|
|
#endif // BUILDFLAG(IS_POSIX)
|
2014-08-20 15:18:55 -04:00
|
|
|
|
|
2022-01-19 15:00:24 -05:00
|
|
|
|
#if BUILDFLAG(IS_WIN) || DOXYGEN
|
2015-05-06 11:09:31 -07:00
|
|
|
|
//! \brief Converts \a argv `wchar_t` UTF-16 to UTF-8, and passes onwards to a
|
|
|
|
|
//! UTF-8 entry point.
|
|
|
|
|
//!
|
|
|
|
|
//! \return The return value of \a entry.
|
|
|
|
|
static int Wmain(int argc, wchar_t* argv[], int (*entry)(int, char*[]));
|
2022-01-19 15:00:24 -05:00
|
|
|
|
#endif // BUILDFLAG(IS_WIN)
|
2015-05-06 11:09:31 -07:00
|
|
|
|
|
|
|
|
|
//! \brief Converts a command line argument to the string type suitable for
|
|
|
|
|
//! base::FilePath.
|
|
|
|
|
//!
|
|
|
|
|
//! On POSIX, this is a no-op. On Windows, assumes that Wmain() was used, and
|
|
|
|
|
//! the input argument was converted from UTF-16 in a `wchar_t*` to UTF-8 in a
|
|
|
|
|
//! `char*`. This undoes that transformation.
|
|
|
|
|
//!
|
|
|
|
|
//! \sa Wmain()
|
2017-03-03 15:11:50 -05:00
|
|
|
|
//! \sa FilePathToCommandLineArgument()
|
2015-05-06 11:09:31 -07:00
|
|
|
|
static base::FilePath::StringType CommandLineArgumentToFilePathStringType(
|
|
|
|
|
const base::StringPiece& arg);
|
|
|
|
|
|
2017-03-03 15:11:50 -05:00
|
|
|
|
//! \brief Converts a base::FilePath to a command line argument.
|
|
|
|
|
//!
|
|
|
|
|
//! On POSIX, this is a no-op. On Windows, this undoes the transformation done
|
|
|
|
|
//! by CommandLineArgumentToFilePathStringType() in the same manner as
|
|
|
|
|
//! Wmain().
|
|
|
|
|
static std::string FilePathToCommandLineArgument(
|
|
|
|
|
const base::FilePath& file_path);
|
2014-08-20 15:18:55 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace crashpad
|
|
|
|
|
|
|
|
|
|
#endif // CRASHPAD_TOOLS_TOOL_SUPPORT_H_
|