如何將單個*.il和多個*.il轉換成單一*.cxt檔案

以下步驟是在Windows使用Allegro ,其版本為V16.5,其他的版本類似的方法

V16.6以下的版本編譯出的*.cxt檔案是32bit

V17.0以上的版本編譯出的*.cxt檔案是64bit,會在編譯的路徑下新增64bit的目錄,並將*.cxt放在此目錄下

1.確認電腦系統是否有安裝Valor ODB++程式,如下圖所示。
因為需要使用csh.exe程式,如果沒有安裝Valor程式時,網站搜索一下odb_inside_install.nt.v820.exe 並安裝

或是使用 tcsh-x64.exe

2.將檔案bc.bat,buildcxt.csh,cxtFuncs.il,startup.il 共四個檔案複製到Cadence的目錄下

新增bc64.bat, buildcxt64.csh 這兩個檔案主要是要編譯64bit的cxt檔案

3.編輯bc.bat檔案,將myskill名稱改為你自己的的檔案名稱,此檔案名稱就是cxt的檔案名稱,如myskill.cxt

4.編輯要轉換的*.il內容,將有這一行axlCmdRegister,標示為註解也就是在開頭加入";" ,並存檔

5.將要轉換的*.il檔案(單一檔案或多個檔案),全部複製到Cadence的目錄下

6.直接點選執行bc.bat,就會產生下圖,並在Cadence的目錄下新增一個myskill.cxt檔案

7.編輯allegro.ilinit檔案,在最後一行加入下面內容

unless(car(errset(loadContext("myskill.cxt")))
	errset(loadContext(strcat(getShellEnvVar("HOME") "\\pcbenv\\myskill.cxt"))
)
axlCmdRegister("autosize" 'RBG_autosize)

8.將myskill.cxt複製到你的skill目錄下或是 pcbenv目錄下

  將64bit這個目錄複製到你的skill目錄下或是 pcbenv目錄下


9.開啟allegro.exe,就可以在command下輸入autosize指令

 

以下是每個檔案的內容

bc.bat 檔案內容如下

@echo off
rem Build cxt command

csh buildcxt.csh myskill

pause

bc64.bat 檔案內容如下

@echo off
rem Build 64bit cxt command

tcsh-x64 buildcxt64.csh myskill

pause

buildcxt.csh 檔案內容如下

#!/bin/csh -f
# This builds a standard context see README.cxt for other set-up requirements
if ($#argv != 1) then
	echo "Usage: $0 <context name>"
	echo "Assumes that a startup.il file exists in current directory"
	echo " this file is used to specify the loading of other skill files"
	exit 1
endif

set theContext = $argv[1]

if (!(-e startup.il)) then
	echo "ERROR: Can't find standard.il file"
	exit 1
endif

il_allegro << EOF
(setSkillPath ".")
(setContext "$theContext")
(load "startup.il")
(defInitProc "$theContext" '${theContext})
(saveContext "$theContext.cxt")
(exit)
EOF

# /bin/rm -f AUTOSAVE.brd
echo ""
echo ""
echo ""
echo "Context will be found $theContext.cxt"
echo ""
exit 0

buildcxt64.csh 檔案內容如下

#!/bin/csh -f
# This builds a standard context see README.cxt for other set-up requirements
if ($#argv != 1) then
	echo "Usage: $0 <context name>"
	echo "Assumes that a startup.il file exists in current directory"
	echo " this file is used to specify the loading of other skill files"
	exit 1
endif

set version = "64"
set theContext = $argv[1]
set theContext64 = $argv[1]$version

if (!(-e startup.il)) then
	echo "ERROR: Can't find standard.il file"
	exit 1
endif

il_allegro << EOF
(setSkillPath ".")
(setContext "$theContext64")
(load "startup.il")
(defInitProc "$theContext64" '${theContext})
(saveContext "$theContext64.cxt")
(exit)
EOF

# /bin/rm -f AUTOSAVE.brd
echo ""
echo ""
echo ""
echo "Context will be found $theContext.cxt"
echo ""
exit 0

cxtfunc.il 檔案內容如下

;(
;---------------------------------------------------
; EXPORTED FUNCTIONS:
; buildContext : used to build a context
; getContext : used to load a context
;
; Mods -- fxf 8/25/95 to support local building of contextes
; 10/26/2010 修改成可以再Windows 下執行  By Sean hung
;---------------------------------------------------
;
; Constants
; ilcDftSourceFileDir : directory name where Skill source
; files reside
; ilcDftDeliveryDir : directory name where delivered
; context files are saved.
; (fxf) may be overridden before calling
;---------------------------------------------------
unless(boundp('ilcDftSourceFileDir) ilcDftSourceFileDir = "pvt\\etc\\context")
unless(boundp('ilcDftDeliveryDir) ilcDftDeliveryDir = "etc\\context")
(defun _parsePath (path)
	(let (lpath)
		(cond 
			(path 
				lpath = parseString(path "\\")
				(while (!rindex(car(lpath) "tools")) lpath = cdr(lpath))
				buildString(lpath "\\")
			)
			(t nil)
		)
	)
)
_stacktrace = 10
setSkillPath(strcat(". ~ " prependInstallPath("local")))
(cond ((getd 'dbSetPath) (dbSetPath ". ~")))
;
; loadCxt --
; Load a context and call its init function.
;
(defun loadCxt (cxt cxtPath)
	(let ((f (strcat (cdsGetInstPath cxtPath) "\\" cxt ".cxt")))
		(cond
			((null (isFile f)) nil)
			((null (loadContext f)) (printf "load of context %s failed\n" cxt))
			((null (callInitProc cxt)) (printf "init proc of context %s failed\n" cxt))
			(t (printf "Loading context %s\n" cxt))
		)
	)
)
;
; buildContext --
; Build a new context, even if one exists.
;
(defun buildContext (cxt @rest targs)
	(let (cxtPath srcPath fullCxtPath)
		cxtPath = ilcDftDeliveryDir
		(setq srcPath (strcat ilcDftSourceFileDir "\\" cxt))
		;printf("srcPath =  %s\n" srcPath) ; ----- by sean 
		;; <fxf>: doesn't allow local contextes so use above 2 lines
		;;(cond ((car targs) (setq cxtPath (car targs)))
		;;((setq cxtPath (_parsePath (_iliGetActualCxtPath cxt))) t)
		;;(t (setq cxtPath ilcDftDeliveryDir)))
		;;(cond ((cadr targs) (setq srcPath (cadr targs)))
		;;((setq srcPath (_parsePath (_iliGetActualSrcPath cxt))) t)
		;;(t (setq srcPath (strcat ilcDftSourceFileDir "/" cxt))))
		fullCxtPath = cdsGetInstPath(cxtPath)
		;printf("srcPath =  %s\n" fullCxtPath) ; ---- by sean
		(deleteFile (strcat fullCxtPath "\\" cxt ".cxt"))
		(deleteFile (strcat fullCxtPath "\\" cxt ".al"))
		(deleteFile (strcat fullCxtPath "\\" cxt ".ini"))
		(updateContext cxt cxtPath srcPath)
		(updateAutoloads cxt cxtPath srcPath)
	)
)
;
; updateContext --
; If there is source and it is newer than the context,
; then build a new context. Otherwise if there is no source
; use the existing context.
;
(defun updateContext (cxt cxtPath srcPath)
	(cond 
		((isDir (cdsGetInstPath srcPath)) (makeCapContext cxt cxtPath srcPath))
		((loadCxt cxt cxtPath) t)
		(t (printf "Can't find context %s\n" cxt ))
	)
)

(defun updateAutoloads (cxt cxtPath srcPath)
	(let 
		((afile (sprintf nil "%s\\%s.al" (cdsGetInstPath srcPath) cxt))
		(ifile (sprintf nil "%s\\%s.ini" (cdsGetInstPath srcPath) cxt)))
		(cond 
			((isFile ifile) 
				(system (sprintf nil "copy %s %s" ifile (cdsGetInstPath cxtPath)))
			)
			((isFile afile) 
				(system (sprintf nil "copy %s %s" afile (cdsGetInstPath cxtPath)))
			)
			(t t)
		)
	)
)
;
; getContext --
; Load the context if it exists, otherwise build it.
;
(defun getContext (cxt @rest targs)
	(let (cxtPath srcPath)
		(cond 
			((car targs) (setq cxtPath (car targs)))
			((setq cxtPath (_parsePath (_iliGetActualCxtPath cxt))) t)
			(t (setq cxtPath ilcDftDeliveryDir))
		)
		(cond 
			((cadr targs) (setq srcPath (cadr targs)))
			((setq srcPath (_parsePath (_iliGetActualSrcPath cxt))) t)
			(t (setq srcPath (strcat ilcDftSourceFileDir "\\" cxt)))
		)
		(cond 
			((loadCxt cxt cxtPath) t)
			((isDir cxt (cdsGetInstPath srcPath)) (makeCapContext cxt cxtPath srcPath))
			(t (printf "Can't get context %s\n" cxt))
		)
	)
)

(sstatus trapDefs ilcDftDeliveryDir)
(sstatus lazyComp nil)

startup.il 檔案內容如下

;-----------------------------------------------------------
;startup.il
foreach(file rexMatchList(".*\\.il$" getDirFiles("."))
	; don't load myself -- bad idea
	when( nequal(file, "startup.il")
		load(file)
	)
)
;-----------------------------------------------------------

 

文章標籤
全站熱搜
創作者介紹
創作者 熊熊 的頭像
熊熊

熊熊的部落格

熊熊 發表在 痞客邦 留言(7) 人氣(1,434)