microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.86k stars 6.3k forks source link

Android prefab broken due to emscripten support #12359

Open AlexAUT opened 4 years ago

AlexAUT commented 4 years ago

Describe the bug It is currently not possible to create android prefabs (AAR) because of the emscripten support.

During the export command vcpkg tries to extract triplet information by running cmake with the toolchain file. However, the toolchain for emscripten returns a FATAL_ERROR in case emscripten is not present/installed. This results in vcpkg aborting.

A fix for this particular issue is to remove the emscripten present checks in the triplet, but this may break other things?

Environment

To Reproduce Steps to reproduce the behavior:

  1. Do not install emscripten / remove from PATH
  2. Try the android AAR example 2.1 Add android triplets 2.2 ./vcpkg install jsoncpp:arm-android jsoncpp:arm64-android jsoncpp:x64-android jsoncpp:x86-android 2.3 ./vcpkg export --triplet arm64-android jsoncpp --prefab --prefab-debug

Expected behavior Should create the AAR prefab for jsoncpp

Failure logs

./vcpkg export --triplet arm64-android jsoncpp --prefab --prefab-debug
The following packages are already built and will be exported:
    jsoncpp:arm64-android
d8187afd-ea4a-4fc3-9aa4-a6782e1ed9af
CMake Error at buildtrees/29.vcpkg_tags.cmake:8 (message):
  The EMSDK environment variable must be defined
Call Stack (most recent call first):
  scripts/vcpkg_get_tags.cmake:3 (vcpkg_triplet_file)
  buildtrees/29.vcpkg_tags.cmake:23 (vcpkg_get_tags)

Additional context Add any other context about the problem here. The first commit where this problem is present is the merge of the emscripten PR: a6257ac262f441a97869b7ec40ddc4bcce19570d

PhoebeHui commented 4 years ago

cc @MoAlyousef

MoAlyousef commented 4 years ago

I could remove the env checks in the cmake script. I don't see why vcpkg would check for it during an export for another triplet.

ras0219 commented 3 years ago

This looks like a bug in the prefab exporter; it should not be iterating through all available triplets and attempting to "divine" the correct ones: https://github.com/microsoft/vcpkg/blob/de70813cf38c55bac793f516751a35f843f12ad8/toolsrc/src/vcpkg/export.prefab.cpp#L276

Instead, the user should explicitly label each of the required architectures; perhaps via individual options:

./vcpkg export jsoncpp --prefab-x86-triplet=x86-android --prefab-x86_64-triplet=x64-android ...

We'd be happy to review a PR fixing this!

+@atkawa7 as the original author

rpavlik commented 3 years ago

Note that if you do "work around" it in this way, or specify something like this, it still fails:

 ./vcpkg export jsoncpp:x64-android jsoncpp:x86-android jsoncpp:arm-android jsoncpp:arm64-android --prefab  --prefab-debug
The following packages are already built and will be exported:
    jsoncpp:x64-android
    jsoncpp:x86-android
    jsoncpp:arm-android
    jsoncpp:arm64-android

Currently supported on android triplets

I've tracked down that the cmake_system_name that's being checked is empty, even though my triplet files match the instructions.

atkawa7 commented 3 years ago

@ras0219 @ras0219-msft I don't have time to look into this but based on my previous conversation with @strega-nil. She advised I do not pre-define triplets since users might define their own custom ones hence ended up loading available triplets.

Since an environment variable is missing for emscripten I am confused why vcpkg marks it as available. Shouldn't there be a check that marks this triplet as not available since all the requirements required for building it are not there. I am not sure if that's similar with platform specific triplets i.e you can't load windows triplets on linux/bsd variants.

One shouldn't check the triplet here, since someone might define their own android triplet.

_Originally posted by @strega-nil in https://github.com/microsoft/vcpkg/pull/10271#discussion_r392461896_.

rpavlik commented 1 year ago

Additionally, it shouldn't require all of the triplets: you can build an aar/prefab with as few architectures as you wish.

dmn-star commented 7 months ago

Are there any news or possible solutions?