Merge pull request #1146 from atn34/fix-actor-warning

Fix actor warning for cmake build
This commit is contained in:
A.J. Beamon 2019-02-13 11:01:37 -08:00 committed by GitHub
commit 9272a41e5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 41 additions and 17 deletions

2
.gitignore vendored
View File

@ -76,6 +76,8 @@ foundationdb.VC.db
foundationdb.VC.VC.opendb
ipch/
compile_commands.json
flow/actorcompiler/obj
flow/coveragetool/obj
# Temporary and user configuration files
*~

View File

@ -14,7 +14,7 @@ endmacro()
set(ACTOR_TARGET_COUNTER "0")
macro(actor_compile target srcs)
set(options DISABLE_ACTOR_WITHOUT_WAIT)
set(options DISABLE_ACTOR_WITHOUT_WAIT_WARNING)
set(oneValueArg)
set(multiValueArgs)
cmake_parse_arguments(ACTOR_COMPILE "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
@ -27,8 +27,8 @@ macro(actor_compile target srcs)
string(REPLACE ".actor.cpp" ".actor.g.cpp" tmp ${src})
endif()
set(actor_compiler_flags "")
if(ACTOR_COMPILE_DISABLE_ACTOR_WITHOUT_WAIT)
set(actor_compiler_flags "--disable-actor-without-wait-error")
if(ACTOR_COMPILE_DISABLE_ACTOR_WITHOUT_WAIT_WARNING)
set(actor_compiler_flags "--disable-actor-without-wait-warning")
endif()
if(tmp)
if(WIN32)

View File

@ -1,5 +1,4 @@
set(FDBRPC_SRCS
ActorFuzz.actor.cpp
AsyncFileCached.actor.h
AsyncFileEIO.actor.h
AsyncFileKAIO.actor.h
@ -11,9 +10,7 @@ set(FDBRPC_SRCS
AsyncFileWriteChecker.cpp
batcher.actor.h
crc32c.cpp
dsltest.actor.cpp
FailureMonitor.actor.cpp
FlowTests.actor.cpp
FlowTransport.actor.cpp
genericactors.actor.h
genericactors.actor.cpp
@ -55,8 +52,14 @@ if(NOT WIN32)
list(APPEND FDBRPC_SRCS libcoroutine/context.c libeio/eio.c)
endif()
actor_set(FDBRPC_BUILD "${FDBRPC_SRCS}")
set(FDBRPC_SRCS_DISABLE_ACTOR_WITHOUT_WAIT_WARNING
ActorFuzz.actor.cpp
FlowTests.actor.cpp
dsltest.actor.cpp)
actor_set(FDBRPC_BUILD "${FDBRPC_SRCS};${FDBRPC_SRCS_DISABLE_ACTOR_WITHOUT_WAIT_WARNING}")
add_library(fdbrpc STATIC ${FDBRPC_BUILD})
actor_compile(fdbrpc "${FDBRPC_SRCS}")
actor_compile(fdbrpc "${FDBRPC_SRCS_DISABLE_ACTOR_WITHOUT_WAIT_WARNING}" DISABLE_ACTOR_WITHOUT_WAIT_WARNING)
target_include_directories(fdbrpc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/libeio)
target_link_libraries(fdbrpc PUBLIC flow)

View File

@ -36,6 +36,19 @@ namespace actorcompiler
}
};
class ErrorMessagePolicy
{
public bool DisableActorWithoutWaitWarning = false;
public void HandleActorWithoutWait(String sourceFile, Actor actor)
{
if (!DisableActorWithoutWaitWarning && !actor.isTestCase)
{
// TODO(atn34): Once cmake is the only build system we can make this an error instead of a warning.
Console.Error.WriteLine("{0}:{1}: warning: ACTOR {2} does not contain a wait() statement", sourceFile, actor.SourceLine, actor.name);
}
}
}
class Token
{
public string Value;
@ -200,10 +213,12 @@ namespace actorcompiler
Token[] tokens;
string sourceFile;
ErrorMessagePolicy errorMessagePolicy;
public ActorParser(string text, string sourceFile)
public ActorParser(string text, string sourceFile, ErrorMessagePolicy errorMessagePolicy)
{
this.sourceFile = sourceFile;
this.errorMessagePolicy = errorMessagePolicy;
tokens = Tokenize(text).Select(t=>new Token{ Value=t }).ToArray();
CountParens();
//if (sourceFile.EndsWith(".h")) LineNumbersEnabled = false;
@ -872,21 +887,21 @@ namespace actorcompiler
var body = range(heading.End+1, tokens.Length)
.TakeWhile(t => t.BraceDepth > toks.First().BraceDepth);
bool warnOnNoWait = false;
if (head_token.Value == "ACTOR")
{
ParseActorHeading(actor, heading);
warnOnNoWait = true;
}
else if (head_token.Value == "TEST_CASE")
else if (head_token.Value == "TEST_CASE") {
ParseTestCaseHeading(actor, heading);
actor.isTestCase = true;
}
else
head_token.Assert("ACTOR or TEST_CASE expected!", t => false);
actor.body = ParseCodeBlock(body);
if (!actor.body.containsWait() && warnOnNoWait)
Console.Error.WriteLine("{0}:{1}: warning: ACTOR {2} does not contain a wait() statement", sourceFile, actor.SourceLine, actor.name);
if (!actor.body.containsWait())
this.errorMessagePolicy.HandleActorWithoutWait(sourceFile, actor);
end = body.End + 1;
}

View File

@ -234,6 +234,7 @@ namespace actorcompiler
public string testCaseParameters = null;
public string nameSpace = null;
public bool isForwardDeclaration = false;
public bool isTestCase = false;
};
class Descr

View File

@ -33,16 +33,21 @@ namespace actorcompiler
if (args.Length < 2)
{
Console.WriteLine("Usage:");
Console.WriteLine(" actorcompiler [input] [output]");
Console.WriteLine(" actorcompiler <input> <output> [--disable-actor-without-wait-warning]");
return 100;
}
Console.WriteLine("actorcompiler {0}", string.Join(" ", args));
string input = args[0], output = args[1], outputtmp = args[1] + ".tmp";
ErrorMessagePolicy errorMessagePolicy = new ErrorMessagePolicy();
if (args.Contains("--disable-actor-without-wait-warning"))
{
errorMessagePolicy.DisableActorWithoutWaitWarning = true;
}
try
{
var inputData = File.ReadAllText(input);
using (var outputStream = new StreamWriter(outputtmp))
new ActorParser(inputData, input.Replace('\\', '/')).Write(outputStream, output.Replace('\\', '/'));
new ActorParser(inputData, input.Replace('\\', '/'), errorMessagePolicy).Write(outputStream, output.Replace('\\', '/'));
if (File.Exists(output))
{
File.SetAttributes(output, FileAttributes.Normal);

View File

@ -12,7 +12,6 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<OutputPath>$(SolutionDir)bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>$(SystemDrive)\temp\msvcfdb\$(Configuration)\actorcompiler\</IntermediateOutputPath>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>

View File

@ -12,7 +12,6 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<OutputPath>$(SolutionDir)bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>$(SystemDrive)\temp\msvcfdb\$(Configuration)\coveragetool\</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>