Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dpdk version string #3105

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backends/dpdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/version.h" @ONLY)

# For files generated by the protobuf compiler
include_directories(${P4C_BINARY_DIR}/control-plane)

Expand Down
3 changes: 2 additions & 1 deletion backends/dpdk/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
#include <iostream>
#include <string>

#include "backends/dpdk/version.h"
#include "backends/dpdk/backend.h"
#include "backends/dpdk/midend.h"
#include "backends/dpdk/options.h"
Expand All @@ -44,7 +45,7 @@ int main(int argc, char *const argv[]) {
AutoCompileContext autoDpdkContext(new DPDK::DpdkContext);
auto &options = DPDK::DpdkContext::get().options();
options.langVersion = CompilerOptions::FrontendVersion::P4_16;
options.compilerVersion = "0.1";
options.compilerVersion = DPDK_VERSION_STRING;

if (options.process(argc, argv) != nullptr) {
if (options.loadIRFromJson == false)
Expand Down
38 changes: 38 additions & 0 deletions backends/dpdk/version.h.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Copyright 2022-present Intel Corp.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef _BACKEND_DPDK_VERSION_H
#define _BACKEND_DPDK_VERSION_H

/**
Set the compiler version at build time.
The build system defines P4C_VERSION as a full string as well as the
following components: P4C_VERSION_MAJOR, P4C_VERSION_MINOR,
P4C_VERSION_PATCH, P4C_VERSION_RC, P4C_GIT_SHA and CMAKE_BUILD_TYPE.

They can be used to construct a version string as follows:
#define VERSION_STRING "@P4C_VERSION@"
or
#define VERSION_STRING "@P4C_VERSION_MAJOR@.@P4C_VERSION_MINOR@.@P4C_VERSION_PATCH@@P4C_VERSION_RC@"

Or, since this is backend specific, feel free to define other numbering
scheme.

*/

#define DPDK_VERSION_STRING "0.1 (SHA: @P4C_GIT_SHA@ BUILD: @CMAKE_BUILD_TYPE@)"

#endif // _BACKEND_DPDK_VERSION_H