generator.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. 
  2. #include "generator.h"
  3. using namespace dsr;
  4. static uint64_t checksum(const ReadableString& text) {
  5. uint64_t a = 0x8C2A03D4;
  6. uint64_t b = 0xF42B1583;
  7. uint64_t c = 0xA6815E74;
  8. uint64_t d = 0;
  9. for (int64_t i = 0; i < string_length(text); i++) {
  10. a = (b * c + ((i * 3756 + 2654) & 58043)) & 0xFFFFFFFF;
  11. b = (231 + text[i] * (a & 154) + c * 867 + 28294061) & 0xFFFFFFFF;
  12. c = (a ^ b ^ (text[i] * 1543217521)) & 0xFFFFFFFF;
  13. d = d ^ (a << 32) ^ b ^ (c << 16);
  14. }
  15. return d;
  16. }
  17. static uint64_t checksum(const Buffer& buffer) {
  18. SafePointer<uint8_t> data = buffer_getSafeData<uint8_t>(buffer, "checksum input buffer");
  19. uint64_t a = 0x8C2A03D4;
  20. uint64_t b = 0xF42B1583;
  21. uint64_t c = 0xA6815E74;
  22. uint64_t d = 0;
  23. for (int64_t i = 0; i < buffer_getSize(buffer); i++) {
  24. a = (b * c + ((i * 3756 + 2654) & 58043)) & 0xFFFFFFFF;
  25. b = (231 + data[i] * (a & 154) + c * 867 + 28294061) & 0xFFFFFFFF;
  26. c = (a ^ b ^ (data[i] * 1543217521)) & 0xFFFFFFFF;
  27. d = d ^ (a << 32) ^ b ^ (c << 16);
  28. }
  29. return d;
  30. }
  31. static int64_t findDependency(ProjectContext &context, const ReadableString& findPath) {
  32. for (int64_t d = 0; d < context.dependencies.length(); d++) {
  33. if (string_match(context.dependencies[d].path, findPath)) {
  34. return d;
  35. }
  36. }
  37. return -1;
  38. }
  39. static void resolveConnection(ProjectContext &context, Connection &connection) {
  40. connection.dependencyIndex = findDependency(context, connection.path);
  41. }
  42. static void resolveDependency(ProjectContext &context, Dependency &dependency) {
  43. for (int64_t l = 0; l < dependency.links.length(); l++) {
  44. resolveConnection(context, dependency.links[l]);
  45. }
  46. for (int64_t i = 0; i < dependency.includes.length(); i++) {
  47. resolveConnection(context, dependency.includes[i]);
  48. }
  49. }
  50. void resolveDependencies(ProjectContext &context) {
  51. for (int64_t d = 0; d < context.dependencies.length(); d++) {
  52. resolveDependency(context, context.dependencies[d]);
  53. }
  54. }
  55. static String findSourceFile(const ReadableString& headerPath, bool acceptC, bool acceptCpp) {
  56. if (file_hasExtension(headerPath)) {
  57. ReadableString extensionlessPath = file_getExtensionless(headerPath);
  58. String cPath = extensionlessPath + U".c";
  59. String cppPath = extensionlessPath + U".cpp";
  60. if (acceptC && file_getEntryType(cPath) == EntryType::File) {
  61. return cPath;
  62. } else if (acceptCpp && file_getEntryType(cppPath) == EntryType::File) {
  63. return cppPath;
  64. }
  65. }
  66. return U"";
  67. }
  68. static void flushToken(List<String> &target, String &currentToken) {
  69. if (string_length(currentToken) > 0) {
  70. target.push(currentToken);
  71. currentToken = U"";
  72. }
  73. }
  74. static void tokenize(List<String> &target, const ReadableString& line) {
  75. String currentToken;
  76. for (int64_t i = 0; i < string_length(line); i++) {
  77. DsrChar c = line[i];
  78. DsrChar nextC = line[i + 1];
  79. if (c == U'#' && nextC == U'#') {
  80. // Appending tokens using ##
  81. i++;
  82. } else if (c == U'#' || c == U'(' || c == U')' || c == U'[' || c == U']' || c == U'{' || c == U'}') {
  83. // Atomic token of a single character
  84. flushToken(target, currentToken);
  85. string_appendChar(currentToken, c);
  86. flushToken(target, currentToken);
  87. } else if (c == U' ' || c == U'\t') {
  88. // Whitespace
  89. flushToken(target, currentToken);
  90. } else {
  91. string_appendChar(currentToken, c);
  92. }
  93. }
  94. flushToken(target, currentToken);
  95. }
  96. // When CACHED_ANALYSIS is enabled, files will only be analyzed once per session, by remembering them from previous projects.
  97. // If features that require a different type of analysis per project are implemented, this can easily be turned off.
  98. #define CACHED_ANALYSIS
  99. #ifdef CACHED_ANALYSIS
  100. // Remembering previous results from analyzing the same files.
  101. List<Dependency> analysisCache;
  102. #endif
  103. void analyzeFile(Dependency &result, const ReadableString& absolutePath, Extension extension) {
  104. #ifdef CACHED_ANALYSIS
  105. // Check if the file has already been analyzed.
  106. for (int c = 0; c < analysisCache.length(); c++) {
  107. if (string_match(analysisCache[c].path, absolutePath)) {
  108. // Clone all the results to keep projects separate in memory for safety.
  109. result = analysisCache[c];
  110. return;
  111. }
  112. }
  113. #endif
  114. // Get the file's binary content.
  115. Buffer fileBuffer = file_loadBuffer(absolutePath);
  116. // Get the checksum
  117. result.contentChecksum = checksum(fileBuffer);
  118. if (extension == Extension::H || extension == Extension::Hpp) {
  119. // The current file is a header, so look for an implementation with the corresponding name.
  120. String sourcePath = findSourceFile(absolutePath, extension == Extension::H, true);
  121. // If found:
  122. if (string_length(sourcePath) > 0) {
  123. // Remember that anything using the header will have to link with the implementation.
  124. result.links.pushConstruct(sourcePath);
  125. }
  126. }
  127. // Interpret the file's content.
  128. String sourceCode = string_loadFromMemory(fileBuffer);
  129. String parentFolder = file_getRelativeParentFolder(absolutePath);
  130. List<String> tokens;
  131. bool continuingLine = false;
  132. int64_t lineNumber = 0;
  133. string_split_callback(sourceCode, U'\n', true, [&result, &parentFolder, &tokens, &continuingLine, &lineNumber](ReadableString line) {
  134. lineNumber++;
  135. if (line[0] == U'#' || continuingLine) {
  136. tokenize(tokens, line);
  137. // Continuing pre-processing line using \ at the end.
  138. continuingLine = line[string_length(line) - 1] == U'\\';
  139. } else {
  140. continuingLine = false;
  141. }
  142. if (!continuingLine && tokens.length() > 0) {
  143. if (tokens.length() >= 3) {
  144. if (string_match(tokens[1], U"include")) {
  145. if (tokens[2][0] == U'\"') {
  146. String relativePath = string_unmangleQuote(tokens[2]);
  147. String absolutePath = file_getTheoreticalAbsolutePath(relativePath, parentFolder, LOCAL_PATH_SYNTAX);
  148. result.includes.pushConstruct(absolutePath, lineNumber);
  149. }
  150. }
  151. }
  152. tokens.clear();
  153. }
  154. });
  155. }
  156. void analyzeFromFile(ProjectContext &context, const ReadableString& absolutePath) {
  157. if (findDependency(context, absolutePath) != -1) {
  158. // Already analyzed the current entry. Abort to prevent duplicate dependencies.
  159. return;
  160. }
  161. Extension extension = extensionFromString(file_getExtension(absolutePath));
  162. if (extension != Extension::Unknown) {
  163. // Create a new dependency for the file.
  164. int64_t parentIndex = context.dependencies.length();
  165. context.dependencies.push(Dependency(absolutePath, extension));
  166. // Summarize the file's content.
  167. analyzeFile(context.dependencies[parentIndex], absolutePath, extension);
  168. // Continue analyzing recursively into the file's dependencies.
  169. for (int64_t i = 0; i < context.dependencies[parentIndex].includes.length(); i++) {
  170. analyzeFromFile(context, context.dependencies[parentIndex].includes[i].path);
  171. }
  172. for (int64_t l = 0; l < context.dependencies[parentIndex].links.length(); l++) {
  173. analyzeFromFile(context, context.dependencies[parentIndex].links[l].path);
  174. }
  175. }
  176. }
  177. static void debugPrintDependencyList(const List<Connection> &connnections, const ReadableString verb) {
  178. for (int64_t c = 0; c < connnections.length(); c++) {
  179. int64_t lineNumber = connnections[c].lineNumber;
  180. if (lineNumber != -1) {
  181. printText(U" @", lineNumber, U"\t");
  182. } else {
  183. printText(U" \t");
  184. }
  185. printText(U" ", verb, U" ", file_getPathlessName(connnections[c].path), U"\n");
  186. }
  187. }
  188. void printDependencies(ProjectContext &context) {
  189. for (int64_t d = 0; d < context.dependencies.length(); d++) {
  190. printText(U"* ", file_getPathlessName(context.dependencies[d].path), U"\n");
  191. debugPrintDependencyList(context.dependencies[d].includes, U"including");
  192. debugPrintDependencyList(context.dependencies[d].links, U"linking");
  193. }
  194. }
  195. static void script_printMessage(String &output, ScriptLanguage language, const ReadableString message) {
  196. if (language == ScriptLanguage::Batch) {
  197. string_append(output, U"echo ", message, U"\n");
  198. } else if (language == ScriptLanguage::Bash) {
  199. string_append(output, U"echo ", message, U"\n");
  200. }
  201. }
  202. static void traverserHeaderChecksums(ProjectContext &context, uint64_t &target, int64_t dependencyIndex) {
  203. // Use checksums from headers
  204. for (int64_t h = 0; h < context.dependencies[dependencyIndex].includes.length(); h++) {
  205. int64_t includedIndex = context.dependencies[dependencyIndex].includes[h].dependencyIndex;
  206. if (!context.dependencies[includedIndex].visited) {
  207. //printText(U" traverserHeaderChecksums(context, ", includedIndex, U") ", context.dependencies[includedIndex].path, "\n");
  208. // Bitwise exclusive or is both order independent and entropy preserving for non-repeated content.
  209. target = target ^ context.dependencies[includedIndex].contentChecksum;
  210. // Just have to make sure that the same checksum is not used twice.
  211. context.dependencies[includedIndex].visited = true;
  212. // Use checksums from headers recursively
  213. traverserHeaderChecksums(context, target, includedIndex);
  214. }
  215. }
  216. }
  217. static uint64_t getCombinedChecksum(ProjectContext &context, int64_t dependencyIndex) {
  218. //printText(U"getCombinedChecksum(context, ", dependencyIndex, U") ", context.dependencies[dependencyIndex].path, "\n");
  219. for (int64_t d = 0; d < context.dependencies.length(); d++) {
  220. context.dependencies[d].visited = false;
  221. }
  222. context.dependencies[dependencyIndex].visited = true;
  223. uint64_t result = context.dependencies[dependencyIndex].contentChecksum;
  224. traverserHeaderChecksums(context, result, dependencyIndex);
  225. return result;
  226. }
  227. static int64_t findObject(SessionContext &source, uint64_t identityChecksum) {
  228. for (int64_t o = 0; o < source.sourceObjects.length(); o++) {
  229. if (source.sourceObjects[o].identityChecksum == identityChecksum) {
  230. return o;
  231. }
  232. }
  233. return -1;
  234. }
  235. void gatherBuildInstructions(SessionContext &output, ProjectContext &context, Machine &settings, ReadableString programPath) {
  236. // The compiler is often a global alias, so the user must supply either an alias or an absolute path.
  237. ReadableString compilerName = getFlag(settings, U"Compiler", U"g++"); // Assume g++ as the compiler if not specified.
  238. ReadableString compileFrom = getFlag(settings, U"CompileFrom", U"");
  239. // Check if the build system was asked to run the compiler from a specific folder.
  240. bool changePath = (string_length(compileFrom) > 0);
  241. if (changePath) {
  242. printText(U"Using ", compilerName, " as the compiler executed from ", compileFrom, ".\n");
  243. } else {
  244. printText(U"Using ", compilerName, " as the compiler from the current directory.\n");
  245. }
  246. // TODO: Warn if -DNDEBUG, -DDEBUG, or optimization levels are given directly.
  247. // Using the variables instead is both more flexible by accepting input arguments
  248. // and keeping the same format to better reuse compiled objects.
  249. if (getFlagAsInteger(settings, U"Debug")) {
  250. printText(U"Building with debug mode.\n");
  251. settings.compilerFlags.push(U"-DDEBUG");
  252. } else {
  253. printText(U"Building with release mode.\n");
  254. settings.compilerFlags.push(U"-DNDEBUG");
  255. }
  256. if (getFlagAsInteger(settings, U"StaticRuntime")) {
  257. if (getFlagAsInteger(settings, U"Windows")) {
  258. printText(U"Building with static runtime. Your application's binary will be bigger but can run without needing any installer.\n");
  259. settings.compilerFlags.push(U"-static");
  260. settings.compilerFlags.push(U"-static-libgcc");
  261. settings.compilerFlags.push(U"-static-libstdc++");
  262. settings.linkerFlags.push(U"-static");
  263. settings.linkerFlags.push(U"-static-libgcc");
  264. settings.linkerFlags.push(U"-static-libstdc++");
  265. } else {
  266. printText(U"The target platform does not support static linking of runtime. But don't worry about bundling any runtimes, because it comes with most of the Posix compliant operating systems.\n");
  267. }
  268. } else {
  269. printText(U"Building with dynamic runtime. Don't forget to bundle the C and C++ runtimes for systems that don't have it pre-installed.\n");
  270. }
  271. ReadableString optimizationLevel = getFlag(settings, U"Optimization", U"2");
  272. printText(U"Building with optimization level ", optimizationLevel, U".\n");
  273. settings.compilerFlags.push(string_combine(U"-O", optimizationLevel));
  274. // Convert lists of linker and compiler flags into strings.
  275. // TODO: Give a warning if two contradictory flags are used, such as optimization levels and language versions.
  276. // TODO: Make sure that no spaces are inside of the flags, because that can mess up detection of pre-existing and contradictory arguments.
  277. // TODO: Use groups of compiler flags, so that they can be generated in the last step.
  278. // This would allow calling the compiler directly when given a folder path for temporary files instead of a script path.
  279. String generatedCompilerFlags;
  280. for (int64_t i = 0; i < settings.compilerFlags.length(); i++) {
  281. string_append(generatedCompilerFlags, " ", settings.compilerFlags[i]);
  282. }
  283. String linkerFlags;
  284. for (int64_t i = 0; i < settings.linkerFlags.length(); i++) {
  285. string_append(linkerFlags, " -l", settings.linkerFlags[i]);
  286. }
  287. printText(U"Generating build instructions for ", programPath, U" using settings:\n");
  288. printText(U" Compiler flags:", generatedCompilerFlags, U"\n");
  289. printText(U" Linker flags:", linkerFlags, U"\n");
  290. for (int64_t v = 0; v < settings.variables.length(); v++) {
  291. printText(U" * ", settings.variables[v].key, U" = ", settings.variables[v].value);
  292. if (settings.variables[v].inherited) {
  293. printText(U" (inherited input)");
  294. }
  295. printText(U"\n");
  296. }
  297. printText(U"Listing source files to compile in the current session.\n");
  298. // The current project's global indices to objects shared between all projects being built during the session.
  299. List<int64_t> sourceObjectIndices;
  300. bool hasSourceCode = false;
  301. for (int64_t d = 0; d < context.dependencies.length(); d++) {
  302. Extension extension = context.dependencies[d].extension;
  303. if (extension == Extension::C || extension == Extension::Cpp) {
  304. // Dependency paths are already absolute from the recursive search.
  305. String sourcePath = context.dependencies[d].path;
  306. String identity = string_combine(sourcePath, generatedCompilerFlags);
  307. uint64_t identityChecksum = checksum(identity);
  308. int64_t previousIndex = findObject(output, identityChecksum);
  309. if (previousIndex == -1) {
  310. // Content checksums were created while scanning for source code, so now we just combine each source file's content checksum with all its headers to get the combined checksum.
  311. // The combined checksum represents the state after all headers are included recursively and given as input for compilation unit generating an object.
  312. uint64_t combinedChecksum = getCombinedChecksum(context, d);
  313. String objectPath = file_combinePaths(output.tempPath, string_combine(U"dfpsr_", identityChecksum, U"_", combinedChecksum, U".o"));
  314. sourceObjectIndices.push(output.sourceObjects.length());
  315. output.sourceObjects.pushConstruct(identityChecksum, combinedChecksum, sourcePath, objectPath, generatedCompilerFlags, compilerName, compileFrom);
  316. } else {
  317. // Link to this pre-existing source file.
  318. sourceObjectIndices.push(previousIndex);
  319. }
  320. hasSourceCode = true;
  321. }
  322. }
  323. if (hasSourceCode) {
  324. printText(U"Listing target executable ", programPath, " in the current session.\n");
  325. bool executeResult = getFlagAsInteger(settings, U"Supressed") == 0;
  326. output.linkerSteps.pushConstruct(compilerName, compileFrom, programPath, settings.linkerFlags, sourceObjectIndices, executeResult);
  327. } else {
  328. printText(U"Filed to find any source code to compile when building ", programPath, U".\n");
  329. }
  330. }
  331. static ScriptLanguage identifyLanguage(const ReadableString &filename) {
  332. String scriptExtension = string_upperCase(file_getExtension(filename));
  333. if (string_match(scriptExtension, U"BAT")) {
  334. return ScriptLanguage::Batch;
  335. } else if (string_match(scriptExtension, U"SH")) {
  336. return ScriptLanguage::Bash;
  337. } else {
  338. throwError(U"Could not identify the scripting language of ", filename, U". Use *.bat or *.sh.\n");
  339. return ScriptLanguage::Unknown;
  340. }
  341. }
  342. void setCompilationFolder(String &generatedCode, ScriptLanguage language, String &currentPath, const ReadableString &newPath) {
  343. if (!string_match(currentPath, newPath)) {
  344. if (string_length(currentPath) > 0) {
  345. if (language == ScriptLanguage::Batch) {
  346. string_append(generatedCode, "popd\n");
  347. } else if (language == ScriptLanguage::Bash) {
  348. string_append(generatedCode, U")\n");
  349. }
  350. }
  351. if (string_length(newPath) > 0) {
  352. if (language == ScriptLanguage::Batch) {
  353. string_append(generatedCode, "pushd ", newPath, "\n");
  354. } else if (language == ScriptLanguage::Bash) {
  355. string_append(generatedCode, U"(cd ", newPath, ";\n");
  356. }
  357. }
  358. }
  359. }
  360. void generateCompilationScript(SessionContext &input, const ReadableString &scriptPath) {
  361. printText(U"Generating build script\n");
  362. String generatedCode;
  363. ScriptLanguage language = identifyLanguage(scriptPath);
  364. if (language == ScriptLanguage::Batch) {
  365. string_append(generatedCode, U"@echo off\n\n");
  366. } else if (language == ScriptLanguage::Bash) {
  367. string_append(generatedCode, U"#!/bin/bash\n\n");
  368. }
  369. // Keep track of the current path, so that it only changes when needed.
  370. String currentPath;
  371. // Generate code for compiling source code into objects.
  372. printText(U"Generating code for compiling ", input.sourceObjects.length(), U" objects.\n");
  373. for (int64_t o = 0; o < input.sourceObjects.length(); o++) {
  374. SourceObject *sourceObject = &(input.sourceObjects[o]);
  375. printText(U"\t* ", sourceObject->sourcePath, U"\n");
  376. setCompilationFolder(generatedCode, language, currentPath, sourceObject->compileFrom);
  377. if (language == ScriptLanguage::Batch) {
  378. string_append(generatedCode, U"if exist ", sourceObject->objectPath, U" (\n");
  379. } else if (language == ScriptLanguage::Bash) {
  380. string_append(generatedCode, U"if [ -e \"", sourceObject->objectPath, U"\" ]; then\n");
  381. }
  382. script_printMessage(generatedCode, language, string_combine(U"Reusing ", sourceObject->sourcePath, U" ID:", sourceObject->identityChecksum, U"."));
  383. if (language == ScriptLanguage::Batch) {
  384. string_append(generatedCode, U") else (\n");
  385. } else if (language == ScriptLanguage::Bash) {
  386. string_append(generatedCode, U"else\n");
  387. }
  388. String compilerFlags = sourceObject->generatedCompilerFlags;
  389. script_printMessage(generatedCode, language, string_combine(U"Compiling ", sourceObject->sourcePath, U" ID:", sourceObject->identityChecksum, U" with ", compilerFlags, U"."));
  390. string_append(generatedCode, sourceObject->compilerName, compilerFlags, U" -c ", sourceObject->sourcePath, U" -o ", sourceObject->objectPath, U"\n");
  391. if (language == ScriptLanguage::Batch) {
  392. string_append(generatedCode, ")\n");
  393. } else if (language == ScriptLanguage::Bash) {
  394. string_append(generatedCode, U"fi\n");
  395. }
  396. }
  397. // Generate code for linking objects into executables.
  398. printText(U"Generating code for linking ", input.linkerSteps.length(), U" executables:\n");
  399. for (int64_t l = 0; l < input.linkerSteps.length(); l++) {
  400. LinkingStep *linkingStep = &(input.linkerSteps[l]);
  401. String programPath = linkingStep->binaryName;
  402. printText(U"\tGenerating code for linking ", programPath, U" of :\n");
  403. setCompilationFolder(generatedCode, language, currentPath, linkingStep->compileFrom);
  404. String linkerFlags;
  405. for (int64_t lib = 0; lib < linkingStep->linkerFlags.length(); lib++) {
  406. String library = linkingStep->linkerFlags[lib];
  407. string_append(linkerFlags, " -l", library);
  408. printText(U"\t\t* ", library, U" library\n");
  409. }
  410. // Generate a list of object paths from indices.
  411. String allObjects;
  412. for (int64_t i = 0; i < linkingStep->sourceObjectIndices.length(); i++) {
  413. int64_t objectIndex = linkingStep->sourceObjectIndices[i];
  414. SourceObject *sourceObject = &(input.sourceObjects[objectIndex]);
  415. if (objectIndex >= 0 || objectIndex < input.sourceObjects.length()) {
  416. printText(U"\t\t* ", sourceObject->sourcePath, U"\n");
  417. string_append(allObjects, U" ", sourceObject->objectPath);
  418. } else {
  419. throwError(U"Object index ", objectIndex, U" is out of bound ", 0, U"..", (input.sourceObjects.length() - 1), U"\n");
  420. }
  421. }
  422. // Generate the code for building.
  423. if (string_length(linkerFlags) > 0) {
  424. script_printMessage(generatedCode, language, string_combine(U"Linking ", programPath, U" with", linkerFlags, U"."));
  425. } else {
  426. script_printMessage(generatedCode, language, string_combine(U"Linking ", programPath, U"."));
  427. }
  428. string_append(generatedCode, linkingStep->compilerName, allObjects, linkerFlags, U" -o ", programPath, U"\n");
  429. if (linkingStep->executeResult) {
  430. script_printMessage(generatedCode, language, string_combine(U"Starting ", programPath));
  431. string_append(generatedCode, programPath, U"\n");
  432. script_printMessage(generatedCode, language, U"The program terminated.");
  433. }
  434. }
  435. setCompilationFolder(generatedCode, language, currentPath, U"");
  436. script_printMessage(generatedCode, language, U"Done building.");
  437. // Save the script.
  438. printText(U"Saving script to ", scriptPath, "\n");
  439. if (language == ScriptLanguage::Batch) {
  440. string_save(scriptPath, generatedCode);
  441. } else if (language == ScriptLanguage::Bash) {
  442. string_save(scriptPath, generatedCode, CharacterEncoding::BOM_UTF8, LineEncoding::Lf);
  443. }
  444. }