* A switch `-j NUMBER' to set the maximum number of parallel jobs (0 =
no limit). * Add missing file to distribution.
This commit is contained in:
		
							parent
							
								
									1f48aa0be7
								
							
						
					
					
						commit
						efa5fa1a91
					
				
					 5 changed files with 30 additions and 9 deletions
				
			
		|  | @ -118,16 +118,29 @@ static void initAndRun(int argc, char * * argv) | ||||||
|             ++i; |             ++i; | ||||||
|             if (i == args.end()) throw UsageError("`--log-type' requires an argument"); |             if (i == args.end()) throw UsageError("`--log-type' requires an argument"); | ||||||
|             setLogType(*i); |             setLogType(*i); | ||||||
|         } else if (arg == "--build-output" || arg == "-B") |         } | ||||||
|  |         else if (arg == "--build-output" || arg == "-B") | ||||||
|             buildVerbosity = lvlError; /* lowest */ |             buildVerbosity = lvlError; /* lowest */ | ||||||
|         else if (arg == "--help") { |         else if (arg == "--help") { | ||||||
|             printHelp(); |             printHelp(); | ||||||
|             return; |             return; | ||||||
|         } else if (arg == "--version") { |         } | ||||||
|  |         else if (arg == "--version") { | ||||||
|             cout << format("%1% (Nix) %2%") % programId % NIX_VERSION << endl; |             cout << format("%1% (Nix) %2%") % programId % NIX_VERSION << endl; | ||||||
|             return; |             return; | ||||||
|         } else if (arg == "--keep-failed" || arg == "-K") |         } | ||||||
|  |         else if (arg == "--keep-failed" || arg == "-K") | ||||||
|             keepFailed = true; |             keepFailed = true; | ||||||
|  |         else if (arg == "--max-jobs" || arg == "-j") { | ||||||
|  |             ++i; | ||||||
|  |             if (i == args.end()) throw UsageError("`--max-jobs' requires an argument"); | ||||||
|  |             istringstream str(*i); | ||||||
|  |             int n; | ||||||
|  |             str >> n; | ||||||
|  |             if (!str || !str.eof() || n < 0) | ||||||
|  |                 throw UsageError(format("`--max-jobs' requires a non-negative integer")); | ||||||
|  |             maxBuildJobs = n; | ||||||
|  |         } | ||||||
|         else remaining.push_back(arg); |         else remaining.push_back(arg); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -9,3 +9,5 @@ string nixDBPath = "/UNINIT"; | ||||||
| bool keepFailed = false; | bool keepFailed = false; | ||||||
| 
 | 
 | ||||||
| Verbosity buildVerbosity = lvlDebug; | Verbosity buildVerbosity = lvlDebug; | ||||||
|  | 
 | ||||||
|  | unsigned int maxBuildJobs = 1; | ||||||
|  |  | ||||||
|  | @ -32,5 +32,8 @@ extern bool keepFailed; | ||||||
| /* Verbosity level for build output. */ | /* Verbosity level for build output. */ | ||||||
| extern Verbosity buildVerbosity; | extern Verbosity buildVerbosity; | ||||||
| 
 | 
 | ||||||
|  | /* Maximum number of parallel build jobs.  0 means unlimited. */ | ||||||
|  | extern unsigned int maxBuildJobs; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| #endif /* !__GLOBALS_H */ | #endif /* !__GLOBALS_H */ | ||||||
|  |  | ||||||
|  | @ -284,6 +284,9 @@ bool Normaliser::startBuild(Path nePath) | ||||||
| { | { | ||||||
|     checkInterrupt(); |     checkInterrupt(); | ||||||
| 
 | 
 | ||||||
|  |     if (maxBuildJobs > 0 && building.size() >= maxBuildJobs) | ||||||
|  |         return false; | ||||||
|  | 
 | ||||||
|     Goals::iterator goalIt = goals.find(nePath); |     Goals::iterator goalIt = goals.find(nePath); | ||||||
|     assert(goalIt != goals.end()); |     assert(goalIt != goals.end()); | ||||||
|     Goal & goal(goalIt->second); |     Goal & goal(goalIt->second); | ||||||
|  | @ -414,11 +417,6 @@ bool Normaliser::startBuild(Path nePath) | ||||||
|             format("build hook died with status %1%") % status); |             format("build hook died with status %1%") % status); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /* Right platform? */ |  | ||||||
|     if (goal.expr.derivation.platform != thisSystem) |  | ||||||
|         throw Error(format("a `%1%' is required, but I am a `%2%'") |  | ||||||
| 		    % goal.expr.derivation.platform % thisSystem); |  | ||||||
| 
 |  | ||||||
|     /* Otherwise, start the build in a child process. */ |     /* Otherwise, start the build in a child process. */ | ||||||
|     startBuildChild(goal); |     startBuildChild(goal); | ||||||
| 
 | 
 | ||||||
|  | @ -428,6 +426,11 @@ bool Normaliser::startBuild(Path nePath) | ||||||
| 
 | 
 | ||||||
| void Normaliser::startBuildChild(Goal & goal) | void Normaliser::startBuildChild(Goal & goal) | ||||||
| { | { | ||||||
|  |     /* Right platform? */ | ||||||
|  |     if (goal.expr.derivation.platform != thisSystem) | ||||||
|  |         throw Error(format("a `%1%' is required, but I am a `%2%'") | ||||||
|  | 		    % goal.expr.derivation.platform % thisSystem); | ||||||
|  | 
 | ||||||
|     /* If any of the outputs already exist but are not registered,
 |     /* If any of the outputs already exist but are not registered,
 | ||||||
|        delete them. */ |        delete them. */ | ||||||
|     for (PathSet::iterator i = goal.expr.derivation.outputs.begin();  |     for (PathSet::iterator i = goal.expr.derivation.outputs.begin();  | ||||||
|  |  | ||||||
|  | @ -30,4 +30,4 @@ EXTRA_DIST = $(TESTS) \ | ||||||
|   dependencies.nix.in dependencies.builder*.sh \ |   dependencies.nix.in dependencies.builder*.sh \ | ||||||
|   locking.nix.in locking.builder.sh \ |   locking.nix.in locking.builder.sh \ | ||||||
|   parallel.nix.in parallel.builder.sh \ |   parallel.nix.in parallel.builder.sh \ | ||||||
|   build-hook.nix.in |   build-hook.nix.in build-hook.hook.sh | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue