Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Enumerations | Functions
ProcessWorklist.h File Reference
#include "include/core/SkSpan.h"
#include <functional>
#include <string>

Go to the source code of this file.

Enumerations

enum class  ResultCode {
  kSuccess = 0 , kCompileError = 1 , kInputError = 2 , kOutputError = 3 ,
  kConfigurationError = 4
}
 

Functions

ResultCode ProcessWorklist (const char *worklistPath, const std::function< ResultCode(SkSpan< std::string > args)> &processCommandFn)
 

Enumeration Type Documentation

◆ ResultCode

enum class ResultCode
strong
Enumerator
kSuccess 
kCompileError 
kInputError 
kOutputError 
kConfigurationError 

Definition at line 16 of file ProcessWorklist.h.

16 {
17 kSuccess = 0,
18 kCompileError = 1,
19 kInputError = 2,
20 kOutputError = 3,
22};
@ kConfigurationError

Function Documentation

◆ ProcessWorklist()

ResultCode ProcessWorklist ( const char *  worklistPath,
const std::function< ResultCode(SkSpan< std::string > args)> &  processCommandFn 
)

Processes multiple inputs in a single invocation by reading a worklist file. The processCommand is invoked with a set of arguments, read from the worklist. A blank line is used to separate one group of arguments from the next group.

Definition at line 15 of file ProcessWorklist.cpp.

17 {
18 std::string inputPath(worklistPath);
19 if (!skstd::ends_with(inputPath, ".worklist")) {
20 printf("expected .worklist file, found: %s\n\n", worklistPath);
22 }
23
24 // The worklist contains one line per argument to pass. When a blank line is reached, those
25 // arguments will be passed to `processCommandFn`.
26 auto resultCode = ResultCode::kSuccess;
27 std::vector<std::string> args = {"sksl"};
28 std::ifstream in(worklistPath);
29 for (std::string line; std::getline(in, line); ) {
30 if (in.rdstate()) {
31 printf("error reading '%s'\n", worklistPath);
33 }
34
35 if (!line.empty()) {
36 // We found an argument. Remember it.
37 args.push_back(std::move(line));
38 } else {
39 // We found a blank line. If we have any arguments stored up, process them as a command.
40 if (!args.empty()) {
41 ResultCode outcome = processCommandFn(args);
42 resultCode = std::max(resultCode, outcome);
43
44 // Clear every argument except the first.
45 args.resize(1);
46 }
47 }
48 }
49
50 // If the worklist ended with a list of arguments but no blank line, process those now.
51 if (args.size() > 1) {
52 ResultCode outcome = processCommandFn(args);
53 resultCode = std::max(resultCode, outcome);
54 }
55
56 // Return the "worst" status we encountered. For our purposes, compilation errors are the least
57 // serious, because they are expected to occur in unit tests. Other types of errors are not
58 // expected at all during a build.
59 return resultCode;
60}
ResultCode
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
constexpr bool ends_with(std::string_view str, std::string_view suffix)