diff options
| -rw-r--r-- | ctor.cc | 108 | ||||
| m--------- | libctor | 0 | 
2 files changed, 30 insertions, 78 deletions
| @@ -12,63 +12,10 @@ int execute(const std::string& command,  namespace  { -class PathRAII -{ -public: -	PathRAII(const std::filesystem::path& path) -	{ -		pwd = std::filesystem::current_path(); -		std::filesystem::current_path(path); -	} - -	~PathRAII() -	{ -		std::filesystem::current_path(pwd); -	} - -private: -	std::filesystem::path pwd; -}; - -std::vector<Source> eval_mocs(const std::string& path, -                              const std::vector<std::pair<std::string, std::string>>& moc_list) -{ -	std::vector<Source> sources; -	for(const auto& moc : moc_list) -	{ -		std::filesystem::path input(moc.first); -		std::filesystem::path output(moc.second); - -		std::filesystem::path fspath(path); - -		if(!std::filesystem::exists(fspath / input)) -		{ -			std::cerr << "Missing moc input file: " << input.string() << '\n'; -			exit(1); -		} - -		if(!std::filesystem::exists(path / output) || -		   std::filesystem::last_write_time(path / input) > -		   std::filesystem::last_write_time(path / output)) -		{ -			PathRAII p(path); -			auto ret = execute("/usr/bin/moc", {"-o", output.string(), input.string()}); -			if(ret != 0) -			{ -				std::cerr << "moc generation failed\n"; -				exit(ret); -			} -		} -		sources.push_back((path / output).string()); -	} - -	return sources; -} - -BuildConfigurations myConfigs() +BuildConfigurations myConfigs(const Settings& settings)  {  	// -	// Qookie-cast client +	// Qookie main application  	//  	BuildConfiguration qookie =  		{ @@ -78,9 +25,13 @@ BuildConfigurations myConfigs()  				"src/database.cc",  				"src/database_gourmet.cc",  				"src/database_krecipes.cc", +				"src/database_qookie.cc",  				"src/mainwindow.cc",  				"src/viewer.cc",  				"src/client.cc", +				settings.builddir + "/moc_mainwindow.cc", +				settings.builddir + "/moc_viewer.cc", +				settings.builddir + "/moc_client.cc",  			},  			.flags = {  				.cxxflags = { @@ -92,17 +43,27 @@ BuildConfigurations myConfigs()  			},  			.externals = { "qt", "sqlite" },  		}; -	std::vector<Source> qookie_mocs = -		eval_mocs("src", -		          { -		           { "mainwindow.h", "moc_mainwindow.cc"}, -		           { "viewer.h",     "moc_viewer.cc"}, -		           { "client.h",     "moc_client.cc"}, -		          }); -	for(const auto& moc : qookie_mocs) -	{ -		qookie.sources.push_back(moc); -	} + +	// +	// Moc generation for all configurations +	// +	BuildConfiguration mocs = +		{ +			.sources = { +				{ "src/mainwindow.h", "moc_mainwindow.cc"}, +				{ "src/viewer.h",     "moc_viewer.cc"}, +				{ "src/client.h",     "moc_client.cc"}, +				{ "src/qookie-cast-client.h", "moc_qookie-cast-client.cc"}, +			}, +			.function = [](const std::string& input, +			               const std::string& output, +			               const BuildConfiguration& config, +			               const Settings& settings) +			{ +				return execute("/usr/bin/moc", {"-I../src", "-o", output, input}, +				               settings.verbose > 0); +			} +		};  	//  	// Qookie-cast client @@ -112,6 +73,7 @@ BuildConfigurations myConfigs()  			.target = "qookie-cast-client",  // output filename  			.sources = {  				"src/qookie-cast-client.cc", +				settings.builddir + "/moc_qookie-cast-client.cc",  			},  			.flags = {  				.cxxflags = { @@ -124,20 +86,10 @@ BuildConfigurations myConfigs()  			.externals = {"qt"},  		}; -	std::vector<Source> qookie_cast_client_mocs = -		eval_mocs("src", -		          { -		           { "qookie-cast-client.h", "moc_qookie-cast-client.cc"}, -		          }); -	for(const auto& moc : qookie_cast_client_mocs) -	{ -		qookie_cast_client.sources.push_back(moc); -	} - -	return {qookie, qookie_cast_client}; +	return { qookie, mocs, qookie_cast_client };  } -ExternalConfigurations ctorExtConfigs() +ExternalConfigurations ctorExtConfigs(const Settings& settings)  {  	return  	{ diff --git a/libctor b/libctor -Subproject fb88dc797f1f5f420416521d4b3088bf6b8450a +Subproject 7a16146600384272baf7fb2fc0fc64f59b17ffe | 
