Skip to content

Commit

Permalink
Remove unnecessary p4include/psa.p4 (p4lang#2837)
Browse files Browse the repository at this point in the history
* Remove unnecessary p4include/psa.p4
It is no longer needed now that p4include/bmv2/psa.p4 and
p4include/dpdk/psa.p4 have been created, and each of those should be
used for their respective targets.
  • Loading branch information
jafingerhut authored Jul 8, 2021
1 parent b3679a5 commit 7055271
Show file tree
Hide file tree
Showing 277 changed files with 2,269 additions and 1,151 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ set (OTHER_HEADERS
add_custom_target(update_includes ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${P4C_BINARY_DIR}/p4include
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${P4C_SOURCE_DIR}/p4include/*.p4 ${P4C_BINARY_DIR}/p4include
COMMAND ${CMAKE_COMMAND} -E make_directory ${P4C_BINARY_DIR}/p4include/bmv2
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${P4C_SOURCE_DIR}/p4include/bmv2/psa.p4 ${P4C_BINARY_DIR}/p4include/bmv2
COMMAND for h in ${OTHER_HEADERS} \; do
${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/\$$h ${P4C_BINARY_DIR}/p4include \;
done
Expand All @@ -390,8 +392,7 @@ endif ()
# Installation
# Targets install themselves. Here we install the core headers
install (DIRECTORY ${P4C_SOURCE_DIR}/p4include
DESTINATION ${P4C_ARTIFACTS_OUTPUT_DIRECTORY}
FILES_MATCHING PATTERN "*.p4")
DESTINATION ${P4C_ARTIFACTS_OUTPUT_DIRECTORY})

# cpplint
list ( SORT CPPLINT_FILES )
Expand Down
2 changes: 1 addition & 1 deletion backends/dpdk/DpdkXfail.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ p4c_add_xfail_reason("dpdk"
)

p4c_add_xfail_reason("dpdk"
"LHS of meter execute"
"Ambiguous method execute"
testdata/p4_16_samples/psa-meter1.p4
)

Expand Down
13 changes: 13 additions & 0 deletions backends/dpdk/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,17 @@ std::vector<const char*>* PsaSwitchOptions::process(int argc, char* const argv[]
return remainingOptions;
}

const char* PsaSwitchOptions::getIncludePath() {
char* driverP4IncludePath = isv1() ? getenv("P4C_14_INCLUDE_PATH")
: getenv("P4C_16_INCLUDE_PATH");
cstring path = "";
if (driverP4IncludePath != nullptr)
path += cstring(" -I") + cstring(driverP4IncludePath);

path += cstring(" -I") + (isv1() ? p4_14includePath : p4includePath);
if (!isv1())
path += cstring(" -I") + p4includePath + cstring("/dpdk");
return path.c_str();
}

}; // namespace DPDK
2 changes: 2 additions & 0 deletions backends/dpdk/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class PsaSwitchOptions : public BMV2::BMV2Options {

/// Process the command line arguments and set options accordingly.
std::vector<const char*>* process(int argc, char* const argv[]) override;

const char* getIncludePath() override;
};

using PsaSwitchContext = P4CContextWithOptions<PsaSwitchOptions>;
Expand Down
2 changes: 1 addition & 1 deletion backends/dpdk/run-dpdk-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def getArch(path):

if not os.path.isfile(options.p4filename):
raise Exception("No such file " + options.p4filename)
args = ["./p4c-dpdk", "--dump", tmpdir, "-I", "p4include", "-o", spec] + options.compilerOptions
args = ["./p4c-dpdk", "--dump", tmpdir, "-o", spec] + options.compilerOptions
arch = getArch(options.p4filename)
if arch is not None:
args.extend(["--arch", arch])
Expand Down
24 changes: 17 additions & 7 deletions frontends/common/parser_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,21 @@ std::vector<const char*>* ParserOptions::process(int argc,

void ParserOptions::validateOptions() const {}

const char* ParserOptions::getIncludePath() {
cstring path = "";
// the p4c driver sets environment variables for include
// paths. check the environment and add these to the command
// line for the preprocessor
char* driverP4IncludePath = isv1() ? getenv("P4C_14_INCLUDE_PATH")
: getenv("P4C_16_INCLUDE_PATH");
if (driverP4IncludePath != nullptr)
path += (cstring(" -I") + cstring(driverP4IncludePath));
path += cstring(" -I") + (isv1() ? p4_14includePath : p4includePath);
if (!isv1())
path += cstring(" -I") + p4includePath + cstring("/bmv2");
return path.c_str();
}

FILE* ParserOptions::preprocess() {
FILE* in = nullptr;

Expand All @@ -313,16 +328,11 @@ FILE* ParserOptions::preprocess() {
#else
std::string cmd("cpp");
#endif
// the p4c driver sets environment variables for include
// paths. check the environment and add these to the command
// line for the preprocessor
char* driverP4IncludePath = isv1() ? getenv("P4C_14_INCLUDE_PATH")
: getenv("P4C_16_INCLUDE_PATH");

cmd +=
cstring(" -C -undef -nostdinc -x assembler-with-cpp") + " " +
preprocessor_options +
(driverP4IncludePath ? " -I" + cstring(driverP4IncludePath) : "") +
" -I" + (isv1() ? p4_14includePath : p4includePath) + " " +
getIncludePath() + " " +
(file != nullptr ? file : "");

if (Log::verbose())
Expand Down
2 changes: 2 additions & 0 deletions frontends/common/parser_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class ParserOptions : public Util::Options {
cstring dumpFolder = ".";
// Expect that the only remaining argument is the input file.
void setInputFile();
// Return target specific include path.
const char *getIncludePath() override;
// Returns the output of the preprocessor.
FILE* preprocess();
// Closes the input stream returned by preprocess.
Expand Down
2 changes: 2 additions & 0 deletions lib/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class Options {
*/
virtual std::vector<const char*>* process(int argc, char* const argv[]);

virtual const char* getIncludePath() = 0;

void usage();
};

Expand Down
Loading

0 comments on commit 7055271

Please sign in to comment.