本文介绍了通用Lisp,asdf,测试,具有不同优化级别的编译系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真正想要的是内部测试定义:

What I really want is the in-source tests definitions:

假设我有一个asdf系统:

Let's suppose I have an asdf system:

(defsystem simple-system
  :serial t
  :components ((:module "src"
                        :components
                        ((:file "0-package")
                         (:file "1-tests-stubs")
                         (:file "2-code") ...))))

另一个测试第一个的系统:

And another system to test the first:

(defsystem simple-system-tests
  :serial t
  :components ((:module "src"
                        :components
                        ((:file "0-package")
                         (:file "1-tests-real")
                         (:file "2-code") ...))))

它们之间的唯一区别是在simple-system中我有1-tests-stubs,在simple-system-tests中我有1-tests-real.在1-tests-stubs中,我定义了一个宏(defmacro def-test (&rest _args) nil),该宏在1-tests-real中获得了真实"实现.

The only difference between them is that in the simple-system I have 1-tests-stubs where in the simple-system-tests I have 1-tests-real.In 1-tests-stubs I define a macro (defmacro def-test (&rest _args) nil) which gets a 'real' implementation in the 1-tests-real.

现在我想用(declare (optimize (safety 0) (debug 0) (speed 3)))编译simple-system,用相反的(declare (optimize (safety 3) (debug 3) (speed 0)))编译simple-system-tests.

Now I want to compile the simple-system with (declare (optimize (safety 0) (debug 0) (speed 3))) and the simple-system-tests with the opposite (declare (optimize (safety 3) (debug 3) (speed 0))).

我该怎么做(在这两个系统中放置位置以及如何以通用方式设置这些声明)?

How can I do that(where to put and how to set these declarations in a generic way for these two systems)?

如何在simple-system-tests中重用simple-system的定义(不要重复键入所有模块/组件的内容)?

How can I reuse the definition of simple-system in the simple-system-tests (not to repeat myself retyping all modules/components)?

而且我必须确保针对每个系统使用不同的优化级别重新编译所有文件.

And I must be sure that all files are recompiled with different optimization levels for each system.

此外,如果每个系统文件只有在更改后才重新编译(每个系统是否有自己的编译文件的副本?),这也很好.

Also, it would be great if for each system files will be recompiled only if they were changed(Own copy of compiled files for each system?).

推荐答案

优化级别

您可以尝试使用 :around-compile :

(defsystem simple-system
  :serial t
  :around-compile (lambda (next)
                    (proclaim '(optimize (debug 3)
                                         (safety 3)
                                         (debug 3)
                                         (speed 0)))
                    (funcall next))
  :components ((:module "src"
                        :components
                        (...))))

文档说(重点是我):

该操作是围绕系统中正在编译的每个文件执行的;您可以为模块中的所有文件或特定文件的:around-compile值添加阴影.

The action is performed around each file that is being compiled in the system; you can shadow the value of :around-compile for all files in a module, or specific files.

这篇关于通用Lisp,asdf,测试,具有不同优化级别的编译系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 13:43