fix(3p/nix): pass SkipEmpty to StrSplit("", ...)
When tokenizeString was changed to absl::StrSplit, there was a behavior change because tokenizeString on an empty string returned an empty vector - which the derivation builder (and likely a bunch of other stuff) was depending on. The canonical way of fixing this is by passing absl::SkipEmpty() to the function - there may be other places we need to fix this as well. This commit also includes some opportunistic absl::StrFormats and StrCats, because I was here anyway, but those have no semantic difference. Change-Id: Ibf9bb602284f793fa55728481f63b838fb7a41db Reviewed-on: https://cl.tvl.fyi/c/depot/+/1631 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									2344f8e528
								
							
						
					
					
						commit
						26a59482d2
					
				
					 1 changed files with 8 additions and 4 deletions
				
			
		
							
								
								
									
										12
									
								
								third_party/nix/src/libstore/build.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								third_party/nix/src/libstore/build.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -15,6 +15,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <absl/strings/ascii.h>
 | 
					#include <absl/strings/ascii.h>
 | 
				
			||||||
#include <absl/strings/numbers.h>
 | 
					#include <absl/strings/numbers.h>
 | 
				
			||||||
 | 
					#include <absl/strings/str_cat.h>
 | 
				
			||||||
 | 
					#include <absl/strings/str_format.h>
 | 
				
			||||||
#include <absl/strings/str_split.h>
 | 
					#include <absl/strings/str_split.h>
 | 
				
			||||||
#include <fcntl.h>
 | 
					#include <fcntl.h>
 | 
				
			||||||
#include <glog/logging.h>
 | 
					#include <glog/logging.h>
 | 
				
			||||||
| 
						 | 
					@ -1970,10 +1972,12 @@ void DerivationGoal::startBuilder() {
 | 
				
			||||||
       by `nix-store --register-validity'.  However, the deriver
 | 
					       by `nix-store --register-validity'.  However, the deriver
 | 
				
			||||||
       fields are left empty. */
 | 
					       fields are left empty. */
 | 
				
			||||||
    std::string s = get(drv->env, "exportReferencesGraph");
 | 
					    std::string s = get(drv->env, "exportReferencesGraph");
 | 
				
			||||||
    std::vector<std::string> ss = absl::StrSplit(s, absl::ByAnyChar(" \t\n\r"));
 | 
					    std::vector<std::string> ss =
 | 
				
			||||||
 | 
					        absl::StrSplit(s, absl::ByAnyChar(" \t\n\r"), absl::SkipEmpty());
 | 
				
			||||||
    if (ss.size() % 2 != 0) {
 | 
					    if (ss.size() % 2 != 0) {
 | 
				
			||||||
      throw BuildError(
 | 
					      throw BuildError(absl::StrFormat(
 | 
				
			||||||
          format("odd number of tokens in 'exportReferencesGraph': '%1%'") % s);
 | 
					          "odd number of tokens %d in 'exportReferencesGraph': '%s'", ss.size(),
 | 
				
			||||||
 | 
					          s));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (auto i = ss.begin(); i != ss.end();) {
 | 
					    for (auto i = ss.begin(); i != ss.end();) {
 | 
				
			||||||
      std::string fileName = *i++;
 | 
					      std::string fileName = *i++;
 | 
				
			||||||
| 
						 | 
					@ -3959,7 +3963,7 @@ SubstitutionGoal::SubstitutionGoal(const Path& storePath, Worker& worker,
 | 
				
			||||||
    : Goal(worker), repair(repair) {
 | 
					    : Goal(worker), repair(repair) {
 | 
				
			||||||
  this->storePath = storePath;
 | 
					  this->storePath = storePath;
 | 
				
			||||||
  state = &SubstitutionGoal::init;
 | 
					  state = &SubstitutionGoal::init;
 | 
				
			||||||
  name = (format("substitution of '%1%'") % storePath).str();
 | 
					  name = absl::StrCat("substitution of ", storePath);
 | 
				
			||||||
  trace("created");
 | 
					  trace("created");
 | 
				
			||||||
  maintainExpectedSubstitutions =
 | 
					  maintainExpectedSubstitutions =
 | 
				
			||||||
      std::make_unique<MaintainCount<uint64_t>>(worker.expectedSubstitutions);
 | 
					      std::make_unique<MaintainCount<uint64_t>>(worker.expectedSubstitutions);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue