Skip to content

Commit

Permalink
Modify buildscripts to configure php.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
yitam committed Apr 20, 2018
1 parent b34d5bd commit 7a3d698
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
24 changes: 16 additions & 8 deletions buildscripts/builddrivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,13 @@ def build_extensions(self, root_dir, logfile):
"""
work_dir = os.path.dirname(os.path.realpath(__file__))

if self.source_path is None:
# This will download from the specified branch on GitHub repo and copy the source
get_source = False if self.source_path is None else True
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)
else:
source = self.source_path
Expand Down Expand Up @@ -164,7 +169,8 @@ def build_extensions(self, root_dir, logfile):
else:
self.util.copy_binary(ext_dir, dest_drivers, self.util.driver, '.dll')
self.util.copy_binary(ext_dir, dest_symbols, self.util.driver, '.pdb')


return ext_dir

def build(self):
"""This is the main entry point of building drivers for PHP.
Expand All @@ -186,15 +192,15 @@ def build(self):
logfile = self.util.get_logfile_name()

try:
self.build_extensions(root_dir, logfile)
ext_dir = self.build_extensions(root_dir, logfile)
print('Build Completed')
except:
print('Something went wrong, launching log file', logfile)
# display log file only when not testing
if not self.testing:
os.startfile(os.path.join(root_dir, 'php-sdk', logfile))
os.chdir(work_dir)
break
os.chdir(work_dir)
exit(1)

if not self.testing:
choice = input("Rebuild using the same configuration(yes) or quit (no) [yes/no]: ")
Expand Down Expand Up @@ -277,8 +283,10 @@ def validate_input(question, values):
repo = 'Microsoft'
if branch == '':
branch = 'dev'

arch_version = arch_version.lower()
else:
repo = branch = None

arch_version = arch_version.lower()
arch = 'x64' if arch_version == 'yes' or arch_version == 'y' or arch_version == '' else 'x86'

debug_mode = debug_mode.lower()
Expand Down
23 changes: 22 additions & 1 deletion buildscripts/buildtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,21 +445,42 @@ def copy_binary(self, from_dir, dest_dir, driver, suffix):
else:
binary = self.driver_name(driver, suffix)
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):
"""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
copy them to the 'ext' folder.
"""
"""

# Get php.ini file from php.ini-production
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)
if copy_to_ext:
dest_dir = os.path.join(build_dir, 'ext')
ext_dir_line = 'extension_dir=ext\\'
else:
ext_dir_line = 'extension_dir=.\\'
# Simply make a copy of the binaries in sdk_dir
dest_dir = sdk_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
if self.driver == 'all':
Expand Down

0 comments on commit 7a3d698

Please sign in to comment.