Is it possible to run only the preprocessor?

+1 vote
asked Jul 18, 2018 in To be sorted by andreas.kagedal (300 points)

Hi,

Iis it possible to just run the preprocessor and get back a new plantuml file without any macros, !include or !define etc

I guess that this would be very useful for testing when implementing the preprocessor features and therefor should already be implemented internally and hidden from use by normal users.

If so, would it be possible to enable this also for users?

The reason I need this is that I need to do a SHA checksum on my the plantuml files and they need to get different checksum depending on what is !included etc. So I need to do the checksum after the preprocessor has been applied.

/Andreas

related to an answer for: View results of preprocessor

1 Answer

+2 votes
answered Jul 18, 2018 by plantuml (295,000 points)

WIth last beta http://beta.plantuml.net/plantuml.jar you can have :

java -jar /path/to/plantuml.jar -preproc foo.txt

Is this what you are looking for ?

commented Jul 19, 2018 by albert (3,520 points)
Not bad at all, didn't try it yet on a big example yet but it also generates  an png file. The output is to the console which is a bit inconsistent and might interfere with other output (I would suggest an automatic file name like aa.pre or aa.pu.pre in case of aa.pu or the possibility of specifying a file name for it).
commented Jul 20, 2018 by plantuml (295,000 points)
Ok, here is a new beta http://beta.plantuml.net/plantuml.jar
- no PNG image generated
- file.preproc used to store output
Feedback welcome :-)
commented Jul 20, 2018 by albert (3,520 points)
Thanks., definitely an improvement.
commented Jul 20, 2018 by andreas.kagedal (300 points)
edited Jul 20, 2018 by andreas.kagedal
Great! I will try this! We run plantuml on a batch of files, so for us the best thing would be to get back one file for each input file. Proposal is to use a different file-extension, just like if a proper image was generated as albert proposes.

So if I did
java -jar /path/to/plantuml.jar -preproc foo1.pu foo2.pu foo3.pu

The result would be three files called
foo1.pu.pre, foo2.pu.pre, foo3.pu.pre

Perhaps .pp instead of .pre (.pp = preprocessed) ?
commented Jul 20, 2018 by albert (3,520 points)
Yes there is a separate file per input file in the newest beta file. They have, in you case,  the names foo1.preproc . foo2.preproc, foo3.preproc.
commented Jul 20, 2018 by andreas.kagedal (300 points)
sounds perfect. Looking forward to try this!
commented Jul 23, 2018 by anonymous
Very nice, I have tested it and it's exactly what I need. However, it takes almost as long time as if I would generate the image (svg). And I run it pointing out a directory with a lot of pu's. Time is crucial in this case.
commented Jul 23, 2018 by albert (3,520 points)
To get an idea how you are invoking the command can you give the command line you used to invoke the generation of the preprocessed file?
commented Jul 24, 2018 by anonymous
I tried two different:
java -jar <path-to-jar>/plantuml.jar - preproc <path-to-pu>/tmp_pu
containing around 20 pu-files and
java -jar <path-to-jar>/plantuml.jar - preproc <path-to-pu>/tmp_pu/ex1.pu <path-to-pu>/tmp_pu/ex2.pu <path-to-pu>/tmp_pu/ex3.pu
etc up to around 20 files.

I get the preproc-files but it takes around 20 seconds to generate.
commented Jul 24, 2018 by albert (3,520 points)
Would also be nice to have the time for 1 and e.g. 5 files. Why? It takes some time to start the plantuml task (jar has to be loaded, initialized etc.) and after this the code can be processed. I don't know if for each file a new thread is started (@plantuml?  some insights) or not. It also has to do with how plantuml handles the 'preproc'.
commented Jul 24, 2018 by plantuml (295,000 points)
Could you add -verbose flag and send us the result ?

java -jar <path-to-jar>/plantuml.jar -verbose -preproc <path-to-pu>/tmp_pu
containing around 20 pu-files and
java -jar <path-to-jar>/plantuml.jar -verbose -preproc <path-to-pu>/tmp_pu/ex1.pu <path-to-pu>/tmp_pu/ex2.pu <path-to-pu>/tmp_pu/ex3.pu
etc up to around 20 files.

Thanks!
commented Jul 24, 2018 by andreas.kagedal (300 points)
Just to clarify, I am the original poster for this question, but chrhe894 is my colleague and has taken over this from me. :-)

Great comunication! Thanks!
commented Jul 24, 2018 by anonymous
Running with:

java -jar plantuml.jar -preproc -verbose svg

where svg is the folder with .pu-files.


The log with -verbose and for each file (of 23 or something):

(18.996 - 401 Mo) 351 Mo - Setting current dir: <path_to_svg>/svg

(18.996 - 401 Mo) 351 Mo - Using default charset

(18.996 - 401 Mo) 351 Mo - Setting current dir: <path_to_svg>/svg

(18.996 - 401 Mo) 351 Mo - Using default charset

(18.997 - 401 Mo) 350 Mo - Using default charset
 

Then repeats pattern of around 10 times:

(18.997 - 401 Mo) 350 Mo - Setting current dir: <path_to_macros>/plantuml_macros

(18.997 - 401 Mo) 350 Mo - Using default charset

(18.998 - 401 Mo) 349 Mo - Using default charset

(18.998 - 401 Mo) 349 Mo - Setting current dir: <path_to_macros>/plantuml_macros

(18.998 - 401 Mo) 347 Mo - Setting current dir: <path_to_macros>/plantuml_macros

(18.999 - 401 Mo) 347 Mo - Using default charset

(18.999 - 401 Mo) 347 Mo - Using default charset

Then finishes with:

(20.247 - 389 Mo) 346 Mo - Export preprocessing source to <path_to_svg>/svg/<name>.preproc
Duration 25.036 seconds.
commented Jul 24, 2018 by albert (3,520 points)
@chrhe894 I was looking for the times of a run with 1, 5 and 20 files to see whether or not I see any pattern. I think the question from @plantuml is better regarding the required information in respect to '-verbose'.
...