Skip to content

[braft] New port#23830

Merged
strega-nil-ms merged 17 commits intomicrosoft:masterfrom
Gab-Menezes:master
Apr 8, 2022
Merged

[braft] New port#23830
strega-nil-ms merged 17 commits intomicrosoft:masterfrom
Gab-Menezes:master

Conversation

@Gab-Menezes
Copy link
Copy Markdown
Contributor

Describe the pull request
New port for braft

  • Which triplets are supported/not supported? Have you updated the CI baseline?

    Linux, No

  • Does your PR follow the maintainer guide?

    Not yet, I am still working on this PR

  • If you have added/updated a port: Have you run ./vcpkg x-add-version --all and committed the result?

    Not yet, I am still working on this PR

If you are still working on the PR, open it as a Draft: https://github.blog/2019-02-14-introducing-draft-pull-requests/

@ghost
Copy link
Copy Markdown

ghost commented Mar 29, 2022

CLA assistant check
All CLA requirements met.

@JackBoosY JackBoosY self-assigned this Mar 29, 2022
@JackBoosY JackBoosY added the category:new-port The issue is requesting a new library to be added; consider making a PR! label Mar 29, 2022
@JackBoosY
Copy link
Copy Markdown
Contributor

Can you please sign CLA first?

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This is a new experimental fast check for PR issues. Please let us know if this bot is helpful!

All manifest files must be formatted

./vcpkg format-manifest ports/*/vcpkg.json

Diff
diff --git a/ports/braft/vcpkg.json b/ports/braft/vcpkg.json
index b054486..cf28ed4 100644
--- a/ports/braft/vcpkg.json
+++ b/ports/braft/vcpkg.json
@@ -1,23 +1,23 @@
-{
-    "name": "braft",
-    "version-date": "2021-26-04",
-    "description": "Consesus algorithm library",
-    "homepage": "https://github.com/baidu/braft",
-    "supports": "!windows",
-    "dependencies": [
-        {
-            "name": "vcpkg-cmake",
-            "host": true
-        },
-        {
-            "name": "vcpkg-cmake-config",
-            "host": true
-        },
-        "brpc",
-        "protobuf",
-        "leveldb",
-        "gflags",
-        "glog",
-        "thrift"
-    ]
-}
+{
+  "name": "braft",
+  "version-date": "2021-26-04",
+  "description": "Consesus algorithm library",
+  "homepage": "https://github.com/baidu/braft",
+  "supports": "!windows",
+  "dependencies": [
+    "brpc",
+    "gflags",
+    "glog",
+    "leveldb",
+    "protobuf",
+    "thrift",
+    {
+      "name": "vcpkg-cmake",
+      "host": true
+    },
+    {
+      "name": "vcpkg-cmake-config",
+      "host": true
+    }
+  ]
+}
After committing all other changes, the version database must be updated
git add -u && git commit
git checkout 773516ecf6014d89cc69b11bb54605ad4be56694 -- versions
./vcpkg x-add-version --all
Diff
diff --git a/versions/baseline.json b/versions/baseline.json
index 316e85c..901aa86 100644
--- a/versions/baseline.json
+++ b/versions/baseline.json
@@ -1132,6 +1132,10 @@
       "baseline": "2.4.1",
       "port-version": 2
     },
+    "braft": {
+      "baseline": "2021-26-04",
+      "port-version": 0
+    },
     "breakpad": {
       "baseline": "2020-09-14",
       "port-version": 5

You have modified or added at least one vcpkg.json where a "license" field is missing.

Details

If you feel able to do so, please consider adding a "license" field to the following files:

  • ports/braft/vcpkg.json

Valid values for the license field can be found in the documentation

@Gab-Menezes
Copy link
Copy Markdown
Contributor Author

Done

@Gab-Menezes
Copy link
Copy Markdown
Contributor Author

If you remove the install step of the patch, the library will compile fine as I said. But we can't reference it in another cmake scripts

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You have modified or added at least one vcpkg.json where a "license" field is missing.

Details

If you feel able to do so, please consider adding a "license" field to the following files:

  • ports/braft/vcpkg.json

Valid values for the license field can be found in the documentation

JackBoosY added 2 commits March 28, 2022 19:35
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You have modified or added at least one vcpkg.json where a "license" field is missing.

Details

If you feel able to do so, please consider adding a "license" field to the following files:

  • ports/braft/vcpkg.json

Valid values for the license field can be found in the documentation

)
endif()
+
+install(EXPORT unofficial-braftConfig
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All the dependency's styles are absolute path, so we don't need find_dependency.

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You have modified or added at least one vcpkg.json where a "license" field is missing.

Details

If you feel able to do so, please consider adding a "license" field to the following files:

  • ports/braft/vcpkg.json

Valid values for the license field can be found in the documentation

@JackBoosY
Copy link
Copy Markdown
Contributor

@Gab-Menezes Can you please test the changes?

@Gab-Menezes
Copy link
Copy Markdown
Contributor Author

Gab-Menezes commented Mar 30, 2022

Hey, so with the changes it the install process went fine fine. So tried linking braft in test binary using

cmake_minimum_required(VERSION 3.20)
project(test)

find_package(unofficial-braft CONFIG REQUIRED)

add_executable(main main.cpp)
target_link_libraries(main PRIVATE unofficial::braft::braft-static)

And the c++ program just have the main function returning 0.
But I got this error when trying to to compile (the configuration step went fine)

[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
make[2]: *** No rule to make target '/mnt/c/dev/vcpkg-dev/vcpkg/installed/x64-linux/debug/lib/libgflags.a', needed by 'main'. 
 Stop.
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/main.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

If I try to link gflags manually

cmake_minimum_required(VERSION 3.20)
project(test)

find_package(unofficial-braft CONFIG REQUIRED)
find_package(gflags CONFIG REQUIRED)

add_executable(main main.cpp)
target_link_libraries(main PRIVATE gflags::gflags)
target_link_libraries(main PRIVATE unofficial::braft::braft-static)

I get the same error, but if I remove the braft link and link only gflags everything is fine

cmake_minimum_required(VERSION 3.20)
project(test)

find_package(gflags CONFIG REQUIRED)

add_executable(main main.cpp)
target_link_libraries(main PRIVATE gflags::gflags)

So I looked at the lib and /debug/lib folders
image
image
As we can see the debug/lib folder has a _debug suffix, but he expected name doesn't have this suffix.

The linking is fine in release mode (by just linking braft, not needing to link gflags manually), so I tried calling anything from braft to see if it was fine

#include <iostream>
#include <braft/raft.h>

int main()
{
    braft::PeerId leader;
    return 0;
}

And got an error saying braft/raft.h is not in the include directories

/mnt/c/dev/vcpkg-dev/tests/main.cpp:2:10: fatal error: braft/raft.h: No such file or directory
    2 | #include <braft/raft.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/main.dir/build.make:76: CMakeFiles/main.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/main.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

After this can you talk me through what you have done, I would love to learn more and maybe create a PR to export brpc.

@JackBoosY
Copy link
Copy Markdown
Contributor

As we can see the debug/lib folder has a _debug suffix, but he expected name doesn't have this suffix.

We should find all kind of gflags.

And got an error saying braft/raft.h is not in the include directories

Okay, will export only path level include.

@JackBoosY
Copy link
Copy Markdown
Contributor

I will handle this tomorrow.

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This is a new experimental fast check for PR issues. Please let us know if this bot is helpful!

PRs must add only one version and must not modify any published versions

When making any changes to a library, the version or port-version in vcpkg.json or CONTROL must be modified.

Error: Local changes detected for braft but no changes to version or port version.
-- Version: 2021-26-04
-- Old SHA: 78874b8ee402a9025a9bcc8662c5f30461231273
-- New SHA: 1e440378c483c1d3a12a666f5f0163bbd3103715
-- Did you remember to update the version or port version?
-- Pass `--overwrite-version` to bypass this check.
***No files were updated.***

@JackBoosY
Copy link
Copy Markdown
Contributor

@Gab-Menezes Please test again.

Thanks.

@Gab-Menezes
Copy link
Copy Markdown
Contributor Author

Gab-Menezes commented Apr 2, 2022

So the configuration step is not working here is the log (running with --debug flag) (I also deleted all the reference to braft to guarantee that it's not a cache problem)
config-x64-linux-dbg-err.log
config-x64-linux-dbg-out.log
console.txt

@dg0yt
Copy link
Copy Markdown
Contributor

dg0yt commented Apr 4, 2022

grep: GFLAGS_INCLUDE_PATH-NOTFOUND/gflags/gflags_declare.h: No such file or directory
CMake Error at CMakeLists.txt:191 (if):
  if given arguments:

    "STREQUAL" "GFLAGS_NAMESPACE"

  Unknown arguments specified

This usually comes from a statement like:

if(${empyt_var} STREQUAL "GFLAGS_NAMESPACE")

Either you find out why it is empty/unset, or you add quotes:

if("${empyt_var}" STREQUAL "GFLAGS_NAMESPACE")

@JackBoosY
Copy link
Copy Markdown
Contributor

@Gab-Menezes Should be good now.

@JackBoosY JackBoosY marked this pull request as ready for review April 6, 2022 09:02
@Gab-Menezes
Copy link
Copy Markdown
Contributor Author

@JackBoosY Yay it compiles when linking to another project, only one thing. We need do link gflags manually if not we get:

CMake Error at /mnt/c/dev/vcpkg-dev/vcpkg/scripts/buildsystems/vcpkg.cmake:559 (_add_executable):
  Target "main" links to target "gflags::gflags" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?
Call Stack (most recent call first):
  CMakeLists.txt:6 (add_executable)

Even though I didn't include nothing from glfags, but if we find and link, it works fine.

@Gab-Menezes
Copy link
Copy Markdown
Contributor Author

Gab-Menezes commented Apr 7, 2022

In the near future I will try to do the brpc one (I'm kinda busy right now). If I have any problem can I ask for your help @JackBoosY ? (I will try to use this one as a reference)

@JackBoosY
Copy link
Copy Markdown
Contributor

@Gab-Menezes Ah I forgot this, sorry.
We already have port grpc. can you please check whether it suitable for you?

@Gab-Menezes
Copy link
Copy Markdown
Contributor Author

Gab-Menezes commented Apr 7, 2022

Yes I know we have, but it's not exported (I'm talking about brpc (braft uses brpc), not grpc)

@JackBoosY
Copy link
Copy Markdown
Contributor

Yes I know we have, but it's not exported (I'm talking about brpc (braft uses brpc), not grpc)

Okay, I will take a look at that.

@JackBoosY
Copy link
Copy Markdown
Contributor

JackBoosY commented Apr 7, 2022

@Gab-Menezes This time it should be okay, I promised.
You will no need to find and use gflags manually.

@Gab-Menezes
Copy link
Copy Markdown
Contributor Author

@JackBoosY It's working perfectly without needing to link gflags manually.

@JackBoosY JackBoosY added the info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. label Apr 8, 2022
@strega-nil-ms
Copy link
Copy Markdown
Contributor

Thanks!

@strega-nil-ms strega-nil-ms merged commit 8fc4b4b into microsoft:master Apr 8, 2022
ekilmer added a commit to ekilmer/vcpkg that referenced this pull request Apr 12, 2022
* master: (139 commits)
  [dstorage] Add port for Microsoft.Direct3D.DirectStorage NuGet (microsoft#24063)
  [vcpkg] Refactor toolchain & generator selection (microsoft#23846)
  [icu] update to 70.1 (microsoft#23445)
  [vcpkg] Update android usage documentation (microsoft#23690)
  [LMDB] update to 0.9.29 (microsoft#24045)
  [catch2] Don't install docs (microsoft#24046)
  [harfbuff] fix arm64 osx build (microsoft#24055)
  [openxr-loader] remove from CI baseline (microsoft#24057)
  [imath] Update to 3.1.5 (microsoft#24059)
  [openssl] Fix dynamic builds on UNIX (microsoft#24061)
  [c-ares] update to 1.18.1 (microsoft#24062)
  [igraph] update to 0.9.8 (microsoft#24065)
  [cmake-user] Fix library check (microsoft#24070)
  [openxr-loader] fix ci.baseline.txt (microsoft#24073)
  [tinycbor] Fix file conflicts with libcbor (microsoft#24056)
  [graphviz,libslirp] Limit msys to windows (microsoft#24032)
  [bdwgc] Don't build docs (microsoft#24025)
  [capstone] update to 5.0.0-rc2 (microsoft#23979)
  [clockutils] Fix x64-windows-static-md (microsoft#23965)
  [braft] New port (microsoft#23830)
  ...
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:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants