Build Instructions for MySQL Shell


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

Mandatory
- cmake 3.5.1 (note: if you're using a very recent version of cmake and it
  doesn't work, try downgrading)
- gcc 10/VisualStudio 2019/clang 10
- MySQL client libraries built from sources
  (libmysqlclient, libmysqlxclient)
- zip (gnuwin32 in windows)
- python 3.8+
- libssh 0.9.2

Optional
- gtest and gmock 1.8 (can be automatically downloaded)
- GraalVM 23.0.1

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


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 mysql-shell/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\
          -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 native Polyglot API library
(From GraalVM) dependency.

To build The native Polyglot API library follow the instructions at
ext/polyglot/README.txt

To support JavaScript on the MySQL Shell add the following flag to the CMake call:

-DBUNDLED_POLYGLOT_DIR=<Path>

Where Path is the path to the folder containing the native Polyglot API library
and headers

Note that version 23.0.1 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 following 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
