I'm looking at the documentation for `INPUT-FILES` and `OUTPUT-FILES` and I see this:
``` (defgeneric output-files (operation component) (:documentation "Methods for this function return two values: a list of output files corresponding to this action, and a boolean indicating if they have already been subjected to relevant output translations and should not be further translated.
Methods on PERFORM *must* call this function to determine where their outputs are to be located. They may rely on the order of the files to discriminate between outputs. ")) (defgeneric input-files (operation component) (:documentation "A list of input files corresponding to this action.
Methods on PERFORM *must* call this function to determine where their inputs are located. They may rely on the order of the files to discriminate between inputs. ")) ```
Missing in the above is an explanation of how to tell `INPUT-FILES` whether to apply output translations or not.
Is this left to the author of the relevant `PERFORM` method? Or is there something one should do when writing a `PERFORM` method or an operator definition?
1. output-translations is for output-files, not for input-files—except of course that input-files often will in turn call output-files on a previous operation that it depends on.
2. as to output-files, it is the outermost method that applies the output translations—when the second value is NIL; the translations are assumed to already have been applied or subsumed when the second value is T.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org Foolishness is rarely a matter of lack of intelligence or even lack of information. — John McCarthy
On Fri, Jan 24, 2020 at 3:56 PM Robert Goldman rpgoldman@sift.info wrote:
I'm looking at the documentation for INPUT-FILES and OUTPUT-FILES and I see this:
(defgeneric output-files (operation component) (:documentation "Methods for this function return two values: a list of output files corresponding to this action, and a boolean indicating if they have already been subjected to relevant output translations and should not be further translated.
Methods on PERFORM *must* call this function to determine where their outputs are to be located. They may rely on the order of the files to discriminate between outputs. ")) (defgeneric input-files (operation component) (:documentation "A list of input files corresponding to this action.
Methods on PERFORM *must* call this function to determine where their inputs are located. They may rely on the order of the files to discriminate between inputs. "))
Missing in the above is an explanation of how to tell INPUT-FILES whether to apply output translations or not.
Is this left to the author of the relevant PERFORM method? Or is there something one should do when writing a PERFORM method or an operator definition?
The impetus for this question is, I have subclassed cl-source-file with org-source-file and have defined tangle-op (as a subclass of both sideway-operation and upward-operation). my perform method is:
(defmethod perform ((op tangle-op) (file org-source-file)) (let* ((input-file (first (input-files op file))) (output-file (first (output-files op file)))) (tangle input-file output-file)))
where (tangle input-file output-file) runs emacs in batch mode to produce a lisp source file.
How can I define my input-files and output-files methods to make the lisp source files appear in some build directory maintained by ASDF, rather than in my source tree?
thanks, Phoebe
On 24 Jan 2020, at 15:30, Phoebe Goldman wrote:
The impetus for this question is, I have subclassed cl-source-file with org-source-file and have defined tangle-op (as a subclass of both sideway-operation and upward-operation). my perform method is:
(defmethod perform ((op tangle-op) (file org-source-file)) (let* ((input-file (first (input-files op file))) (output-file (first (output-files op file)))) (tangle input-file output-file)))
where (tangle input-file output-file) runs emacs in batch mode to produce a lisp source file.
How can I define my input-files and output-files methods to make the lisp source files appear in some build directory maintained by ASDF, rather than in my source tree?
If I understand Faré correctly, you define output files normally, but then I believe you need to do the following:
``` (defmethod input-files ((op compile-op) (file org-source-file)) (output-files (asdf:make-operation 'tangle-op) file)) ```
If I'm right, this will ensure that `compile-op` sees the translated pathnames for the lisp files, instead of looking in the source directory.
On Fri, Jan 24, 2020 at 4:53 PM Robert Goldman rpgoldman@sift.info wrote:
(defmethod input-files ((op compile-op) (file org-source-file)) (output-files (asdf:make-operation 'tangle-op) file))
If I'm right, this will ensure that compile-op sees the translated pathnames for the lisp files, instead of looking in the source directory.
This should work, too. Either you add a dependency to prepare-op, or a dependency between prepare-op and compile-op; which methods you have to override slightly depends on how you define your operation classes.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org Statists seek the solution to all human problems in arbitrary political power and bureaucracies above society. They choose to ignore that when they are not all too human, politicians and bureaucrats are oh so inhuman.
I think you're trying to do something similar to what I do in https://github.com/brown/protobuf/blob/master/protobuf.asd The example file in https://github.com/brown/protobuf/blob/master/example/protobuf-example.asd uses it to translate a protocol buffer source file into Lisp code, which is then compiled. Both the Lisp intermediate code and its compiled version live in the directory where ASDF places compiled objects, not in your source code tree.
On Fri, Jan 24, 2020 at 4:53 PM Robert Goldman rpgoldman@sift.info wrote:
On 24 Jan 2020, at 15:30, Phoebe Goldman wrote:
The impetus for this question is, I have subclassed cl-source-file with org-source-file and have defined tangle-op (as a subclass of both sideway-operation and upward-operation). my perform method is:
(defmethod perform ((op tangle-op) (file org-source-file)) (let* ((input-file (first (input-files op file))) (output-file (first (output-files op file)))) (tangle input-file output-file)))
where (tangle input-file output-file) runs emacs in batch mode to produce a lisp source file.
How can I define my input-files and output-files methods to make the lisp source files appear in some build directory maintained by ASDF, rather than in my source tree?
If I understand Faré correctly, you define output files normally, but then I believe you need to do the following:
(defmethod input-files ((op compile-op) (file org-source-file)) (output-files (asdf:make-operation 'tangle-op) file))
If I'm right, this will ensure that compile-op sees the translated pathnames for the lisp files, instead of looking in the source directory.
Thanks, all!
I did the thing my dad suggested, and as far as I can tell everything is working now. All in all I have about half a page of code at https://github.com/gefjon/asdf-org-babel-tangle/blob/master/main.lisp https://github.com/gefjon/asdf-org-babel-tangle/blob/master/main.lisp which could probably be improved somewhat. I’d appreciate any glances and tips as to how I should be doing things.
thanks, Phoebe
Personally, I wouldn't bother with the (make-operation 'foo) and would use 'foo instead, letting the convenience methods do their job.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org
On Fri, Jan 24, 2020 at 5:51 PM Phoebe Goldman phoebe@goldman-tribe.org wrote:
Thanks, all!
I did the thing my dad suggested, and as far as I can tell everything is working now. All in all I have about half a page of code at https://github.com/gefjon/asdf-org-babel-tangle/blob/master/main.lisp which could probably be improved somewhat. I’d appreciate any glances and tips as to how I should be doing things.
thanks, Phoebe
On Fri, Jan 24, 2020 at 4:30 PM Phoebe Goldman phoebe@goldman-tribe.org wrote:
Interesting to see a new member of the "goldman tribe" hacking on ASDF!
The impetus for this question is, I have subclassed cl-source-file with org-source-file and have defined tangle-op (as a subclass of both sideway-operation and upward-operation). my perform method is:
(defmethod perform ((op tangle-op) (file org-source-file)) (let* ((input-file (first (input-files op file))) (output-file (first (output-files op file)))) (tangle input-file output-file)))
where (tangle input-file output-file) runs emacs in batch mode to produce a lisp source file.
Things should mostly "just work" thanks to selfward-operation causing the propagation of input-files to output-files. All you should have to do is declare the dependencies. You can't have the selfward-operation slot of compile-op depend on the component being operated on, so probably you should instead have prepare-op depend on tangle-op, and ensure that the input-files of prepare-op are the output-files of tangle-op.
I suggest you define and test your input-files and output-files methods at the SLIME REPL before you try to run ASDF on your system.
How can I define my input-files and output-files methods to make the lisp source files appear in some build directory maintained by ASDF, rather than in my source tree?
That should happen mostly automatically thanks to selfward-operation.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org My knowledge is finite. My ignorance is infinite.