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

[bug] conan install --output-folder ignored for build context when cross-compiling #14418

Closed
DoDoENT opened this issue Aug 3, 2023 · 9 comments
Assignees

Comments

@DoDoENT
Copy link
Contributor

DoDoENT commented Aug 3, 2023

Environment details

  • Operating System+version: Macos 13.4.1
  • Compiler+version: apple clang 14.0.3
  • Conan version: 2.0.9
  • Python version: 3.11

Steps to reproduce

Run conan install . -pr emscripten --output-folder my-build-folder

I'd expect my-build-folder to be created with both subfolders for emscripten and macos (build context).

However, I end-up with my-build-folder/emscripten and build/macos folders.

And if there is additional conan install . --output-folder my-build-folder to also install for the host system, CMakeUserPresets.json ends up with duplicate presets for mac (one in my-build-folder and one in build folder).

Logs

Example log with ls outputs from my run:

(conan2-venv) [dodo@nm-nmiksa: core-nn-models-image-capture (feature/conan-v2)]$ ls
accuracy_test_model_tolerances.json  benchmark_profiles  cmake  CMakeLists.txt  conanfile.py  jenkins-helper  Jenkinsfile  NeuralNetworkModel  README.md  Session.vim  test-data  test_package
(conan2-venv) [dodo@nm-nmiksa: core-nn-models-image-capture (feature/conan-v2)]$ conan install . -pr emscripten-3.1.32-advanced --output-folder my-build-folder

======== Input profiles ========
Profile host:
[settings]
arch=wasm-advanced
build_type=Release
compiler=clang
compiler.libcxx=libc++
compiler.version=17.emsdk-3.1.32
os=Emscripten
[tool_requires]
*: emsdk/3.1.32@microblink/stable
[conf]
tools.cmake.cmake_layout:build_folder_vars=['settings.os', 'settings.os.sdk', 'settings.arch', 'settings.compiler', 'settings.compiler.version', 'settings.compiler.sanitizers', 'settings.compiler.link_time_optimization']
tools.files.download:retry=5
tools.files.download:retry_wait=2
tools.cmake.cmaketoolchain:generator=Ninja
tools.build:cflags=['-mmutable-globals', '-mreference-types', '-mbulk-memory', '-mnontrapping-fptoint', '-msign-ext', '-msimd128']
tools.build:cxxflags=['-mmutable-globals', '-mreference-types', '-mbulk-memory', '-mnontrapping-fptoint', '-msign-ext', '-msimd128']
tools.build:exelinkflags=['-msimd128']
tools.build:sharedlinkflags=['-msimd128']

Profile build:
[settings]
arch=armv8
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=14.0.3
os=Macos
[tool_requires]
*: mb_foundation/0.1.0@microblink/stable
[conf]
tools.cmake.cmake_layout:build_folder_vars=['settings.os', 'settings.os.sdk', 'settings.arch', 'settings.compiler', 'settings.compiler.version', 'settings.compiler.sanitizers', 'settings.compiler.link_time_optimization']
tools.files.download:retry=5
tools.files.download:retry_wait=2
tools.cmake.cmaketoolchain:generator=Xcode


======== Computing dependency graph ========
Graph root
    conanfile.py (ml_models_image_capture/1.0.0): /Users/dodo/Work/Microblink/core-nn-models-image-capture/conanfile.py
Requirements
    adv_obfuscator/20170904.0@nenad/testing#35b6a767471e030de9640d6676d3035b - Cache
    boost/1.80@nenad/testing#b5f6784ab18ef24bc1423972f4d4c54e - Cache
    cmake_build/0.1.0@nenad/testing#40d33964dbe3f77e4f766bb8c34afd82 - Cache
    concurrent_queue/0.1.0@nenad/testing#63dcb9780d5aec456a2a83217fa55d79 - Cache
    config_ex/0.1.0@nenad/testing#8ac20ee44de37e4bcf5dc764d5d9f9fb - Cache
    core_utils/1.0.0@nenad/testing#5a16b213ec5f90cf8c61e4590efd82b0 - Cache
    cpuinfo/20230428.1@nenad/testing#c1e17d1098c745caa4462abaef85f8c6 - Cache
    eigen/3.4.0@nenad/testing#f0f42f40b9dcd259bae0b92feacca4f5 - Cache
    err/1.0.0@nenad/testing#deb27027360b5937da47ff192cdeb3e4 - Cache
    functionoid/0.1.0@nenad/testing#c1f5773dcea65d05d27a7f83075c777a - Cache
    gtest/1.11.0@nenad/testing#b86e737a89c05fb7e92eeb24dcfd4e05 - Cache
    hash/1.0.0@nenad/testing#5ec3db8c88c4a679e5d5ad6c6b0e1fe4 - Cache
    kiwaku/20230522.1@nenad/testing#caab153f2877dacbbaf89b0b8fb46de0 - Cache
    libjpeg_turbo/2.1.4.1@nenad/testing#328a17322058cd185ed6a6c4899b9e2e - Cache
    libpng/1.6.38.1@nenad/testing#7c45891acf66fd0e7b9c6f136c8ccfbe - Cache
    log_and_timer/0.1.0@nenad/testing#6346bb0a705637150950be0af5af33ad - Cache
    micro_ecc/1.0.0@nenad/testing#e3617d4b177b9e352ae1fde6839839fe - Cache
    mmap/1.0.0@nenad/testing#3aafec364b424c5b266a7bae5938b6a7 - Cache
    nlohmann_json/3.10.4#2d3ba0c641692cca9fb4514e05154688 - Cache
    opencv/4.6.0.2@nenad/testing#a037b128042b4e7f9d5ff6663bcb61ed - Cache
    protection/1.0.0@nenad/testing#a4005e34e83d1701812c8194f66c2fa2 - Cache
    protobuf/3.21.7@nenad/testing#4968cc8799438f3746a0ffef6f8c267a - Cache
    range-v3/0.12.0#4c05d91d7b40e6b91b44b5345ac64408 - Cache
    rapidjson/1.1.5@nenad/testing#d9cb20226d91dc7437d38f4433f0072c - Cache
    runner/1.0.0@nenad/testing#c6ecbcc838ac4515e23aeafdf5748432 - Cache
    std_fix/1.0.0@nenad/testing#49129ddf1d1a32deef32ba86f2897bde - Cache
    sweater/1.0.0@nenad/testing#5aa855c096711beb6d24b207f7c13d90 - Cache
    utfcpp/3.2.1@nenad/testing#a1f070448470fee48fe8377c5e64e08b - Cache
    version_and_paths/0.1.0@nenad/testing#1d4ece2deec299f3dc8594539e89328a - Cache
    xnnpack/20230525.0@nenad/testing#2d11e64818e995d6376f3e7f9a3a75ed - Cache
    zlib/1.2.13@nenad/testing#73ea6005846950a84f51347ff7e13b99 - Cache
Test requirements
    boost/1.80@nenad/testing#b5f6784ab18ef24bc1423972f4d4c54e - Cache
    cmake_build/0.1.0@nenad/testing#40d33964dbe3f77e4f766bb8c34afd82 - Cache
    config_ex/0.1.0@nenad/testing#8ac20ee44de37e4bcf5dc764d5d9f9fb - Cache
    functionoid/0.1.0@nenad/testing#c1f5773dcea65d05d27a7f83075c777a - Cache
    gtest/1.11.0@nenad/testing#b86e737a89c05fb7e92eeb24dcfd4e05 - Cache
    log_and_timer/0.1.0@nenad/testing#6346bb0a705637150950be0af5af33ad - Cache
    tensorflow/1.13.1@nenad/testing#611bd2364b1c74efbeb058065a492f2c - Cache
    version_and_paths/0.1.0@nenad/testing#1d4ece2deec299f3dc8594539e89328a - Cache
Build requirements
    adv_obfuscator/20170904.0@nenad/testing#35b6a767471e030de9640d6676d3035b - Cache
    boost/1.80@nenad/testing#b5f6784ab18ef24bc1423972f4d4c54e - Cache
    cmake_build/0.1.0@nenad/testing#40d33964dbe3f77e4f766bb8c34afd82 - Cache
    config_ex/0.1.0@nenad/testing#8ac20ee44de37e4bcf5dc764d5d9f9fb - Cache
    core_utils/1.0.0@nenad/testing#5a16b213ec5f90cf8c61e4590efd82b0 - Cache
    cpuinfo/20230428.1@nenad/testing#c1e17d1098c745caa4462abaef85f8c6 - Cache
    eigen/3.4.0@nenad/testing#f0f42f40b9dcd259bae0b92feacca4f5 - Cache
    emsdk/3.1.32@microblink/stable#5549f540cc62f96eb419846bed1a15ff - Cache
    err/1.0.0@nenad/testing#deb27027360b5937da47ff192cdeb3e4 - Cache
    functionoid/0.1.0@nenad/testing#c1f5773dcea65d05d27a7f83075c777a - Cache
    gtest/1.11.0@nenad/testing#b86e737a89c05fb7e92eeb24dcfd4e05 - Cache
    hash/1.0.0@nenad/testing#5ec3db8c88c4a679e5d5ad6c6b0e1fe4 - Cache
    kiwaku/20230522.1@nenad/testing#caab153f2877dacbbaf89b0b8fb46de0 - Cache
    libjpeg_turbo/2.1.4.1@nenad/testing#328a17322058cd185ed6a6c4899b9e2e - Cache
    libpng/1.6.38.1@nenad/testing#7c45891acf66fd0e7b9c6f136c8ccfbe - Cache
    log_and_timer/0.1.0@nenad/testing#6346bb0a705637150950be0af5af33ad - Cache
    mb_foundation/0.1.0@microblink/stable#2bec1a9c2b12df8b2ed7ac464f5b1e1f - Cache
    micro_ecc/1.0.0@nenad/testing#e3617d4b177b9e352ae1fde6839839fe - Cache
    ml_models_image_capture/1.0.0 - Editable
    mmap/1.0.0@nenad/testing#3aafec364b424c5b266a7bae5938b6a7 - Cache
    nasm/2.14#d4c0f102da173fe6ea0fe5c486a29709 - Cache
    nlohmann_json/3.10.4#2d3ba0c641692cca9fb4514e05154688 - Cache
    opencv/4.6.0.2@nenad/testing#a037b128042b4e7f9d5ff6663bcb61ed - Cache
    protection/1.0.0@nenad/testing#a4005e34e83d1701812c8194f66c2fa2 - Cache
    protobuf/3.21.7@nenad/testing#4968cc8799438f3746a0ffef6f8c267a - Cache
    range-v3/0.12.0#4c05d91d7b40e6b91b44b5345ac64408 - Cache
    rapidjson/1.1.5@nenad/testing#d9cb20226d91dc7437d38f4433f0072c - Cache
    runner/1.0.0@nenad/testing#c6ecbcc838ac4515e23aeafdf5748432 - Cache
    std_fix/1.0.0@nenad/testing#49129ddf1d1a32deef32ba86f2897bde - Cache
    sweater/1.0.0@nenad/testing#5aa855c096711beb6d24b207f7c13d90 - Cache
    tensorflow/1.13.1@nenad/testing#611bd2364b1c74efbeb058065a492f2c - Cache
    utfcpp/3.2.1@nenad/testing#a1f070448470fee48fe8377c5e64e08b - Cache
    version_and_paths/0.1.0@nenad/testing#1d4ece2deec299f3dc8594539e89328a - Cache
    xnnpack/20230525.0@nenad/testing#2d11e64818e995d6376f3e7f9a3a75ed - Cache
    zlib/1.2.13@nenad/testing#73ea6005846950a84f51347ff7e13b99 - Cache
Python requires
    conanfile_utils/0.1.0@nenad/testing#22e39d9779ab95f144c79a6c34b21146 - Cache
Resolved version ranges
    boost/[~1.80]@nenad/testing: boost/1.80@nenad/testing
    boost/[~1]@nenad/testing: boost/1.80@nenad/testing
    cmake_build/[~0]@nenad/testing: cmake_build/0.1.0@nenad/testing
    conanfile_utils/[~0]@nenad/testing: conanfile_utils/0.1.0@nenad/testing
    concurrent_queue/[~0]@nenad/testing: concurrent_queue/0.1.0@nenad/testing
    config_ex/[~0]@nenad/testing: config_ex/0.1.0@nenad/testing
    core_utils/[~1]@nenad/testing: core_utils/1.0.0@nenad/testing
    cpuinfo/[~20230428]@nenad/testing: cpuinfo/20230428.1@nenad/testing
    eigen/[~3.4.0]@nenad/testing: eigen/3.4.0@nenad/testing
    err/[~1]@nenad/testing: err/1.0.0@nenad/testing
    functionoid/[~0]@nenad/testing: functionoid/0.1.0@nenad/testing
    gtest/[~1]@nenad/testing: gtest/1.11.0@nenad/testing
    hash/[~1]@nenad/testing: hash/1.0.0@nenad/testing
    kiwaku/[~20230522]@nenad/testing: kiwaku/20230522.1@nenad/testing
    libjpeg_turbo/[~2.1]@nenad/testing: libjpeg_turbo/2.1.4.1@nenad/testing
    libpng/[~1.6]@nenad/testing: libpng/1.6.38.1@nenad/testing
    log_and_timer/[~0]@nenad/testing: log_and_timer/0.1.0@nenad/testing
    micro_ecc/[~1]@nenad/testing: micro_ecc/1.0.0@nenad/testing
    mmap/[~1]@nenad/testing: mmap/1.0.0@nenad/testing
    opencv/[~4.6.0]@nenad/testing: opencv/4.6.0.2@nenad/testing
    protection/[~1]@nenad/testing: protection/1.0.0@nenad/testing
    protobuf/[~3.21]@nenad/testing: protobuf/3.21.7@nenad/testing
    runner/[~1.0]@nenad/testing: runner/1.0.0@nenad/testing
    std_fix/[~1]@nenad/testing: std_fix/1.0.0@nenad/testing
    sweater/[~1]@nenad/testing: sweater/1.0.0@nenad/testing
    tensorflow/[~1.13.1]@nenad/testing: tensorflow/1.13.1@nenad/testing
    version_and_paths/[~0]@nenad/testing: version_and_paths/0.1.0@nenad/testing
    xnnpack/[~20230525]@nenad/testing: xnnpack/20230525.0@nenad/testing
    zlib/[~1.2]@nenad/testing: zlib/1.2.13@nenad/testing

======== Computing necessary packages ========
range-v3/0.12.0: WARN: apple-clang 14.0.3 support for range-v3 is unknown, assuming it is supported.
range-v3/0.12.0: WARN: apple-clang 14.0.3 support for range-v3 is unknown, assuming it is supported.
range-v3/0.12.0: WARN: apple-clang 14.0.3 support for range-v3 is unknown, assuming it is supported.
Requirements
    adv_obfuscator/20170904.0@nenad/testing#35b6a767471e030de9640d6676d3035b:df6c97fde094ef9a36f63e81c41e5253e72a2977#f6396f5a866f840a971e62c438a902c0 - Cache
    boost/1.80@nenad/testing#b5f6784ab18ef24bc1423972f4d4c54e:da39a3ee5e6b4b0d3255bfef95601890afd80709#e41614b4db81f145a4b79617850f5bbd - Cache
    cmake_build/0.1.0@nenad/testing#40d33964dbe3f77e4f766bb8c34afd82:da39a3ee5e6b4b0d3255bfef95601890afd80709#3334e37fc79ace9b71783a931daa8c77 - Cache
    concurrent_queue/0.1.0@nenad/testing#63dcb9780d5aec456a2a83217fa55d79:df6c97fde094ef9a36f63e81c41e5253e72a2977#56ccfaee0337bf802fe05933fc1f305e - Cache
    config_ex/0.1.0@nenad/testing#8ac20ee44de37e4bcf5dc764d5d9f9fb:df6c97fde094ef9a36f63e81c41e5253e72a2977#164af33db0fcc9a504d31c2febdf22c9 - Cache
    core_utils/1.0.0@nenad/testing#5a16b213ec5f90cf8c61e4590efd82b0:a915893de9ffd8407c14e8eac891e0e34df9ef57#cfc63009c465b18bfcb10c015f6ccf71 - Cache
    cpuinfo/20230428.1@nenad/testing#c1e17d1098c745caa4462abaef85f8c6:e981c5e8bc91de6adf94eeeb5761522340c7f57a#da06d109e66a49ebadb0745450c86710 - Cache
    eigen/3.4.0@nenad/testing#f0f42f40b9dcd259bae0b92feacca4f5:df6c97fde094ef9a36f63e81c41e5253e72a2977#738c6d38c60eb26068fb3b50f6515107 - Cache
    err/1.0.0@nenad/testing#deb27027360b5937da47ff192cdeb3e4:df6c97fde094ef9a36f63e81c41e5253e72a2977#c1027d4c74ecbba68b5cb484f089cb8b - Cache
    functionoid/0.1.0@nenad/testing#c1f5773dcea65d05d27a7f83075c777a:df6c97fde094ef9a36f63e81c41e5253e72a2977#0cba0b5c615a0f448595e7a90e2ec147 - Cache
    gtest/1.11.0@nenad/testing#b86e737a89c05fb7e92eeb24dcfd4e05:8a07849faa04095c9ebf7fb8bc6038aecc0bcf00#fbe9415b6943f7dc7b9572b11dc51af5 - Cache
    hash/1.0.0@nenad/testing#5ec3db8c88c4a679e5d5ad6c6b0e1fe4:6d4816a01a8c518faab1f827c998049a10d758ea#fcabe56bc1762e5d473cadec61e15b90 - Cache
    kiwaku/20230522.1@nenad/testing#caab153f2877dacbbaf89b0b8fb46de0:df6c97fde094ef9a36f63e81c41e5253e72a2977#f27f47dab2e797fd663ef896604ac62b - Cache
    libjpeg_turbo/2.1.4.1@nenad/testing#328a17322058cd185ed6a6c4899b9e2e:e981c5e8bc91de6adf94eeeb5761522340c7f57a#05815f0146f2e3f3a6444ccba8d0e1aa - Cache
    libpng/1.6.38.1@nenad/testing#7c45891acf66fd0e7b9c6f136c8ccfbe:e64676848d9fcce22df91ede11e31b98feba6904#819eb33d89bce3016693510e8d71f41f - Cache
    log_and_timer/0.1.0@nenad/testing#6346bb0a705637150950be0af5af33ad:4ad89de0d9b57a2455594bfe18ff1536dbd1095b#9353bb16500fedf56daf12e251d633a4 - Cache
    micro_ecc/1.0.0@nenad/testing#e3617d4b177b9e352ae1fde6839839fe:e10ed589f0a4a674333f041f984c96dd4e13c495#d2c7089671c908d942752d93cedfde59 - Cache
    mmap/1.0.0@nenad/testing#3aafec364b424c5b266a7bae5938b6a7:df6c97fde094ef9a36f63e81c41e5253e72a2977#94044f158bc9243777bd77bbbfc276f4 - Cache
    nlohmann_json/3.10.4#2d3ba0c641692cca9fb4514e05154688:da39a3ee5e6b4b0d3255bfef95601890afd80709#c778d4e6040abc2114a46c9599471b3c - Cache
    opencv/4.6.0.2@nenad/testing#a037b128042b4e7f9d5ff6663bcb61ed:7171d7a5d98ecb1e4633e601cc19ddabf6534c52#8a3a212dc45d21706838fa7e73e2671b - Cache
    protection/1.0.0@nenad/testing#a4005e34e83d1701812c8194f66c2fa2:fc8798e1975ea4e8495cb11d1d086052f0de0a05#8e541400b081ae57618ba64f54bcc68c - Cache
    protobuf/3.21.7@nenad/testing#4968cc8799438f3746a0ffef6f8c267a:e981c5e8bc91de6adf94eeeb5761522340c7f57a#e14f91173c131090fe3a0142e08a11ab - Cache
    range-v3/0.12.0#4c05d91d7b40e6b91b44b5345ac64408:da39a3ee5e6b4b0d3255bfef95601890afd80709#ecc6172c3cd6694c36d1cd98a702deb0 - Cache
    rapidjson/1.1.5@nenad/testing#d9cb20226d91dc7437d38f4433f0072c:df6c97fde094ef9a36f63e81c41e5253e72a2977#b3ae0ec1d159c57de4e34638419ec47c - Cache
    runner/1.0.0@nenad/testing#c6ecbcc838ac4515e23aeafdf5748432:6d512ce8d3063ccec1b2aecbd3f8a2eebb894be3#9bdef65049af0eefb858a10faa12420c - Cache
    std_fix/1.0.0@nenad/testing#49129ddf1d1a32deef32ba86f2897bde:df6c97fde094ef9a36f63e81c41e5253e72a2977#cd264f67a39b435409963d56bd6c3950 - Cache
    sweater/1.0.0@nenad/testing#5aa855c096711beb6d24b207f7c13d90:571b33dac76ad1be138cd44b97398ea757a062e1#a0b68209f99b680a2f13ae0515874e8c - Cache
    utfcpp/3.2.1@nenad/testing#a1f070448470fee48fe8377c5e64e08b:df6c97fde094ef9a36f63e81c41e5253e72a2977#aa77a3eefd1f6446a6b836fb887cd13e - Cache
    version_and_paths/0.1.0@nenad/testing#1d4ece2deec299f3dc8594539e89328a:df6c97fde094ef9a36f63e81c41e5253e72a2977#23c2fcf758f23e8b428195b19d8f5713 - Cache
    xnnpack/20230525.0@nenad/testing#2d11e64818e995d6376f3e7f9a3a75ed:1aeac9dcf7f62ca3403b9da73a245a8cf9f10c91#6cd158e9c8691c7d36424634500d5cda - Cache
    zlib/1.2.13@nenad/testing#73ea6005846950a84f51347ff7e13b99:e981c5e8bc91de6adf94eeeb5761522340c7f57a#63d832aa06fbfb9dcbaf1893bb8fda52 - Cache
Test requirements
Build requirements
    adv_obfuscator/20170904.0@nenad/testing#35b6a767471e030de9640d6676d3035b:df6c97fde094ef9a36f63e81c41e5253e72a2977#f6396f5a866f840a971e62c438a902c0 - Cache
    boost/1.80@nenad/testing#b5f6784ab18ef24bc1423972f4d4c54e:da39a3ee5e6b4b0d3255bfef95601890afd80709#e41614b4db81f145a4b79617850f5bbd - Cache
    cmake_build/0.1.0@nenad/testing#40d33964dbe3f77e4f766bb8c34afd82:da39a3ee5e6b4b0d3255bfef95601890afd80709#3334e37fc79ace9b71783a931daa8c77 - Cache
    config_ex/0.1.0@nenad/testing#8ac20ee44de37e4bcf5dc764d5d9f9fb:df6c97fde094ef9a36f63e81c41e5253e72a2977#164af33db0fcc9a504d31c2febdf22c9 - Cache
    core_utils/1.0.0@nenad/testing#5a16b213ec5f90cf8c61e4590efd82b0:bfcd9a4e12ddf5a9ef48e51081c198a88f67a6ae#c4017f7890ded390ada250f87570c685 - Cache
    cpuinfo/20230428.1@nenad/testing#c1e17d1098c745caa4462abaef85f8c6:a4ee5f530c1eed0dd8e262508ed8c83d7db25814#74b97bb3c33caa8f62f931e7d3887a41 - Cache
    eigen/3.4.0@nenad/testing#f0f42f40b9dcd259bae0b92feacca4f5:df6c97fde094ef9a36f63e81c41e5253e72a2977#738c6d38c60eb26068fb3b50f6515107 - Cache
    emsdk/3.1.32@microblink/stable#5549f540cc62f96eb419846bed1a15ff:dcf68e932572755309a5f69f3cee1bede410e907#429de819a47fc109f4e8500b59d0c9d0 - Cache
    err/1.0.0@nenad/testing#deb27027360b5937da47ff192cdeb3e4:df6c97fde094ef9a36f63e81c41e5253e72a2977#c1027d4c74ecbba68b5cb484f089cb8b - Cache
    functionoid/0.1.0@nenad/testing#c1f5773dcea65d05d27a7f83075c777a:df6c97fde094ef9a36f63e81c41e5253e72a2977#0cba0b5c615a0f448595e7a90e2ec147 - Cache
    gtest/1.11.0@nenad/testing#b86e737a89c05fb7e92eeb24dcfd4e05:bdbda0dfd17289fb8b15cb0f2ac3f0964103f72c#d0d10705bcd23c9e86a1eb55c663a936 - Cache
    hash/1.0.0@nenad/testing#5ec3db8c88c4a679e5d5ad6c6b0e1fe4:aa499286699bf1ae1837c67d1197ac93438e2afc#088f3034242e6792e4cc764ea444bab8 - Cache
    kiwaku/20230522.1@nenad/testing#caab153f2877dacbbaf89b0b8fb46de0:df6c97fde094ef9a36f63e81c41e5253e72a2977#f27f47dab2e797fd663ef896604ac62b - Cache
    libjpeg_turbo/2.1.4.1@nenad/testing#328a17322058cd185ed6a6c4899b9e2e:a4ee5f530c1eed0dd8e262508ed8c83d7db25814#8d90486693315feb4b185e7ff4bfa922 - Cache
    libpng/1.6.38.1@nenad/testing#7c45891acf66fd0e7b9c6f136c8ccfbe:95f1f6536c64ba4b9ec209c02481967c9b8e812e#8516ea85bb559bfa5914f83d8c29da6e - Cache
    log_and_timer/0.1.0@nenad/testing#6346bb0a705637150950be0af5af33ad:206bd62cc7313db21c3bc45b23508ad24911dc55#1cfb3667f772dd9d8fa4823aafa10081 - Cache
    mb_foundation/0.1.0@microblink/stable#2bec1a9c2b12df8b2ed7ac464f5b1e1f:da39a3ee5e6b4b0d3255bfef95601890afd80709#0ba8627bd47edc3a501e8f0eb9a79e5e - Cache
    micro_ecc/1.0.0@nenad/testing#e3617d4b177b9e352ae1fde6839839fe:809c1bab4be4c56a805cefd0794528c1d783f343#d4d9f38415d70acfbdb60749170b792d - Cache
    ml_models_image_capture/1.0.0:a565b3e2a572b5af2ccf186a96c88a05d30e53bc - Editable
    mmap/1.0.0@nenad/testing#3aafec364b424c5b266a7bae5938b6a7:df6c97fde094ef9a36f63e81c41e5253e72a2977#94044f158bc9243777bd77bbbfc276f4 - Cache
    nlohmann_json/3.10.4#2d3ba0c641692cca9fb4514e05154688:da39a3ee5e6b4b0d3255bfef95601890afd80709#c778d4e6040abc2114a46c9599471b3c - Cache
    opencv/4.6.0.2@nenad/testing#a037b128042b4e7f9d5ff6663bcb61ed:2f57ce45bad631ca6ee2ff537fa11a130fbd22cf#605b49fc93a151db1444672f53fb7480 - Cache
    protection/1.0.0@nenad/testing#a4005e34e83d1701812c8194f66c2fa2:bd096d3b37cf43d23b2a348357495651b7409ffe#a6fd4b6bc9739970babc54d27267640e - Cache
    protobuf/3.21.7@nenad/testing#4968cc8799438f3746a0ffef6f8c267a:a4ee5f530c1eed0dd8e262508ed8c83d7db25814#bd1282c883317f645ffd9146fa3a7171 - Cache
    range-v3/0.12.0#4c05d91d7b40e6b91b44b5345ac64408:da39a3ee5e6b4b0d3255bfef95601890afd80709#ecc6172c3cd6694c36d1cd98a702deb0 - Cache
    rapidjson/1.1.5@nenad/testing#d9cb20226d91dc7437d38f4433f0072c:df6c97fde094ef9a36f63e81c41e5253e72a2977#b3ae0ec1d159c57de4e34638419ec47c - Cache
    runner/1.0.0@nenad/testing#c6ecbcc838ac4515e23aeafdf5748432:c2bd28ded70d1c8df5730f641d76893d41c84bbe#10e82b809226ed1fca6763960ca16e0c - Cache
    std_fix/1.0.0@nenad/testing#49129ddf1d1a32deef32ba86f2897bde:df6c97fde094ef9a36f63e81c41e5253e72a2977#cd264f67a39b435409963d56bd6c3950 - Cache
    sweater/1.0.0@nenad/testing#5aa855c096711beb6d24b207f7c13d90:dbe8849e14617e85988b0ff6d22187a4f4bab5d3#ea4655eef9ea63c486212b33a3443195 - Cache
    tensorflow/1.13.1@nenad/testing#611bd2364b1c74efbeb058065a492f2c:29519c561700604859427195600ed4763c88b809#8795ddacd0dca0db96d2f293d3b11c9a - Cache
    utfcpp/3.2.1@nenad/testing#a1f070448470fee48fe8377c5e64e08b:df6c97fde094ef9a36f63e81c41e5253e72a2977#aa77a3eefd1f6446a6b836fb887cd13e - Cache
    version_and_paths/0.1.0@nenad/testing#1d4ece2deec299f3dc8594539e89328a:df6c97fde094ef9a36f63e81c41e5253e72a2977#23c2fcf758f23e8b428195b19d8f5713 - Cache
    xnnpack/20230525.0@nenad/testing#2d11e64818e995d6376f3e7f9a3a75ed:863456d894eee8e525e7e6507f1c4c24609a4134#3e69bb6ad8e9ef8317fbb17e824744a3 - Cache
    zlib/1.2.13@nenad/testing#73ea6005846950a84f51347ff7e13b99:df6c97fde094ef9a36f63e81c41e5253e72a2977#994efbbb20a29028c92e9370664b57a5 - Cache
Skipped binaries
    boost/1.80@nenad/testing, cmake_build/0.1.0@nenad/testing, config_ex/0.1.0@nenad/testing, functionoid/0.1.0@nenad/testing, gtest/1.11.0@nenad/testing, log_and_timer/0.1.0@nenad/testing, tensorflow/1.13.1@nenad/testing, version_and_paths/0.1.0@nenad/testing, nasm/2.14

======== Installing packages ========
mb_foundation/0.1.0@microblink/stable: Already installed! (1 of 50)
adv_obfuscator/20170904.0@nenad/testing: Already installed! (2 of 50)
boost/1.80@nenad/testing: Already installed! (3 of 50)
cmake_build/0.1.0@nenad/testing: Already installed! (4 of 50)
emsdk/3.1.32@microblink/stable: Already installed! (5 of 50)
nlohmann_json/3.10.4: Already installed! (6 of 50)
range-v3/0.12.0: Already installed! (7 of 50)
version_and_paths/0.1.0@nenad/testing: Already installed! (8 of 50)
std_fix/1.0.0@nenad/testing: Already installed! (9 of 50)
concurrent_queue/0.1.0@nenad/testing: Already installed! (10 of 50)
kiwaku/20230522.1@nenad/testing: Already installed! (11 of 50)
rapidjson/1.1.5@nenad/testing: Already installed! (12 of 50)
utfcpp/3.2.1@nenad/testing: Already installed! (13 of 50)
gtest/1.11.0@nenad/testing: Already installed! (14 of 50)
gtest/1.11.0@nenad/testing: Already installed! (15 of 50)
micro_ecc/1.0.0@nenad/testing: Already installed! (16 of 50)
micro_ecc/1.0.0@nenad/testing: Already installed! (17 of 50)
protobuf/3.21.7@nenad/testing: Already installed! (18 of 50)
protobuf/3.21.7@nenad/testing: Already installed! (19 of 50)
config_ex/0.1.0@nenad/testing: Already installed! (20 of 50)
zlib/1.2.13@nenad/testing: Already installed! (21 of 50)
zlib/1.2.13@nenad/testing: Already installed! (22 of 50)
cpuinfo/20230428.1@nenad/testing: Already installed! (23 of 50)
cpuinfo/20230428.1@nenad/testing: Already installed! (24 of 50)
eigen/3.4.0@nenad/testing: Already installed! (25 of 50)
libjpeg_turbo/2.1.4.1@nenad/testing: Already installed! (26 of 50)
libjpeg_turbo/2.1.4.1@nenad/testing: Already installed! (27 of 50)
tensorflow/1.13.1@nenad/testing: Already installed! (28 of 50)
functionoid/0.1.0@nenad/testing: Already installed! (29 of 50)
libpng/1.6.38.1@nenad/testing: Already installed! (30 of 50)
libpng/1.6.38.1@nenad/testing: Already installed! (31 of 50)
err/1.0.0@nenad/testing: Already installed! (32 of 50)
log_and_timer/0.1.0@nenad/testing: Already installed! (33 of 50)
log_and_timer/0.1.0@nenad/testing: Already installed! (34 of 50)
mmap/1.0.0@nenad/testing: Already installed! (35 of 50)
sweater/1.0.0@nenad/testing: Already installed! (36 of 50)
sweater/1.0.0@nenad/testing: Already installed! (37 of 50)
opencv/4.6.0.2@nenad/testing: Already installed! (38 of 50)
opencv/4.6.0.2@nenad/testing: Already installed! (39 of 50)
xnnpack/20230525.0@nenad/testing: Already installed! (40 of 50)
xnnpack/20230525.0@nenad/testing: Already installed! (41 of 50)
core_utils/1.0.0@nenad/testing: Already installed! (42 of 50)
core_utils/1.0.0@nenad/testing: Already installed! (43 of 50)
hash/1.0.0@nenad/testing: Already installed! (44 of 50)
hash/1.0.0@nenad/testing: Already installed! (45 of 50)
protection/1.0.0@nenad/testing: Already installed! (46 of 50)
protection/1.0.0@nenad/testing: Already installed! (47 of 50)
runner/1.0.0@nenad/testing: Already installed! (48 of 50)
runner/1.0.0@nenad/testing: Already installed! (49 of 50)
ml_models_image_capture/1.0.0: Rewriting files of editable package 'ml_models_image_capture' at '/Users/dodo/Work/Microblink/core-nn-models-image-capture/build/macos-armv8-apple-clang-14.0.3/generators'
ml_models_image_capture/1.0.0: Calling generate()
ml_models_image_capture/1.0.0: Generators folder: /Users/dodo/Work/Microblink/core-nn-models-image-capture/build/macos-armv8-apple-clang-14.0.3/generators
ml_models_image_capture/1.0.0: CMakeToolchain generated: conan_toolchain.cmake
ml_models_image_capture/1.0.0: CMakeToolchain generated: CMakePresets.json
ml_models_image_capture/1.0.0: CMakeToolchain generated: ../../../CMakeUserPresets.json
ml_models_image_capture/1.0.0: Generating aggregated env files
ml_models_image_capture/1.0.0: Generated aggregated env files: ['conanrun.sh']
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated:     'cpp_info.names' used in: range-v3/0.12.0

======== Finalizing install (deploy, generators) ========
conanfile.py (ml_models_image_capture/1.0.0): Calling generate()
conanfile.py (ml_models_image_capture/1.0.0): Generators folder: /Users/dodo/Work/Microblink/core-nn-models-image-capture/my-build-folder/build/emscripten-wasm-advanced-clang-17.emsdk-3.1.32/Release/generators
conanfile.py (ml_models_image_capture/1.0.0): CMakeToolchain generated: conan_toolchain.cmake
conanfile.py (ml_models_image_capture/1.0.0): Preset 'conan-emscripten-wasm-advanced-clang-17.emsdk-3.1.32-release' added to CMakePresets.json. Invoke it manually using 'cmake --preset conan-emscripten-wasm-advanced-clang-17.emsdk-3.1.32-release' if using CMake>=3.23
conanfile.py (ml_models_image_capture/1.0.0): If your CMake version is not compatible with CMakePresets (<3.23) call cmake like: 'cmake <path> -G Ninja -DCMAKE_TOOLCHAIN_FILE=/Users/dodo/Work/Microblink/core-nn-models-image-capture/my-build-folder/build/emscripten-wasm-advanced-clang-17.emsdk-3.1.32/Release/generators/conan_toolchain.cmake -DMB_EMSCRIPTEN_COMPILE_TO_WEBASSEMBLY=ON -DMB_EMSCRIPTEN_ENABLE_PTHREADS=OFF -DMB_EMSCRIPTEN_SIMD=ON -DMB_EMSCRIPTEN_ADVANCED_FEATURES=ON -DMB_CONAN_FIND_PATHS="/Users/dodo/.conan2/p/emsdk8f2449b56f570/p/;/Users/dodo/.conan2/p/emsdk8f2449b56f570/p/upstream/emscripten;/Users/dodo/.conan2/p/b/runne6053fc9f17294/p/bin;/Users/dodo/Desktop/conan2-venv/bin;/opt/homebrew/opt/openjdk@11/bin;/Users/dodo/.cargo/bin;/Users/dodo/.npm-packages/bin;/opt/bin;/opt/homebrew/bin;/opt/homebrew/sbin;/usr/local/bin;/usr/local/sbin;/opt/local/bin;/usr/local/bin;/System/Cryptexes/App/usr/bin;/usr/bin;/bin;/usr/sbin;/sbin;/Applications/VMware Fusion.app/Contents/Public;/usr/local/MacGPG2/bin;/usr/local/share/dotnet;/opt/X11/bin;~/.dotnet/tools;/Library/Apple/usr/bin;/Library/Frameworks/Mono.framework/Versions/Current/Commands;/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin;/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin;/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin;/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin;/opt/homebrew/opt/openjdk@11/bin;/Users/dodo/.cargo/bin;/Users/dodo/.npm-packages/bin;/opt/bin;/opt/homebrew/bin;/opt/homebrew/sbin;/usr/local/sbin;/opt/local/bin;/Users/dodo/Build/dex-tools-2.1-20171001-lanchon;/Users/dodo/bin;/Users/dodo/android-sdks/platform-tools;/Users/dodo/android-sdks/tools;/Users/dodo/android-sdks/cmdline-tools/latest/bin;/Users/dodo/android-sdks/tools/proguard/bin;/Users/dodo/android-sdks/build-tools/30.0.3;/Users/dodo/.conan/data/AndroidNdk/r24/microblink/stable/package/13033aa1a9db6bdc6849cb2d5012d7a6b76359f5;/Users/dodo/.conan/data/AndroidNdk/r24/microblink/stable/package/13033aa1a9db6bdc6849cb2d5012d7a6b76359f5/toolchains/llvm/prebuilt/darwin-x86_64/bin;/Applications/CMake.app/Contents/bin;/Users/dodo/Work/dex2jar-2.0;/opt/homebrew/Cellar/[email protected]/3.9.1_1/Frameworks/Python.framework/Versions/3.9/bin;/Users/dodo/Work/CloneOuts/arcanist/bin;/opt/homebrew/opt/fzf/bin;/Users/dodo/Build/dex-tools-2.1-20171001-lanchon;/Users/dodo/bin;/Users/dodo/android-sdks/platform-tools;/Users/dodo/android-sdks/tools;/Users/dodo/android-sdks/cmdline-tools/latest/bin;/Users/dodo/android-sdks/tools/proguard/bin;/Users/dodo/android-sdks/build-tools/30.0.3;/Users/dodo/.conan/data/AndroidNdk/r24/microblink/stable/package/13033aa1a9db6bdc6849cb2d5012d7a6b76359f5;/Users/dodo/.conan/data/AndroidNdk/r24/microblink/stable/package/13033aa1a9db6bdc6849cb2d5012d7a6b76359f5/toolchains/llvm/prebuilt/darwin-x86_64/bin;/Applications/CMake.app/Contents/bin;/Users/dodo/Work/dex2jar-2.0;/opt/homebrew/Cellar/[email protected]/3.9.1_1/Frameworks/Python.framework/Versions/3.9/bin;/Users/dodo/Work/CloneOuts/arcanist/bin" -DMB_GLOBAL_LOG_LEVEL=LOG_WARNINGS_AND_ERRORS -DMB_GLOBAL_ENABLE_TIMER=OFF -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release'
conanfile.py (ml_models_image_capture/1.0.0): CMakeToolchain generated: CMakePresets.json
conanfile.py (ml_models_image_capture/1.0.0): CMakeToolchain generated: ../../../../../CMakeUserPresets.json
conanfile.py (ml_models_image_capture/1.0.0): Generating aggregated env files
conanfile.py (ml_models_image_capture/1.0.0): Generated aggregated env files: ['conanrun.sh']
Install finished successfully
(conan2-venv) [dodo@nm-nmiksa: core-nn-models-image-capture (feature/conan-v2)]$ ls
accuracy_test_model_tolerances.json  benchmark_profiles  build  cmake  CMakeLists.txt  CMakeUserPresets.json  conanfile.py  jenkins-helper  Jenkinsfile  my-build-folder  NeuralNetworkModel  README.md  Session.vim  test-data  test_package
(conan2-venv) [dodo@nm-nmiksa: core-nn-models-image-capture (feature/conan-v2)]$ ls my-build-folder/
build
(conan2-venv) [dodo@nm-nmiksa: core-nn-models-image-capture (feature/conan-v2)]$ ls my-build-folder/build/
emscripten-wasm-advanced-clang-17.emsdk-3.1.32
(conan2-venv) [dodo@nm-nmiksa: core-nn-models-image-capture (feature/conan-v2)]$ ls build/
macos-armv8-apple-clang-14.0.3
@memsharded
Copy link
Member

Hi @DoDoENT

I am trying to reproduce this, so far this is what I got:

def test_install_output_folder():
    c = TestClient()
    profile = textwrap.dedent("""
        [settings]
        os=Windows
        arch=x86_64
        build_type=Release
        [conf]
        tools.cmake.cmake_layout:build_folder_vars=['settings.os', 'settings.arch']
        """)
    app = textwrap.dedent("""
        from conan import ConanFile
        from conan.tools.cmake import cmake_layout, CMakeDeps
        class App(ConanFile):
            settings = "os", "arch", "build_type"
            requires = "lib/0.1"
            tool_requires = "tool/0.1"
            def layout(self):
                cmake_layout(self)
            def generate(self):
                deps = CMakeDeps(self)
                deps.build_context_activated = ["tool"]
                deps.generate()
            """)
    c.save({"tool/conanfile.py": GenConanfile("tool", "0.1"),
            "lib/conanfile.py": GenConanfile("lib", "0.1"),
            "app/conanfile.py": app,
            "profile": profile})
    c.run("create tool")
    c.run("create lib")
    c.run("install app -of=my_output -pr=profile -pr:b=profile -s:b os=Linux -s:b arch=armv8")
    print(c.out)
    print(c.current_folder)

But I can't see that build folder.

It would be useful to have:

  • Your consumer conanfile.py
  • What is inside the build/macos-armv8-apple-clang-14.0.3 folder

@DoDoENT
Copy link
Contributor Author

DoDoENT commented Aug 4, 2023

What is inside the build/macos-armv8-apple-clang-14.0.3 folder

(conan2-venv) [dodo@nm-nmiksa: core-nn-models-image-capture (feature/conan-v2)]$ ls build/macos-armv8-apple-clang-14.0.3/
generators

generators folder contain usual cmake generators for Macos

Similarly ls my-build-folder shows just the build, and ls my-build-folder/build shows the emscripten-wasm-advanced-clang-17.emsdk-3.1.32 folder which contains folder Release which then contains generators which then contain usual cmake generators for Emscripten.

The conanfile.py in question looks like this:

from conan import ConanFile
from conan.tools.files import copy

import os


class NeuralNetworkModelsImageCaptureConan(ConanFile):
    name = "ml_models_image_capture"
    license = "EULA"
    description = "ML models for Capture SDK"
    url = "https://bitbucket.org/microblink/core-nn-models-image-capture"

    python_requires = "conanfile_utils/[~0]@nenad/testing"
    python_requires_extend = "conanfile_utils.MicroblinkConanFile"

    def requirements(self):
        self.requires('runner/[~1.0]@nenad/testing', transitive_headers=True, package_id_mode='full_package_mode')

    @property
    def _is_cross_compiling(self):
        return self.settings.os not in ['Linux', 'Macos', 'Windows']

    def build_requirements(self):
        self.tool_requires('runner/<host_version>@nenad/testing')

        if self._is_cross_compiling:
            suffix = ''
            if self.user and self.channel:
                suffix = f'@{self.user}/{self.channel}'

            self.tool_requires(f'ml_models_image_capture/{self.version}{suffix}')

    def build(self):
        pkg_build_args = {}
        if self._is_cross_compiling:
            pkg_build_args['MB_HOST_DUMP_FOLDER'] = os.path.join(
                self.dependencies.direct_build['ml_models_image_capture'].cpp_info.resdirs[0],
                'NeuralNetworkModel'
            )
        self.mb_build_target(build_only_vars=pkg_build_args)

    def package(self):
        self.mb_package_custom_libraries(libs=['DocumentCaptureModels'])
        if self.settings.os == "Android":
            copy(
                self,
                pattern="NeuralNetworkModel/*.rtttl",
                src=self.build_folder,
                dst=os.path.join(self.package_folder, "res")
            )
        else:
            copy(
                self,
                pattern="NeuralNetworkModel/*.strop",
                src=self.build_folder,
                dst=os.path.join(self.package_folder, "res")
            )
        copy(
            self,
            pattern="*README.md",
            src=self.source_folder,
            dst=self.package_folder,
        )
        copy(
            self,
            pattern="NeuralNetworkModel/*.json",
            src=self.source_folder,
            dst=os.path.join(self.package_folder, "res"),
            excludes=("*/info.json", "*/test_data.json"),
        )

        copy(
            self,
            pattern="NeuralNetworkModel/*.hpp",
            src=self.build_folder,
            dst=os.path.join(self.package_folder, "include"),
            excludes=("*_ModelData.hpp", "*_Model.hpp"),
        )

        copy(
            self,
            pattern="model_names.cmake",
            src=self.build_folder,
            dst=self.package_folder,
        )

    def package_info(self):
        self.cpp_info.libs = ["DocumentCaptureModels"]
        self.cpp_info.resdirs = ['res']

# pylint: skip-file

Maybe this is a side-effect of package tool-requiring itself?

@DoDoENT
Copy link
Contributor Author

DoDoENT commented Aug 4, 2023

For sake of completness, here is also the conanfile_utils:

from conan import ConanFile
from conan.tools.cmake import cmake_layout, CMake, CMakeDeps, CMakeToolchain
from conan.tools.env import VirtualRunEnv, VirtualBuildEnv
from conan.tools.files import copy, load
from conan.tools.build import can_run
from conan.tools.microsoft import VCVars

import os

from typing import List, AnyStr, Dict


class MicroblinkConanFile:
    options = {
        'log_level': ['Verbose', 'Debug', 'Info', 'WarningsAndErrors'],
        'enable_timer': [True, False],
    }
    default_options = {
        'log_level': 'WarningsAndErrors',
        'enable_timer': False,
    }
    settings = "os", "compiler", "build_type", "arch"
    no_copy_source = True
    exports_sources = '*', '!test-data/*', '!.git/*', '!test_package/*'
    package_type = 'static-library'

    # -----------------------------------------------------------------------------
    # Now follow the mb-specific methods
    # -----------------------------------------------------------------------------

    def mb_generate_with_cmake_args(self, cmake_args: Dict):
        custom_cmake_cache_variables = 'user.microblink.cmaketoolchain:cache_variables'

        vcvars = VCVars(self)
        vcvars.generate()

        self.mb_add_base_args(cmake_args)

        tc = CMakeToolchain(self)

        skip_user_presets = self.conf.get('user.microblink.cmaketoolchain:skip_user_presets', default=False)
        if skip_user_presets:
            tc.user_presets_path = False

        for require, dependency in self.dependencies.items():
            custom_cmake_options = dependency.conf_info.get(custom_cmake_cache_variables)
            if custom_cmake_options is not None:
                tc.cache_variables.update(custom_cmake_options)

        # calculate variable with all build requirements paths, for purposes of
        # mb_find_program, so that developers don't need to activate conanbuild environment,
        # which is not easy in every IDE
        buildenv_generator = VirtualBuildEnv(self)
        paths = buildenv_generator.environment().vars(self).get('PATH', default='')
        if self.settings.os == 'Windows':
            tc.cache_variables['MB_CONAN_FIND_PATHS'] = paths
        else:
            tc.cache_variables['MB_CONAN_FIND_PATHS'] = paths.replace(':', ';')

        direct_cmake_options = self.conf.get(custom_cmake_cache_variables)
        if direct_cmake_options:
            tc.cache_variables.update(direct_cmake_options)

        tc.cache_variables.update(cmake_args)
        tc.generate()

        deps = CMakeDeps(self)
        deps.generate()

        if self.tested_reference_str is not None and can_run(self):
            conanrun = VirtualRunEnv(self)
            conanrun.generate(scope='run')

    def mb_add_base_args(self, cmake_args: Dict):
        if 'log_level' in self.options:
            if self.options.log_level == 'Verbose':
                cmake_log_level = 'LOG_VERBOSE'
            elif self.options.log_level == 'Debug':
                cmake_log_level = 'LOG_DEBUG'
            elif self.options.log_level == 'Info':
                cmake_log_level = 'LOG_INFO'
            elif self.options.log_level == 'WarningsAndErrors':
                cmake_log_level = 'LOG_WARNINGS_AND_ERRORS'
            cmake_args['MB_GLOBAL_LOG_LEVEL'] = cmake_log_level

        if 'enable_timer' in self.options:
            cmake_args['MB_GLOBAL_ENABLE_TIMER'] = self.options.enable_timer

    def mb_build_target(self, target: AnyStr = None, build_only_vars: Dict = {}):
        cmake = CMake(self)
        # invoked only when building the package in cache.
        # We generally want to treat warnings as errors, but not during
        # package build, as we want forward compatibilty with new compilers
        # that add new warnings.
        build_only_vars.update({
            'MB_TREAT_WARNINGS_AS_ERRORS': 'OFF',
            'MB_BUILDING_CONAN_PACKAGE': 'ON',
        })
        cmake.configure(
            variables=build_only_vars
        )

        if self.settings.os == 'iOS':
            if self.settings.os.sdk == 'maccatalyst':
                # CMake currently does not support invoking Mac Catalyst builds
                if target is None:
                    target = 'ALL_BUILD'
                self.run(
                    f"xcodebuild build -configuration {self.settings.build_type} -scheme {target} " +
                    "-destination 'platform=macOS,variant=Mac Catalyst' ONLY_ACTIVE_ARCH=NO"
                )
            else:
                cmake.build(target=target, build_tool_args=['-sdk', str(self.settings.os.sdk), 'ONLY_ACTIVE_ARCH=NO'])
        else:
            cmake.build(target=target)

    def mb_cmake_install(self):
        cmake = CMake(self)
        if self.settings.os == 'iOS':
            if self.settings.os.sdk == 'maccatalyst':
                # CMake currently does not support invoking Mac Catalyst builds
                self.run(
                    f"xcodebuild build -configuration {self.settings.build_type} -scheme install " +
                    "-destination 'platform=macOS,variant=Mac Catalyst' ONLY_ACTIVE_ARCH=NO"
                )
            else:
                # cmake.install in conan v2 does not support build_tool_args, like cmake.build
                self.run(
                    f"xcodebuild build -configuration {self.settings.build_type} -scheme install " +
                    f"-sdk {self.settings.os.sdk} ONLY_ACTIVE_ARCH=NO"
                )
        else:
            cmake.install()

    def mb_package_all_headers(self):
        copy(
            self,
            pattern="*.h*",
            src=os.path.join(self.source_folder, self.name, "Source"),
            dst=os.path.join(self.package_folder, "include"),
            keep_path=True
        )

    def mb_package_public_headers(self):
        copy(
            self,
            pattern="*.h*",
            src=os.path.join(self.source_folder, self.name, "Include"),
            dst=os.path.join(self.package_folder, "include"),
            keep_path=True
        )

    def mb_package_custom_libraries(self, libs: List[AnyStr], subfolders: List[AnyStr] = ['']):
        if self.settings.os == 'Windows':
            for lib in libs:
                for subfolder in subfolders:
                    copy(
                        self,
                        pattern=f"{lib}.lib",
                        src=os.path.join(self.build_folder, subfolder),
                        dst=os.path.join(self.package_folder, 'lib'),
                        keep_path=False
                    )
                    copy(
                        self,
                        pattern=f"*{lib}.pdb",
                        src=os.path.join(self.build_folder, subfolder),
                        dst=os.path.join(self.package_folder, "lib"),
                        keep_path=False
                    )
        elif self.settings.os in ['iOS', 'Macos']:
            cmake_generator = self.conf.get('tools.cmake.cmaketoolchain:generator', default='Xcode')
            if cmake_generator == 'Xcode':
                prefix = str(self.settings.build_type)
                if self.settings.os == 'iOS':
                    prefix = f"{self.settings.build_type}-{self.settings.os.sdk}"
                for lib in libs:
                    for subfolder in subfolders:
                        copy(
                            self,
                            pattern=f"{prefix}/lib{lib}.a",
                            src=os.path.join(self.build_folder, subfolder),
                            dst=os.path.join(self.package_folder, "lib"),
                            keep_path=False
                        )
            else:
                for lib in libs:
                    for subfolder in subfolders:
                        copy(
                            self,
                            pattern=f"lib{lib}.a",
                            src=os.path.join(self.build_folder, subfolder),
                            dst=os.path.join(self.package_folder, "lib"),
                            keep_path=False
                        )
        else:
            for lib in libs:
                for subfolder in subfolders:
                    copy(
                        self,
                        pattern=f"lib{lib}.a",
                        src=os.path.join(self.build_folder, subfolder),
                        dst=os.path.join(self.package_folder, "lib"),
                        keep_path=False
                    )

    def mb_package_all_libraries(self, subfolders: List[AnyStr] = ['']):
        self.mb_package_custom_libraries(['*'], subfolders)

    def mb_define_apple_universal_binary(self):
        if self.info.settings.os == 'Macos' or \
                (self.info.settings.os == 'iOS' and self.info.settings.os.sdk in ['iphonesimulator', 'maccatalyst']):
            cmake_generator = self.conf.get('tools.cmake.cmaketoolchain:generator', default='Xcode')
            if cmake_generator == 'Xcode':
                self.info.settings.arch = 'universal'

    def mb_run_test(self, exename: AnyStr, args: List[AnyStr] = []):
        if can_run(self):
            suffix = ''
            if self.settings.os == 'Windows':
                suffix = '.exe'
            bin_path = os.path.join(self.cpp.build.bindirs[0], exename + suffix)
            if len(args) != 0:
                bin_path += ' '
                bin_path += ' '.join(args)
            self.run(bin_path, env='conanrun')

    def mb_define_editable_paths_for_components(self, components: List[AnyStr]):
        for component_name in components:
            self.cpp.build.components[component_name].libdirs = [
                str(self.settings.build_type),
                'lib',
                f'lib/{self.settings.build_type}'
            ]
            if self.settings.os == 'iOS':
                self.cpp.build.components[component_name].libdirs.append(
                    f'{self.settings.build_type}-{self.settings.os.sdk}'
                )

            # add include to every subfolder that contains Include subfolder
            self.cpp.source.components[component_name].includedirs = [
                os.path.join(f.path, 'Include') for f in os.scandir(self.recipe_folder)
                if f.is_dir() and os.path.exists(os.path.join(f.path, 'Include'))
            ]

    # -----------------------------------------------------------------------------
    # Now follow the default implementations of conan methods (no mb_ prefix)
    # -----------------------------------------------------------------------------

    def set_version(self):
        """Automatically parse version from README.md (if it exists)"""

        readme_path = os.path.join(self.recipe_folder, 'README.md')
        if self.version is None and os.path.exists(readme_path):
            # load the version from README.md
            readme = load(self, readme_path)
            assert readme is not None
            regex = r"^##\s+(\d+.\d+(.\d+(.\d+)?)?)+\s+$"
            import re
            version_match = re.search(regex, readme, re.MULTILINE)
            assert version_match is not None
            self.version = version_match.group(1)

    def layout(self):
        cmake_layout(self)
        # support for editable packages
        self.cpp.build.libdirs = [str(self.settings.build_type), 'lib', f'lib/{self.settings.build_type}']
        if self.settings.os == 'iOS':
            self.cpp.build.libdirs.append(f'{self.settings.build_type}-{self.settings.os.sdk}')

        # add include to every subfolder that contains Include subfolder
        self.cpp.source.includedirs = [
            os.path.join(f.path, 'Include') for f in os.scandir(self.recipe_folder)
            if f.is_dir() and os.path.exists(os.path.join(f.path, 'Include'))
        ]

    def generate(self):
        self.mb_generate_with_cmake_args({})

    def build(self):
        self.mb_build_target()

    def package(self):
        self.mb_cmake_install()

    def package_id(self):
        self.mb_define_apple_universal_binary()


class MicroblinkConanFilePackage(ConanFile):
    name = "conanfile_utils"
    version = "0.1.0"
    package_type = 'python-require'

# pylint: skip-file

@DoDoENT
Copy link
Contributor Author

DoDoENT commented Aug 4, 2023

You can imagine runner/* package having similar behavior as protobuf from conan-center - it contains both libraries that need to be used in the host context and executables that need to be used as part of the build in the build context.

The ml_models_image_capture package also has a similar behavior - the building of the package requires first building the same package in the build context and then copying some files that get generated by executables generated as part of the build process.

@DoDoENT
Copy link
Contributor Author

DoDoENT commented Aug 4, 2023

Aha, maybe the build folder gets generated because ml_models_image_capture needs to be in editable mode in order for emscripten version to be installed (see here for the discussion).

@DoDoENT
Copy link
Contributor Author

DoDoENT commented Aug 4, 2023

Yes, I've confirmed it. The problem was due to ml_models_image_capture need being in editable mode in order to cross-compile it, and the editable location was the default build, so conan re-generated that folder while installing for emscripten.

It's a bit confusing that conan remove "*" -c does not automatically also "clean up" editable packages, "as if" they also get deleted. Somewhere this is persisted so that it outlives cache nuking.

OK, so it's not a conan bug after all. Sorry for misreporting (I'm easy on a trigger lately 😛 ).

@DoDoENT DoDoENT closed this as completed Aug 4, 2023
@memsharded
Copy link
Member

he problem was due to ml_models_image_capture need being in editable mode in order to cross-compile it, and the editable location was the default build, so conan re-generated that folder while installing for emscripten.

Ok, that makes sense, if it is in editable mode, it is being consumed by others and that is generating that folder. I need to check anyway this, not sure if it would make sense to try to change it and align the editable with the consumer folders

OK, so it's not a conan bug after all. Sorry for misreporting (I'm easy on a trigger lately 😛 ).

No prob! 😄 Better reporting and then following up and closing that not giving feedback at all, or struggle too much trying to find some solution instead of asking.

@DoDoENT
Copy link
Contributor Author

DoDoENT commented Aug 4, 2023

Better reporting and then following up and closing that not giving feedback at all, or struggle too much trying to find some solution instead of asking.

😄 , sometimes I even report a bug, then discover that it's not a bug and close it, just to discover that it was the bug after all, but a different one than initially thought (see here 😛 )

@memsharded
Copy link
Member

Checked in #14426 that editables respect the build_folder_vars conf even when consumed as dependency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants