<commit_before>#!/usr/bin/python3
#########################################################################################
#
# Description:  This script builds a custom keystore provider and compiles the app that 
#               uses this KSP. Their names can be passed as arguments, but the outputs
#               are always 
#               - myKSP.dll (myKSPx64.dll) / myKSP.so 
#               - ksp_app.exe / ksp_app
#
# Requirement:
#               python 3.x
#               myKSP.c (or any equivalent)
#               ksp_app.c (or any equivalent)
#               msodbcsql.h (odbc header file)
#
# Execution: Run with command line with required options
#            py build_ksp.py --KSP myKSP --APP ksp_app
#
#############################################################################################

import sys
import os
import platform
import argparse

# This returns the path to the batch file vcvarsall.bat that comes with Visual Studio 
def getCompilerPath():
    root_dir = 'C:' + os.sep
    return os.path.join(root_dir, "Program Files (x86)", "Microsoft Visual Studio 14.0", "VC", "vcvarsall.bat")

# This creates a batch file to compile myKSP.c into a dll, according to *arch* (either x86 or x64)
def create_batch_file(arch, filename, command):
    vcvarsall = getCompilerPath()
    try:
        file = open(filename, 'w')
        file.write('@ECHO OFF' + os.linesep)
        if arch == 'x64':
            file.write('@CALL "' + vcvarsall + '" amd64' + os.linesep)
        else:
            file.write('@CALL "' + vcvarsall + '" x86' + os.linesep)
            
        # compile the code
        file.write('@CALL ' + command + os.linesep)
        file.close()
    except:
        print('Cannot create ', filename)

# This invokes the newly created batch file to compile the code, 
# according to *arch* (either x86 or x64). The batch file will be 
# removed afterwards
def compile_KSP_windows(arch, ksp_name):
    output = 'myKSP'
    if arch == 'x64':
        output = output + arch + '.dll'<commit_msg>minor modifications to build_ksp.py<commit_after>#!/usr/bin/python3
#########################################################################################
#
# Description:  This script builds a custom keystore provider and compiles the app that 
#               uses this KSP. Their names can be passed as arguments, but the outputs
#               are always 
#               - myKSP.dll (myKSPx64.dll) / myKSP.so 
#               - ksp_app.exe / ksp_app
#
# Requirement:
#               python 3.x
#               myKSP.c (or any equivalent)
#               ksp_app.c (or any equivalent)
#               msodbcsql.h (odbc header file)
#
# Execution: Run with command line with required options
#            py build_ksp.py --KSP myKSP --APP ksp_app
#
#############################################################################################

import sys
import os
import platform
import argparse

# This creates a batch *filename*, which compiles a C program according to 
# *command* and *arch* (either x86 or x64)
def create_batch_file(arch, filename, command):
    root_dir = 'C:' + os.sep
    vcvarsall = os.path.join(root_dir, "Program Files (x86)", "Microsoft Visual Studio 14.0", "VC", "vcvarsall.bat")

    try:
        file = open(filename, 'w')
        file.write('@ECHO OFF' + os.linesep)
        if arch == 'x64':
            file.write('@CALL "' + vcvarsall + '" amd64' + os.linesep)
        else:
            file.write('@CALL "' + vcvarsall + '" x86' + os.linesep)
            
        # compile the code
        file.write('@CALL ' + command + os.linesep)
        file.close()
    except:
        print('Cannot create ', filename)

# This invokes the newly created batch file to compile the code, 
# according to *arch* (either x86 or x64). The batch file will be 
# removed afterwards
def compile_KSP_windows(arch, ksp_name):
    output = 'myKSP'
    if arch == 'x64':
        output = output + arch + '.dll'
{'fraction_non_alphanumeric': 0.18975523593237448, 'fraction_numerical': 0.012616704516780217, 'mean_word_length': 2.636697247706422, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2629228', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1149, 'n_words': 369}