Community
Participate
Working Groups
xdc.bld.BuildEnvironment.usePlatform() should be a supported API and have the @_nodoc attribute removed.
Here's the use case... In some Codec Engine package.bld scripts, for _some_ platforms, we can build an application configured with remote codecs. So, conditionally, we'd like to Pkg.addExectuable() based on the platform properties. The build scripts currently do something like this: for (all targets) { for (all platforms in each target's .platforms[] array) { /* always build a 'local' app */ Pkg.addExecutable(); /* conditionally build a 'remote' app, if I recognize the platform */ if (platform name matches "something I know to have a slave") { Pkg.addExecutable(); } } } Today, we're matching on a platform string name, but that has problems (since a customer could create their own 'mycompany.myplatform' platforms we won't know about). Using Build.usePlatform(), we can instead walk through a platform's properties, in the build model, to make this decision more reliably.
I removed nodoc tag in xdc-z36. However, I also noticed that some platforms don't behave well when loaded in an object model other than 'cfg'. For example, tms320x28 platform references Boot.configurePll, where Boot is ti.catalog.c2800.init.Boot, and all config parameters exists only in config world for non-metaonly modules. Therefore, calling usePlatform on tms320x28 in the build model causes a fatal error. It's a bu in the platform, but I am sure there are many such issues in various platforms. Also, usePlatform doesn't really fit the purpose of the function. Maybe we can change it to loadPlatform or something similar?
If we add a config parameter 'target' to IPlatform, we would be able to correctly instantiate a platform in both 'bld' and 'cfg' object model. In 'bld' model, the flow would be: Build.usePlatform(name, target)->Platform.create(name, {target: target}). In 'cfg' model, we add 'target' to 'params' in the generated cfg shell script before calling Platform.create(). An additional benefit would be to remove prog.build.target references in instance$meta$init functions, and replace them with 'target', and that would work same in both models.
Chris's use case doesn't really require use of usePlatform(). He would benefit more if we added a string 'deviceName' to IPlatform that he can use to identify what's the device on the platform. Right now, he has to use const structures DSP, GPP, GEM, etc. that are usually found in IPlatform modules but are not defined by the interface. I'll add back the @nodoc tag, and postpone the bug to 3.30. The only current user of usePlatform is ProductView view, so we will take that usage into account when defining any changes in Build.usePlatform.
Build.usePlatform is used in xdc.tools.xgconf.productview.Main to build an xdc.cfg.Program object as context for the IProductView modules.