Wireshark-dev: Re: [Wireshark-dev] Attempted to build NSIS installer for 2.6.3

From: John Dill <John.Dill@xxxxxxxxxxxxxxxxx>
Date: Tue, 2 Oct 2018 18:58:56 +0000
I've been able to whittle my issue down to a specific spot in the build process.  For those trying to follow, I'm trying to build
2.6.3 on Windows in Cygwin (since I don't have control of the build environment).  I've been able to install an asciidoctor
program on Cygwin64 when ruby and rubygems package is installed through setup-x86_64.exe using

gem install asciidoctor
cp ~/bin/asciidoctor /bin

Then, I see that FindAsciidoctor is only supporting Chocolatey.  I compare against FindYACC which does work with my
Cygwin64 installation to FindAsciidoctor.

I add the following statements to FindAsciidoctor

#
# - Find Asciidoctor
# Sets:
#  ASCIIDOCTOR_EXECUTABLE
#

+INCLUDE(FindCygwin)
INCLUDE(FindChocolatey)

FIND_PROGRAM(ASCIIDOCTOR_EXECUTABLE
    NAMES
        asciidoctorj
        asciidoctor
    PATHS
        /bin
        /usr/bin
        /usr/local/bin
+      ${CYGWIN_INSTALL_PATH}/bin
        ${CHOCOLATEY_BIN_PATH}
    DOC "Path to Asciidoctor or AsciidoctorJ"
)

if(ASCIIDOCTOR_EXECUTABLE)
    # The AsciidctorJ wrapper script sets -Xmx256m. This isn't enough
    # for the User's Guide.
    set(_asciidoctorj_opts -Xmx800m $ENV{ASCIIDOCTORJ_OPTS})
    execute_process( COMMAND ${ASCIIDOCTOR_EXECUTABLE} --version OUTPUT_VARIABLE _ad_full_version )
    separate_arguments(_ad_full_version)
    list(GET _ad_full_version 1 ASCIIDOCTOR_VERSION)

    function(set_asciidoctor_target_properties _target)
    ...

At the 'list(GET _ad_full_version 1 ASCIIDOCTOR_VERSION)' command, I get a cmake error because the previous execute_process
command produces an _ad_full_version that's empty.  When I run 'asciidoctor --version' in my Cygwin prompt, I get

Asciidoctor 1.5.7.1 [https://asciidoctor.org]
Runtime Environment (ruby 2.3.6p384 (2017-12-14 revision 9808) [x86_64-cygwin])
(lc:UTF-8 fs:Windows-1252 in:UTF-8 ex:UTF-8)

If I put in a 'message( "ASCIIDOCTOR_EXECUTABLE " ${ASCIIDOCTOR_EXECUTABLE} )' I get something that looks like this

-- ZLIB libs: zlib
ASCIIDOCTOR_EXECUTABLE C:/cygwin64/bin/asciidoctor
CMake Error at cmake/modules/FindAsciidoctor.cmake:30 (list):
  list GET given empty list
Call Stack (most recent call first):
  docbook/CMakeLists.txt:15 (find_package)

I don't know exactly how execute_process is trying to run the asciidoctor program.

Any ideas why this execute_process CMake command isn't working?

Thanks,
John D.

________________________________________
From: John Dill
Sent: Tuesday, October 2, 2018 11:26 AM
To: Gerald Combs; Developer support list for Wireshark
Cc: graham.bloice@xxxxxxxxxxxxx
Subject: Re: [Wireshark-dev] Attempted to build NSIS installer for 2.6.3

>From: Gerald Combs <gerald@xxxxxxxxxxxxx>
>Sent: Monday, October 1, 2018 3:30 PM
>To: Developer support list for Wireshark; John Dill
>Subject: Re: [Wireshark-dev] Attempted to build NSIS installer for 2.6.3
>
>On 10/1/18 10:57 AM, John Dill wrote:
>> I'm trying to build an installer for Wireshark 2.6.3 on Windows using NSIS and I'm getting the following when I run
>>
>> msbuild /m /p:Configuration=RelWithDebInfo nsis_package.vcxproj
>>
>> Here is the commands I used before hand:
>>
>> set CYGWIN=nodosfilewarning
>
>The Windows build doesn't rely on shell scripts (or Cygwin for that matter) so this shouldn't be necessary.

As far as I understand it used to in the past, though it seems to have moved on from it.  I'm trying to update my local repo from
Wireshark 2.4.4 where my environment used to work fine to the current branch of 2.6.3.

>> set WIRESHARK_LIB_DIR=C:\Wireshark-win64-libs-2.6
>> set PLATFORM=win64
>> set QT5_BASE_DIR=C:\Qt\Qt5.8.0\5.8\msvc2015_64
>>
>> cd wsbuild64
>>
>> cmake -G "Visual Studio 14 2015 Win64" ..\wireshark-src
>> msbuild /m /p:Configuration=RelWithDebInfo /p:Platform=x64 Wireshark.sln (... ok ...)
>>
>> msbuild /m /p:Configuration=RelWithDebInfo nsis_package_prep.vcxproj (... ok ...)
>> msbuild /m /p:Configuration=RelWithDebInfo nsis_package.vcxproj
>>
>> ...
>>         Processing config: C:\Program Files (x86)\NSIS\nsisconf.nsh
>>         File: "C:\Users\DillJA\Desktop\wsbuild64\docbook\user-guide.chm" -> no files found.
>
>By default the Windows packages require user-guide.chm, which is an HTMLHelp file. The User's Guide itself is written in Asciidoctor >markup. Converting it to .chm requires Asciidoctor, xsltproc + DocBook XSL, and HTMLHelp Compiler.
>
>>         Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...]
>>               /oname=outfile one_file_only)
>>         Error in script "wireshark.nsi" on line 1173 -- aborting creation process
>>
>> Then it errors out with Build FAILED.
>>
>> I noticed that I can finish the NSIS installer script if I comment out the USER_GUIDE_DIR section, but I'm trying to install
>>the right packages and can't seem to get this error to go away without modifying the wireshark.nsi script.
>>
>> I notice in the cmake that the build script can't find asciidoctor even though ruby is installed on Cygwin64, and if I do a
>>'gem list --local', I see 'asciidoctor (1.5.7.1)'.
>
>What does `asciidoctor --version` return? I'm not sure if `gem install` results in something that you can run as a command on >Windows, e.g. via a .bat wrapper or a command line shim. If it does, you need to make sure the resulting command is in your PATH.

asciidoctor after setup_x86_64.exe for installing cygwin64 returns a '-bash: asciidoctor: command not found' cause there is no
package to install asciidoctor at least from the Cygwin setup-x86_64.exe program.

>> I tried to look for the packages asciidoctor in setup_x86_64.exe for Cygwin and couldn't find asciidoctorj, xsltproc, and
>>docbook-bundle.
>
>Those are all Chocolatey packages, not Cygwin. Asciidoctorj is a bundle containing JRuby, Asciidoctor, and associated utilities. You >shouldn't need it if you have a working plain-Ruby Asciidoctor. xsltproc is part of Cygwin's libxslt package. The closest corresponding >DocBook Cygwin package is docbook-xml45.

I know I selected docbook-xml45, but don't think I specifically picked up libxslt directly.  It may have been installed as a dependency.

The cmake script can find the following components

-- Could NOT find ASCIIDOCTOR (missing:  ASCIIDOCTOR_EXECUTABLE)
-- Found XSLTPROC: C:/cygwin64/bin/xsltproc.exe
-- Found HTMLHelp: C:/Program Files (x86)/HTML Help Workshop/hhc.exe

>> Can someone familiar with the Windows build offer some hints?  Do I need to switch from Cygwin to Chocolatey (which I
>>haven't tried yet)?
>
>I'd recommend Chocolatey. We've largely moved away from requiring Cygwin for Windows development and I'm not sure if anyone >has ever built the Asciidoctor documentation using Cygwin.

I'd have to get Chocolately approved by govt IT and not sure if or how long that would take.  Wouldn't be a problem if this was
for personal use.

I can use 'gem install asciidoctor' to create an asciidoctor and asciidoctor-safe that is placed in a local /bin directory in the user's
/home in Cygwin and when I run that '~/bin/asciidoctor --version' I get

Asciidoctor 1.5.7.1 [https://asciidoctor.org]
Runtime Environment (ruby 2.3.6p384 (2017-12-14 revision 9808) [x86_64-cygwin])
(lc:UTF-8 fs:Windows-1252 in:UTF-8 ex:UTF-8)

I believe this requires ruby and rubygems packages to be selected in Cygwin's setup-x86_64.exe program.

With admin privileges, I can move this to C:\cygwin64\bin so I can run asciidoctor --version from a cygwin prompt, but when I
run the CMake command, build script still doesn't find it.  Curious since it finds

-- YACC FOUND
-- YACC executable: C:/cygwin64/bin/bison.exe

And asciidoctor is in the same folder.

Comparing FindYACC.cmake and FindAsciidoctor.cmake shows that YACC has ${CYGWIN_INSTALL_PATH}/bin in its lists of
Paths.  Not sure why the directories in the FindYACC and FindAsciidoctor cmake scripts have different orders.

By adding '${CYGWIN_INSTALL_PATH}/bin' to FindAsciidoctor.cmake, cmake now finds asciidoctor.

-- Found ASCIIDOCTOR: C:/cygwin64/bin/asciidoctor

However, at the end of the script, it says Configuring incomplete, errors occurred!

Trying to run visual diff between CMakeOutput.log and CMakeError.log before I added ${CYGWIN_INSTALL_PATH}/bin to
FindAsciidoctor.cmake to after to try to see what's up.  Lots of diffs due to generated filenames, hard to make out what the
issue is.

That's where I'm at right now.

Thanks,
John D.