Changeset 134511


Ignore:
Timestamp:
Mar 27, 2015, 9:15:41 PM (9 years ago)
Author:
cal@…
Message:

base: provide macports::version as pure Tcl, and macports_version in Portfile ctxt

Use a pure-Tcl macports::version rather than using C to read a Tcl variable and
pass it back to Tcl(?!). Also make macports::version available in Portfiles as
macports_version so Portfiles can check for the base version and return helpful
error messages rather than failing.

Location:
trunk/base/src/macports1.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/macports1.0/macports.c

    r64998 r134511  
    4141#include "sysctl.h"
    4242
    43 static int
    44 macports__version(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[])
    45 {
    46         if (objc != 1) {
    47                 Tcl_WrongNumArgs(interp, 1, objv, NULL);
    48                 return TCL_ERROR;
    49         }
    50         Tcl_SetObjResult(interp, Tcl_GetVar2Ex(interp, "macports::autoconf::macports_version", NULL, 0));
    51         return TCL_OK;
    52 }
    53 
    5443int
    5544Macports_Init(Tcl_Interp *interp)
     
    5746        if (Tcl_InitStubs(interp, "8.4", 0) == NULL)
    5847                return TCL_ERROR;
    59         Tcl_CreateObjCommand(interp, "macports::version", macports__version, NULL, NULL);
    6048        Tcl_CreateObjCommand(interp, "get_systemconfiguration_proxies", GetSystemConfigurationProxiesCmd, NULL, NULL);
    6149        Tcl_CreateObjCommand(interp, "sysctl", SysctlCmd, NULL, NULL);
  • trunk/base/src/macports1.0/macports.tcl

    r134508 r134511  
    8181}
    8282
     83##
     84# Return the version of MacPorts you are running
     85#
     86# This proc never fails and always returns the current version in the format
     87# major.minor.patch. Note that the value of patch will not be meaningful for
     88# trunk releases, but we guarantee that it will compare to be greater than any
     89# released versions from the same major.minor.x series. You should use the
     90# MacPorts-provided Tcl extension "vercmp" to do version number comparisons on
     91# the return value of this function.
     92proc macports::version {} {
     93    return ${macports::autoconf::macports_version}
     94}
     95
    8396# Provided UI instantiations
    8497# For standard messages, the following priorities are defined
     
    13271340
    13281341    # Export some utility functions defined here.
     1342    $workername alias macports_version macports::version
    13291343    $workername alias macports_create_thread macports::create_thread
    13301344    $workername alias getportworkpath_from_buildpath macports::getportworkpath_from_buildpath
Note: See TracChangeset for help on using the changeset viewer.