查找预编译或编译macOS的Tcl / Tk框架

问题描述 投票:0回答:2

我是Tcl / Tk的初学者,但我已经需要在其中部署带有Tcl / Tk框架的.app(因为.app需要依赖于自己的Tcl / Tk版本而不是macOS标准和旧Tcl / TK)。有人可以指出我可以在哪里找到预编译的框架或者如何在macOS上编译它们的分步指南?

在这方面,半天的搜索工作并不是很有成效。我想我的需求并不是很特别,因为我看到很多.apps发布他们自己的Tcl / Tk框架。 (PS:我需要从Perl访问这些框架,但这不应该有任何区别。)

compilation frameworks tcl tk
2个回答
2
投票

这是我的构建脚本。您需要进行修改以满足您的需求。

  • 我对init.tcl进行了修改,以便Tcl将在适当的位置进行搜索,并且不会首先查看MacOS标准位置。脚本的这一部分将从Tcl / Tk 8.7开始。它还有一个非常特定于我的安装的路径('darwin 64 tcl lib'部分)。留下它不会伤害任何东西,或者你可以根据需要修改路径。
  • 我使应用程序可重定位,以便它可以从任何位置运行。这可能是一个安全问题。建议在安装后进行其他处理,以将库路径设置为静态位置。

我个人推荐Tcl / Tk 8.6.8,但它必须使用早期的XCode版本构建(我在Sierra上使用XCode Command Line Tools 9.2)。 MacOS Mojave正在进行各种错误修复。其他人可能会另有建议。

变量:

  • macosxminver:将为其编译Tcl / Tk的最早版本的MacOS。
  • INSTLOC:安装位置。将此指向目标目录以外的其他位置,然后将文件复制到目标目录。请注意,脚本完全删除了INSTLOC目录。
  • sver:简短的Tcl版本。使用它的唯一地方是SRCDIR定义。您可能不需要这个,具体取决于您的SRCDIR目录结构。
  • ver:Tcl版本号。
  • mver:Tcl主要版本号。
  • SRCDIR:Tcl / Tk源树所在的位置。出于此脚本的目的,我有一个具有以下结构的目录:

目录结构:

tcl868/
  tcl8.6.8/
  tk8.6.8/

TCL build.是:

#!/bin/bash

macosxminver=10.9
sver=868cp
ver=8.6.8
mver=8.6
tclmver=$mver
tkmver=$mver
SRCDIR=$HOME/t/tcl${sver}
INSTLOC=$HOME/t/localB

if [[ $1 != "" ]]; then
  INSTLOC=$1
fi

if [[ -d $INSTLOC ]]; then
  rm -rf $INSTLOC
fi
mkdir $INSTLOC

cd $SRCDIR

test -d build && rm -rf build

cd $SRCDIR
cd tcl${ver}
if [[ $? -eq 0 ]]; then
  f=library/init.tcl
  if [[ ! -f $f-orig ]]; then
    cp -pf $f $f-orig
  fi
  cp -pf $f-orig $f

  ed $f << _HERE_
/issafe/
i
    foreach Dir [list \$::tcl_library [file dirname \$::tcl_library]] {
        if { [string match *Tcl.framework* \$Dir] } {
          regsub Tcl.framework \$Dir Tk.framework Dir
          if {\$Dir ni \$::auto_path} {
            lappend ::auto_path \$Dir
          }
        }
    }

    # This needs to be at the end
    # The real wish executable is in an odd place.
    # Find the tcl directory in the path.
    set Dir [file dirname [info nameofexecutable]]
    if { [string match *MacOS* \$Dir] } {
      regsub {MacOS.*} \$Dir {MacOS} Dir
      set Dir [file join \$Dir darwin 64 tcl lib]
      lappend ::auto_path \$Dir
    } else {
      set Dir [file join [file dirname [file dirname \\
           [info nameofexecutable]]] lib]
    }

.
?catch
?set Dir
.,.+4 s/^/#/
/catch
.+1,.+5 s/^/#/
w
q
_HERE_

  make -C macosx \
      PREFIX="" \
      CFLAGS_OPTIMIZE="-O2 -mmacosx-version-min=${macosxminver}" \
      INSTALL_ROOT=$INSTLOC install

  cd $SRCDIR

  chmod u+w $INSTLOC/bin/tclsh${tclmver}
  install_name_tool -change \
      "/Library/Frameworks/Tcl.framework/Versions/${tclmver}/Tcl" \
      @executable_path/../Library/Frameworks/Tcl.framework/Versions/${tclmver}/Tcl \
      $INSTLOC/bin/tclsh${tclmver}
fi

cd $SRCDIR
cd tk${ver}
if [[ $? -eq 0 ]]; then
  make -C macosx \
      PREFIX="" \
      CFLAGS_OPTIMIZE="-O2 -mmacosx-version-min=${macosxminver}" \
      INSTALL_ROOT=$INSTLOC install
  cd $SRCDIR

  chmod u+w $INSTLOC/Library/Frameworks/Tk.framework/Versions/${tkmver}/Resources/Wish.app/Contents/MacOS/Wish
  install_name_tool -change \
      "/Library/Frameworks/Tk.framework/Versions/${tkmver}/Tk" \
      @executable_path/../../../../Tk \
      $INSTLOC/Library/Frameworks/Tk.framework/Versions/${tkmver}/Resources/Wish.app/Contents/MacOS/Wish
  install_name_tool -change \
      "/Library/Frameworks/Tcl.framework/Versions/${tclmver}/Tcl" \
      @executable_path/../../../../../../../Tcl.framework/Versions/${tclmver}/Tcl \
      $INSTLOC/Library/Frameworks/Tk.framework/Versions/${tkmver}/Resources/Wish.app/Contents/MacOS/Wish
fi

cd $SRCDIR
find $INSTLOC -type f -print0 | xargs -0 chmod u+w
exit 0

0
投票

编译几分钟后,我提议的脚本在Mojave上失败,出现以下错误:

ERROR: version conflict for package "Tcl": have 8.5.9, need 8.6-
If running this script from 'make html', set the NATIVE_TCLSH environment
variable to point to an installed tclsh8.6 (or the equivalent tclsh86.exe
on Windows).
make[3]: *** [html-tcl] Error 1
make[2]: *** [install-strip] Error 2
make[1]: *** [install-tcl] Error 2
make: *** [install-deploy] Error 2
tclbuild.sh: line 74: cd: /Users/xl/t/tcl869cp: No such file or directory
tclbuild.sh: line 83: cd: /Users/xl/t/tcl869cp: No such file or directory
tclbuild.sh: line 84: cd: tk8.6.9: No such file or directory
tclbuild.sh: line 103: cd: /Users/xl/t/tcl869cp: No such file or directory

我有最新的Tcl / Tk(8.6.9)资源和相同的文件夹结构,如上所示。

© www.soinside.com 2019 - 2024. All rights reserved.