Modify buildscripts to configure php.ini

This commit is contained in:
Jenny Tam 2018-04-20 14:57:24 -07:00
parent b34d5bdb8c
commit 7a3d6983cd
2 changed files with 38 additions and 9 deletions

View file

@ -123,8 +123,13 @@ class BuildDriver(object):
""" """
work_dir = os.path.dirname(os.path.realpath(__file__)) work_dir = os.path.dirname(os.path.realpath(__file__))
if self.source_path is None: get_source = False if self.source_path is None else True
# This will download from the specified branch on GitHub repo and copy the source if self.repo is None or self.branch is None:
# If GitHub repo or branch is None, get the source locally
get_source = True
if not get_source:
# This will download from the specified branch on GitHub repo and copy the source
self.util.download_msphpsql_source(repo, branch) self.util.download_msphpsql_source(repo, branch)
else: else:
source = self.source_path source = self.source_path
@ -164,7 +169,8 @@ class BuildDriver(object):
else: else:
self.util.copy_binary(ext_dir, dest_drivers, self.util.driver, '.dll') self.util.copy_binary(ext_dir, dest_drivers, self.util.driver, '.dll')
self.util.copy_binary(ext_dir, dest_symbols, self.util.driver, '.pdb') self.util.copy_binary(ext_dir, dest_symbols, self.util.driver, '.pdb')
return ext_dir
def build(self): def build(self):
"""This is the main entry point of building drivers for PHP. """This is the main entry point of building drivers for PHP.
@ -186,15 +192,15 @@ class BuildDriver(object):
logfile = self.util.get_logfile_name() logfile = self.util.get_logfile_name()
try: try:
self.build_extensions(root_dir, logfile) ext_dir = self.build_extensions(root_dir, logfile)
print('Build Completed') print('Build Completed')
except: except:
print('Something went wrong, launching log file', logfile) print('Something went wrong, launching log file', logfile)
# display log file only when not testing # display log file only when not testing
if not self.testing: if not self.testing:
os.startfile(os.path.join(root_dir, 'php-sdk', logfile)) os.startfile(os.path.join(root_dir, 'php-sdk', logfile))
os.chdir(work_dir) os.chdir(work_dir)
break exit(1)
if not self.testing: if not self.testing:
choice = input("Rebuild using the same configuration(yes) or quit (no) [yes/no]: ") choice = input("Rebuild using the same configuration(yes) or quit (no) [yes/no]: ")
@ -277,8 +283,10 @@ if __name__ == '__main__':
repo = 'Microsoft' repo = 'Microsoft'
if branch == '': if branch == '':
branch = 'dev' branch = 'dev'
else:
arch_version = arch_version.lower() repo = branch = None
arch_version = arch_version.lower()
arch = 'x64' if arch_version == 'yes' or arch_version == 'y' or arch_version == '' else 'x86' arch = 'x64' if arch_version == 'yes' or arch_version == 'y' or arch_version == '' else 'x86'
debug_mode = debug_mode.lower() debug_mode = debug_mode.lower()

View file

@ -445,21 +445,42 @@ class BuildUtil(object):
else: else:
binary = self.driver_name(driver, suffix) binary = self.driver_name(driver, suffix)
shutil.copy2(os.path.join(from_dir, binary), dest_dir) shutil.copy2(os.path.join(from_dir, binary), dest_dir)
if suffix == '.dll':
php_ini_file = os.path.join(from_dir, 'php.ini')
with open(php_ini_file, 'a') as php_ini:
php_ini.write('extension=' + binary + '\n');
def copy_binaries(self, sdk_dir, copy_to_ext): def copy_binaries(self, sdk_dir, copy_to_ext):
"""Copy the sqlsrv and/or pdo_sqlsrv binaries, including the pdb files, """Copy the sqlsrv and/or pdo_sqlsrv binaries, including the pdb files,
to the right place, depending on *copy_to_ext*. The default is to to the right place, depending on *copy_to_ext*. The default is to
copy them to the 'ext' folder. copy them to the 'ext' folder.
""" """
# Get php.ini file from php.ini-production
build_dir = self.build_abs_path(sdk_dir) build_dir = self.build_abs_path(sdk_dir)
php_ini_file = os.path.join(build_dir, 'php.ini')
print('Setting up php ini file', php_ini_file)
# Copy php.ini-production file to php.ini
phpsrc = self.phpsrc_root(sdk_dir)
shutil.copy(os.path.join(phpsrc, 'php.ini-production'), php_ini_file)
# Copy run-tests.php as well
phpsrc = self.phpsrc_root(sdk_dir)
shutil.copy(os.path.join(phpsrc, 'run-tests.php'), build_dir)
print('Copying the binaries from', build_dir) print('Copying the binaries from', build_dir)
if copy_to_ext: if copy_to_ext:
dest_dir = os.path.join(build_dir, 'ext') dest_dir = os.path.join(build_dir, 'ext')
ext_dir_line = 'extension_dir=ext\\'
else: else:
ext_dir_line = 'extension_dir=.\\'
# Simply make a copy of the binaries in sdk_dir # Simply make a copy of the binaries in sdk_dir
dest_dir = sdk_dir dest_dir = sdk_dir
print('Destination:', dest_dir) print('Destination:', dest_dir)
with open(php_ini_file, 'a') as php_ini:
php_ini.write(ext_dir_line + '\n')
# Now copy the binaries # Now copy the binaries
if self.driver == 'all': if self.driver == 'all':