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 libftdi versions 1.2-1.5. #3957

Merged
merged 19 commits into from
Jun 26, 2021
Merged

Conversation

planetmarshall
Copy link
Contributor

Specify library name and version: lib/1.0

  • [x ] I've read the guidelines for contributing.
  • [ x] I've followed the PEP8 style guides for Python code in the recipes.
  • [ x] I've used the latest Conan client version.
  • [ x] I've tried at least one configuration locally with the
    conan-center hook activated.

@planetmarshall planetmarshall changed the title Add libftdi versions 1.2-1.5. Follows from stale PR #1880 Add libftdi versions 1.2-1.5. Dec 19, 2020
@planetmarshall planetmarshall mentioned this pull request Dec 19, 2020
4 tasks
self.cpp_info.includedirs.append(
os.path.join(self.package_folder, "include", "libftdi1")
)
self.cpp_info.libs = ["ftdipp1", "ftdi1"]
Copy link
Contributor

Choose a reason for hiding this comment

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

You combine both libraries.
Does the cmake config file, installed by libftdi's cmake config (and removed by us), create separate targets for the c and c++ library?
Maybe this requires conan components?

Copy link
Contributor

Choose a reason for hiding this comment

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

These batch of errors (the .pc related errors) show that you need to use components,
and set the pkg_config names.

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'm not sure it's possible to exactly mimic LibFTDI's CMake configuration with conan (Libftdi uses LibFTDI1 as the package name but LIBFTDI and LIBFTDIPP as the package variable names), but I've attempted to get as close as I can with conan components using the targets LibFTDI1::ftdi and LibFTDI1::ftdipp.

Copy link
Contributor

Choose a reason for hiding this comment

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

Conan has 3 settings

Filenames (sets the cmake package name, is find_package)
Names (the cmake namespace of the targets)
Components names (each unique target)

I am sure we have an example I just can't recall one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The find_package name is LibFTDI1, as used in examples/cmake_example. The built-in find package then generates the variables $LIBFTDI_LIBRARIES and $LIBFTDIPP_LIBRARIES,

However the variables generated by the conan-generated find package when using components are ${LibFTDI1_component_LIBRARIES} etc. I'm not sure it's possible to create multiple top-level variable names with conan, with a different name from the find_package (I did try various combinations as you suggested).

The targets created by LibFTDI are not namespaced, which I know conan doesn't support. See also conan-io/conan#7615

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes since the variables fashion is outdated its unlikely that conan will add support for that. So yes it seems this can not be done.

Comment on lines 70 to 72
self.cpp_info.includedirs.append(
os.path.join(self.package_folder, "include", "libftdi1")
)
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for absolute paths.
.includedirs can contain relative paths.
self.deps_cpp_info[xxx].include_paths automatically converts these to absolute paths.

Suggested change
self.cpp_info.includedirs.append(
os.path.join(self.package_folder, "include", "libftdi1")
)
self.cpp_info.includedirs.append(os.path.join("include", "libftdi1"))

recipes/libftdi/1.x/conandata.yml Outdated Show resolved Hide resolved
@ghost
Copy link

ghost commented Dec 19, 2020

I detected other pull requests that are modifying libftdi/1.x recipe:

This message is automatically generated by https://github.com/ericLemanissier/conan-center-conflicting-prs so don't hesitate to report issues/improvements there.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

Copy link
Contributor

@prince-chrismc prince-chrismc left a comment

Choose a reason for hiding this comment

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

Please fix the license

I would allow appreciate if you could try the patch but it's not required to merge

class LibFtdiConan(ConanFile):
name = "libftdi"
description = "A library to talk to FTDI chips"
license = ["GNU LGPL v2.1"]
Copy link
Contributor

Choose a reason for hiding this comment

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

https://www.intra2net.com/en/developer/libftdi/
https://spdx.org/licenses/LGPL-2.1.html

Suggested change
license = ["GNU LGPL v2.1"]
license = "LGPL-2.1"

Comment on lines 47 to 50
def _patch_cmakelists(self, subfolder):
cmakelists_path = os.path.join(self._source_subfolder, subfolder, "CMakeLists.txt")
tools.replace_in_file(cmakelists_path, "CMAKE_SOURCE_DIR", "PROJECT_SOURCE_DIR", strict=False)
tools.replace_in_file(cmakelists_path, "CMAKE_BINARY_DIR", "PROJECT_BINARY_DIR", strict=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking over the project. I think we can do sometime much less aggressive.

Can you please try to add the following? This way we can contribute it back to upstream 🤞

cmake-allow-subproject.patch.txt

tools.rmdir(os.path.join(lib_folder, "pkgconfig"))
# STATIC config creates both static and shared libraries
if not self.options.shared:
tools.remove_files_by_mask(lib_folder, "*.so*")
Copy link
Contributor

Choose a reason for hiding this comment

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

@madebr
Copy link
Contributor

madebr commented Dec 27, 2020

@planetmarshall
Please consider planetmarshall#1

@SSE4 SSE4 requested a review from uilianries December 29, 2020 08:00
@conan-center-bot

This comment has been minimized.

@prince-chrismc
Copy link
Contributor

Missing MacOS framework symbols? ocornut/imgui#2546 (comment)

@conan-center-bot
Copy link
Collaborator

All green in build 13 (0e4f0e5fcbedb34af238a169146be26341e0a45c):

  • libftdi/1.5@:
    All packages built successfully! (All logs)

Copy link
Contributor

@prince-chrismc prince-chrismc left a comment

Choose a reason for hiding this comment

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

Try aim to keep the patches to a minimum. These modification make them less portable to newer versions and the recipe harder to maintain...

#3903 and the related PR have a lot of discussion on the topic

I feel this patch is far larger than is required and there's a lot of non trivial changes. I stopped marking but I scanned over the file.

➡️ Please reduce this patch to only the essential changes

Comment on lines +6 to +8
-# Project
project(libftdi1 C)
+
Copy link
Contributor

Choose a reason for hiding this comment

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

extra

Comment on lines +17 to +24
-# CMake
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_COLOR_MAKEFILE ON)
-cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
+
+cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
Copy link
Contributor

Choose a reason for hiding this comment

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

extra

Comment on lines +25 to +33
+if(POLICY CMP0057)
+ cmake_policy(SET CMP0057 NEW)
+endif()
+if(POLICY CMP0011)
+ cmake_policy(SET CMP0011 NEW)
+endif()
+if(POLICY CMP0099)
+ cmake_policy(SET CMP0099 NEW)
+endif()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please explain why you are adjusting the policies, these do not seem required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the policies are not set, there are warnings in the CMake log for recent versions.

Comment on lines +47 to +48
-message("-- Build type: ${CMAKE_BUILD_TYPE}")
+message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
Copy link
Contributor

Choose a reason for hiding this comment

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

extra

include(CMakeOptions.txt)

+set(as_subproject LibFTDI)
+macro(find_package)
Copy link
Contributor

Choose a reason for hiding this comment

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

Overriding the cmake function? 😕 Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows the library to be consumed by examples and applications in the build tree as if it were an external project, and is considered CMake best practice. See Effective CMake by Daniel Pfeiffer (CPPNow 2017) Slide 31

Comment on lines +92 to +97
if ( BUILD_TESTS )
+ project(libftdi1 C CXX)
+ find_package(Boost COMPONENTS unit_test_framework REQUIRED)
+ enable_testing()
add_subdirectory(test)
endif ()
Copy link
Contributor

Choose a reason for hiding this comment

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

CCI should not be building tests!

extra

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 isn't. BUILD_TESTS is not defined by the cmake configuration in the conanfile.

Comment on lines +114 to +156
-if(CMAKE_VERSION VERSION_LESS 2.8.8)
- configure_file ( cmake/LibFTDI1Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake @ONLY )
- configure_file ( cmake/LibFTDI1ConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1ConfigVersion.cmake @ONLY )
-else ()
- include(CMakePackageConfigHelpers)
-
- configure_package_config_file (
- cmake/LibFTDI1Config.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake
- INSTALL_DESTINATION ${LIBFTDI_CMAKE_CONFIG_DIR}
- PATH_VARS
- LIBFTDI_USE_FILE
- LIBFTDI_ROOT_DIR
- LIBFTDI_INCLUDE_DIR
- LIBFTDI_INCLUDE_DIRS
- LIBFTDI_LIBRARY_DIRS
- NO_CHECK_REQUIRED_COMPONENTS_MACRO
- )
- write_basic_package_version_file (
- LibFTDI1ConfigVersion.cmake
- VERSION ${LIBFTDI_VERSION_STRING}
- COMPATIBILITY AnyNewerVersion
- )
-endif ()
+include(CMakePackageConfigHelpers)
+
+configure_package_config_file (
+cmake/LibFTDI1Config.cmake.in
+${CMAKE_CURRENT_BINARY_DIR}/LibFTDI1Config.cmake
+INSTALL_DESTINATION ${LIBFTDI_CMAKE_CONFIG_DIR}
+PATH_VARS
+ LIBFTDI_USE_FILE
+ LIBFTDI_ROOT_DIR
+ LIBFTDI_INCLUDE_DIR
+ LIBFTDI_INCLUDE_DIRS
+ LIBFTDI_LIBRARY_DIRS
+NO_CHECK_REQUIRED_COMPONENTS_MACRO
+)
+write_basic_package_version_file (
+LibFTDI1ConfigVersion.cmake
+VERSION ${LIBFTDI_VERSION_STRING}
+COMPATIBILITY AnyNewerVersion
+)
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like an overkill. The if is always true in CCI and should not need to be changed

Is this really required?

@planetmarshall
Copy link
Contributor Author

planetmarshall commented Feb 6, 2021

Try aim to keep the patches to a minimum. These modification make them less portable to newer versions and the recipe harder to maintain...

#3903 and the related PR have a lot of discussion on the topic

I took a quick look at the discussion but it seemed to be pretty personal and argumentative. In short though I think the patch meets danimtb's criteria in that it only modifies the build system.

I feel this patch is far larger than is required and there's a lot of non trivial changes. I stopped marking but I scanned over the file.

While a smaller patch would work for CCI, it would not be sufficient to build the tests and examples which would be necessary for the patch to be accepted upstream, which was mentioned above as a goal for using patch files.

@conan-center-bot
Copy link
Collaborator

All green in build 14 (0e4f0e5fcbedb34af238a169146be26341e0a45c):

  • libftdi/1.5@:
    All packages built successfully! (All logs)

@stale
Copy link

stale bot commented Apr 6, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 6, 2021
@uilianries
Copy link
Member

While a smaller patch would work for CCI, it would not be sufficient to build the tests and examples which would be necessary for the patch to be accepted upstream, which was mentioned above as a goal for using patch files

@planetmarshall Is it an official patch provided by upstream? Or did you create it and pushed to upstream? If it's official, no problem accepting. Otherwise, let's reduce it, testing and examples anre not used on CCI

@stale stale bot removed the stale label Apr 9, 2021
@planetmarshall
Copy link
Contributor Author

...let's reduce it, testing and examples anre not used on CCI

Sure, will take a look over the weekend. I've submitted the patch upstream but could be a while before seeing any feedback.

@stale
Copy link

stale bot commented May 9, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Copy link
Contributor

@jgsogo jgsogo left a comment

Choose a reason for hiding this comment

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

I agree with @prince-chrismc that the patch should be simplified. Here the aim should be to modify the build-system the minimum just to make it buildable using Conan... OTH I agree it is better to merge the recipe and improve it in the following iterations.

50/50, wdyt, @prince-chrismc ?

Copy link
Contributor

@prince-chrismc prince-chrismc left a comment

Choose a reason for hiding this comment

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

There's too many changes in the patch which likely change the output so I do feel comfortable approving... but that's why we have lots of reviewers!

Given the age there's a few conventions that have changed too if we move this forwarded

for subdivisors 0, 0.5, 0.25, 0.125
*/
-static int ftdi_to_clkbits(int baudrate, unsigned int clk, int clk_div, unsigned long *encoded_divisor)
+static int ftdi_to_clkbits(int baudrate, int clk, int clk_div, unsigned long *encoded_divisor)
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually digging in the patch I found code changes which I was not expect ... this is beyond "fixing cmake"... 700+ lines of diff and lots of meaningless changes

@conan-center-bot conan-center-bot merged commit f7b143c into conan-io:master Jun 26, 2021
@planetmarshall planetmarshall deleted the libftdi branch March 4, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants