Azure / azure-sdk-tools

Tools repository leveraged by the Azure SDK team.
MIT License
109 stars 166 forks source link

Unable to create and upload new APIView listing for Embedded C #1681

Open ahsonkhan opened 3 years ago

ahsonkhan commented 3 years ago

Here are the steps: Clone the embedded C SDK repo, open up powershell, create the ast and zip, and upload it to api view.

cd .\GitHub\Fork\azure-sdk-for-c\

cd .\sdk\inc

clang "azure\iot\az_iot_common.h" "azure\iot\az_iot_hub_client.h" "azure\iot\az_iot_provisioning_client.h" -Xclang -ast-dump=json -I E:\GitHub\Fork\azure-sdk-for-c\sdk\inc -I "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29115\include" > az_iot.ast

Compress-Archive "E:\GitHub\Fork\azure-sdk-for-c\sdk\inc\az_iot.ast" E:\GitHub\Fork\azure-sdk-for-c\sdk\inc\az_iot.zip

image

cc @praveenkuttappan, @pakrym

ahsonkhan commented 3 years ago

cc @RickWinter

praveenkuttappan commented 3 years ago

Upload is failing with out of mem error on APIView side. I will look into it.

ahsonkhan commented 3 years ago

If I run the clang command in Windows Powershell to generate the AST, it adds a UTF-16 LE BOM to the AST file (0xFF 0xFE), and that is causing the api view tool to get tripped up. image

Running it in bash which doesn't add the bom, or manually removing the BOM from the ast before zipping and uploading seems to fix the issue.

clang "azure/iot/az_iot_common.h" "azure/iot/az_iot_hub_client.h" "azure/iot/az_iot_provisioning_client.h" -Xclang -ast-dump=json -I E:/GitHub/Fork/azure-sdk-for-c/sdk/inc -I "C:/Program Files (x86)\Microsoft Visual Studio/2019/Preview/VC/Tools/MSVC/14.28.29115/include" > az_iot_with_pnp_bash.ast

It would be useful if the JSON processing code was resilient against the presence of such BOMs and validated/skipped it.

kurtzeborn commented 3 years ago

@praveenkuttappan, sounds like this is just a bug in ApaView handling uploads with different BOMs more gracefully. If this turns into feature work specific to supporting embedded C in ApiView, let's get this over to the language team for follow up.