mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:20:10 +01:00
This shifts explorer's file_test to use ExplorerMain in order to be able to pass arguments similar to how the command line would. It also means that various output wrapping done by the command line is shared, no longer copied by file_test. In order to help make this work, I plugged vfs::FileSystem into explorer, similar to how we're doing this on the toolchain side (might try to share more code later). I was having trouble getting an overlay working, I think due to how paths are specified -- but due to the issues in fixing this, I'm just loading the prelude into the InMemoryFilesystem for now. Under this approach, I'm unifying more of the file versus string handling. I think we should shift towards an approach where, like toolchain code, anyone trying to use Explorer should use a vfs implementation to supply code. This should reduce the number of distinct code paths which we're maintaining/testing. Short-term, this allows the trace testdata to be merged into file_test with less special casing, using ARGS:. Long-term, it means that the file_test knows the ARGS to pass to generate checks to match against, which is the direction I'm planning for autoupdate.
35 lines
1.4 KiB
C++
35 lines
1.4 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_EXPLORER_MAIN_H_
|
|
#define CARBON_EXPLORER_MAIN_H_
|
|
|
|
#include "common/ostream.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/Support/VirtualFileSystem.h"
|
|
|
|
namespace Carbon {
|
|
|
|
// Runs explorer. relative_prelude_path must be POSIX-style, not native, and
|
|
// will be translated to native.
|
|
auto ExplorerMain(int argc, char** argv, void* static_for_main_addr,
|
|
llvm::StringRef relative_prelude_path) -> int;
|
|
|
|
// Wrapped by the above, but without some process init. This is used directly by
|
|
// tests, whereas the above is used directly by main binaries. The
|
|
// out_stream_for_trace is only used when `--trace_file=-` is specified.
|
|
//
|
|
// TODO: We use argc/argv for parameters because command line parsing requires
|
|
// it. When that's replaced, we should switch to
|
|
// llvm::SmallVector<llvm::StringRef> args because it'll work better with tests.
|
|
auto ExplorerMain(int argc, const char** argv, llvm::StringRef install_path,
|
|
llvm::StringRef relative_prelude_path,
|
|
llvm::raw_ostream& out_stream, llvm::raw_ostream& err_stream,
|
|
llvm::raw_ostream& out_stream_for_trace,
|
|
llvm::vfs::FileSystem& fs) -> int;
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // CARBON_EXPLORER_MAIN_H_
|