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

xz_utils: conan v2 support #13038

Merged
merged 11 commits into from
Sep 28, 2022
Merged

Conversation

SpaceIm
Copy link
Contributor

@SpaceIm SpaceIm commented Sep 20, 2022

Specify library name and version: lib/1.0

This is also a good place to share with all of us why you are submitting this PR (specially if it is a new addition to ConanCenter): is it a dependency of other libraries you want to package? Are you the author of the library? Thanks!


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

targets=[target],
build_type=self._effective_msbuild_type,
platforms={"x86": "Win32", "x86_64": "x64"},
upgrade_project=Version(self.settings.compiler.version) >= "17")
Copy link
Contributor Author

@SpaceIm SpaceIm Sep 20, 2022

Choose a reason for hiding this comment

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

upgrade_project logic is lost in this conan v2 migration, I don't know what is the equivalent in the new MSBuild build helper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and it's required, it fails on Windows with Visual Studio 2022

Copy link
Contributor Author

@SpaceIm SpaceIm Sep 20, 2022

Choose a reason for hiding this comment

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

Comment on lines 123 to 131
self.win_bash = True
autotools.configure()
autotools.make()
self.win_bash = None
Copy link
Contributor Author

@SpaceIm SpaceIm Sep 20, 2022

Choose a reason for hiding this comment

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

@memsharded could you confirm this is the canonical way to conditionally enable win_bash in conan v2 methods (for this case it's for MinGW, and we ensure that a bash is available on windows build machine by adding msys2 recipe to tool_requires if user did not define tools.microsoft.bash:path in its conan configuration)?

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've tested locally on windows with MinGW. It works... almost:

It fails during installation because install path is not converted to unix path:

 /usr/bin/install -c -m 644  /c/users/spaceim/.conan/data/xz_utils/5.2.5/_/_/build/3cbc13750c61092b2c900ee6caef68cf1cd320b4/src/src/liblzma/api/lzma.h 'C:Usersspaceim.conandataxz_utils5.2.5__package3cbc13750c61092b2c900ee6caef68cf1cd320b4/include/.'
make[4]: Leaving directory '/c/Users/spaceim/.conan/data/xz_utils/5.2.5/_/_/build/3cbc13750c61092b2c900ee6caef68cf1cd320b4/build-release/src/liblzma/api'
make[3]: Leaving directory '/c/Users/spaceim/.conan/data/xz_utils/5.2.5/_/_/build/3cbc13750c61092b2c900ee6caef68cf1cd320b4/build-release/src/liblzma/api'
make[3]: Entering directory '/c/Users/spaceim/.conan/data/xz_utils/5.2.5/_/_/build/3cbc13750c61092b2c900ee6caef68cf1cd320b4/build-release/src/liblzma'
make[4]: Entering directory '/c/Users/spaceim/.conan/data/xz_utils/5.2.5/_/_/build/3cbc13750c61092b2c900ee6caef68cf1cd320b4/build-release/src/liblzma'
 /usr/bin/mkdir -p 'C:Usersspaceim.conandataxz_utils5.2.5__package3cbc13750c61092b2c900ee6caef68cf1cd320b4/lib'
 /usr/bin/mkdir -p 'C:Usersspaceim.conandataxz_utils5.2.5__package3cbc13750c61092b2c900ee6caef68cf1cd320b4/lib/pkgconfig'
 /bin/sh ../../libtool   --mode=install /usr/bin/install -c   liblzma.la 'C:Usersspaceim.conandataxz_utils5.2.5__package3cbc13750c61092b2c900ee6caef68cf1cd320b4/lib'
 /usr/bin/install -c -m 644 liblzma.pc 'C:Usersspaceim.conandataxz_utils5.2.5__package3cbc13750c61092b2c900ee6caef68cf1cd320b4/lib/pkgconfig'
Usage: /c/Users/spaceim/.conan/data/xz_utils/5.2.5/_/_/build/3cbc13750c61092b2c900ee6caef68cf1cd320b4/build-release/libtool [OPTION]... [MODE-ARG]...
Try 'libtool --help' for more information.
libtool:   error: 'C:Usersspaceim.conandataxz_utils5.2.5__package3cbc13750c61092b2c900ee6caef68cf1cd320b4/lib' must be an absolute directory name
make[4]: *** [Makefile:876: install-libLTLIBRARIES] Error 1
make[4]: Leaving directory '/c/Users/spaceim/.conan/data/xz_utils/5.2.5/_/_/build/3cbc13750c61092b2c900ee6caef68cf1cd320b4/build-release/src/liblzma'
make[3]: *** [Makefile:1802: install-am] Error 2
make[3]: Leaving directory '/c/Users/spaceim/.conan/data/xz_utils/5.2.5/_/_/build/3cbc13750c61092b2c900ee6caef68cf1cd320b4/build-release/src/liblzma'
make[2]: *** [Makefile:1638: install-recursive] Error 1
make[2]: Leaving directory '/c/Users/spaceim/.conan/data/xz_utils/5.2.5/_/_/build/3cbc13750c61092b2c900ee6caef68cf1cd320b4/build-release/src/liblzma'
make[1]: *** [Makefile:422: install-recursive] Error 1
make[1]: Leaving directory '/c/Users/spaceim/.conan/data/xz_utils/5.2.5/_/_/build/3cbc13750c61092b2c900ee6caef68cf1cd320b4/build-release/src'
make: *** [Makefile:616: install-recursive] Error 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's it. If I replace autotools.install() by autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]), it works (note: if I call conan create -kb it fails with ConanException: The config 'tools.microsoft.bash:subsystem' is needed to run commands in a Windows subsystem, funny since this config is injected by msys2 recipe)

Copy link
Contributor Author

@SpaceIm SpaceIm Sep 20, 2022

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@SpaceIm Thank you very much for checking it. The new MSBuild is still limited in terms of features, compared to the legacy.

@conan-center-bot

This comment has been minimized.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Sep 20, 2022

Error: recipes/xz_utils/all/conanfile.py:107: [E1123(unexpected-keyword-arg), XZUtils._build_msvc] Unexpected keyword argument 'targets' in method call

Ok, it requires conan >= 1.52.0 :( conan-io/conan#11968

@ghost
Copy link

ghost commented Sep 20, 2022

I detected other pull requests that are modifying xz_utils/all 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.

DESTDIR manually injected due to conan-io/conan#12153
@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Sep 20, 2022

LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library [C:\J\w\prod\BuildSingleReference@2\conan-center-index\recipes\xz_utils\all\test_v1_package\build\7f904f5e60fd8354a86d19e62c1e7c493d74cd43\test_package.vcxproj]
lzma.lib(common.obj) : warning LNK4217: locally defined symbol free imported in function lzma_free [C:\J\w\prod\BuildSingleReference@2\conan-center-index\recipes\xz_utils\all\test_v1_package\build\7f904f5e60fd8354a86d19e62c1e7c493d74cd43\test_package.vcxproj]
lzma.lib(common.obj) : warning LNK4217: locally defined symbol malloc imported in function lzma_alloc [C:\J\w\prod\BuildSingleReference@2\conan-center-index\recipes\xz_utils\all\test_v1_package\build\7f904f5e60fd8354a86d19e62c1e7c493d74cd43\test_package.vcxproj]
lzma.lib(common.obj) : error LNK2019: unresolved external symbol __imp_calloc referenced in function lzma_alloc_zero [C:\J\w\prod\BuildSingleReference@2\conan-center-index\recipes\xz_utils\all\test_v1_package\build\7f904f5e60fd8354a86d19e62c1e7c493d74cd43\test_package.vcxproj]

Ok so the build of xz_utils didn't honor MTd runtime, and it fails afterwards in test_package due to runtime discrepancy.

In sln & vcxproj files of xz_utils, there is no DebugMTd config (only ReleaseMT, ReleaseMD, DebugMDd). I'm not familiar enough with MSBuild files internal mechanism, so I'm not sure how to fix this issue so that props file generated by MSBuildToolchain works in a robust way against sln & vcxproj files of xz_utils. All I know is that it was working with legacy MSBuild.

/cc @memsharded

Actually it's not honored also in MT static build (https://c3i.jfrog.io/c3i/misc/logs/pr/13038/10-configs/windows-visual_studio/xz_utils/5.2.5//7bd6f2c3d5c4e48a75805376b58cde753392f711-test.txt):

  Checking Build System
  Building Custom Rule C:/J/w/prod/BuildSingleReference/conan-center-index/recipes/xz_utils/all/test_package/CMakeLists.txt
  test_package.c
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library [C:\J\w\prod\BuildSingleReference\conan-center-index\recipes\xz_utils\all\test_package\build\test_package.vcxproj]
lzma.lib(common.obj) : warning LNK4217: locally defined symbol calloc imported in function lzma_alloc_zero [C:\J\w\prod\BuildSingleReference\conan-center-index\recipes\xz_utils\all\test_package\build\test_package.vcxproj]
lzma.lib(common.obj) : warning LNK4217: locally defined symbol free imported in function lzma_end [C:\J\w\prod\BuildSingleReference\conan-center-index\recipes\xz_utils\all\test_package\build\test_package.vcxproj]
lzma.lib(common.obj) : warning LNK4217: locally defined symbol malloc imported in function lzma_alloc [C:\J\w\prod\BuildSingleReference\conan-center-index\recipes\xz_utils\all\test_package\build\test_package.vcxproj]
  test_package.vcxproj -> C:\J\w\prod\BuildSingleReference\conan-center-index\recipes\xz_utils\all\test_package\build\Release\test_package.exe
  Building Custom Rule C:/J/w/prod/BuildSingleReference/conan-center-index/recipes/xz_utils/all/test_package/CMakeLists.txt
xz_utils/5.2.5 (test package): Running test()

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Sep 20, 2022

It should work now (even MinGW). Honestly I'm not very proud of all these MSBuild tricks. There are currently 27 recipes in conan-center relying on legacy MSBuild. If anybody has something more robust to propose (inject conantoolchain.props from MSBuildToolchain, avoid conflicts, honor custom clflags, cxxflags, ldflags from profile etc), please share !

Note: on macos if shared, install_name of dependencies in executables are not correct (see conan-io/conan#12107). But since PATH was not populated, I guess nobody was using them.

@conan-center-bot

This comment has been minimized.

@jgsogo jgsogo requested a review from memsharded September 21, 2022 08:07
variables from https://cmake.org/cmake/help/latest/module/FindLibLZMA.html must be defined

LIBLZMA_HAS_AUTO_DECODER, LIBLZMA_HAS_EASY_ENCODER & LIBLZMA_HAS_LZMA_PRESET are not modeled for the moment
@conan-center-bot

This comment has been minimized.

uilianries
uilianries previously approved these changes Sep 22, 2022
@conan-center-bot
Copy link
Collaborator

All green in build 14 (45b063657d14323c8a87dcf0cdca5b91f403bb3d):

  • xz_utils/5.2.5@:
    All packages built successfully! (All logs)

  • xz_utils/5.2.4@:
    All packages built successfully! (All logs)

@conan-center-bot conan-center-bot merged commit 14eec9c into conan-io:master Sep 28, 2022
@SpaceIm SpaceIm deleted the xz_utils-conan-v2 branch September 28, 2022 12:48
kayoub5 pushed a commit to kayoub5/conan-center-index that referenced this pull request Sep 29, 2022
* conan v2 support

* typo

* refactor slightly

* fix MinGW build

DESTDIR manually injected due to conan-io/conan#12153

* workaround to update PlatformToolset in vcxproj files

* fix install for compiler=msvc

* remove WindowsTargetPlatformVersion in 5.2.4

* add ugly tricks for MSBuild

* test custom CMake variables in conan generator

variables from https://cmake.org/cmake/help/latest/module/FindLibLZMA.html must be defined

LIBLZMA_HAS_AUTO_DECODER, LIBLZMA_HAS_EASY_ENCODER & LIBLZMA_HAS_LZMA_PRESET are not modeled for the moment

* typo

* set win_bash in build_requirements
System-Arch pushed a commit to System-Arch/conan-center-index that referenced this pull request Oct 7, 2022
* conan v2 support

* typo

* refactor slightly

* fix MinGW build

DESTDIR manually injected due to conan-io/conan#12153

* workaround to update PlatformToolset in vcxproj files

* fix install for compiler=msvc

* remove WindowsTargetPlatformVersion in 5.2.4

* add ugly tricks for MSBuild

* test custom CMake variables in conan generator

variables from https://cmake.org/cmake/help/latest/module/FindLibLZMA.html must be defined

LIBLZMA_HAS_AUTO_DECODER, LIBLZMA_HAS_EASY_ENCODER & LIBLZMA_HAS_LZMA_PRESET are not modeled for the moment

* typo

* set win_bash in build_requirements
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.

4 participants