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

[fbthrift] Add new port #13072

Merged
merged 7 commits into from
Sep 28, 2020
Merged

[fbthrift] Add new port #13072

merged 7 commits into from
Sep 28, 2020

Conversation

curoky
Copy link
Contributor

@curoky curoky commented Aug 22, 2020

Describe the pull request

What does your PR fix?
Add new port: facebook/fbthrift

Which triplets are supported/not supported? Have you updated the CI baseline?
N/A. No.

Does your PR follow the maintainer guide?
Yes.

@curoky
Copy link
Contributor Author

curoky commented Aug 22, 2020

Hello, how can i upgrade system package bison?

On osx, system default /usr/bin/bison is two old 2.5, but fbthrift need 3.0.4+.

CMake Error at /Volumes/data/downloads/tools/cmake-3.17.2-osx/cmake-3.17.2-Darwin-x86_64/CMake.app/Contents/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
  Could NOT find BISON: Found unsuitable version "2.3", but required is at
  least "3.0.4" (found /usr/bin/bison)
Call Stack (most recent call first):
  /Volumes/data/downloads/tools/cmake-3.17.2-osx/cmake-3.17.2-Darwin-x86_64/CMake.app/Contents/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:443 (_FPHSA_FAILURE_MESSAGE)
  /Volumes/data/downloads/tools/cmake-3.17.2-osx/cmake-3.17.2-Darwin-x86_64/CMake.app/Contents/share/cmake-3.17/Modules/FindBISON.cmake:296 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /Volumes/data/work/1/s/scripts/buildsystems/vcpkg.cmake:455 (_find_package)
  CMakeLists.txt:105 (find_package)

@curoky
Copy link
Contributor Author

curoky commented Aug 22, 2020

Azure-pipelines use brew to install bison, but brew don't symlink it into /usr/bin or /usr/local/bin.

brew_formulas = [
'autoconf',
'automake',
'libtool',
'bison' ]

$ brew install bison
...
bison is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have bison first in your PATH run:
  echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.zshrc

For compilers to find bison you may need to set:
  export LDFLAGS="-L/usr/local/opt/bison/lib"
...

So should i patch fbthrift, and then let cmake use the bison installed by brew.

find_package(BISON 3.0.4 REQUIRED)

to

find_package(BISON 3.0.4 REQUIRED PATHS /usr/local/opt/bison)

Is this the best solution?

@NancyLi1013 NancyLi1013 self-assigned this Aug 24, 2020
ports/fbthrift/CONTROL Show resolved Hide resolved
ports/fbthrift/CONTROL Outdated Show resolved Hide resolved
ports/fbthrift/portfile.cmake Outdated Show resolved Hide resolved
ports/fbthrift/portfile.cmake Outdated Show resolved Hide resolved
ports/fbthrift/portfile.cmake Outdated Show resolved Hide resolved
@NancyLi1013 NancyLi1013 added category:new-port The issue is requesting a new library to be added; consider making a PR! requires:author-response labels Aug 24, 2020
@NancyLi1013
Copy link
Contributor

Hi @curoky
Thanks for this PR.
This port cannot build osx. Is it due to bsion?

@curoky
Copy link
Contributor Author

curoky commented Aug 24, 2020

Hi @curoky
Thanks for this PR.
This port cannot build osx. Is it due to bsion?

I'm not sure, that's just the first problem I encountered on osx.

@JackBoosY
Copy link
Contributor

If this port need bison 3.0.4, please modify the following codes:

elseif(VAR MATCHES "FLEX" OR VAR MATCHES "BISON")
if(CMAKE_HOST_WIN32)
set(SOURCEFORGE_ARGS
REPO winflexbison
FILENAME winflexbison-2.5.16.zip
SHA512 0a14154bff5d998feb23903c46961528f8ccb4464375d5384db8c4a7d230c0c599da9b68e7a32f3217a0a0735742242eaf3769cb4f03e00931af8640250e9123
NO_REMOVE_ONE_LEVEL
WORKING_DIRECTORY "${DOWNLOADS}/tools/winflexbison"
)
if(VAR MATCHES "FLEX")
set(PROGNAME win_flex)
else()
set(PROGNAME win_bison)
endif()
set(PATHS ${DOWNLOADS}/tools/winflexbison/0a14154bff-a8cf65db07)
if(NOT EXISTS "${PATHS}/data/m4sugar/m4sugar.m4")
file(REMOVE_RECURSE "${PATHS}")
endif()
elseif(VAR MATCHES "FLEX")
set(PROGNAME flex)
set(APT_PACKAGE_NAME flex)
set(BREW_PACKAGE_NAME flex)
else()
set(PROGNAME bison)
set(APT_PACKAGE_NAME bison)
set(BREW_PACKAGE_NAME bison)
if (APPLE)
set(PATHS /usr/local/opt/bison/bin)
endif()
endif()

# Find required dependencies for thrift/compiler
if(compiler_only OR build_all)
+ if(APPLE)
+ set(BISON_EXECUTABLE "/usr/local/opt/bison/bin/bison" CACHE PATH "Bison executable")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't do that.
Different bison versions will cause this port to fail to build. Therefore, we need to use the built-in bison in vcpkg instead of the system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that bison does not have a pre-compiled version, we need to compile bison from source during vcpkg installation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@curoky We don't need to build bison now, as I said, we need to update vcpkg build-in tools bison instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add these lines only for OSX, and only CMAKE_HOST_WIN32 have pre-compiled bison.

So how to use the built-in bison on OSX without compiling from source?

If there is no official pre-compiled version, or we don't want to compile from the source, then the version installed by brew is also a good choice.

$ brew info bison          
bison: stable 3.7.1 (bottled) [keg-only]
Parser generator
https://www.gnu.org/software/bison/
/usr/local/Cellar/bison/3.7.1 (94 files, 3.2MB)
  Poured from bottle on 2020-08-23 at 01:23:11
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/bison.rb
License: GPL-3.0
==> Caveats
bison is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have bison first in your PATH run:
  echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.zshrc

For compilers to find bison you may need to set:
  export LDFLAGS="-L/usr/local/opt/bison/lib"

if(CMAKE_HOST_WIN32)
set(SOURCEFORGE_ARGS
REPO winflexbison
FILENAME winflexbison-2.5.16.zip
SHA512 0a14154bff5d998feb23903c46961528f8ccb4464375d5384db8c4a7d230c0c599da9b68e7a32f3217a0a0735742242eaf3769cb4f03e00931af8640250e9123
NO_REMOVE_ONE_LEVEL
WORKING_DIRECTORY "${DOWNLOADS}/tools/winflexbison"
)
if(VAR MATCHES "FLEX")
set(PROGNAME win_flex)
else()
set(PROGNAME win_bison)
endif()
set(PATHS ${DOWNLOADS}/tools/winflexbison/0a14154bff-a8cf65db07)
if(NOT EXISTS "${PATHS}/data/m4sugar/m4sugar.m4")
file(REMOVE_RECURSE "${PATHS}")
endif()
elseif(VAR MATCHES "FLEX")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bison path should be automatically added to the environment or general vcpkg_find_acquire_program is automatically exported, so there is no need to set its path here.
See

vcpkg_find_acquire_program(BISON)
get_filename_component(BISON_PATH ${BISON} DIRECTORY)
vcpkg_add_to_path(${BISON_PATH})

Copy link
Contributor

@ras0219 ras0219 Sep 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best way to handle this is to add this bison path (/usr/local/opt/bison/bin/bison) to be searched for in vcpkg_find_acquire_program(BISON) preferentially over the system bison on OSX. We can then pass this in directly to the build using OPTIONS -DBISON_EXECUTABLE=${BISON} as an additional argument to vcpkg_configure_cmake().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ras0219 👍🏻️ Thanks for your suggestion, it's elegant and simple.

# Find required dependencies for thrift/compiler
if(compiler_only OR build_all)
+ if(APPLE)
+ set(BISON_EXECUTABLE "/usr/local/opt/bison/bin/bison" CACHE PATH "Bison executable")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bison path should be automatically added to the environment or general vcpkg_find_acquire_program is automatically exported, so there is no need to set its path here.
See

vcpkg_find_acquire_program(BISON)
get_filename_component(BISON_PATH ${BISON} DIRECTORY)
vcpkg_add_to_path(${BISON_PATH})

@curoky
Copy link
Contributor Author

curoky commented Sep 12, 2020

@JackBoosY Also thanks for your suggestion. I just updated this pr. Hope this one can go through soon.

@NancyLi1013 NancyLi1013 added info:reviewed Pull Request changes follow basic guidelines and removed requires:author-response labels Sep 14, 2020
@ras0219-msft ras0219-msft merged commit 10d005d into microsoft:master Sep 28, 2020
@ras0219-msft
Copy link
Contributor

Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:new-port The issue is requesting a new library to be added; consider making a PR! info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants