<commit_before>/**
 * @autor kgar
 * @date 05.09.2014.
 * @company Gameduell GmbH
 */

package duell.build.plugin.library.filesystem;

import duell.build.plugin.library.filesystem.LibraryConfiguration;
import duell.build.plugin.platform.PlatformConfiguration;
import duell.build.objects.Configuration;

import duell.objects.DuellLib;
import duell.helpers.TemplateHelper;
import duell.helpers.FileHelper;
import duell.helpers.PathHelper;
import duell.helpers.LogHelper;
import duell.helpers.DirHashHelper;

import sys.FileSystem;
import sys.io.File;

using duell.helpers.HashHelper;

import sys.io.Process;

using StringTools;

import haxe.io.Path;

class LibraryBuild
{
	public static var pathToAssetStagingArea: String = null; /// will be set after post

	private static inline var INTERNAL_ASSET_FOLDER = "assets";

	private var hashPath: String;

	public function new () {}

	public function postParse() : Void
	{
		/// if no parsing is made we need to add the default state.
		if (Configuration.getData().LIBRARY.FILESYSTEM == null)
		{
			Configuration.getData().LIBRARY.FILESYSTEM = LibraryConfiguration.getData();
		}

		var haxeExtraSources = Path.join([Configuration.getData().OUTPUT,"haxe"]);
		if (Configuration.getData().SOURCES.indexOf(haxeExtraSources) == -1)
		{
			Configuration.getData().SOURCES.push(haxeExtraSources);
		}

		postParsePerPlatform();
	}

	public function postPostParse(): Void
	{
		pathToAssetStagingArea = Path.join([Configuration.getData().OUTPUT, "filesystem", INTERNAL_ASSET_FOLDER]);
		hashPath = Path.join([Configuration.getData().OUTPUT, "filesystem", "assetFolderHash.hash"]);

		var currentHash = getHashOfAssetFolders();

		var previousHash = getCachedHash();

		if (currentHash != previousHash)
		{
			LogHelper.info("[Filesystem] Assets changed! reprocessing");
			if (FileSystem.exists(pathToAssetStagingArea))
			{
				PathHelper.removeDirectory(pathToAssetStagingArea);
			}

			PathHelper.mkdir(pathToAssetStagingArea);

			copyFilesToStagingArea();

			processFiles();

			saveHash(currentHash);
		}
		else
		{
			LogHelper.info("[Filesystem] no asset change! bypassing the processing");
		}

		cleanUpIgnoredFiles();
	    postPostParsePerPlatform();
	}

	public function preBuild() : Void
	{
		determineFileListFromAssetFolders();

		copyAssetListHaxeFile();

		preBuildPerPlatform();
	}

	private static function regexifyPath(path: String): String
	{
		// dots in filenames have to be escaped, otherwise they mean "any character"
		path = path.replace(".", "\\.");<commit_msg>minor tweaks<commit_after>/**
 * @autor kgar
 * @date 05.09.2014.
 * @company Gameduell GmbH
 */

package duell.build.plugin.library.filesystem;

import duell.build.plugin.library.filesystem.LibraryConfiguration;
import duell.build.plugin.platform.PlatformConfiguration;
import duell.build.objects.Configuration;

import duell.objects.DuellLib;
import duell.helpers.TemplateHelper;
import duell.helpers.FileHelper;
import duell.helpers.PathHelper;
import duell.helpers.LogHelper;
import duell.helpers.DirHashHelper;

import sys.FileSystem;
import sys.io.File;

using duell.helpers.HashHelper;

import sys.io.Process;

using StringTools;

import haxe.io.Path;

class LibraryBuild
{
	public static var pathToAssetStagingArea: String = null; /// will be set after post

	private static inline var INTERNAL_ASSET_FOLDER = "assets";

	private var hashPath: String;

	public function new () {}

	public function postParse() : Void
	{
		/// if no parsing is made we need to add the default state.
		if (Configuration.getData().LIBRARY.FILESYSTEM == null)
		{
			Configuration.getData().LIBRARY.FILESYSTEM = LibraryConfiguration.getData();
		}

		var haxeExtraSources = Path.join([Configuration.getData().OUTPUT,"haxe"]);
		if (Configuration.getData().SOURCES.indexOf(haxeExtraSources) == -1)
		{
			Configuration.getData().SOURCES.push(haxeExtraSources);
		}

		postParsePerPlatform();
	}

	public function postPostParse(): Void
	{
		pathToAssetStagingArea = Path.join([Configuration.getData().OUTPUT, "filesystem", INTERNAL_ASSET_FOLDER]);
		hashPath = Path.join([Configuration.getData().OUTPUT, "filesystem", "assetFolderHash.hash"]);

		var currentHash = getHashOfAssetFolders();

		var previousHash = getCachedHash();

		if (currentHash != previousHash)
		{
			LogHelper.info("", "[Filesystem] Assets changed! reprocessing");

			if (FileSystem.exists(pathToAssetStagingArea))
			{
				PathHelper.removeDirectory(pathToAssetStagingArea);
			}

			PathHelper.mkdir(pathToAssetStagingArea);

			copyFilesToStagingArea();

			cleanUpIgnoredFiles();

			processFiles();

			saveHash(currentHash);
		}
		else
		{
			LogHelper.info("", "[Filesystem] no asset change! bypassing the processing");
		}

	    postPostParsePerPlatform();
	}

	public function preBuild() : Void
	{
		determineFileListFromAssetFolders();

		copyAssetListHaxeFile();

		preBuildPerPlatform();
	}

	private static function regexifyPath(path: String): String
	{
		// dots in filenames have to be escaped, otherwise they mean "any character"
		path = path.replace(".", "\\.");
{'fraction_non_alphanumeric': 0.11799526440410418, 'fraction_numerical': 0.003551696921862668, 'mean_word_length': 4.860115606936416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2647464', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1564, 'n_words': 331}