Announcement

Collapse
No announcement yet.

!define and environment variable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • !define and environment variable

    Hi all,

    My installation requires a version number that is !define'd in the NSIS script. Is it possible to read a value from an environment variable (or pass a value to the compiler via command line) *at compile time*?

    This would allow my "create release" batch to pass the version number to the NSIS script, thus freeing me from the need to set the version number there manually (which is rather error-prone).

    Or is it, by some way, possible the other way round? Can the compiler "return" the version number to the calling batch?

    I couldn't find anything useful when searching the forum and the net. Any idea or pointer would be greatly appreciated.

    Regards,

    Steve

  • #2
    I don't know whether NSIS can do it or not, someone else may provide an answer, but there are other preprocessors. My free PPWIZARD will certainly allow you to do this.

    Bye
    Dennis

    Comment


    • #3
      Use the command line option /D to define you version.

      makensis.exe /DVERSION=2 file.nsi

      Make sure your script doesn't over right it though by doing the following.

      !ifndef VERSION
      !define VERSION 1
      !endif

      Comment


      • #4
        I couldn't find anything useful when searching the forum and the net. Any idea or pointer would be greatly appreciated.
        Well, you didn't search hard enough... It's in the FAQ on the top of the page
        NSIS FAQ | NSIS Home Page | Donate $
        "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

        Comment


        • #5
          Works perfect, thanks a lot.

          I must have been blind, though ... shouldn't have worked so late last night!

          Steve

          Comment


          • #6
            no problem and i know the feeling, hehe

            Comment


            • #7
              Originally posted by dselkirk
              Use the command line option /D to define you version.

              makensis.exe /DVERSION=2 file.nsi

              Make sure your script doesn't over right it though by doing the following.

              !ifndef VERSION
              !define VERSION 1
              !endif
              Ok, you just lost me. I am using code similar to what you said above, and it's not working. It shouldn't enter the ifndef unless it's not defined, right?

              Lookie here:

              I call

              Makensis /V3 /NOCONFIG /HDRINFO /CD /DMAJORVER=2 /DMINORVER=2 /DMICROVER=0 TechDemo.nsi

              In the nsi, I have this code:

              !ifndef ${MAJORVER}
              !warning "MAJORVER not defined."
              !define MAJORVER 0
              !endif

              !ifndef ${MINORVER}
              !warning "MINORVER not defined."
              !define MINORVER 0
              !endif

              !ifndef ${MICROVER}
              !warning "MICROVER not defined."
              !define MICROVER 0
              !endif

              But get this error!:

              warning: !warning: MAJORVER not defined. (TechDemo.nsi:35)

              !define: "MAJORVER" already defined!
              Error in script "TechDemo.nsi" on line 36 -- aborting creation process

              Am I overlooking something?

              Comment


              • #8
                You should call the ifndef like this:

                !ifndef MAJORVER

                ${MAJORVER} translates to its value and because of that NSIS tries to see if 2 is not defined, which is of course true.
                NSIS FAQ | NSIS Home Page | Donate $
                "I hear and I forget. I see and I remember. I do and I understand." -- Confucius

                Comment


                • #9
                  OK, in retrospect that should have been obvious. Thank you!

                  Comment

                  Working...
                  X
                  😀
                  🥰
                  🤢
                  😎
                  😡
                  👍
                  👎