Build Instructions for MySQL Shell


Dependencies
============

Mandatory
- cmake 2.8.12 (note: if you're using a very recent version of cmake and it
  doesn't work, try downgrading)
- gcc 5/VisualStudio 2015/clang 8
- MySQL client libraries built from sources
  (libmysqlclient, libmysqlxclient)
- zip (gnuwin32 in windows)
- python 3.7+

Optional
- gtest and gmock 1.8 (can be automatically downloaded)
- v8 8.5.210.20

Building From Source
====================
The following instructions build MySQL Shell with a minimal set of features,
additional features can be included by properly configuring the related
dependencies.

Preparation
-----------

MySQL
.....

The MySQL server sources are required to compile with the X protocol client library.

1) Download and unpack MySQL (8.0.11 or newer) source code
2) Configure MySQL server:

  mkdir mysql-server/bld
  cd mysql-server/bld
  cmake .. -DWITH_BOOST=<path to boost> -DWITH_SSL=system

  If boost is not available use the next options to let cmake download the
  required version:

  -DDOWNLOAD_BOOST=1 -DENABLE_DOWNLOADS=1


3) Compile the client libraries:

  cmake --build . --target mysqlclient
  cmake --build . --target mysqlxclient

  Alternatively you can build the entire server:

  make


Building the Shell
------------------

1) Download and unpack MySQL Shell source code
2) Configure and Build
Linux/OSX
       mkdir mysql-shell/bld
       cd bld
       cmake .. \
            -DMYSQL_SOURCE_DIR=../../mysql-server\
            -DMYSQL_BUILD_DIR=../../mysql-server/bld\
            -DHAVE_PYTHON=1\
            <other options>
       make -j4

Windows
     mkdir bld
     cd bld
     cmake .. -G "Visual Studio 16" \
          -DMYSQL_SOURCE_DIR=../../mysql-server\
          -DMYSQL_BUILD_DIR=../../mysql-server/bld\
          -DWITH_STATIC_LINKING=1 \
          -DHAVE_PYTHON=1\
          -DPYTHON_LIBRARY=<path_to_python_library> \
          -DPYTHON_INCLUDE_DIR=<python_src>\include;<python_src>\PC
    Open the generated solution mysh.sln and build it using Visual Studio.

* Note that in Windows, all dependencies must be built with compatible build
  settings, specially regarding Release vs Debug and /MD vs /MT.

Enabling JavaScript Support
---------------------------
JavaScript is enabled by satisfying the dependency with V8.
To build V8 follow the build V8 standard build instructions.
To support JavaScript on the MySQL Shell add the next flags to the CMake call:

-DHAVE_V8=1

-DV8_INCLUDE_DIR=<path_to_v8>/include
-DV8_LIB_DIR=<path_to_folder_containing_the_built_libraries>

Note that version 8.5.210.20 is needed and newer versions may not work.


Enabling Python Support
-----------------------
Python is enabled by satisfying the dependency with Python.
To support Python on the MySQL Shell add the next flags to the CMake call:

-DHAVE_PYTHON=1

Additional for windows only:
-DPYTHON_LIBRARY=<path_to_python_library>
-DPYTHON_INCLUDE_DIR=<python_src>\include;<python_src>\PC


Adding Unit Test Support
------------------------
GTest is required to enable Unit Testing. Make them available by adding the
following parameters to the cmake call.
-DWITH_TESTS=1
-DENABLE_DOWNLOADS=1

