intel-iot-devkit / meta-iot-cloud

OpenEmbedded layer to add support for multiple cloud IoT services including Microsoft Azure & Google Cloud Platform.
MIT License
69 stars 80 forks source link

Build samples for azure-iot-sdk-c and aws-iot-device-sdk-cpp-v2-samples #94

Closed robertlinux closed 3 years ago

srware commented 3 years ago

Hi Robert,

Thanks for the PR.

Is there a reason that the samples for the aws-iot-device-sdk-cpp-v2 package can't be built at the same time as the main library by enabling BUILDSAMPLES and a ${PN}-samples defined in the recipe with corresponding FILES${PN}-samples?

Otherwise this looks good to me.

Thanks.

robertlinux commented 3 years ago

Hi Robert,

Thanks for the PR.

Is there a reason that the samples for the aws-iot-device-sdk-cpp-v2 package can't be built at the same time as the main library by enabling BUILDSAMPLES and a ${PN}-samples defined in the recipe with corresponding FILES${PN}-samples?

Hi Scott,

From git/CMakeLists.txt: if (BUILD_SAMPLES) message(WARNING "BUILD_SAMPLES has been deprecated. Please build each sample separately.") endif()

So it does nothing when set BUILD_SAMPLES=ON

And from git/samples/README.md:

==================== mkdir build cd build cmake -DCMAKE_PREFIX_PATH="" -DCMAKE_BUILD_TYPE="<Release|RelWithDebInfo|Debug>" .. cmake --build . --config "<Release|RelWithDebInfo|Debug>"



#### Note

* `-DCMAKE_PREFIX_PATH` needs to be set to the path aws-iot-device-sdk-cpp-v2 installed.
================

So the samples should be built after aws-iot-device-sdk-cpp-v2 is installed, I tried to make -DCMAKE_PREFIX_PATH point to build dir,  but it didn't work, it only worked when point to image dir (the installed dir), if we need build the samples in the same recipe, we need add tasks like:

addtask do_configure_samples after do_install
addtask do_compile_samples after do_configure_samples
[snip]

And the problem is that it's hard to rerun cmake_do_configure with a different OECMAKE_SOURCEPATH (for do_configure_samples) since it is a value which is assigned during parsring, so we have to do either:
1) Copy the whole code of cmake_do_configure into the recipe
2) Patch cmake.bbclass to use a argument as  OECMAKE_SOURCEPATH

Either of them don't look good, so the easy way is building the samples in another recipes.

// Robert

> 
> Otherwise this looks good to me.
> 
> Thanks.
srware commented 3 years ago

Thanks for the explanation Robert. In this instance I agree that a separate recipe is the easiest approach.

Should we also remove BUILD_SAMPLES from EXTRA_OECMAKE if it is now deprecated?

robertlinux commented 3 years ago

Thanks for the explanation Robert. In this instance I agree that a separate recipe is the easiest approach.

Should we also remove BUILD_SAMPLES from EXTRA_OECMAKE if it is now deprecated?

Makes sense, I will send a new single PULL to remove it, or should I drop this PULL and send a new one with the removed BUILD_SAMPLES, please?

srware commented 3 years ago

A new PR is fine. I will merge this now.

Thanks.

srware commented 3 years ago

A new PR is fine. I will merge this now.

Thanks.