<commit_before>#include "buildcontroller.h"

#include "../filesys/dgprojectloader.h"
#include "../filesys/dgprojectinfo.h"

#include "../consts.h"

BuildController::BuildController(DGProjectLoader& pl) {
	this->pl = &pl;
}

QString BuildController::getBuildDirName(const DGProjectInfo& info) const {
	return info.getName()+"-build"+(info.hasAltTargets()?'-'+info.getTargetName():dg_consts::STRING_EMPTY); //TODO: Targets.
}

void BuildController::build(DGProjectInfo& f) const {
	QDir bd = getBuildDir(f,true);
	if(bd.exists() && f.getTarget())
		f.getTarget()->build(bd);
}

void BuildController::clean(DGProjectInfo& f) const {
	QDir bd = getBuildDir(f,false);
	if(bd.exists()) {
		if(f.getTarget())
			f.getTarget()->clean(bd);
		bd.cdUp();
		bd.rmdir(getBuildDirName(f));
	}
}


void BuildController::rebuild(DGProjectInfo& f) const {
	QDir bd = getBuildDir(f,false);
	if(bd.exists()) {
		if(f.getTarget()) {
			f.getTarget()->clean(bd);
			f.getTarget()->build(bd);
		}
	} else {
		if(bd.mkdir(".") && f.getTarget())
			f.getTarget()->build(bd);
	}
}


QDir BuildController::getBuildDir(const DGProjectInfo& info, bool make) const {
	QDir retval;
	if(!info.isSingleFile())
		retval = info.getFile()->dir();
	else {
		retval = *info.getDir();
		retval.cdUp();
	}
	if(make && !retval.exists(getBuildDirName(info)))
		retval.mkdir(getBuildDirName(info));
	return retval;
}
<commit_msg>inb4 segfault<commit_after>#include "buildcontroller.h"

#include "../filesys/dgprojectloader.h"
#include "../filesys/dgprojectinfo.h"

#include "../consts.h"

BuildController::BuildController(DGProjectLoader& pl) {
	this->pl = &pl;
}

QString BuildController::getBuildDirName(const DGProjectInfo& info) const {
	return info.getName()+"-build"+(info.hasAltTargets()?'-'+info.getTargetName():dg_consts::STRING_EMPTY); //TODO: Targets.
}

void BuildController::build(DGProjectInfo& f) const {
	QDir bd = getBuildDir(f,true);
	if(bd.exists() && f.getTarget())
		f.getTarget()->build(bd);
}

void BuildController::clean(DGProjectInfo& f) const {
	QDir bd = getBuildDir(f,false);
	if(bd.exists()) {
		if(f.getTarget())
			f.getTarget()->clean(bd);
		bd.cdUp();
		bd.rmdir(getBuildDirName(f));
	}
}

void BuildController::rebuild(DGProjectInfo& f) const {
	QDir bd = getBuildDir(f,false);
	if(bd.exists()) {
		if(f.getTarget()) {
			f.getTarget()->clean(bd);
			f.getTarget()->build(bd);
		}
	} else {
		if(bd.mkdir(".") && f.getTarget())
			f.getTarget()->build(bd);
	}
}


QDir BuildController::getBuildDir(const DGProjectInfo& info, bool make) const {
	QDir retval;
	if(info.isSingleFile())
		retval = info.getFile()->dir();
	else {
		retval = *info.getDir();
		retval.cdUp();
	}
	if(make && !retval.exists(getBuildDirName(info)))
		retval.mkdir(getBuildDirName(info));
	return retval;
}

{'fraction_non_alphanumeric': 0.193001443001443, 'fraction_numerical': 0.00036075036075036075, 'mean_word_length': 5.203579418344519, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5499649', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1040, 'n_words': 159}