3 Replies Latest reply on Jan 3, 2019 1:08 AM by PriyaM_16

    conditional build based on platform

    NaFi_2915566

      I am trying to build based on platform and having a hard time finding what to check.

      For now it is the BlinkLed example but we will need it later when we create the platform for our own board.

      ideally I'd like to

      #ifdef CYW943907AEVAL1F
         #define WICED_LEDG WICED_GPIO_5
         #define WICED_LEDR WICED_GPIO_16
      #elif defined(Quicksilver_EVL)
         #define WICED_LEDG WICED_GPIO_28
         #define WICED_LEDR WICED_GPIO_29
      #else
         #error "must choose a platform"
      #endif
      

       

      but the only define I can find is in config.mk

      PLATFORM                  := CYW943907AEVAL1F

      which is almost impossible to check in a preprocessor directive.

       

      Does anybody know a better define or way to check which platform we're building for?

        • 1. Re: conditional build based on platform
          PriyaM_16

          Do you want this based on the build string that in specified in make target? Or we can explore an easier option to define a MACRO based on platform.

          Defining a MACRO as:

          #define PLATFORM_1

           

          Taking decision based on this MACRO

          #if PLATFORM_1

          //do something for platform1

          #else

          //do something else

          #endif /*PLATFORM_1*/

          • 2. Re: conditional build based on platform
            NaFi_2915566

            PriyaM_16

            This: "Do you want this based on the build string that in specified in make target?"

            I'd like to automate this as much as possible and not change my code for the platforms.

             

            I am not sure of the order of execution. 

            I could add a new macro into each platform (in board.h or in one of the MK files) if it will propagate to my code.

            It would require some care when doing SDK updates.

            • 3. Re: conditional build based on platform
              PriyaM_16

              Kindly follow the MACRO based approach as explained in the earlier response. You will have to define the MACRO in your application .c/.h file. If the MACRO is defined at multiple locations, the compiler will throw a warning regarding the locations where the MACRO is defined. 

              2 of 2 people found this helpful