ldc/driver/args.h
Martin Kinkelin 42619762e9 Windows: Read environment variables as UTF-8
And use the wide API for pure is-env-variable-set checks too, as the
first call to a narrow env API function would lead to the C runtime
preparing and maintaining both narrow and wide environments.
2019-08-08 22:38:38 +02:00

50 lines
1.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//===-- driver/args.h - Command-line & environment variables ----*- C++ -*-===//
//
// LDC the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
//
//===----------------------------------------------------------------------===//
#pragma once
#include "llvm/ADT/SmallVector.h"
namespace args {
// On Windows, the host LDC druntime features _d_wrun_main with UTF-16 command-
// line arguments support starting with v2.087.
#if defined(_WIN32) && LDC_HOST_FE_VER >= 2087
#define LDC_WINDOWS_WMAIN 1
using CArgChar = wchar_t;
#else
using CArgChar = char;
#endif
// Converts the native command-line to a vector of UTF-8 arguments.
void getCommandLineArguments(int argc, const CArgChar **argv,
llvm::SmallVectorImpl<const char *> &result);
// Expands any response files (@file), in-place.
void expandResponseFiles(llvm::SmallVectorImpl<const char *> &args);
// Calls _d_run_main with the specified arguments, initializing druntime and
// continuing with _Dmain in driver/main.d.
int forwardToDruntime(int argc, const CArgChar **argv);
// Returns true if the specified arg is either `-run` or `--run`.
bool isRunArg(const char *arg);
}
namespace env {
// Indicates whether the specified environment variable is set.
bool has(const char *name);
#ifdef _WIN32
bool has(const wchar_t *wname);
#endif
// Returns the value of the specified environment variable (in UTF-8).
std::string get(const char *name);
}