Skip to content

Commit

Permalink
Start moving win-setup to PowerShell.
Browse files Browse the repository at this point in the history
Add win-setup.ps1, which duplicates the following tasks performed by
config.nmake + Makefile.nmake + win-setup.sh:

- Create the windows library directory.
- Download files.
- Download and unpack zip files.
- Check and set current-tag.txt

Don't verify applications or libraries. CMakeLists.txt does that.

Update the Developer's Guide.

Have POWERSHELL_COMMAND use dot sourcing instead of "-File", which
appears to be a synonym for "-IgnoreTheExitStatusReturnedByThisScript".

This removes our dependencies on unzip and wget and reduces our dependency
on bash.

Change-Id: Ia9def24acbe183d81b9d477fa42e655e4a3a6614
Reviewed-on: https://code.wireshark.org/review/7990
Reviewed-by: Graham Bloice <[email protected]>
Petri-Dish: Graham Bloice <[email protected]>
Tested-by: Petri Dish Buildbot <[email protected]>
Reviewed-by: Gerald Combs <[email protected]>
  • Loading branch information
geraldcombs committed Apr 14, 2015
1 parent 311758a commit 1404605
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 20 deletions.
39 changes: 30 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ cmake_policy(SET CMP0011 OLD)
# Policy since 2.8.1
cmake_policy(SET CMP0015 NEW)

#Where to find local cmake scripts
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)

# If our target platform is enforced by our generator, set
# WIRESHARK_TARGET_PLATFORM accordingly. Otherwise use
# %WIRESHARK_TARGET_PLATFORM%.

if(WIN32)
find_package(PowerShell REQUIRED)

if("${CMAKE_GENERATOR}" MATCHES "Win64")
set(WIRESHARK_TARGET_PLATFORM win64)
set(PROCESSOR_ARCHITECTURE amd64)
Expand All @@ -49,6 +54,7 @@ if(WIN32)
set(WIRESHARK_TARGET_PLATFORM $ENV{WIRESHARK_TARGET_PLATFORM})
endif()

# Sanity check
if(DEFINED ENV{PLATFORM})
string(TOLOWER $ENV{PLATFORM} _vs_platform)
else()
Expand All @@ -62,10 +68,30 @@ if(WIN32)
message(FATAL_ERROR "The PLATFORM environment variable (${_vs_platform})"
" doesn't match the generator platform (${WIRESHARK_TARGET_PLATFORM})")
endif()
endif(WIN32)

#Where to find local cmake scripts
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
# Download third-party libraries
file (TO_NATIVE_PATH ${CMAKE_SOURCE_DIR}/tools/win-setup.ps1 _win_setup)
file (TO_NATIVE_PATH "$ENV{WIRESHARK_BASE_DIR}/wireshark-${WIRESHARK_TARGET_PLATFORM}-libs" _ws_lib_dir)
if(MSVC12)
set(_vsversion_args "-VSVersion 12")
elseif(MSVC11)
set(_vsversion_args "-VSVersion 11")
elseif(MSVC10)
set(_vsversion_args "-VSVersion 10")
endif()
# Is it possible to have a one-time, non-cached option in CMake? If
# so, we could add a "-DFORCE_WIN_SETUP" which passes -Force to
# win-setup.ps1.
execute_process(
COMMAND ${POWERSHELL_COMMAND} "${_win_setup}" -Destination "${_ws_lib_dir}" -Platform ${WIRESHARK_TARGET_PLATFORM} ${_vsversion_args}
RESULT_VARIABLE _win_setup_failed
)
if (${_win_setup_failed})
message(FATAL_ERROR "Windows setup (win-setup.ps1) failed.")
endif()

# XXX Add a dependency on ${_ws_lib_dir}/current_tag.txt?
endif(WIN32)

include(UseCustomIncludes)
ADD_CUSTOM_CMAKE_INCLUDE()
Expand Down Expand Up @@ -542,10 +568,7 @@ set(PythonInterp_FIND_VERSION 2)
set(Python_ADDITIONAL_VERSIONS 3)
set(YACC_REQUIRED TRUE)

if (WIN32)
set(PACKAGELIST ${PACKAGELIST} PowerShell)
set(PowerShell_REQUIRED TRUE)
else()
if (NOT WIN32)
set(M_REQUIRED TRUE)
endif()

Expand Down Expand Up @@ -711,8 +734,6 @@ foreach(PACKAGE ${PACKAGELIST})
set(PACKAGE_VAR "HTML_VIEWER")
elseif(${PACKAGE} STREQUAL "Perl")
set(PACKAGE_VAR "PERL")
elseif(${PACKAGE} STREQUAL "PowerShell")
set(PACKAGE_VAR "POWERSHELL")
else()
set(PACKAGE_VAR ${PACKAGE})
endif()
Expand Down
5 changes: 4 additions & 1 deletion cmake/modules/FindPowerShell.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ find_package_handle_standard_args(POWERSHELL DEFAULT_MSG POWERSHELL_EXECUTABLE)

set(_powershell_command "POWERSHELL_COMMAND-NOTFOUND")
if(POWERSHELL_FOUND)
set(_powershell_command "${POWERSHELL_EXECUTABLE}" -NoProfile -NonInteractive -executionpolicy bypass -File)
# Calling a script using "-File" doesn't properly return exit codes.
# Use dot sourcing instead
# https://connect.microsoft.com/PowerShell/feedback/details/777375/powershell-exe-does-not-set-an-exit-code-when-file-is-used
set(_powershell_command "${POWERSHELL_EXECUTABLE}" -NoProfile -NonInteractive -executionpolicy bypass .)
endif()
set(POWERSHELL_COMMAND ${_powershell_command}
CACHE STRING "Command suitable for running PowerShell scripts."
Expand Down
8 changes: 3 additions & 5 deletions docbook/wsdg_src/WSDG_chapter_quick_setup.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ Navigate to the required Category/Package row and, if the package
has a "Skip" item in the "New" column, click on the "Skip" item
so it shows a version number for:

// Only used by win-setup.sh
* Archive/unzip
* Archive/unzip (not needed if using CMake)

* Devel/bison (or install Win flex-bison - see Chocolatey below)

Expand All @@ -210,8 +209,7 @@ so it shows a version number for:

* Utils/patch (only if needed) (may be Devel/patch instead)

// Only used by win-setup.sh
* Web/wget
* Web/wget (not needed if using CMake)

* asciidoc

Expand All @@ -237,7 +235,7 @@ Alternatively you can install Cygwin and its packages using Chocolatey:
----
PS$>choco install cygwin
PS$>choco install cyg-get
PS$>choco install unzip wget asciidoc [...] -source cygwin
PS$>choco install sed asciidoc [...] -source cygwin
----

Chocolatey installs Cygwin in 'C:\tools\cygwin' by default.
Expand Down
12 changes: 7 additions & 5 deletions docbook/wsdg_src/WSDG_chapter_tools.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Chocolatey installs Cygwin in 'C:\tools\cygwin' by default.
One or more Cygwin packages can be installed using "-source cygwin":

----
PS$>choco install unzip wget asciidoc -source cygwin
PS$>choco install sed asciidoc -source cygwin
----

[[ChToolsGNUChain]]
Expand Down Expand Up @@ -1149,7 +1149,8 @@ installation should be straightforward.

=== Windows: GNU wget (optional)

GNU wget is used to download files from the internet using the command line.
GNU wget is used by the Nmake toolchain to download files from the internet
using the command line. It is not needed when building with CMake.

GNU wget is available for most of the UNIX-like platforms and as the wget
package from the <<ChToolsCygwin,Cygwin setup>> and also using Chocolatey.
Expand All @@ -1161,7 +1162,7 @@ PS$> choco install wget -source cygwin
----

You will only need wget if you want to use the Windows automated library
download, see <<ChLibsSetup>>for details.
download. See <<ChLibsSetup>>for details.

If GNU wget isn't already installed or available as a package for your platform
(well, for Windows it is available as a Cygwin package), you can get it at
Expand All @@ -1186,12 +1187,13 @@ If you are unsure about the settings, you might ask your system administrator.
=== Windows: GNU unzip (optional)

GNU unzip is used to, well, unzip the zip files downloaded using the wget tool.
As with wget it is not needed when building with CMake.

GNU unzip is available for most of the UNIX-like platforms and as the unzip
package from the <<ChToolsCygwin,Cygwin setup>>.

You will only need unzip, if you want to use the Windows automated library
download, see <<ChLibsSetup>>for details.
You will only need unzip if you want to use the Windows automated library
download. See <<ChLibsSetup>>for details.

If GNU unzip isn't already installed or available as a package for your platform
(well, for Windows it is available as a Cygwin package), you can get it at
Expand Down
Loading

0 comments on commit 1404605

Please sign in to comment.