问题描述
到现在为止,我一直在使用保利/毫升,所有源$ C $ C文件都在同一目录下几个小项目。要建立这些项目,都是我必须做在REPL中运行以下命令:
Until now, I have been using Poly/ML for several small projects where all source code files are all in the same directory. To build these projects, all I had to do was run the following command in the REPL:
> PolyML.make "Main";
但现在我有一个项目,其规模使得它不切实际把所有源$ C $ C文件在同一目录下。要在REPL建设这些项目,我需要运行下面的命令:
But now I have a project whose scale makes it impractical to put all source code files in the same directory. To build these projects in the REPL, I need to run the following commands:
> PolyML.make "foo/Foo";
> PolyML.make "bar/Bar";
> PolyML.make "qux/Qux";
> PolyML.make "Main";
作为子系统数量的增长是不是非常实用。
which is not terribly practical as the number of subsystems grows.
有什么办法来自动化建设有嵌套的目录结构项目保利/ ML?
Is there any way to automate the process of building projects with nested directory structures in Poly/ML?
Pd积:我不得不看看这两个SML / NJ的编译管理和MLton的ML基础系统。毫无疑问,虽然功能强大,这些都是我的需要太复杂了。
P.D.: I have had a look at both SML/NJ's Compilation Manager and MLton's ML Basis system. While unquestionably powerful, these are too complicated for my needs.
推荐答案
将一个名为ml_bind.ML文件中的每个子目录,并且已经将这些文件建立该目录的组件。
Put a file called ml_bind.ML in each of the sub-directories and have those files build the component for that directory.
PolyML.make期望源文件的名称相匹配的成分(结构,签名或算符)的名称。因此,如果正在寻找一个名为foo的结构,它会期望在一个所谓的富,Foo.ML或Foo.sml文件富的来源。相反,如果它发现了一个名为foo的目录递归进入富目录,并使用ml_bind.ML文件为指导,以打造富的结构。通常情况下,富/ ml_bind.ML看起来像
PolyML.make expects the name of the source file to match the name of the component (structure, signature or functor). So if it is looking for a structure called "Foo" it will expect the source for "Foo" in a file called "Foo", "Foo.ML" or "Foo.sml". If instead it finds a directory called "Foo" it recursively enters the "Foo" directory and uses the "ml_bind.ML" file as the guide to build the "Foo" structure. Typically, "Foo/ml_bind.ML" will look like
structure Foo = FooFunctor(structure A = FooA and B = FooB);
与文件的富/ FooFunctor.ML,富/ FooA.ML和Foo / FooB.ML包含FooFunctor源FooA及FooB。
with files "Foo/FooFunctor.ML", "Foo/FooA.ML" and "Foo/FooB.ML" containing the source for "FooFunctor", "FooA" and "FooB" respectively.
您可以找到code,对于它当属保利/ ML源$ C $ C分发的一部分保利/ ML编译器这样的例子。
You can find examples of this in the code for the Poly/ML compiler which comes as part of the Poly/ML source code distribution.
这篇关于使用聚/ ML建立与嵌套目录结构工程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!