Skip to content

Commit

Permalink
Removed source indexing code from build scripts (#1132)
Browse files Browse the repository at this point in the history
  • Loading branch information
yitam committed May 4, 2020
1 parent 1aca278 commit 7e58d1a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 58 deletions.
12 changes: 6 additions & 6 deletions buildscripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
To build extensions for
1. PHP 7.0* or PHP 7.1*
* install Visual Studio 2015 and make sure C++ tools are enabled.
2. PHP 7.2*
2. PHP 7.2* or above
* install Visual Studio 2017, including Visual C++ toolset and the Windows SDK components.

To use the sample build scripts `builddrivers.py` and `buildtools.py`, install Python 3.x and Git for Windows (which comes with Visual Studio 2017). If `git` is unrecognized in a regular command prompt, make sure the environment path is set up correctly.
Expand All @@ -14,7 +14,7 @@ To use the sample build scripts `builddrivers.py` and `buildtools.py`, install P

You must first be able to build PHP 7.* without including our PHP extensions. For help with building PHP 7.0* or PHP 7.1* in Windows, see the [official PHP website](https://wiki.php.net/internals/windows/stepbystepbuild). For PHP 7.2 or above, visit [PHP SDK page](https://github.com/OSTC/php-sdk-binary-tools) for new instructions.

The Microsoft Drivers for PHP for SQL Server have been compiled and tested with PHP 7.0.* and 7.1.* using Visual C++ 2015 as well as PHP 7.2.1 using Visual C++ 2017 v15.5.
The Microsoft Drivers for PHP for SQL Server have been compiled and tested with PHP 7.0.* and 7.1.* using Visual C++ 2015 as well as PHP 7.2+ using Visual C++ 2017 v15.*.

### Manually building from source

Expand Down Expand Up @@ -45,7 +45,7 @@ The sample build scripts, `builddrivers.py` and `buildtools.py`, can be used to

#### Overview

When asked to provide the PHP version, you should enter values like `7.1.7`. If it's alpha, beta, or RC version, make sure the name you provide matches the PHP tag name without the prefix `php-`. For example, for PHP 7.2 beta 2, the tag name is `php-7.2.0beta2`, so you will enter `7.2.0beta2`. Visit [PHP SRC]( https://github.com/php/php-src) to find the appropriate tag names.
When asked to provide the PHP version, you should enter values like `7.3.17`. If it's alpha, beta, or RC version, make sure the name you provide matches the PHP tag name without the prefix `php-`. For example, for PHP 7.4 beta 2, the tag name is `php-7.4.0beta2`, so you will enter `7.4.0beta2`. Visit [PHP SRC]( https://github.com/php/php-src) to find the appropriate tag names.

PHP recommends to unzip the PHP SDK into the shortest possible path, preferrably somewhere near the root drive. Therefore, this script will, by default, create a `php-sdk` folder in the C:\ drive, and this `php-sdk` directory tree will remain unless you remove it yourself. For ongoing development, we suggest you keep it around. The build scripts will handle updating the PHP SDK if a new version is available.

Expand All @@ -57,7 +57,7 @@ PHP recommends to unzip the PHP SDK into the shortest possible path, preferrably

3. Interactive mode:
* Type `py builddrivers.py` to start the interactive mode. Use lower cases to answer the following questions:
* PHP Version (e.g. `7.1.7` or `7.2.1`)
* PHP Version
* 64-bit?
* Thread safe?
* Driver?
Expand All @@ -68,8 +68,8 @@ PHP recommends to unzip the PHP SDK into the shortest possible path, preferrably
4. Use Command-line arguments
* Type `py builddrivers.py -h` to get a list of options and their descriptions
* For example,
* `py builddrivers.py --PHPVER=7.2.1 --ARCH=x64 --THREAD=nts --DRIVER=sqlsrv --SOURCE=C:\local\source`
* `py builddrivers.py --PHPVER=7.1.13 --ARCH=x86 --THREAD=ts --DEBUG`
* `py builddrivers.py --PHPVER=7.4.5 --ARCH=x64 --THREAD=nts --DRIVER=sqlsrv --SOURCE=C:\local\source`
* `py builddrivers.py --PHPVER=7.2.30 --ARCH=x86 --THREAD=ts --DEBUG`

5. Based on the given configuration, if the script detects the presence of the PHP source directory, you can choose whether to rebuild, clean or superclean:
* `rebuild` to build again using the same configuration (32 bit, thread safe, etc.)
Expand Down
56 changes: 5 additions & 51 deletions buildscripts/builddrivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import argparse
import subprocess
from buildtools import BuildUtil
from indexsymbols import *

class BuildDriver(object):
"""Build sqlsrv and/or pdo_sqlsrv drivers with PHP source with the following properties:
Expand All @@ -40,8 +39,6 @@ class BuildDriver(object):
make_clean # a boolean flag - whether make clean is necessary
source_path # path to a local source folder
testing # whether the user has turned on testing mode
srctool_path # path to source indexing tools (empty string by default)
tag_version # tag version for source indexing (empty string by default)
"""

def __init__(self, phpver, driver, arch, thread, debug, repo, branch, source, path, testing, no_rename):
Expand All @@ -53,8 +50,6 @@ def __init__(self, phpver, driver, arch, thread, debug, repo, branch, source, pa
self.testing = testing
self.rebuild = False
self.make_clean = False
self.srctool_path = ''
self.tag_version = ''

def show_config(self):
print()
Expand Down Expand Up @@ -118,34 +113,6 @@ def get_local_source(self, source_path):
print("The path provided is invalid. Please re-enter.")
return source

def index_all_symbols(self, ext_dir, srctool_path, tag_version):
"""This takes care of indexing all the symbols
:param ext_dir: the directory where we can find the built extension(s)
:param srctool_path: the path to the tools for source indexing
:param tag_version: tag version for source indexing
:outcome: all symbols will be source indexed
"""
work_dir = os.path.dirname(os.path.realpath(__file__))
os.chdir(srctool_path)

if self.util.driver == 'all':
driver = 'sqlsrv'
pdbfile = os.path.join(ext_dir, self.util.driver_name(driver, '.pdb'))
print('Indexing this symbol: ', pdbfile)
run_indexing_tools(pdbfile, driver, tag_version)
driver = 'pdo_sqlsrv'
pdbfile = os.path.join(ext_dir, self.util.driver_name(driver, '.pdb'))
print('Indexing this symbol: ', pdbfile)
run_indexing_tools(pdbfile, driver, tag_version)
else:
driver = self.util.driver
pdbfile = os.path.join(ext_dir, self.util.driver_name(driver, '.pdb'))
print('Indexing this symbol: ', pdbfile)
run_indexing_tools(pdbfile, driver, tag_version)

os.chdir(work_dir)

def build_extensions(self, root_dir, logfile):
"""This takes care of getting the drivers' source files, building the drivers.
If dest_path is defined, the binaries will be copied to the designated destinations.
Expand Down Expand Up @@ -185,12 +152,6 @@ def build_extensions(self, root_dir, logfile):
# ext_dir is the directory where we can find the built extension(s)
ext_dir = self.util.build_drivers(self.make_clean, dest, logfile)

# Do source indexing only if the tag and tools path are both specified
if self.tag_version is not '' and self.srctool_path is not '':
print('Source indexing begins...')
self.index_all_symbols(ext_dir, self.srctool_path, self.tag_version)
print('Source indexing done')

# Copy the binaries if a destination path is defined
if self.dest_path is not None:
dest_drivers = os.path.join(self.dest_path, self.util.major_version(), self.util.arch)
Expand All @@ -212,12 +173,10 @@ def build_extensions(self, root_dir, logfile):

return ext_dir

def build(self, srctool_path, tag_version):
def build(self):
"""This is the main entry point of building drivers for PHP.
For development, this will loop till the user decides to quit.
:param srctool_path: the path to the tools for source indexing
:param tag_version: tag version for source indexing
"""
self.show_config()

Expand All @@ -234,10 +193,6 @@ def build(self, srctool_path, tag_version):

logfile = self.util.get_logfile_name()

# Save source indexing details
self.srctool_path = srctool_path
self.tag_version = tag_version

try:
ext_dir = self.build_extensions(root_dir, logfile)
print('Build Completed')
Expand Down Expand Up @@ -280,7 +235,7 @@ def validate_input(question, values):
################################### Main Function ###################################
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--PHPVER', help="PHP version, e.g. 7.1.*, 7.2.* etc.")
parser.add_argument('--PHPVER', help="PHP version, e.g. 7.4.* etc.")
parser.add_argument('--ARCH', choices=['x64', 'x86'])
parser.add_argument('--THREAD', choices=['nts', 'ts'])
parser.add_argument('--DRIVER', default='all', choices=['all', 'sqlsrv', 'pdo_sqlsrv'], help="driver to build (default: all)")
Expand All @@ -291,8 +246,6 @@ def validate_input(question, values):
parser.add_argument('--TESTING', action='store_true', help="turns on testing mode (default: False)")
parser.add_argument('--DESTPATH', default=None, help="an alternative destination for the drivers (default: None)")
parser.add_argument('--NO_RENAME', action='store_true', help="drivers will not be renamed(default: False)")
parser.add_argument('--SRCIDX_PATH', default='', help="the path to the tools for source indexing (default: '')")
parser.add_argument('--TAG_VERSION', default='', help="the tag version for source indexing (default: '')")

args = parser.parse_args()

Expand Down Expand Up @@ -354,4 +307,5 @@ def validate_input(question, values):
path,
testing,
no_rename)
builder.build(args.SRCIDX_PATH, args.TAG_VERSION)

builder.build()
2 changes: 1 addition & 1 deletion buildscripts/buildtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def determine_compiler(self, sdk_dir, vs_ver):

def compiler_version(self, sdk_dir):
"""Return the appropriate compiler version based on PHP version."""
if self.vc is '':
if self.vc == '':
VC = 'vc14'
version = self.version_label()
if version >= '72': # Compiler version for PHP 7.2 or above
Expand Down

0 comments on commit 7e58d1a

Please sign in to comment.