如何使用xpidl(header.py,typelib.py)

bas*_*sil 5 xul xulrunner xpcom firefox-addon

我正在编写一个XPCOM组件.我有我的idl文件,它非常简单,只包含以下内容:

#include "nsISupports.idl"

[scriptable, uuid(4ead-ba5c-49c9-beb2=64209c7699a)]
interface nsIPageSummary : nsISupports
{
    boolean saveSummary(in nsIDOMDocument document,
                        out unsigned long numLinks,
                        out unsigned long numImages);
};
Run Code Online (Sandbox Code Playgroud)

我下载了xulrunner sdk,并尝试通过以下命令从包含上述文件的目录(nsIPageSummary.idl)生成我的标头:

〜/ xulrunner-sdk/sdk/bin/header.py --cachedir =〜/ xulrunner-sdk/idl/-o nsIPageSummary.h nsIPageSummary.idl

运行时,我收到以下消息:

$ ~/xulrunner-sdk/sdk/bin/header.py --cachedir=~/xulrunner-sdk/idl -o nsIPageSummary.h nsIPageSummary.idl 
Traceback (most recent call last):
  File "~/xulrunner/xulrunner-sdk/sdk/bin/header.py", line 497, in <module>
    idl.resolve(options.incdirs, p)
  File "~/xulrunner/xulrunner-sdk/sdk/bin/xpidl.py", line 285, in resolve
    p.resolve(self)
  File "~/xulrunner-sdk/sdk/bin/xpidl.py", line 255, in resolve
    raise IDLError("File '%s' not found" % self.filename, self.location)
xpidl.IDLError: error: File 'nsISupports.idl' not found, nsIPageSummary.idl line 1:0
#include "nsISupports.idl"
Run Code Online (Sandbox Code Playgroud)

我已经验证文件存在于上面的文件夹中.我使用MDN链接(https://developer.mozilla.org/en-US/docs/XPIDL/pyxpidl)作为指南,但它没有多大帮助.我如何使用这些工具?

Wla*_*ant 5

您应该定义~/xulrunner-sdk/idl/为包含路径:

~/xulrunner-sdk/sdk/bin/header.py -I ~/xulrunner-sdk/idl/ ...
Run Code Online (Sandbox Code Playgroud)

另一方面,缓存目录应该是文档建议的一些临时目录.