Skip to content
Tcl Source Code Artifact [9cc46f975e]
Login

Artifact [9cc46f975e]

Artifact 9cc46f975ecebbf7902fd12225d3ab0a5d9dcfbbf4945de524fe346b2e4d23b0:



CommandName: platform ManualSection: n Version: 1.0.4 TclPart: platform TclDescription: Tcl Bundled Packages Keywords:

Name

platform - System identification support code and utilities

Synopsis

::: {.synopsis} ::: [package]{.cmd} [require]{.sub} [platform]{.lit} [1.0.10]{.optlit}

[platform::generic]{.cmd} [platform::identify]{.cmd} [platform::patterns]{.cmd} [identifier]{.arg} :::

Description

The fBplatformfR package provides several utility commands useful for the identification of the architecture of a machine running Tcl.

Whilst Tcl provides the fBtcl_platformfR array for identifying the current architecture (in particular, the platform and machine elements) this is not always sufficient. This is because (on Unix machines) fBtcl_platformfR reflects the values returned by the fBunamefR command and these are not standardized across platforms and architectures. In addition, on at least one platform (AIX) the fBtcl_platform(machine)fR contains the CPU serial number.

Consequently, individual applications need to manipulate the values in fBtcl_platformfR (along with the output of system specific utilities) - which is both inconvenient for developers, and introduces the potential for inconsistencies in identifying architectures and in naming conventions.

The fBplatformfR package prevents such fragmentation - i.e., it establishes a standard naming convention for architectures running Tcl and makes it more convenient for developers to identify the current architecture a Tcl program is running on.

Commands

platform::identify : This command returns an identifier describing the platform the Tcl core is running on. The returned identifier has the general format fIOSfR-fICPUfR. The fIOSfR part of the identifier may contain details like kernel version, libc version, etc., and this information may contain dashes as well. The fICPUfR part will not contain dashes, making the preceding dash the last dash in the result.

platform::generic : This command returns a simplified identifier describing the platform the Tcl core is running on. In contrast to fBplatform::identifyfR it leaves out details like kernel version, libc version, etc. The returned identifier has the general format fIOSfR-fICPUfR.

platform::patterns fIidentifierfR : This command takes an identifier as returned by fBplatform::identifyfR and returns a list of identifiers describing compatible architectures.

Example

This can be used to allow an application to be shipped with multiple builds of a shared library, so that the same package works on many versions of an operating system. For example:

package require platform
# Assume that app script is .../theapp/bin/theapp.tcl
set binDir [file dirname [file normalize [info script]]]
set libDir [file join $binDir .. lib]
set platLibDir [file join $libDir [platform::identify]]
load [file join $platLibDir support[info sharedlibextension]]