port diagnose and xcode

Ryan Schmidt ryandesign at macports.org
Sun Mar 13 05:35:39 UTC 2022

On Mar 12, 2022, at 21:57, Richard L. Hamilton wrote:

> Is there a way one can see by examining Portfiles (ideally something that could be scanned for with e.g. a perl script), or preferably, with some "port" command, which ports require command line tools vs Xcode vs neither (albeit perhaps needing something to get a compiler port installed)?

Ports that require Xcode *to build* contain the line "use_xcode yes". There is no port command to see this information. You can use grep (or perl or some other tool) to search the Portfiles for this, however it is also possible for portgroups to set this, and then any port that uses that portgroup could also require Xcode. And Portfiles can use the full features of the Tcl programming language; possibly Xcode is only needed in some situations; you'd have to read the Portfile to see in what context (globally? in a subport? in a variant? based on some other condition?) "use_xcode yes" is specified.

Ports that require a MacPorts-provided compiler *to build* will declare a dependency on it. "port echo depends_build:(clang|gcc)" could be a starting point for identifying these ports, though you'll probably get false positives; not every port whose name contains "clang" or "gcc" is a compiler. And there are also compilers other than clang and gcc -- rust for example.

Compiled Mach-O files are architecture-specific. (They are for arm64, or x86_64, etc.) Ports that install only files that are not architecture-specific contain the line "supported_archs noarch" (or include a portgroup that contains that line). So these ports probably don't need a compiler *to build*. But some of them might still need other files provided by Xcode or the command line tools. There's no way to know without trying to build the port and see what happens.

Most of the remaining ports probably need a compiler from Xcode or the Xcode command line tools *to build*, though there could also be ports that just repackage binaries provided by upstream, in which case they don't need a compiler.

And as I said, if you get a binary of the port from MacPorts, then you don't need to build it at all, so you don't need any compiler. There are a variety of reasons why a binary might not be available. There isn't a port command to check in advance whether a binary is available. If you want to know, you can check the directory listings at https://packages.macports.org

More information about the macports-users mailing list