]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Add YAML files with path env and tool extdeps
authorSean Brogan <sean.brogan@microsoft.com>
Tue, 8 Oct 2019 01:37:13 +0000 (18:37 -0700)
committerMichael D Kinney <michael.d.kinney@intel.com>
Mon, 11 Nov 2019 21:01:53 +0000 (13:01 -0800)
https://bugzilla.tianocore.org/show_bug.cgi?id=2315

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Bin/gcc_aarch64_linux_ext_dep.yaml [new file with mode: 0644]
BaseTools/Bin/gcc_arm_linux_ext_dep.yaml [new file with mode: 0644]
BaseTools/Bin/iasl_ext_dep.yaml [new file with mode: 0644]
BaseTools/Bin/nasm_ext_dep.yaml [new file with mode: 0644]
BaseTools/BinWrappers/PosixLike/posix_path_env.yaml [new file with mode: 0644]
BaseTools/BinWrappers/WindowsLike/win_build_tools_path_env.yaml [new file with mode: 0644]
BaseTools/Edk2ToolsBuild.py [new file with mode: 0644]
BaseTools/Source/Python/basetool_tiano_python_path_env.yaml [new file with mode: 0644]
BaseTools/basetools_calling_path_env.yaml [new file with mode: 0644]
BaseTools/basetools_path_env.yaml [new file with mode: 0644]

diff --git a/BaseTools/Bin/gcc_aarch64_linux_ext_dep.yaml b/BaseTools/Bin/gcc_aarch64_linux_ext_dep.yaml
new file mode 100644 (file)
index 0000000..e81223f
--- /dev/null
@@ -0,0 +1,21 @@
+## @file\r
+# Download GCC AARCH64 compiler from Linaro's release site\r
+# Set shell variable GCC5_AARCH64_INSTALL to this folder\r
+#\r
+# This is only downloaded when a build activates scope gcc_aarch64_linux\r
+#\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+{\r
+  "scope": "gcc_aarch64_linux",\r
+  "type": "web",\r
+  "name": "gcc_aarch64_linux",\r
+  "source": "http://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz",\r
+  "version": "7.4.1",\r
+  "sha256": "27f1dc2c491ed61ae8f0d4b0c11de59cd2f7dd9c94761ee7153006fcac1bf9ab",\r
+  "compression_type": "tar",\r
+  "internal_path": "/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/",\r
+  "flags": ["set_shell_var", ],\r
+  "var_name": "GCC5_AARCH64_INSTALL"\r
+}\r
diff --git a/BaseTools/Bin/gcc_arm_linux_ext_dep.yaml b/BaseTools/Bin/gcc_arm_linux_ext_dep.yaml
new file mode 100644 (file)
index 0000000..09481ce
--- /dev/null
@@ -0,0 +1,21 @@
+## @file\r
+# Download GCC ARM compiler from Linaro's release site\r
+# Set shell variable GCC5_ARM_INSTALL to this folder\r
+#\r
+# This is only downloaded when a build activates scope gcc_arm_linux\r
+#\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+{\r
+  "scope": "gcc_arm_linux",\r
+  "type": "web",\r
+  "name": "gcc_arm_linux",\r
+  "source": "https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/arm-linux-gnueabihf/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz",\r
+  "version": "7.4.1",\r
+  "sha256": "3C951CF1941D0FA06D64CC0D5E88612B209D8123B273FA26C16D70BD7BC6B163",\r
+  "compression_type": "tar",\r
+  "internal_path": "/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/",\r
+  "flags": ["set_shell_var", ],\r
+  "var_name": "GCC5_ARM_INSTALL"\r
+}\r
diff --git a/BaseTools/Bin/iasl_ext_dep.yaml b/BaseTools/Bin/iasl_ext_dep.yaml
new file mode 100644 (file)
index 0000000..1d81e89
--- /dev/null
@@ -0,0 +1,21 @@
+## @file\r
+# Download iasl executable tool from a nuget.org package\r
+# - package contains different binaries based on host\r
+# Add the folder with the tool to the path\r
+#\r
+# This is only downloaded for scope cibuild thus\r
+# should have no impact on the asl compiler used by any\r
+# given platform to build.\r
+#\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+{\r
+  "id": "iasl-ci-1",\r
+  "scope": "cibuild",\r
+  "type": "nuget",\r
+  "name": "iasl",\r
+  "source": "https://api.nuget.org/v3/index.json",\r
+  "version": "20190215.0.0",\r
+  "flags": ["set_path", "host_specific"]\r
+}\r
diff --git a/BaseTools/Bin/nasm_ext_dep.yaml b/BaseTools/Bin/nasm_ext_dep.yaml
new file mode 100644 (file)
index 0000000..60b1f71
--- /dev/null
@@ -0,0 +1,18 @@
+## @file\r
+# Download nasm x86 assembler executable tool from a nuget.org package\r
+# - package contains different binaries based on host\r
+# Put on the tool on the path\r
+#\r
+#\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+{\r
+  "id": "nasm-1",\r
+  "scope": "edk2-build",\r
+  "type": "nuget",\r
+  "name": "mu_nasm",\r
+  "source": "https://api.nuget.org/v3/index.json",\r
+  "version": "2.14.02",\r
+  "flags": ["set_path", "host_specific"]\r
+}\r
diff --git a/BaseTools/BinWrappers/PosixLike/posix_path_env.yaml b/BaseTools/BinWrappers/PosixLike/posix_path_env.yaml
new file mode 100644 (file)
index 0000000..8b32e01
--- /dev/null
@@ -0,0 +1,10 @@
+## @file\r
+# Set this folder on the path for all linux builds\r
+#\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+{\r
+  "scope": "global-nix",\r
+  "flags": ["set_path"]\r
+}\r
diff --git a/BaseTools/BinWrappers/WindowsLike/win_build_tools_path_env.yaml b/BaseTools/BinWrappers/WindowsLike/win_build_tools_path_env.yaml
new file mode 100644 (file)
index 0000000..83f5856
--- /dev/null
@@ -0,0 +1,10 @@
+## @file\r
+# Add this folder to the path on Windows\r
+#\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+{\r
+  "scope": "global-win",\r
+  "flags": ["set_path"]\r
+}\r
diff --git a/BaseTools/Edk2ToolsBuild.py b/BaseTools/Edk2ToolsBuild.py
new file mode 100644 (file)
index 0000000..057d2e9
--- /dev/null
@@ -0,0 +1,163 @@
+# @file Edk2ToolsBuild.py\r
+# Invocable class that builds the basetool c files.\r
+#\r
+# Supports VS2017, VS2019, and GCC5\r
+##\r
+# Copyright (c) Microsoft Corporation\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+import os\r
+import sys\r
+import logging\r
+import argparse\r
+from edk2toolext import edk2_logging\r
+from edk2toolext.environment import self_describing_environment\r
+from edk2toolext.base_abstract_invocable import BaseAbstractInvocable\r
+from edk2toollib.utility_functions import RunCmd\r
+from edk2toollib.windows.locate_tools import QueryVcVariables\r
+\r
+\r
+class Edk2ToolsBuild(BaseAbstractInvocable):\r
+\r
+    def ParseCommandLineOptions(self):\r
+        ''' parse arguments '''\r
+        ParserObj = argparse.ArgumentParser()\r
+        ParserObj.add_argument("-t", "--tool_chain_tag", dest="tct", default="VS2017",\r
+                               help="Set the toolchain used to compile the build tools")\r
+        args = ParserObj.parse_args()\r
+        self.tool_chain_tag = args.tct\r
+\r
+    def GetWorkspaceRoot(self):\r
+        ''' Return the workspace root for initializing the SDE '''\r
+\r
+        # this is the bastools dir...not the traditional EDK2 workspace root\r
+        return os.path.dirname(os.path.abspath(__file__))\r
+\r
+    def GetActiveScopes(self):\r
+        ''' return tuple containing scopes that should be active for this process '''\r
+\r
+        # for now don't use scopes\r
+        return ('global',)\r
+\r
+    def GetLoggingLevel(self, loggerType):\r
+        ''' Get the logging level for a given type (return Logging.Level)\r
+        base == lowest logging level supported\r
+        con  == Screen logging\r
+        txt  == plain text file logging\r
+        md   == markdown file logging\r
+        '''\r
+        if(loggerType == "con"):\r
+            return logging.ERROR\r
+        else:\r
+            return logging.DEBUG\r
+\r
+    def GetLoggingFolderRelativeToRoot(self):\r
+        ''' Return a path to folder for log files '''\r
+        return "BaseToolsBuild"\r
+\r
+    def GetVerifyCheckRequired(self):\r
+        ''' Will call self_describing_environment.VerifyEnvironment if this returns True '''\r
+        return True\r
+\r
+    def GetLoggingFileName(self, loggerType):\r
+        ''' Get the logging file name for the type.\r
+        Return None if the logger shouldn't be created\r
+\r
+        base == lowest logging level supported\r
+        con  == Screen logging\r
+        txt  == plain text file logging\r
+        md   == markdown file logging\r
+        '''\r
+        return "BASETOOLS_BUILD"\r
+\r
+    def WritePathEnvFile(self, OutputDir):\r
+        ''' Write a PyTool path env file for future PyTool based edk2 builds'''\r
+        content = '''##\r
+# Set shell variable EDK_TOOLS_BIN to this folder\r
+#\r
+# Autogenerated by Edk2ToolsBuild.py\r
+#\r
+# Copyright (c), Microsoft Corporation\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+{\r
+  "id": "You-Built-BaseTools",\r
+  "scope": "edk2-build",\r
+  "flags": ["set_shell_var", "set_path"],\r
+  "var_name": "EDK_TOOLS_BIN"\r
+}\r
+'''\r
+        with open(os.path.join(OutputDir, "basetoolsbin_path_env.yaml"), "w") as f:\r
+            f.write(content)\r
+\r
+    def Go(self):\r
+        logging.info("Running Python version: " + str(sys.version_info))\r
+\r
+        (build_env, shell_env) = self_describing_environment.BootstrapEnvironment(\r
+            self.GetWorkspaceRoot(), self.GetActiveScopes())\r
+\r
+        # # Bind our current execution environment into the shell vars.\r
+        ph = os.path.dirname(sys.executable)\r
+        if " " in ph:\r
+            ph = '"' + ph + '"'\r
+        shell_env.set_shell_var("PYTHON_HOME", ph)\r
+        # PYTHON_COMMAND is required to be set for using edk2 python builds.\r
+        pc = sys.executable\r
+        if " " in pc:\r
+            pc = '"' + pc + '"'\r
+        shell_env.set_shell_var("PYTHON_COMMAND", pc)\r
+\r
+        if self.tool_chain_tag.lower().startswith("vs"):\r
+\r
+            # # Update environment with required VC vars.\r
+            interesting_keys = ["ExtensionSdkDir", "INCLUDE", "LIB"]\r
+            interesting_keys.extend(\r
+                ["LIBPATH", "Path", "UniversalCRTSdkDir", "UCRTVersion", "WindowsLibPath", "WindowsSdkBinPath"])\r
+            interesting_keys.extend(\r
+                ["WindowsSdkDir", "WindowsSdkVerBinPath", "WindowsSDKVersion", "VCToolsInstallDir"])\r
+            vc_vars = QueryVcVariables(\r
+                interesting_keys, 'x86', vs_version=self.tool_chain_tag.lower())\r
+            for key in vc_vars.keys():\r
+                logging.debug(f"Var - {key} = {vc_vars[key]}")\r
+                if key.lower() == 'path':\r
+                    shell_env.insert_path(vc_vars[key])\r
+                else:\r
+                    shell_env.set_shell_var(key, vc_vars[key])\r
+\r
+            self.OutputDir = os.path.join(\r
+                shell_env.get_shell_var("EDK_TOOLS_PATH"), "Bin", "Win32")\r
+\r
+            # compiled tools need to be added to path because antlr is referenced\r
+            shell_env.insert_path(self.OutputDir)\r
+\r
+            # Actually build the tools.\r
+            ret = RunCmd('nmake.exe', None,\r
+                         workingdir=shell_env.get_shell_var("EDK_TOOLS_PATH"))\r
+            if ret != 0:\r
+                raise Exception("Failed to build.")\r
+\r
+            self.WritePathEnvFile(self.OutputDir)\r
+            return ret\r
+\r
+        elif self.tool_chain_tag.lower().startswith("gcc"):\r
+            ret = RunCmd("make", "-C .", workingdir=shell_env.get_shell_var("EDK_TOOLS_PATH"))\r
+            if ret != 0:\r
+                raise Exception("Failed to build.")\r
+\r
+            self.OutputDir = os.path.join(\r
+                shell_env.get_shell_var("EDK_TOOLS_PATH"), "Source", "C", "bin")\r
+\r
+            self.WritePathEnvFile(self.OutputDir)\r
+            return ret\r
+\r
+        logging.critical("Tool Chain not supported")\r
+        return -1\r
+\r
+\r
+def main():\r
+    Edk2ToolsBuild().Invoke()\r
+\r
+\r
+if __name__ == "__main__":\r
+    main()\r
diff --git a/BaseTools/Source/Python/basetool_tiano_python_path_env.yaml b/BaseTools/Source/Python/basetool_tiano_python_path_env.yaml
new file mode 100644 (file)
index 0000000..59369cc
--- /dev/null
@@ -0,0 +1,11 @@
+## @file\r
+# Add this folder to the pypath so modules can be easily\r
+# loaded\r
+#\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+{\r
+  "scope": "global",\r
+  "flags": ["set_pypath"]\r
+}\r
diff --git a/BaseTools/basetools_calling_path_env.yaml b/BaseTools/basetools_calling_path_env.yaml
new file mode 100644 (file)
index 0000000..f33f6ea
--- /dev/null
@@ -0,0 +1,11 @@
+## @file\r
+# Set shell variable BASE_TOOL_PATH to this folder\r
+#\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+{\r
+  "scope": "global",\r
+  "flags": ["set_shell_var"],\r
+  "var_name": "BASE_TOOLS_PATH"\r
+}\r
diff --git a/BaseTools/basetools_path_env.yaml b/BaseTools/basetools_path_env.yaml
new file mode 100644 (file)
index 0000000..6bdddcd
--- /dev/null
@@ -0,0 +1,11 @@
+## @file\r
+# Set shell variable EDK_TOOL_PATH to this folder\r
+#\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+{\r
+  "scope": "global",\r
+  "flags": ["set_shell_var", "set_build_var"],\r
+  "var_name": "EDK_TOOLS_PATH"\r
+}\r