diff --git a/buildscripts/builddrivers.py b/buildscripts/builddrivers.py index 680f602b..75fcb5b1 100644 --- a/buildscripts/builddrivers.py +++ b/buildscripts/builddrivers.py @@ -123,8 +123,13 @@ class BuildDriver(object): """ 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 @@ -164,7 +169,8 @@ class BuildDriver(object): 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. @@ -186,15 +192,15 @@ class BuildDriver(object): 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]: ") @@ -277,8 +283,10 @@ if __name__ == '__main__': 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() diff --git a/buildscripts/buildtools.py b/buildscripts/buildtools.py index 50b2abb4..d617087c 100644 --- a/buildscripts/buildtools.py +++ b/buildscripts/buildtools.py @@ -445,21 +445,42 @@ class BuildUtil(object): 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':