Search code examples
yoctobitbakeopenembedded

Yocto rust recipe also produces -native output that needs packaging


I tried this approach on hardknott but I couldn't get it to work recipe also produces -native output that needs packaging

It is a rust recipe that generates an x86_64 app which I would like to package the right way in sdk, so that it can be used.

I can separate the main package to -native-bin, and I see it in the recipe-sysroot, but I can't get it to populate the recipe-sysroot of the workdir of the file when building the -native-helper recipe. And I suspect the reason is that I get an error that the main recipe for x86_64 can't be found?

ERROR: Manifest xxxxxx.populate_sysroot not found in vs_imx8mp cortexa53 armv8a-crc armv8a aarch64 allarch x86_64_x86_64-nativesdk (variant '')?

So any helpful information would be appreciated!


Solution

  • Hacked like this:

    Recipe.bb:

    do_install_append() {
        # Set permision without run flag so that it doesn't fail on checks
        chmod 644 ${D}/usr/bin/@RECIPE@-compiler
    }
    
    # @RECIPE@ generates a compiler during the target generation step
    #separate this to the -native-bin package, and skip the ARCH checks
    #also in the image file for stations_sdk move the app to right dir and add execute flag
    PACKAGES_prepend = "${PN}-native-bin "
    PROVIDES_prepend = "${PN}-native-bin "
    INSANE_SKIP_${PN}-native-bin = "arch"
    FILES_${PN}-native-bin = "/usr/bin/@RECIPE@-compiler"
    
    SYSROOT_DIRS += "/"
    

    Image.bb:

    # @RECIPE@ produces a compiler that is produced as a part of the target generation
    #so we use the recipe and hack it to supply the -compiler as part of the 
    #host binaries
    TOOLCHAIN_TARGET_TASK_append = " @RECIPE@-native-bin"
    
    do_fix_@RECIPE@() {
        mv ${SDK_OUTPUT}/${SDKTARGETSYSROOT}/usr/bin/@RECIPE@-compiler ${SDK_OUTPUT}/${SDKPATHNATIVE}/usr/bin/@RECIPE@-compiler
        chmod 755 ${SDK_OUTPUT}/${SDKPATHNATIVE}/usr/bin/@RECIPE@-compiler
    }
    
    SDK_POSTPROCESS_COMMAND_prepend = "do_fix_@RECIPE@; "
    

    This produces at the end the binary in the right directory