<commit_before>#!/usr/bin/env python
import sys
import os
import re
import os.path as path
import imp

import Common.EdkLogger
import GenC
import GenMake
import GenDepex

from BuildInfo import *
from StrGather import *
from Common.BuildToolError import *
from Common.EdkIIWorkspaceBuild import *
from Common.EdkIIWorkspace import *
from Common.DataType import *

#
# generate AutoGen.c, AutoGen.h
# parse unicode file and generate XXXXString.h, XXXXString.c
# generate makefile
#

gPlatformDatabase = {}      # {arch : {dsc file path : PlatformBuildClassObject}}
gModuleDatabase = {}        # {arch : {inf file path : ModuleBuildClassObject}}
gPackageDatabase = {}       # {arch : {dec file path : PackageBuildClassObject}}
gAutoGenDatabase = {}       # (module/package/platform obj, BuildTarget, ToolChain, Arch) : build info
gWorkspace = None
gWorkspaceDir = ""
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
gMakeTypeMap = {"MSFT":"nmake", "GCC":"gmake"}

gDefaultOutputFlag = "-o "

gOutputFlag = {
    ("MSFT", "CC", "OUTPUT")      :   "/Fo",
    ("MSFT", "SLINK", "OUTPUT")   :   "/OUT:",
    ("MSFT", "DLINK", "OUTPUT")   :   "/OUT:",
    ("MSFT", "ASMLINK", "OUTPUT") :   "/OUT:",
    ("MSFT", "PCH", "OUTPUT")     :   "/Fp",
    ("MSFT", "ASM", "OUTPUT")     :   "/Fo",

    ("INTEL", "CC", "OUTPUT")          :   "/Fo",
    ("INTEL", "SLINK", "OUTPUT")       :   "/OUT:",
    ("INTEL", "DLINK", "OUTPUT")       :   "/OUT:",
    ("INTEL", "ASMLINK", "OUTPUT")     :   "/OUT:",
    ("INTEL", "PCH", "OUTPUT")         :   "/Fp",
    ("INTEL", "ASM", "OUTPUT")         :   "/Fo",
#    ("INTEL", "IPF", "ASM", "OUTPUT")  :   "-o ",

    ("GCC", "CC", "OUTPUT")        :   "-o ",
    ("GCC", "SLINK", "OUTPUT")     :   "-cr ",
    ("GCC", "DLINK", "OUTPUT")     :   "-o ",
    ("GCC", "ASMLINK", "OUTPUT")   :   "-o ",
    ("GCC", "PCH", "OUTPUT")       :   "-o ",
    ("GCC", "ASM", "OUTPUT")       :   "-o ",

#   ("OUTPUT")                     :    "-o "
}

gIncludeFlag = {"MSFT" : "/I", "GCC" : "-I", "INTEL" : "-I"}

def FindModuleOwnerPackage(module, pkgdb):
    for pkg in pkgdb:
        pkgDir = path.dirname(pkg)
        if module.DescFilePath.find(pkgDir) == 0:
            return pkgdb[pkg]
    return None

class AutoGen(object):

    def __init__(self, moduleFile, platformFile, workspace, target, toolchain, arch):
        global gModuleDatabase, gPackageDatabase, gPlatformDatabase, gAutoGenDatabase, gWorkspace, gWorkspaceDir

        if gWorkspace == None:
            gWorkspace = workspace
        if gWorkspaceDir == "":
            gWorkspaceDir = workspace.Workspace.WorkspaceDir

        if gModuleDatabase == {}:
            for a in workspace.Build:
                gModuleDatabase[a] = gWorkspace.Build[a].ModuleDatabase
        if gPackageDatabase == {}:<commit_msg>Changed per the new Workspace class<commit_after>#!/usr/bin/env python
import sys
import os
import re
import os.path as path
import imp

import Common.EdkLogger
import GenC
import GenMake
import GenDepex

from BuildInfo import *
from StrGather import *
from Common.BuildToolError import *
from Common.EdkIIWorkspaceBuild import *
from Common.EdkIIWorkspace import *
from Common.DataType import *

#
# generate AutoGen.c, AutoGen.h
# parse unicode file and generate XXXXString.h, XXXXString.c
# generate makefile
#

gPlatformDatabase = {}      # {arch : {dsc file path : PlatformBuildClassObject}}
gModuleDatabase = {}        # {arch : {inf file path : ModuleBuildClassObject}}
gPackageDatabase = {}       # {arch : {dec file path : PackageBuildClassObject}}
gAutoGenDatabase = {}       # (module/package/platform obj, BuildTarget, ToolChain, Arch) : build info
gWorkspace = None
gWorkspaceDir = ""
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
gMakeTypeMap = {"MSFT":"nmake", "GCC":"gmake"}

gDefaultOutputFlag = "-o "

gOutputFlag = {
    ("MSFT", "CC", "OUTPUT")      :   "/Fo",
    ("MSFT", "SLINK", "OUTPUT")   :   "/OUT:",
    ("MSFT", "DLINK", "OUTPUT")   :   "/OUT:",
    ("MSFT", "ASMLINK", "OUTPUT") :   "/OUT:",
    ("MSFT", "PCH", "OUTPUT")     :   "/Fp",
    ("MSFT", "ASM", "OUTPUT")     :   "/Fo",

    ("INTEL", "CC", "OUTPUT")          :   "/Fo",
    ("INTEL", "SLINK", "OUTPUT")       :   "/OUT:",
    ("INTEL", "DLINK", "OUTPUT")       :   "/OUT:",
    ("INTEL", "ASMLINK", "OUTPUT")     :   "/OUT:",
    ("INTEL", "PCH", "OUTPUT")         :   "/Fp",
    ("INTEL", "ASM", "OUTPUT")         :   "/Fo",
#    ("INTEL", "IPF", "ASM", "OUTPUT")  :   "-o ",

    ("GCC", "CC", "OUTPUT")        :   "-o ",
    ("GCC", "SLINK", "OUTPUT")     :   "-cr ",
    ("GCC", "DLINK", "OUTPUT")     :   "-o ",
    ("GCC", "ASMLINK", "OUTPUT")   :   "-o ",
    ("GCC", "PCH", "OUTPUT")       :   "-o ",
    ("GCC", "ASM", "OUTPUT")       :   "-o ",

#   ("OUTPUT")                     :    "-o "
}

gIncludeFlag = {"MSFT" : "/I", "GCC" : "-I", "INTEL" : "-I"}

def FindModuleOwnerPackage(module, pkgdb):
    for pkg in pkgdb:
        pkgDir = path.dirname(pkg)
        if module.DescFilePath.find(pkgDir) == 0:
            return pkgdb[pkg]
    return None

class AutoGen(object):

    def __init__(self, moduleFile, platformFile, workspace, target, toolchain, arch):
        global gModuleDatabase, gPackageDatabase, gPlatformDatabase, gAutoGenDatabase, gWorkspace, gWorkspaceDir

        if gWorkspace == None:
            gWorkspace = workspace
        if gWorkspaceDir == "":
            gWorkspaceDir = workspace.WorkspaceDir

        if gModuleDatabase == {}:
            for a in workspace.Build:
                gModuleDatabase[a] = gWorkspace.Build[a].ModuleDatabase
        if gPackageDatabase == {}:
{'fraction_non_alphanumeric': 0.18176972281449894, 'fraction_numerical': 0.00035536602700781805, 'mean_word_length': 2.6718851924331375, 'pattern_counts': {'":': 6, '<': 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': '5373260', 'n_tokens_mistral': 1893, 'n_tokens_neox': 1849, 'n_words': 461}