@@ -1200,15 +1200,18 @@ class ShellTool : public Tool {
1200
1200
1201
1201
class ClangShellCommand : public ExternalCommand {
1202
1202
// / The compiler command to invoke.
1203
- std::string args;
1203
+ std::vector<std:: string> args;
1204
1204
1205
1205
// / The path to the dependency output file, if used.
1206
1206
std::string depsPath;
1207
1207
1208
1208
virtual uint64_t getSignature () override {
1209
- uint64_t result = ExternalCommand::getSignature ();
1210
- result ^= basic::hashString (args);
1211
- return result;
1209
+ using llvm::hash_combine;
1210
+ llvm::hash_code code = ExternalCommand::getSignature ();
1211
+ for (const auto & arg: args) {
1212
+ code = hash_combine (code, arg);
1213
+ }
1214
+ return size_t (code);
1212
1215
}
1213
1216
1214
1217
bool processDiscoveredDependencies (BuildSystemCommandInterface& bsci,
@@ -1267,13 +1270,24 @@ class ClangShellCommand : public ExternalCommand {
1267
1270
}
1268
1271
1269
1272
virtual void getVerboseDescription (SmallVectorImpl<char > &result) override {
1270
- llvm::raw_svector_ostream (result) << args;
1273
+ llvm::raw_svector_ostream os (result);
1274
+ bool first = true ;
1275
+ for (const auto & arg: args) {
1276
+ if (!first) os << " " ;
1277
+ first = false ;
1278
+ basic::appendShellEscapedString (os, arg);
1279
+ }
1271
1280
}
1272
1281
1273
1282
virtual bool configureAttribute (const ConfigureContext& ctx, StringRef name,
1274
1283
StringRef value) override {
1275
1284
if (name == " args" ) {
1276
- args = value;
1285
+ // When provided as a scalar string, we default to executing using the
1286
+ // shell.
1287
+ args.clear ();
1288
+ args.push_back (" /bin/sh" );
1289
+ args.push_back (" -c" );
1290
+ args.push_back (value);
1277
1291
} else if (name == " deps" ) {
1278
1292
depsPath = value;
1279
1293
} else {
@@ -1284,7 +1298,13 @@ class ClangShellCommand : public ExternalCommand {
1284
1298
}
1285
1299
virtual bool configureAttribute (const ConfigureContext& ctx, StringRef name,
1286
1300
ArrayRef<StringRef> values) override {
1287
- return ExternalCommand::configureAttribute (ctx, name, values);
1301
+ if (name == " args" ) {
1302
+ args = std::vector<std::string>(values.begin (), values.end ());
1303
+ } else {
1304
+ return ExternalCommand::configureAttribute (ctx, name, values);
1305
+ }
1306
+
1307
+ return true ;
1288
1308
}
1289
1309
virtual bool configureAttribute (
1290
1310
const ConfigureContext& ctx, StringRef name,
@@ -1295,8 +1315,13 @@ class ClangShellCommand : public ExternalCommand {
1295
1315
virtual bool executeExternalCommand (BuildSystemCommandInterface& bsci,
1296
1316
Task* task,
1297
1317
QueueJobContext* context) override {
1318
+ std::vector<StringRef> commandLine;
1319
+ for (const auto & arg: args) {
1320
+ commandLine.push_back (arg);
1321
+ }
1322
+
1298
1323
// Execute the command.
1299
- if (!bsci.getExecutionQueue ().executeShellCommand (context, args )) {
1324
+ if (!bsci.getExecutionQueue ().executeProcess (context, commandLine )) {
1300
1325
// If the command failed, there is no need to gather dependencies.
1301
1326
return false ;
1302
1327
}
0 commit comments