Community
    • Login

    NppExec compilation of AutoIt files, with includes...

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    15 Posts 3 Posters 4.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dave BinbinD
      Dave Binbin @PeterJones
      last edited by

      @PeterJones Thank you for your very constructive solution !
      I will integrate it right now.

      1 Reply Last reply Reply Quote 0
      • Dave BinbinD
        Dave Binbin @PeterJones
        last edited by

        @PeterJones I just wonder if the variable PROJECTMAINFILE defined in the makefile.nppexec script would be visible in the common NppExec script ? Infact I wonder if the makefile could only contain this variable declaration and put the rest back in the main NppExec script ? I suppose it does not work like an “include”. Or maybe Environement variables are “remanent” ?

        1 Reply Last reply Reply Quote 0
        • Michael VincentM
          Michael Vincent @Dave Binbin
          last edited by

          @Dave-Binbin said in NppExec compilation of AutoIt files, with includes...:

          Is there a way that the NppExec script would work from any file of my project ?

          You could set a NppExec global variable to the project root directory and then at the beginning of your compile script, just CD to that directory. I do something very similar - I have a “project” NppExec script which sets a project directory as an NppExec global variable and then all of my other scripts can see / use that directory (e.g., CD to it) to do stuff. So I can set my project directory to the one with the Makefile and then press my compile shortcut hotkey for my NppExec compile script from the header file in a different directory and it will compile the whole project.

          Cheers.

          Dave BinbinD 1 Reply Last reply Reply Quote 0
          • Dave BinbinD
            Dave Binbin @Michael Vincent
            last edited by

            @Michael-Vincent I do not understand how you implement this… By global NppExec variable, do you mean env_set variable ? Could you post a example ?

            Michael VincentM PeterJonesP 2 Replies Last reply Reply Quote 0
            • Michael VincentM
              Michael Vincent @Dave Binbin
              last edited by

              @Dave-Binbin said in NppExec compilation of AutoIt files, with includes...:

              By global NppExec variable, do you mean env_set variable ? Could you post a example ?

              Exactly:

              ENV_SET PROJECT_DIR=C:\my\proj\dir
              

              This way, if I spawn a shell (i.e., launch Command Prompt from NppExec) - that environment variable is present there as well.

              Cheers.

              Dave BinbinD 1 Reply Last reply Reply Quote 1
              • Dave BinbinD
                Dave Binbin @Michael Vincent
                last edited by

                @Michael-Vincent as I will not define a “makefile” in every project, I would like to compile by default the current NPP file $(FULL_CURRENT_PATH). So I wonder how I could test if the env variable exists or not ?

                if "$(SYS.PROJECTMAINFILE)" != "" then
                

                crashes if the env var is not defined…

                PeterJonesP 1 Reply Last reply Reply Quote 0
                • PeterJonesP
                  PeterJones @Dave Binbin
                  last edited by PeterJones

                  @Dave-Binbin ,

                  In your main script, start with

                  ENV_SET PROJECTMAINFILE="$(FULL_CURRENT_PATH)"
                  

                  then call the makefile – if the makefile defines that same variable, the value will be updated to whatever’s in the makefile, otherwise it will use the initial value from the main script.

                  (There might even be a way in NppExec to say “if file makefile.nppexec exists then npp_exec that file”, but I don’t know how to do file-exist tests in NppExec. @Michael-Vincent might.)

                  Dave BinbinD 1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @Dave Binbin
                    last edited by

                    @Dave-Binbin said in NppExec compilation of AutoIt files, with includes...:

                    By global NppExec variable

                    local vs global vs environment

                    • set local myvar=value – only seen in the active script
                    • set myglobal=value – seen in the active script and in subsequent scripts or the Console
                    • env_set myenv=value – seen in the active script, subsequent scripts, and the console as $(SYS.MYENV); seen in any subshells (like cmd.exe or powershell called from NppExec) as a normal environment variable, using appropriate shell syntax
                    1 Reply Last reply Reply Quote 1
                    • Dave BinbinD
                      Dave Binbin @PeterJones
                      last edited by

                      @PeterJones said in NppExec compilation of AutoIt files, with includes...:

                      ENV_SET PROJECTMAINFILE=“$(FULL_CURRENT_PATH)”

                      great, thanks !!!

                      do you know how I can test the file extension “.au3” of this file like I did in the original script,
                      in case there is no makefile and I point on a non-au3 file…

                      if $(EXT_PART) != .au3 goto BADFILE
                      
                      PeterJonesP 1 Reply Last reply Reply Quote 0
                      • PeterJonesP
                        PeterJones @Dave Binbin
                        last edited by PeterJones

                        @Dave-Binbin ,

                        do you know how I can test the file extension “.au3” of this file like I did in the original script,

                        By doing it like you did in the original script, or like I showed in my original “main NppExec script”.

                        main script

                        npp_saveall
                        ENV_SET PROJECTMAINFILE=$(FULL_CURRENT_PATH)
                        echo Starting from : $(FILE_NAME)
                        cd "$(CURRENT_DIRECTORY)"
                        if $(EXT_PART) != .au3 goto BADFILE
                        npp_exec makefile.nppexec   // this runs the "makefile" for the current project
                        "C:\Program Files (x86)\AutoIt3\Au3check.exe" "$(SYS.PROJECTMAINFILE)"
                        if $(EXITCODE) >= 2 goto EXITSCRIPT
                        "C:\Program Files (x86)\AutoIt3\AutoIt3.exe" /ErrorStdOut "$(SYS.PROJECTMAINFILE)"
                        goto EXITSCRIPT
                        :BADFILE
                        echo "Not an autoit file !!!"
                        :EXITSCRIPT
                        

                        makefile.nppexec

                        ENV_SET PROJECTMAINFILE=MyNameHere.au3
                        

                        —
                        EDIT: removed the quotes from the env_set, which puts quotes in the string

                        Dave BinbinD 1 Reply Last reply Reply Quote 1
                        • Dave BinbinD
                          Dave Binbin @PeterJones
                          last edited by

                          @PeterJones said in NppExec compilation of AutoIt files, with includes...:

                          EXT_PART

                          but in case the makefile exists, EXT_PART will not test the updated PROJECTMAINFILE but still the file from which I run the script, no ?

                          PeterJonesP 1 Reply Last reply Reply Quote 0
                          • PeterJonesP
                            PeterJones @Dave Binbin
                            last edited by PeterJones

                            @Dave-Binbin said in NppExec compilation of AutoIt files, with includes...:

                            but in case the makefile exists, EXT_PART will not test the updated PROJECTMAINFILE but still the file from which I run the script, no ?

                            Correct, $(EXT_PART) is always the extension portion of the active file in Notepad++, and it is not affected by the makefile at all.

                            So I may have misunderstood your original follow-on request. I think the best advice is “don’t set PROJECTMAINFILE to a non-.au3 file”.

                            Using the substring notation (see help set or Plugins > NppExec > Docs…) for variable setting, you might be able to extract the last three characters from $(SYS.PROJECTMAINFILE) into a separate variable, and use that for testing whether or not to skip. But that would take some research and experimenting; I think you should be able to read those documents as well as I can.

                            PeterJonesP 1 Reply Last reply Reply Quote 2
                            • PeterJonesP
                              PeterJones @PeterJones
                              last edited by

                              I got curious, and had a couple spare minutes, so I did the experiment.

                              set local e ~ substr -4 4 $(SYS.PROJECTMAINFILE)
                              if $(e) != .au3 goto BADFILE
                              

                              so if you put that immediately after the npp_exec makefile.nppexec and before the Au3check.exe call, it will do a test for the PROJECTMAINFILE extension as well.

                              1 Reply Last reply Reply Quote 2
                              • First post
                                Last post
                              The Community of users of the Notepad++ text editor.
                              Powered by NodeBB | Contributors