0

我有下面的 Makefile 代码。如果我在命令行中运行“make”,它会创建 xpi 文件。但是当我运行“make install”命令时,它会显示“正在配置文件文件夹中安装。完成!” 但是找不到 .xpi ,而且路径中也没有我需要复制它的路径。

我昨天完成了这项工作,但今天我丢失了所有数据,需要从头开始,似乎我遗漏了一些东西。想不通是什么。

    # The name of the extension.
extension_name := helloworld@xulschool.com

# The UUID of the extension.
extension_uuid := helloworld@xulschool.com

# The name of the profile dir where the extension can be installed.
profile_dir := wiuxd07g.default

# The zip application to be used.
ZIP := zip

# The target location of the build and build files.
bin_dir := ../bin

# The target XPI file.
xpi_file := $(bin_dir)/$(extension_name).xpi

# The type of operating system this make command is running on.
os_type := $(patsubst darwin%,darwin,$(shell echo $(OSTYPE)))

# The location of the extension profile.
ifeq ($(os_type), darwin)
  profile_location := \
    ~/Library/Application\ Support/Firefox/Profiles/$(profile_dir)/extensions/\{$(extension_uuid)\}
else
  ifeq ($(os_type), linux-gnu)
    profile_location := \
      ~/.mozilla/firefox/$(profile_dir)/extensions/\{$(extension_uuid)\}
  else
    profile_location := \
      "$(subst \,\\,$(APPDATA))\\Mozilla\\Firefox\\Profiles\\$(profile_dir)\\extensions\\"
  endif
endif

# The temporary location where the extension tree will be copied and built.
build_dir := $(bin_dir)/build

# This builds the extension XPI file.
.PHONY: all
all: $(xpi_file)
    @echo
    @echo "Build finished successfully."
    @echo

# This cleans all temporary files and directories created by 'make'.
.PHONY: clean
clean:
    @rm -rf $(build_dir)
    @rm -f $(xpi_file)
    @echo "Cleanup is done."

# The sources for the XPI file.
xpi_built := install.rdf \
             chrome.manifest \
             $(wildcard content/*.js) \
             $(wildcard content/*.xul) \
             $(wildcard content/*.xml) \
             $(wildcard content/*.css) \
             $(wildcard skin/*.css) \
             $(wildcard skin/*.png) \
             $(wildcard locale/*/*.dtd) \
             $(wildcard locale/*/*.properties)

# This builds everything except for the actual XPI, and then it copies it to the
# specified profile directory, allowing a quick update that requires no install.
.PHONY: install
install: $(build_dir) $(xpi_built)
    @echo "Installing in profile folder: $(profile_location)"
    @cp -Rf ../bin/* $(profile_location)
    @echo "Installing in profile folder. Done!"
    @echo

$(xpi_file): $(build_dir) $(xpi_built)
    @echo "Creating XPI file."
    @$(ZIP) $(xpi_file) $(xpi_built)
    @echo "Creating XPI file. Done!"

$(build_dir)/%: %
    @cp -f $< $@

$(build_dir):
    @if [ ! -x $(build_dir) ]; \
  then \
    mkdir $(build_dir); \
  fi
4

1 回答 1

1

[你的愿望就是我的命令!]

  1. 在安装规则中使用$(bin_dir)而不是。../bin
  2. @当它不工作时,不要隐藏正在执行的内容。
  3. 研究cp正在执行的命令是否是您认为应该执行的命令。如果是,请检查源目录 ( ../bin) 是否包含您期望的文件。你cp-v(详细)模式吗?如果是这样,请使用它。

所以cp命令有效。无论文件夹中的内容是什么,它都会复制到另一个路径。但是没有要复制的 xpi 文件,所以它什么也不做。在某处它不会创建 xpi 文件。

  1. 从已执行的命令中删除更多@符号(您可以将它们留在echo命令上),以便您可以看到出了什么问题——为什么 xpi 文件没有按照您的预期构建。
  2. 或用于make -d从 make 获取(丰富的)调试输出。您可能想要使用类似的东西:

    make -d install 2>&1 | tee make.log
    

    所以你捕捉到 make 正在做什么。如果选项不是-d,请咨询您的man make或同等人员。

于 2013-04-11T13:56:45.580 回答