blob: 01860b082d62d53461a7f53a3665e5904197b08b [file] [log] [blame]
Reid Spencer76b83a12004-08-29 19:20:41 +00001//===-- Program.cpp - Implement OS Program Concept --------------*- C++ -*-===//
Misha Brukman10468d82005-04-21 22:55:34 +00002//
Reid Spencer76b83a12004-08-29 19:20:41 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukman10468d82005-04-21 22:55:34 +00007//
Reid Spencer76b83a12004-08-29 19:20:41 +00008//===----------------------------------------------------------------------===//
9//
10// This header file implements the operating system Program concept.
11//
12//===----------------------------------------------------------------------===//
13
Michael J. Spencer447762d2010-11-29 18:16:10 +000014#include "llvm/Support/Program.h"
Reid Spencer51ea06a2004-12-27 06:16:25 +000015#include "llvm/Config/config.h"
Chris Lattnerd9e22a82010-04-18 03:33:55 +000016using namespace llvm;
Reid Spencer76b83a12004-08-29 19:20:41 +000017using namespace sys;
18
19//===----------------------------------------------------------------------===//
20//=== WARNING: Implementation here must contain only TRULY operating system
Misha Brukman10468d82005-04-21 22:55:34 +000021//=== independent code.
Reid Spencer76b83a12004-08-29 19:20:41 +000022//===----------------------------------------------------------------------===//
23
Mikhail Glushenkov36cb8322009-07-18 21:43:12 +000024int
25Program::ExecuteAndWait(const Path& path,
26 const char** args,
27 const char** envp,
28 const Path** redirects,
29 unsigned secondsToWait,
30 unsigned memoryLimit,
31 std::string* ErrMsg) {
32 Program prg;
33 if (prg.Execute(path, args, envp, redirects, memoryLimit, ErrMsg))
Dan Gohmanfc815792010-10-29 16:54:25 +000034 return prg.Wait(path, secondsToWait, ErrMsg);
Mikhail Glushenkov36cb8322009-07-18 21:43:12 +000035 else
36 return -1;
37}
38
39void
40Program::ExecuteNoWait(const Path& path,
41 const char** args,
42 const char** envp,
43 const Path** redirects,
44 unsigned memoryLimit,
45 std::string* ErrMsg) {
46 Program prg;
47 prg.Execute(path, args, envp, redirects, memoryLimit, ErrMsg);
48}
49
Reid Spencer76b83a12004-08-29 19:20:41 +000050// Include the platform-specific parts of this class.
Reid Spencer51ea06a2004-12-27 06:16:25 +000051#ifdef LLVM_ON_UNIX
Reid Spencerc892a0d2005-01-09 23:29:00 +000052#include "Unix/Program.inc"
Reid Spencer51ea06a2004-12-27 06:16:25 +000053#endif
54#ifdef LLVM_ON_WIN32
Michael J. Spencer447762d2010-11-29 18:16:10 +000055#include "Windows/Program.inc"
Reid Spencer51ea06a2004-12-27 06:16:25 +000056#endif