http://www.perlmonks.org?node_id=1006636

gepebril69 has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm using pp to create executables of my projects to make them easily transferred to other machines and a little more difficult to steel my code.

As the projects get bigger it takes longer before executables are created, what I would like and not have found yet is that executables are only created when the source (pl) has been changed. So executables are not recreated when no changes to sources have been made.

Is this possible within pp, or is there a way to do this?

sample, of code:

pp -o name.exe --link=C:\strawberry\c\bin\libmysql_.dll -x -c -vvv name.pl

Replies are listed 'Best First'.
Re: pp only to create executable when source has changed
by LanX (Saint) on Dec 01, 2012 at 20:22 UTC
    > or is there a way to do this?

    checking last-change-time and/or with diff?

    Cheers Rolf

      I'm using Windows, I have to due to drivers

Re: pp only to create executable when source has changed
by hippo (Bishop) on Dec 01, 2012 at 23:13 UTC
    Is there a reason not to use make for this?

      Thx for the help

      I'm not sure what you mean by this, I'm creating multiple executables. Every executable is doing it's own task and its started on a regular basis by the Windows taskmanager. Although the scripts are several hundred lines of code it takes easily 45 minutes to build the corresponding executable. I created a batch script to create all executables, what I like to see that it only creates new executables if the related source .pl file has changed

      Is that possible with make? Does it record the creation date of the source?

        Is that possible with make?

        Yes. From Make_(software)#Behavior:

        Make is typically used to build executable programs and libraries from source code. Generally though, any process that involves transforming a source file to a target result (by executing arbitrary commands) is applicable to Make.
        Does it record the creation date of the source?

        No, it doesn’t need to:

        Make decides whether a target needs to be regenerated by comparing file modification times. This solves the problem of avoiding the building of files which are already up to date... (idem)

        You can build GNU Make for various platforms, including Windows.

        Hope that helps,

        Athanasius <°(((><contra mundum

Re: pp only to create executable when source has changed
by space_monk (Chaplain) on Dec 02, 2012 at 08:57 UTC

    Adding more information to the succinct comment by hippo, I would have thought that all your projects would use Makefiles to be built in any event, so why not simply add a rule to build the .exe file using pp whenever the parent source file has changed?

    A Monk aims to give answers to those who have none, and to learn from those who know more.
Re: pp only to create executable when source has changed
by muba (Priest) on Dec 02, 2012 at 19:44 UTC
    my %files = "source1.pl" => " source1.exe", "source2.pl" => " source2.exe", ... "source375.pl" => " source375.exe", ); while (my ($source, $exe) = keys %files) { my ($source, $exe) = splice(@ARGV, 0, 2); if (-m $source > -m $exe) { system "pp -o $exe --link=C:\strawberry\c\bin\libmysql_.dll -x + -c -vvv $source"; } }
      Sorry but

          if (-m $source > -m $exe) {

      where do I find the docs of this -m function?

      UPDATE:

           while (my ($source, $exe) = keys %files) {

      did you really mean keys? not each?

               my ($source, $exe) = splice(@ARGV, 0, 2);

      and now your directly overwriting the loop vars?

      Cheers Rolf

        You raise valid points. -m should have been -M, keys should have been each, and that splice line shouldn't be there at all. My bad.

      Aha, I get it, you make a script that checks the date of modification of a file. If the modification time of the .pl (perl script) is greater than the corresponding .exe (executable file), you generate a new executable.

      Never looked at the problem from this angle. But this wont help you 100% on the dependencies, like when I require a .pl, which store the genetal subroutines. So now I get the use and power of a make file

      So final stage is finding a good example of a makefile using PAR:Packer, so pp instead of cc so I can parse my code into)

        Has anyone an idea of how to do this as GNU make seems to be quite complex for a newbie like me and all examples are in C.