Browse Source

Switch default compiler to g++

This makes it a zero-install on the other Linux system I tested. I had
to rename log to logging in order to avoid the g++ built-in "log"
windows-support
Macoy Madson 6 months ago
parent
commit
31cf1bdb60
13 changed files with 123 additions and 133 deletions
  1. +2
    -2
      Build.sh
  2. +4
    -4
      Jamrules
  3. +1
    -1
      runtime/HotReloading.cake
  4. +42
    -46
      src/Evaluator.cpp
  5. +7
    -7
      src/FileUtilities.cpp
  6. +1
    -1
      src/Logging.cpp
  7. +1
    -1
      src/Logging.hpp
  8. +21
    -21
      src/Main.cpp
  9. +29
    -29
      src/ModuleManager.cpp
  10. +3
    -3
      src/RunProcess.cpp
  11. +1
    -1
      src/Tokenizer.cpp
  12. +1
    -1
      src/Utilities.cpp
  13. +10
    -16
      src/Writer.cpp

+ 2
- 2
Build.sh View File

@ -1,8 +1,8 @@
#!/bin/sh
CAKELISP_BOOTSTRAP_BIN=bin/cakelisp_bootstrap
CC=clang++
LINK=clang++
CC=g++
LINK=g++
# Note: If you make changes to the bootstrap process, you will need to delete
# $CAKELISP_BOOTSTRAP_BIN so that it is updated


+ 4
- 4
Jamrules View File

@ -2,10 +2,10 @@
## Compilation
##
C++ = clang++ ;
LINK = clang++ ;
# C++ = g++ ;
# LINK = g++ ;
# C++ = clang++ ;
# LINK = clang++ ;
C++ = g++ ;
LINK = g++ ;
if $(UNIX) { SUFSHR = .so ; }
else if $(NT) { SUFSHR = .dll ; }


+ 1
- 1
runtime/HotReloading.cake View File

@ -117,7 +117,7 @@
;; TODO: This only makes sense on a per-target basis. Instead, modules should be able to append
;; arguments to the link command only
(set-cakelisp-option build-time-linker "/usr/bin/clang++")
(set-cakelisp-option build-time-linker "/usr/bin/g++")
;; This needs to link -ldl and such (depending on platform...)
(set-cakelisp-option build-time-link-arguments
;; "-shared" ;; This causes c++ initializers to fail and no linker errors. Need to only enable on lib?


+ 42
- 46
src/Evaluator.cpp View File

@ -121,7 +121,7 @@ const ObjectReferenceStatus* addObjectReference(EvaluatorEnvironment& environmen
}
const char* defName = definitionName.c_str();
if (log.references)
if (logging.references)
Logf("Adding reference %s to %s\n", referenceNameToken.contents.c_str(), defName);
// Add the reference requirement to the definition it occurred in
@ -132,7 +132,7 @@ const ObjectReferenceStatus* addObjectReference(EvaluatorEnvironment& environmen
if (definitionName.compare(globalDefinitionName) != 0)
{
Logf("error: expected definition %s to already exist. Things will break\n",
definitionName.c_str());
definitionName.c_str());
}
else
{
@ -571,7 +571,7 @@ bool ReplaceAndEvaluateDefinition(EvaluatorEnvironment& environment,
if (findIt == environment.definitions.end())
{
Logf("error: ReplaceAndEvaluateDefinition() could not find definition '%s'\n",
definitionToReplaceName);
definitionToReplaceName);
return false;
}
@ -641,16 +641,16 @@ static void PropagateRequiredToReferences(EvaluatorEnvironment& environment)
if (findIt != environment.requiredCompileTimeFunctions.end())
{
if (log.dependencyPropagation)
Logf("Define %s promoted to required because %s\n",
definition.name.c_str(), findIt->second);
if (logging.dependencyPropagation)
Logf("Define %s promoted to required because %s\n", definition.name.c_str(),
findIt->second);
definition.isRequired = true;
definition.environmentRequired = true;
}
}
if (log.dependencyPropagation)
if (logging.dependencyPropagation)
{
const char* status = definition.isRequired ? "(required)" : "(not required)";
Logf("Define %s %s\n", definition.name.c_str(), status);
@ -660,7 +660,7 @@ static void PropagateRequiredToReferences(EvaluatorEnvironment& environment)
{
ObjectReferenceStatus& referenceStatus = reference.second;
if (log.dependencyPropagation)
if (logging.dependencyPropagation)
Logf("\tRefers to %s\n", referenceStatus.name->contents.c_str());
if (definition.isRequired)
@ -669,9 +669,9 @@ static void PropagateRequiredToReferences(EvaluatorEnvironment& environment)
environment.definitions.find(referenceStatus.name->contents);
if (findIt != environment.definitions.end() && !findIt->second.isRequired)
{
if (log.dependencyPropagation)
if (logging.dependencyPropagation)
Logf("\t Infecting %s with required due to %s\n",
referenceStatus.name->contents.c_str(), definition.name.c_str());
referenceStatus.name->contents.c_str(), definition.name.c_str());
++numRequiresStatusChanged;
findIt->second.isRequired = true;
@ -729,7 +729,7 @@ int BuildExecuteCompileTimeFunctions(EvaluatorEnvironment& environment,
{
ObjectDefinition* definition = buildObject.definition;
if (log.buildProcess)
if (logging.buildProcess)
Logf("Build %s\n", definition->name.c_str());
if (!definition->output)
@ -847,7 +847,7 @@ int BuildExecuteCompileTimeFunctions(EvaluatorEnvironment& environment,
if (canUseCachedFile(environment, sourceOutputName, buildObject.dynamicLibraryPath.c_str()))
{
if (log.buildProcess)
if (logging.buildProcess)
Logf("Skipping compiling %s (using cached library)\n", sourceOutputName);
// Skip straight to linking, which immediately becomes loading
buildObject.stage = BuildStage_Linking;
@ -930,7 +930,7 @@ int BuildExecuteCompileTimeFunctions(EvaluatorEnvironment& environment,
buildObject.stage = BuildStage_Linking;
if (log.buildProcess)
if (logging.buildProcess)
Logf("Compiled %s successfully\n", buildObject.definition->name.c_str());
ProcessCommandInput linkTimeInputs[] = {
@ -973,7 +973,7 @@ int BuildExecuteCompileTimeFunctions(EvaluatorEnvironment& environment,
buildObject.stage = BuildStage_Loading;
if (log.buildProcess)
if (logging.buildProcess)
Logf("Linked %s successfully\n", buildObject.definition->name.c_str());
DynamicLibHandle builtLib = loadDynamicLibrary(buildObject.dynamicLibraryPath.c_str());
@ -1036,8 +1036,7 @@ int BuildExecuteCompileTimeFunctions(EvaluatorEnvironment& environment,
if (referencePoolIt == environment.referencePools.end())
{
if (!buildObject.definition->environmentRequired)
Log(
"error: built an object which had no references. It should not have been "
Log("error: built an object which had no references. It should not have been "
"required. There must be a problem with Cakelisp internally\n");
continue;
}
@ -1075,7 +1074,7 @@ int BuildExecuteCompileTimeFunctions(EvaluatorEnvironment& environment,
// function, clear that invocation output
resetGeneratorOutput(*referenceValidPreEval->spliceOutput);
if (log.buildProcess)
if (logging.buildProcess)
NoteAtToken((*referenceValidPreEval->tokens)[referenceValidPreEval->startIndex],
"resolving reference");
@ -1112,7 +1111,7 @@ int BuildExecuteCompileTimeFunctions(EvaluatorEnvironment& environment,
if (hasErrors)
continue;
if (log.buildProcess)
if (logging.buildProcess)
Logf("Resolved %d references\n", numReferencesResolved);
// Remove need to build
@ -1120,9 +1119,9 @@ int BuildExecuteCompileTimeFunctions(EvaluatorEnvironment& environment,
buildObject.stage = BuildStage_Finished;
if (log.buildProcess)
if (logging.buildProcess)
Logf("Successfully built, loaded, and executed %s\n",
buildObject.definition->name.c_str());
buildObject.definition->name.c_str());
}
return numReferencesResolved;
@ -1162,7 +1161,7 @@ bool BuildEvaluateReferences(EvaluatorEnvironment& environment, int& numErrorsOu
ObjectDefinition& definition = *definitionPointer;
const char* defName = definition.name.c_str();
if (log.compileTimeBuildReasons)
if (logging.compileTimeBuildReasons)
Logf("Checking to build %s\n", defName);
// Can it be built in the current environment?
@ -1209,7 +1208,7 @@ bool BuildEvaluateReferences(EvaluatorEnvironment& environment, int& numErrorsOu
// incorrectly that this was a C call
if (referenceStatus.guessState != GuessState_Resolved)
{
if (log.compileTimeBuildReasons)
if (logging.compileTimeBuildReasons)
Log("\tRequired code has been loaded\n");
hasRelevantChangeOccurred = true;
@ -1221,9 +1220,9 @@ bool BuildEvaluateReferences(EvaluatorEnvironment& environment, int& numErrorsOu
{
// If we know we are missing a compile time function, we won't try to
// guess
if (log.compileTimeBuildReasons)
if (logging.compileTimeBuildReasons)
Logf("\tCannot build until %s is loaded\n",
referenceStatus.name->contents.c_str());
referenceStatus.name->contents.c_str());
referenceStatus.guessState = GuessState_WaitingForLoad;
canBuild = false;
@ -1254,9 +1253,9 @@ bool BuildEvaluateReferences(EvaluatorEnvironment& environment, int& numErrorsOu
{
if (referenceStatus.guessState == GuessState_None)
{
if (log.compileTimeBuildReasons)
if (logging.compileTimeBuildReasons)
Logf("\tCannot build until %s is guessed. Guessing now\n",
referenceStatus.name->contents.c_str());
referenceStatus.name->contents.c_str());
// Find all the times the definition makes this reference
// We must use indices because the call to FunctionInvocationGenerator can
@ -1305,7 +1304,7 @@ bool BuildEvaluateReferences(EvaluatorEnvironment& environment, int& numErrorsOu
}
}
if (log.compileTimeBuildObjects && !definitionsToBuild.empty())
if (logging.compileTimeBuildObjects && !definitionsToBuild.empty())
{
int numToBuild = (int)definitionsToBuild.size();
Logf("Building %d compile-time object%c\n", numToBuild, numToBuild > 1 ? 's' : ' ');
@ -1325,7 +1324,7 @@ bool BuildEvaluateReferences(EvaluatorEnvironment& environment, int& numErrorsOu
bool EvaluateResolveReferences(EvaluatorEnvironment& environment)
{
// Print state
if (log.references)
if (logging.references)
{
for (ObjectDefinitionPair& definitionPair : environment.definitions)
{
@ -1349,12 +1348,12 @@ bool EvaluateResolveReferences(EvaluatorEnvironment& environment)
bool needsAnotherPass = false;
do
{
if (log.buildProcess)
if (logging.buildProcess)
Log("Propagate references\n");
PropagateRequiredToReferences(environment);
if (log.buildProcess)
if (logging.buildProcess)
Log("Build and evaluate references\n");
needsAnotherPass = BuildEvaluateReferences(environment, numBuildResolveErrors);
@ -1365,7 +1364,7 @@ bool EvaluateResolveReferences(EvaluatorEnvironment& environment)
if (numBuildResolveErrors)
break;
if (log.buildProcess)
if (logging.buildProcess)
Log("Run post references resolved hooks\n");
// At this point, all known references are resolved. Time to let the user do arbitrary code
@ -1390,7 +1389,7 @@ bool EvaluateResolveReferences(EvaluatorEnvironment& environment)
} while (codeModified);
// Check whether everything is resolved
if (log.phases)
if (logging.phases)
Log("\nResult:\n");
if (numBuildResolveErrors)
@ -1457,7 +1456,7 @@ bool EvaluateResolveReferences(EvaluatorEnvironment& environment)
}
else
{
if (log.buildOmissions && isCompileTimeObject(definition.type))
if (logging.buildOmissions && isCompileTimeObject(definition.type))
NoteAtTokenf(*definition.definitionInvocation,
"did not build %s (not required by any module)",
definition.name.c_str());
@ -1472,8 +1471,7 @@ EvaluatorEnvironment::~EvaluatorEnvironment()
{
if (!comptimeTokens.empty())
{
Log(
"Warning: environmentDestroyInvalidateTokens() has not been called. This will leak "
Log("Warning: environmentDestroyInvalidateTokens() has not been called. This will leak "
"memory.\n Call it once you are certain no tokens in any expansions will be "
"referenced.\n");
}
@ -1498,8 +1496,7 @@ void environmentDestroyInvalidateTokens(EvaluatorEnvironment& environment)
if (!tokenizeLinePrintError(g_environmentCompileTimeVariableDestroySignature,
__FILE__, __LINE__, expectedSignature))
{
Log(
"error: failed to tokenize "
Log("error: failed to tokenize "
"g_environmentCompileTimeVariableDestroySignature! Internal code "
"error. Compile time variable memory will leak\n");
continue;
@ -1510,8 +1507,7 @@ void environmentDestroyInvalidateTokens(EvaluatorEnvironment& environment)
findObjectDefinition(environment, destroyFuncName.c_str());
if (!destroyFuncDefinition)
{
Log(
"error: could not find compile-time variable destroy function to verify "
Log("error: could not find compile-time variable destroy function to verify "
"signature. Internal code error?\n");
continue;
}
@ -1635,16 +1631,16 @@ bool searchForFileInPaths(const char* shortPath, const char* encounteredInFile,
getDirectoryFromPath(encounteredInFile, relativePathBuffer, sizeof(relativePathBuffer));
SafeSnprinf(foundFilePathOut, foundFilePathOutSize, "%s/%s", relativePathBuffer, shortPath);
if (log.fileSearch)
if (logging.fileSearch)
Logf("File exists? %s (", foundFilePathOut);
if (fileExists(foundFilePathOut))
{
if (log.fileSearch)
if (logging.fileSearch)
Log("yes)\n");
return true;
}
if (log.fileSearch)
if (logging.fileSearch)
Log("no)\n");
}
@ -1652,20 +1648,20 @@ bool searchForFileInPaths(const char* shortPath, const char* encounteredInFile,
{
SafeSnprinf(foundFilePathOut, foundFilePathOutSize, "%s/%s", path.c_str(), shortPath);
if (log.fileSearch)
if (logging.fileSearch)
Logf("File exists? %s (", foundFilePathOut);
if (fileExists(foundFilePathOut))
{
if (log.fileSearch)
if (logging.fileSearch)
Log("yes)\n");
return true;
}
if (log.fileSearch)
if (logging.fileSearch)
Log("no)\n");
}
if (log.fileSearch)
if (logging.fileSearch)
Logf("> Not found: %s\n", shortPath);
return false;


+ 7
- 7
src/FileUtilities.cpp View File

@ -23,7 +23,7 @@ unsigned long fileGetLastModificationTime(const char* filename)
struct stat fileStat;
if (stat(filename, &fileStat) == -1)
{
if (log.fileSystem || errno != ENOENT)
if (logging.fileSystem || errno != ENOENT)
perror("fileGetLastModificationTime: ");
return 0;
}
@ -41,13 +41,13 @@ bool fileIsMoreRecentlyModified(const char* filename, const char* reference)
struct stat referenceStat;
if (stat(filename, &fileStat) == -1)
{
if (log.fileSystem || errno != ENOENT)
if (logging.fileSystem || errno != ENOENT)
perror("fileIsMoreRecentlyModified: ");
return true;
}
if (stat(reference, &referenceStat) == -1)
{
if (log.fileSystem || errno != ENOENT)
if (logging.fileSystem || errno != ENOENT)
perror("fileIsMoreRecentlyModified: ");
return true;
}
@ -73,7 +73,7 @@ void makeDirectory(const char* path)
if (mkdir(path, 0755) == -1)
{
// We don't care about EEXIST, we just want the dir
if (log.fileSystem || errno != EEXIST)
if (logging.fileSystem || errno != EEXIST)
perror("makeDirectory: ");
}
#else
@ -245,13 +245,13 @@ bool copyBinaryFileTo(const char* srcFilename, const char* destFilename)
numRead = fread(buffer, sizeof(buffer[0]), ArraySize(buffer), srcFile);
}
if (log.fileSystem)
if (logging.fileSystem)
Logf("%lu bytes copied\n", totalCopied);
fclose(srcFile);
fclose(destFile);
if (log.fileSystem)
if (logging.fileSystem)
Logf("Wrote %s\n", destFilename);
return true;
@ -275,7 +275,7 @@ bool copyFileTo(const char* srcFilename, const char* destFilename)
fclose(srcFile);
fclose(destFile);
if (log.fileSystem)
if (logging.fileSystem)
Logf("Wrote %s\n", destFilename);
return true;


+ 1
- 1
src/Logging.cpp View File

@ -1,3 +1,3 @@
#include "Logging.hpp"
LoggingSettings log = {};
LoggingSettings logging = {};

+ 1
- 1
src/Logging.hpp View File

@ -25,4 +25,4 @@ struct LoggingSettings
bool strictIncludes;
};
extern LoggingSettings log;
extern LoggingSettings logging;

+ 21
- 21
src/Main.cpp View File

@ -56,49 +56,49 @@ int main(int numArguments, char* arguments[])
"List all built-in compile-time procedures, then exit. This list contains every procedure "
"you can possibly call, until you import more or define your own"},
// Logging
{"--verbose-phases", &log.phases,
{"--verbose-phases", &logging.phases,
"Output labels for each major phase Cakelisp goes through"},
{"--verbose-performance", &log.performance,
{"--verbose-performance", &logging.performance,
"Output statistics which help estimate Cakelisp's compilation performance"},
{"--verbose-build-omissions", &log.buildOmissions,
{"--verbose-build-omissions", &logging.buildOmissions,
"Output when compile-time functions are not built at all (because they were never "
"invoked). This can be useful if you expect your function to be referenced, but it isn't"},
{"--verbose-imports", &log.imports,
{"--verbose-imports", &logging.imports,
"Output when .cake files are loaded. Also outputs when a .cake file is imported but has "
"already been loaded"},
{"--verbose-tokenization", &log.tokenization,
{"--verbose-tokenization", &logging.tokenization,
"Output details about the conversion from file text to tokens"},
{"--verbose-references", &log.references,
{"--verbose-references", &logging.references,
"Output when references to function/macro/generator invocations are created, and list all "
"definitions and their references"},
{"--verbose-dependency-propagation", &log.dependencyPropagation,
{"--verbose-dependency-propagation", &logging.dependencyPropagation,
"Output why objects are being built (why they are required for building)"},
{"--verbose-build-reasons", &log.buildReasons,
{"--verbose-build-reasons", &logging.buildReasons,
"Output why objects are being built (i.e., why the cached version couldn't be used"},
{"--verbose-compile-time-build-reasons", &log.compileTimeBuildReasons,
{"--verbose-compile-time-build-reasons", &logging.compileTimeBuildReasons,
"Output why objects are or are not being built in each compile-time build cycle"},
{"--verbose-build-process", &log.buildProcess,
{"--verbose-build-process", &logging.buildProcess,
"Output object statuses as they move through the compile-time pipeline"},
{"--verbose-compile-time-build-objects", &log.compileTimeBuildObjects,
{"--verbose-compile-time-build-objects", &logging.compileTimeBuildObjects,
"Output when a compile-time object is being built/loaded. Like --verbose-build-process, "
"but less verbose"},
{"--verbose-command-crcs", &log.commandCrcs,
{"--verbose-command-crcs", &logging.commandCrcs,
"Output CRC32s generated by process argument lists to determine whether cached files need "
"rebuilds"},
{"--verbose-processes", &log.processes,
{"--verbose-processes", &logging.processes,
"Output full command lines and other information about all child processes created during "
"the compile-time build process"},
{"--verbose-file-system", &log.fileSystem,
{"--verbose-file-system", &logging.fileSystem,
"Output why files are being written, the status of comparing files, etc."},
{"--verbose-file-search", &log.fileSearch,
{"--verbose-file-search", &logging.fileSearch,
"Output when paths are being investigated for a file"},
{"--verbose-include-scanning", &log.includeScanning,
{"--verbose-include-scanning", &logging.includeScanning,
"Output when #include files are being checked for modifications. If they are modified, "
"the cached object files will be rebuilt"},
{"--verbose-strict-includes", &log.strictIncludes,
{"--verbose-strict-includes", &logging.strictIncludes,
"Output when #include files are not found during include scanning. The more header files "
"not found, the higher the chances false \"nothing to do\" builds could occur"},
{"--verbose-metadata", &log.metadata, "Output generated metadata"},
{"--verbose-metadata", &logging.metadata, "Output generated metadata"},
};
if (numArguments == 1)
@ -203,10 +203,10 @@ int main(int numArguments, char* arguments[])
return 1;
}
if (log.phases)
if (logging.phases)
Log("Successfully generated files\n");
if (log.phases)
if (logging.phases)
Log("\nBuild:\n");
std::vector<std::string> builtOutputs;
@ -218,7 +218,7 @@ int main(int numArguments, char* arguments[])
if (executeOutput)
{
if (log.phases)
if (logging.phases)
Log("\nExecute:\n");
if (builtOutputs.empty())


+ 29
- 29
src/ModuleManager.cpp View File

@ -75,7 +75,7 @@ void moduleManagerInitialize(ModuleManager& manager)
// Command defaults
{
manager.environment.compileTimeBuildCommand.fileToExecute = "/usr/bin/clang++";
manager.environment.compileTimeBuildCommand.fileToExecute = "/usr/bin/g++";
manager.environment.compileTimeBuildCommand.arguments = {
{ProcessCommandArgumentType_String, "-g"},
{ProcessCommandArgumentType_String, "-c"},
@ -85,14 +85,14 @@ void moduleManagerInitialize(ModuleManager& manager)
{ProcessCommandArgumentType_CakelispHeadersInclude, EmptyString},
{ProcessCommandArgumentType_String, "-fPIC"}};
manager.environment.compileTimeLinkCommand.fileToExecute = "/usr/bin/clang++";
manager.environment.compileTimeLinkCommand.fileToExecute = "/usr/bin/g++";
manager.environment.compileTimeLinkCommand.arguments = {
{ProcessCommandArgumentType_String, "-shared"},
{ProcessCommandArgumentType_String, "-o"},
{ProcessCommandArgumentType_DynamicLibraryOutput, EmptyString},
{ProcessCommandArgumentType_ObjectInput, EmptyString}};
manager.environment.buildTimeBuildCommand.fileToExecute = "/usr/bin/clang++";
manager.environment.buildTimeBuildCommand.fileToExecute = "/usr/bin/g++";
manager.environment.buildTimeBuildCommand.arguments = {
{ProcessCommandArgumentType_String, "-g"},
{ProcessCommandArgumentType_String, "-c"},
@ -103,7 +103,7 @@ void moduleManagerInitialize(ModuleManager& manager)
{ProcessCommandArgumentType_IncludeSearchDirs, EmptyString},
{ProcessCommandArgumentType_AdditionalOptions, EmptyString}};
manager.environment.buildTimeLinkCommand.fileToExecute = "/usr/bin/clang++";
manager.environment.buildTimeLinkCommand.fileToExecute = "/usr/bin/g++";
manager.environment.buildTimeLinkCommand.arguments = {
{ProcessCommandArgumentType_String, "-o"},
{ProcessCommandArgumentType_ExecutableOutput, EmptyString},
@ -117,7 +117,7 @@ void moduleManagerInitialize(ModuleManager& manager)
manager.environment.useCachedFiles = true;
makeDirectory(cakelispWorkingDir);
if (log.fileSystem || log.phases)
if (logging.fileSystem || logging.phases)
Logf("Using cache at %s\n", cakelispWorkingDir);
// By always searching relative to CWD, any subsequent imports with the module filename will
@ -157,7 +157,7 @@ bool moduleLoadTokenizeValidate(const char* filename, const std::vector<Token>**
bool isFirstLine = true;
while (fgets(lineBuffer, sizeof(lineBuffer), file))
{
if (log.tokenization)
if (logging.tokenization)
Logf("%s", lineBuffer);
// Check for shebang and ignore this line if found. This allows users to execute their
@ -167,7 +167,7 @@ bool moduleLoadTokenizeValidate(const char* filename, const std::vector<Token>**
isFirstLine = false;
if (lineBuffer[0] == '#' && lineBuffer[1] == '!')
{
if (log.tokenization)
if (logging.tokenization)
Log("Skipping shebang\n");
continue;
}
@ -190,7 +190,7 @@ bool moduleLoadTokenizeValidate(const char* filename, const std::vector<Token>**
tokens = tokens_CREATIONONLY;
}
if (log.tokenization)
if (logging.tokenization)
Logf("Tokenized %d lines\n", lineNumber - 1);
if (tokens->empty())
@ -206,7 +206,7 @@ bool moduleLoadTokenizeValidate(const char* filename, const std::vector<Token>**
return false;
}
if (log.tokenization)
if (logging.tokenization)
{
Log("\nResult:\n");
@ -300,7 +300,7 @@ bool moduleManagerAddEvaluateFile(ModuleManager& manager, const char* filename,
if (moduleOut)
*moduleOut = module;
if (log.imports)
if (logging.imports)
Logf("Already loaded %s\n", normalizedFilename);
free((void*)normalizedFilename);
free((void*)normalizedProspectiveModuleFilename);
@ -353,7 +353,7 @@ bool moduleManagerAddEvaluateFile(ModuleManager& manager, const char* filename,
if (moduleOut)
*moduleOut = newModule;
if (log.imports)
if (logging.imports)
Logf("Loaded %s\n", newModule->filename);
return true;
}
@ -414,7 +414,7 @@ static bool createBuildOutputDirectory(EvaluatorEnvironment& environment, std::s
makeDirectory(outputDirName);
if (log.fileSystem || log.phases)
if (logging.fileSystem || logging.phases)
Logf("Outputting artifacts to %s\n", outputDirName);
outputDirOut = outputDirName;
@ -474,7 +474,7 @@ bool moduleManagerWriteGeneratedOutput(ModuleManager& manager)
return false;
}
if (log.phases || log.performance)
if (logging.phases || logging.performance)
Logf("Processed %d lines\n", g_totalLinesTokenized);
return true;
@ -503,7 +503,7 @@ static unsigned long GetMostRecentIncludeModified_Recursive(
const HeaderModificationTimeTable::iterator findIt = isModifiedCache.find(filename);
if (findIt != isModifiedCache.end())
{
if (log.includeScanning)
if (logging.includeScanning)
Logf(" > cache hit %s\n", filename);
return findIt->second;
}
@ -514,7 +514,7 @@ static unsigned long GetMostRecentIncludeModified_Recursive(
if (!searchForFileInPaths(filename, includedInFile, searchDirectories, resolvedPathBuffer,
ArraySize(resolvedPathBuffer)))
{
if (log.includeScanning || log.strictIncludes)
if (logging.includeScanning || logging.strictIncludes)
Logf("warning: failed to find %s in search paths\n", filename);
// Might as well not keep failing to find it. It doesn't cause modification up the stream if
@ -532,7 +532,7 @@ static unsigned long GetMostRecentIncludeModified_Recursive(
return findIt->second;
}
if (log.includeScanning)
if (logging.includeScanning)
Logf("Checking %s for headers\n", resolvedPathBuffer);
const unsigned long thisModificationTime = fileGetLastModificationTime(resolvedPathBuffer);
@ -561,7 +561,7 @@ static unsigned long GetMostRecentIncludeModified_Recursive(
{
if (*c == '\"' || *c == '>')
{
if (log.includeScanning)
if (logging.includeScanning)
Logf("\t%s include: %s\n", resolvedPathBuffer, foundInclude);
unsigned long includeModifiedTime = GetMostRecentIncludeModified_Recursive(
@ -656,7 +656,7 @@ void getExecutableOutputName(ModuleManager& manager, std::string& finalOutputNam
bool copyExecutableToFinalOutput(ModuleManager& manager, const std::string& cachedOutputExecutable,
const std::string& finalOutputName)
{
if (log.fileSystem)
if (logging.fileSystem)
Log("Copying executable from cache\n");
if (!copyBinaryFileTo(cachedOutputExecutable.c_str(), finalOutputName.c_str()))
@ -685,12 +685,12 @@ static bool commandEqualsCachedCommand(ModuleManager& manager, const char* artif
ArtifactCrcTable::iterator findIt = manager.cachedCommandCrcs.find(artifactKey);
if (findIt == manager.cachedCommandCrcs.end())
{
if (log.commandCrcs)
if (logging.commandCrcs)
Logf("CRC32 for %s: %u (not cached)\n", artifactKey, newCommandCrc);
return false;
}
if (log.commandCrcs)
if (logging.commandCrcs)
Logf("CRC32 for %s: old %u new %u\n", artifactKey, findIt->second, newCommandCrc);
return findIt->second == newCommandCrc;
@ -747,11 +747,11 @@ bool moduleManagerBuild(ModuleManager& manager, std::vector<std::string>& builtO
buildCommandOverride = &module->buildTimeBuildCommand;
}
if (log.buildProcess)
if (logging.buildProcess)
Logf("Build module %s\n", module->sourceOutputName.c_str());
for (ModuleDependency& dependency : module->dependencies)
{
if (log.buildProcess)
if (logging.buildProcess)
Logf("\tRequires %s\n", dependency.name.c_str());
// Cakelisp files are built at the module manager level, so we need not concern
@ -887,7 +887,7 @@ bool moduleManagerBuild(ModuleManager& manager, std::vector<std::string>& builtO
unsigned long artifactModTime = fileGetLastModificationTime(object->filename.c_str());
if (artifactModTime > mostRecentHeaderModTime)
{
if (log.buildProcess)
if (logging.buildProcess)
Logf("Skipping compiling %s (using cached object)\n",
object->sourceFilename.c_str());
continue;
@ -895,13 +895,13 @@ bool moduleManagerBuild(ModuleManager& manager, std::vector<std::string>& builtO
else
{
headersModified = true;
if (log.includeScanning || log.buildProcess)
if (logging.includeScanning || logging.buildProcess)
Logf("--- Must rebuild %s (header files modified)\n",
object->sourceFilename.c_str());
}
}
if (log.buildReasons)
if (logging.buildReasons)
{
Logf("Build %s reason(s):\n", object->filename.c_str());
if (!canUseCache)
@ -941,7 +941,7 @@ bool moduleManagerBuild(ModuleManager& manager, std::vector<std::string>& builtO
}
}
if (log.includeScanning || log.performance)
if (logging.includeScanning || logging.performance)
Logf("%lu files tested for modification times\n", headerModifiedCache.size());
waitForAllProcessesClosed(OnCompileProcessOutput);
@ -983,7 +983,7 @@ bool moduleManagerBuild(ModuleManager& manager, std::vector<std::string>& builtO
continue;
}
if (log.buildProcess)
if (logging.buildProcess)
Logf("Need to link %s\n", object->filename.c_str());
++numObjectsToLink;
@ -1044,7 +1044,7 @@ bool moduleManagerBuild(ModuleManager& manager, std::vector<std::string>& builtO
// Check if we can use the cached version
if (!objectsDirty && commandEqualsCached)
{
if (log.buildProcess)
if (logging.buildProcess)
Log("Skipping linking (no built objects are newer than cached executable, command "
"identical)\n");
@ -1066,7 +1066,7 @@ bool moduleManagerBuild(ModuleManager& manager, std::vector<std::string>& builtO
return true;
}
if (log.buildReasons)
if (logging.buildReasons)
{
Logf("Link %s reason(s):\n", finalOutputName.c_str());
if (objectsDirty)


+ 3
- 3
src/RunProcess.cpp View File

@ -57,7 +57,7 @@ void subprocessReceiveStdOut(const char* processOutputBuffer)
int runProcess(const RunProcessArguments& arguments, int* statusOut)
{
#ifdef UNIX
if (log.processes)
if (logging.processes)
{
Log("RunProcess command: ");
for (const char** arg = arguments.arguments; *arg != nullptr; ++arg)
@ -122,7 +122,7 @@ int runProcess(const RunProcessArguments& arguments, int* statusOut)
goto childProcessFailed;
}
if (log.processes)
if (logging.processes)
Logf("Set working directory to %s\n", arguments.workingDir);
}
@ -143,7 +143,7 @@ int runProcess(const RunProcessArguments& arguments, int* statusOut)
// Only read
close(pipeFileDescriptors[PipeWrite]);
if (log.processes)
if (logging.processes)
Logf("Created child process %d\n", pid);
std::string command = "";


+ 1
- 1
src/Tokenizer.cpp View File

@ -98,7 +98,7 @@ const char* tokenizeLine(const char* inputLine, const char* source, unsigned int
// Finished the symbol
if (std::isspace(*currentChar) || *currentChar == '\n' || isParenthesis)
{
if (log.tokenization)
if (logging.tokenization)
Logf("%s\n", contentsBuffer);
Token symbol = {TokenType_Symbol, EmptyString, source,
lineNumber, columnStart, currentColumn};


+ 1
- 1
src/Utilities.cpp View File

@ -23,7 +23,7 @@ FILE* fileOpen(const char* filename, const char* mode)
}
else
{
if (log.fileSystem)
if (logging.fileSystem)
Logf("Opened %s\n", filename);
}
return file;


+ 10
- 16
src/Writer.cpp View File

@ -25,14 +25,14 @@ bool writeIfContentsNewer(const char* tempFilename, const char* outputFilename)
if (!oldFile)
{
// Write new and remove temp
if (log.fileSystem)
if (logging.fileSystem)
Log("Destination file didn't exist. Writing\n");
return moveFile(tempFilename, outputFilename);
}
else
{
if (log.fileSystem)
if (logging.fileSystem)
Log("Destination file exists. Comparing\n");
char newBuffer[1024] = {0};
@ -58,7 +58,7 @@ bool writeIfContentsNewer(const char* tempFilename, const char* outputFilename)
if (identical)
{
if (log.fileSystem)
if (logging.fileSystem)
Log("Files are identical. Skipping\n");
fclose(newFile);
@ -71,7 +71,7 @@ bool writeIfContentsNewer(const char* tempFilename, const char* outputFilename)
return true;
}
if (log.fileSystem)
if (logging.fileSystem)
Log("File changed. writing\n");
fclose(newFile);
@ -110,8 +110,7 @@ static NameStyleMode getNameStyleModeForFlags(const NameStyleSettings& settings,
if (!hasWarned && mode == NameStyleMode_PascalCase)
{
hasWarned = true;
Log(
"\nWarning: Use of PascalCase for type names is discouraged because it will "
Log("\nWarning: Use of PascalCase for type names is discouraged because it will "
"destroy lowercase C type names. You should use PascalCaseIfPlural instead, which "
"will only apply case changes if the name looks lisp-y. This warning will only "
"appear once.\n");
@ -307,7 +306,7 @@ void writeOutputFollowSplices_Recursive(const NameStyleSettings& nameSettings,
if (!operation.output.empty() && false)
{
Logf("%s \t%d\tline %d\n", operation.output.c_str(), outputState.numCharsOutput + 1,
outputState.currentLine + 1);
outputState.currentLine + 1);
}
if (operation.modifiers == StringOutMod_Splice)
@ -349,11 +348,7 @@ bool writeOutputs(const NameStyleSettings& nameSettings, const WriterFormatSetti
// To determine if anything was actually written
StringOutputState stateBeforeOutputWrite;
char tempFilename[MAX_PATH_LENGTH];
} outputs[] = {{/*isHeader=*/false,
outputSettings.sourceOutputName,
{},
{},
{0}},
} outputs[] = {{/*isHeader=*/false, outputSettings.sourceOutputName, {}, {}, {0}},
{
/*isHeader=*/true,
outputSettings.headerOutputName,
@ -405,7 +400,7 @@ bool writeOutputs(const NameStyleSettings& nameSettings, const WriterFormatSetti
if (outputs[i].outputState.numCharsOutput ==
outputs[i].stateBeforeOutputWrite.numCharsOutput)
{
if (log.fileSystem)
if (logging.fileSystem)
Logf("%s had no meaningful output\n", outputs[i].tempFilename);
fclose(outputs[i].outputState.fileOut);
@ -460,14 +455,13 @@ bool writeGeneratorOutput(const GeneratorOutput& generatedOutput,
return false;
// TODO: Write mapping and metadata
if (log.metadata)
if (logging.metadata)
{
// Metadata
Log("\n\tImports:\n");
for (const ImportMetadata& import : generatedOutput.imports)
{
Logf("%s\t(%s)\n", import.importName.c_str(),
importLanguageToString(import.language));
Logf("%s\t(%s)\n", import.importName.c_str(), importLanguageToString(import.language));
}
Log("\n\tFunctions:\n");


Loading…
Cancel
Save