首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Flymake指定Makefile的位置

Flymake指定Makefile的位置
EN

Stack Overflow用户
提问于 2012-06-13 16:14:53
回答 1查看 660关注 0票数 2

我试图输入来自Haxe编译器的flymake输出,但我不知道如何告诉它make文件在哪里(理想情况下,我应该使用nxml文件)。到目前为止,我在Makefile中有这样的内容:

代码语言:javascript
运行
复制
BIN = ./bin
MAIN = com.wunderwafer.Main
SWF = wunderwafer.swf
SWFSETTINGS = -debug -swf-version 10 -swf-header 800:600:31
HFLAGS = -main $(MAIN) $(SWFSETTINGS) -cp ./src -swf $(BIN)/$(SWF)
HC = haxe

default: compile

compile: $(HC) $(HFLAGS)

clean:
    $(RM) -r $(BIN)/*

.PHONY: check-syntax

check-syntax:
    $(HC) $(HFLAGS)

如果我以后像这样运行它:

代码语言:javascript
运行
复制
$ make -k check-syntax

它产生预期的输出。但是,flymake无法找到Makefile (似乎是这样),因为我要检查的文件在src目录中更深。

配置flymake的方法是什么,以便它知道makefile在哪里?(更好的是,只需执行shell命令,因为编译Haxe代码的常用方法是使用*.nxml设置文件。

编辑:

看起来我离得越来越近了,非常感谢,但是flymake做了一些奇怪的事情,我不知道它到底做了什么,所以,下面是日志:

代码语言:javascript
运行
复制
received 65 byte(s) of output from process 967
file /home/wvxvw/projects/wafer/src/com/wunderwafer/map/Battlefield.hx, init=haxe-flymake-init
parsed 'Error : Invalid class name /home/wvxvw/projects/wafer/build.nxml', no line-err-info
file /home/wvxvw/projects/wafer/src/com/wunderwafer/map/Battlefield.hx, init=haxe-flymake-init
process 967 exited with code 1
cleaning up using haxe-flymake-cleanup
deleted file /tmp/flymake-Battlefield-855Cad.hx
Battlefield.hx: 0 error(s), 0 warning(s) in 0.15 second(s)
switched OFF Flymake mode for buffer Battlefield.hx due to fatal status CFGERR, warning Configuration error has occurred while running (haxe /home/wvxvw/projects/wafer/build.nxml)

我试图让它运行的命令如下所示:

代码语言:javascript
运行
复制
(defun haxe-flymake-get-cmdline (source base-dir)
  "Gets the cmd line for running a flymake session in a Haxe buffer.
This gets called by flymake itself. The output is a list of two elements:
the command to run, and a list of arguments.  The resulting command is like:

  $ haxe ${project-root}/build.nxml

"
  (message "base-dir %s" (file-name-as-directory base-dir))
  (list *haxe-compiler*
        (list
     (concat (file-name-as-directory base-dir)
         *build-nxml*))))

打印的消息如下所示:

代码语言:javascript
运行
复制
base-dir /home/wvxvw/projects/wafer/

因此,据我所知,得到的命令应该是:

haxe /home/wvxvw/projects/wafer/build.nxml

但是它看起来要么是在参数前面添加了什么,要么是后来,这使得Haxe编译器生成了错误"Error :无效类名“--如果有一个额外的参数,编译器就会将其理解为要编译的额外类,就会给出这个错误。但日志上没有显示要发送什么..。

编辑2:

我补充说:

代码语言:javascript
运行
复制
#!/usr/bin/env bash

echo "$@" > /home/wvxvw/projects/wafer/log

并且让flymake这个脚本而不是编译器,它只传递一个参数,正如我所期望的.叹息

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-13 16:24:11

这是个好问题。我不知道有一种简单的方法来添加一种新的“口味”的制造工具到飞制。我知道一种方法,这并不简单。这就是我对php codesniffer所做的工作--对于任何任意的make工具,它都是类似的。

首先,定义安装fn。

代码语言:javascript
运行
复制
(defun fly/phpcs-install ()
  "install flymake stuff for PHP CodeSniffer files."
  (add-to-list
   'flymake-err-line-patterns
   (list fly/phpcs-error-pattern 1 2 3 4))

  (let* ((key "\\.php\\'")
         (phpentry (assoc key flymake-allowed-file-name-masks)))
    (if phpentry
        (setcdr phpentry '(fly/phpcs-init fly/phpcs-cleanup))
      (add-to-list
       'flymake-allowed-file-name-masks
       (list key 'fly/phpcs-init 'fly/phpcs-cleanup)))))

这会将一个新条目安装到flymake中,输入.php作为文件扩展名。flymake列表中的条目基本上将文件扩展名与一对函数联系在一起,一个函数用于init,另一个用于清理。

init只返回要运行的命令以检查语法。这可以是一个shell命令,带有适当的参数。对于codesniffer,fn看起来如下所示:

代码语言:javascript
运行
复制
(defun fly/phpcs-init ()
  "initialize flymake for PHP using the PHP CodeSniffer tool."
  (let ((create-temp-f 'fly/phpcs-create-temp-intemp)
        (use-relative-base-dir t)
        (use-relative-source t)
        (get-cmdline-f 'fly/phpcs-get-cmdline)
        args
        temp-source-file-name)
    (setq temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f)
          args (flymake-get-syntax-check-program-args
                temp-source-file-name "."
                use-relative-base-dir use-relative-source
                get-cmdline-f))
    args))

呀!到兔子洞里去。get-cmdline fn如下所示:

代码语言:javascript
运行
复制
(defun fly/phpcs-get-cmdline (source base-dir)
  "Gets the cmd line for running a flymake session in a PHP buffer.
This gets called by flymake itself. The output is a list of two elements:
the command to run, and a list of arguments.  The resulting command is like:

  php.exe -d auto_append_file="" -d auto_prepend_file="" phpcs\scripts\phpcs --report=emacs file.php

"
  (list fly/phpcs-phpexe
        (list
         "-d" "auto_append_file=''"
         "-d" "auto_prepend_file=''"
         (concat (file-name-as-directory fly/phpcs-phpcs-dir)
                 "scripts\\phpcs")
         (concat "--standard="  fly/phpcs-standard)
         "--report=emacs"
         "-s" ;; show the fullname of the rule being violated
         (expand-file-name source))))

你可以在http://www.emacswiki.org/emacs/flyphpcs.el看到完整的elisp

也许还有更简单的方法。我只是不知道。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11019085

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档