mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
In Compilation, perform Jobs by scheduling Commands which need to be run (currently all Commands, but this can be refined later) on TaskQueues by doing the following: 1. Perform all inputs to all Jobs in the current JobList. (Treat a JobList as its own inputs for scheduling purposes.) 2. After each Command's inputs run, check to see if that Command needs to run. If so, schedule it for execution. (Currently, all Commands always need to run.) 3. Set up a TaskFinishedCallback which will check to see if any other Commands need to run as a result of executing a particular Command. (Currently, all Commands depend on all other Commands.) If a Command needs to run and it is not already scheduled for execution, schedule it for execution. 4. Ask the TaskQueue to execute. (This will call the TaskFinishedCallback as necessary). Swift SVN r12060
93 lines
2.6 KiB
C++
93 lines
2.6 KiB
C++
//===--- Compilation.h - Compilation Task Data Structure --------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// TODO: Document me
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_DRIVER_COMPILATION_H
|
|
#define SWIFT_DRIVER_COMPILATION_H
|
|
|
|
#include <memory>
|
|
|
|
namespace llvm {
|
|
namespace opt {
|
|
class InputArgList;
|
|
class DerivedArgList;
|
|
}
|
|
}
|
|
|
|
namespace swift {
|
|
namespace driver {
|
|
class Driver;
|
|
class Job;
|
|
class JobList;
|
|
class ToolChain;
|
|
|
|
class Compilation {
|
|
/// The driver we were created by.
|
|
const Driver &TheDriver;
|
|
|
|
/// The default tool chain.
|
|
const ToolChain &DefaultToolChain;
|
|
|
|
/// The Jobs which will be performed by this compilation.
|
|
std::unique_ptr<JobList> Jobs;
|
|
|
|
// The original (untranslated) input argument list.
|
|
std::unique_ptr<llvm::opt::InputArgList> InputArgs;
|
|
|
|
// The translated input arg list.
|
|
std::unique_ptr<llvm::opt::DerivedArgList> TranslatedArgs;
|
|
|
|
/// The number of commands which this compilation should attempt to run in
|
|
/// parallel.
|
|
unsigned NumberOfParallelCommands;
|
|
|
|
public:
|
|
Compilation(const Driver &D, const ToolChain &DefaultToolChain,
|
|
std::unique_ptr<llvm::opt::InputArgList> InputArgs,
|
|
std::unique_ptr<llvm::opt::DerivedArgList> TranslatedArgs,
|
|
unsigned NumberOfParallelCommands = 1);
|
|
~Compilation();
|
|
|
|
const Driver &getDriver() const { return TheDriver; }
|
|
|
|
const ToolChain &getDefaultToolChain() const { return DefaultToolChain; }
|
|
|
|
JobList &getJobs() const { return *Jobs; }
|
|
void addJob(Job *J);
|
|
|
|
const llvm::opt::InputArgList &getInputArgs() const { return *InputArgs; }
|
|
|
|
const llvm::opt::DerivedArgList &getArgs() const { return *TranslatedArgs; }
|
|
|
|
unsigned getNumberOfParallelCommands() const {
|
|
return NumberOfParallelCommands;
|
|
}
|
|
|
|
/// Asks the Compilation to perform the Jobs which it knows about.
|
|
/// \returns result code for the Compilation's Jobs; 0 indicates success
|
|
int performJobs();
|
|
|
|
private:
|
|
/// \brief Perform the Jobs in \p JL if necessary.
|
|
///
|
|
/// \returns exit code of the first failed Job, or 0 on success
|
|
int performJobsInList(const JobList &JL);
|
|
};
|
|
|
|
} // end namespace driver
|
|
} // end namespace swift
|
|
|
|
#endif
|