Saturday, June 25, 2016

Build Python and EfiPy source code

Host:

    Required compiler: VS2012/VS2013
    Download EfiPy source code from https://sourceforge.net/projects/efipy/
      Assume it is untared at M:\EfiPy\
    Download UDK2015 rev #20289 from https://svn.code.sf.net/p/edk2/code/branches/UDK2015
      Assume it is downloaded to M:\EDK2
    Merge EfiPy code into UDK2015
      xcopy /E /I /Y M:\EfiPy_r0.1.1(20289)\Src M:\EDK2
    Build M:\EDK2\AppPkg\AppPkg.dsc, configurations:
      ACTIVE_PLATFORM       = AppPkg/AppPkg.dsc
      TARGET                = RELEASE
      TARGET_ARCH           = X64
    
  # It depends on host environment
      #TOOL_CHAIN_TAG        = VS2012x86
 
     # It depends on host environment
      TOOL_CHAIN_TAG        = VS2013x86
    Modify M:\EDK2\AppPkg\AppPkg.dsc

    [LibraryClasses.Common.UEFI_APPLICATION]
      EfiPy|AppPkg/Applications/Python/EfiPy.inf

    [Components]
      AppPkg/Applications/Python/PythonCore.inf{
        <LibraryClasses>
          ShellCEntryLib|AppPkg/Applications/Python/UefiShellCEntryLib/UefiShellCEntryLib.inf
      }


      For the detail how to build EDK2 code, please reference it from EDK2 official website.

Setup Python environment in disk (N:):

    mkdir N:\EFI\Boot
    mkdir N:\EFI\Tools
    copy M:\EDK2\Build\AppPkg\RELEASE_VS2013x86\X64\AppPkg\Applications\Python\PythonCore\DEBUG\Python.efi N:\EFI\Tools
    copy M:\EfiPy_r0.1.1(20289)\Src\AppPkg\Applications\Python\EfiPy\Tools\EfiPyShell.py N:\EFI\Tools
    xcopy /E /I /Y M:\Edk2\AppPkg\Applications\Python\Python-2.7.2\Lib N:\EFI\StdLib\Lib\python.27
    xcopy /E /I /Y M:\EDK2\AppPkg\Applications\Python\PyMod-2.7.2\Lib N:\EFI\StdLib\Lib\python.27
    xcopy /E /I /Y M:\EfiPy_r0.1.1(20289)\Src\AppPkg\Applications\Python\EfiPy\lib\EfiPy N:\EFI\StdLib\Lib\python.27\EfiPy


Target:


    Compile Pytghon .py file to .pyc

      Boot to EFI shell and changing working directory to fsX:\EFI\Tools

        FSX:\EFI\Tools\>Python.efi
        >>> import compileall
        >>> compileall.compile_dir('FS0:\EFI\StdLib\Lib\python.27', force=True)