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

Force CPP++17 installation for Thrift and Boost. #66

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions p4studio/dependencies/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ packages:
protobuf: {version: 3.12.2}
version: 1.31.0
64b:
protobuf: {version: 3.25.3}
protobuf: {version: 25.0.0}
version: 1.60.0
tags: [default, source]
dependencies: [boost]
Expand All @@ -350,7 +350,7 @@ packages:
tags: [default, source]
type: source
thrift:
attributes: {flags: --with-cl="no" --with-java="no" --with-kotlin="no" --with-python="yes" --with-py3="yes" --with-ruby="no" --with-haskell="no" --with-haxe="no" --with-netstd="no" --with-perl="no" --with-php="no" --with-php_extension="no" --with-dart="no" --with-erlang="no" --with-go="no" --with-d="no" --with-nodejs="no" --with-nodets="no" --with-lua="no" --with-rs="no" --with-swift="no" --enable-tests=no, url: 'https://archive.apache.org/dist/thrift/0.14.1/thrift-0.14.1.tar.gz', version: 0.14.1}
attributes: {flags: -DWITH_CPP=ON -DWITH_QT5=OFF -DWITH_PYTHON=ON -DWITH_PYTHON3=ON -DWITH_CL=OFF -DWITH_JAVA=OFF -DWITH_JAVASCRIPT=OFF -DWITH_KOTLIN=OFF -DWITH_RUBY=OFF -DWITH_HASKELL=OFF -DWITH_HAXE=OFF -DWITH_NETSTD=OFF -DWITH_PERL=OFF -DWITH_PHP=OFF -DWITH_PHP_EXTENSION=OFF -DWITH_DART=OFF -DWITH_ERLANG=OFF -DWITH_GO=OFF -DWITH_D=OFF -DWITH_NODEJS=OFF -DWITH_NODETS=OFF -DWITH_LUA=OFF -DWITH_RS=OFF -DWITH_SWIFT=OFF -DBUILD_TESTING=OFF, url: 'https://archive.apache.org/dist/thrift/0.21.0/thrift-0.21.0.tar.gz', version: 0.21.0}
tags: [default, source]
dependencies: [boost]
type: source
3 changes: 2 additions & 1 deletion p4studio/dependencies/source/install_boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def install_boost(config: SourceDependencyConfig) -> None:

execute("tar xf {} --strip-components 1 -C {}".format(boost_file, build_dir))
execute("./bootstrap.sh --prefix={} --without-libraries=python".format(config.install_dir), build_dir)
execute("./b2 -j{} {}".format(config.jobs, boost_attrs["flags"]), build_dir)
# Use C++17 here.
execute("./b2 cxxstd=17 -j{} {}".format(config.jobs, boost_attrs["flags"]), build_dir)
execute("sudo ldconfig", build_dir)


Expand Down
2 changes: 1 addition & 1 deletion p4studio/dependencies/source/install_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def install_grpc(config: SourceDependencyConfig) -> None:

# P4C requires static and dynamic libraries. Install protobuf from source.
protobuf_build_dir = (build_dir / 'third_party/protobuf')
if protobuf_version == '3.25.3':
if protobuf_version == '25.0.0':
execute("""cmake . -DCMAKE_INSTALL_PREFIX={install_path} -Dprotobuf_WITH_ZLIB=ON """
""" -DZLIB_INCLUDE_DIR={install_path}/include -DZLIB_LIB={install_path}/lib """
""" -Dprotobuf_ABSL_PROVIDER=package -DCMAKE_PREFIX_PATH={install_path} """
Expand Down
32 changes: 15 additions & 17 deletions p4studio/dependencies/source/install_thrift.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,24 @@ def install_thrift(config: SourceDependencyConfig) -> None:
thrift_package = config.download_dir(ensure_exists=True) / _THRIFT_FILE
execute("tar xf {} --strip-components 1 -C {}".format(thrift_package, build_dir))

override_envs = {
'PATH': '{}/bin:{}'.format(config.install_dir, os.environ['PATH']),
}
configure_command = './configure PY_PREFIX={dir} {flags} --prefix={dir} --with-boost={dir}'.format(
dir=config.install_dir,
flags=attrs['flags']
build_dir = build_dir / "thrift_build"
os.makedirs(build_dir, exist_ok=True)

# Set the C++ standard to 17 and other flags
cmake_flags = (
f"{attrs['flags']} "
f"-DCMAKE_CXX_STANDARD=17 "
f"-DCMAKE_PREFIX_PATH={config.install_dir} "
f"-DCMAKE_INSTALL_PREFIX={config.install_dir} "
f"-DCMAKE_INSTALL_RPATH={config.install_dir} "
"-DBUILD_SHARED_LIBS=ON "
)
execute(configure_command, build_dir, override_env=override_envs)

execute('make -j{}'.format(config.jobs), build_dir)
execute("make install -j{}".format(config.jobs), build_dir)
execute("sudo ldconfig", build_dir)
# Run CMake to configure Thrift
execute(f"cmake {cmake_flags} ..", build_dir)

if config.os.lower() in {'ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:24.04', 'debian:11'}:
python_thrift_package = 'python3-thrift'
else:
python_thrift_package = 'python-thrift'

os_package_manager = config.dependency_manager().os_package_manager
execute('sudo {} -y remove {}'.format(os_package_manager, python_thrift_package), build_dir)
# Build and install Thrift
execute(f"cmake --build . --target install --config Release -- -j{config.jobs}", build_dir)


def _is_thrift_installed(version: str, path: Path) -> bool:
Expand Down
3 changes: 0 additions & 3 deletions pkgsrc/bf-diags/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ find_program(PDSPLIT split_pd_thrift.py REQUIRED)

include_directories(api/include)
include_directories(third-party/libcrafter/include)
# FIXME: Port libcrafter to C++17.
set(CMAKE_CXX_STANDARD 11)
add_subdirectory(third-party/libcrafter)
set(CMAKE_CXX_STANDARD 17)


set(P4_NAME "diag")
Expand Down