Skip to content

Instantly share code, notes, and snippets.

@fundon
Created March 4, 2020 09:59
Show Gist options
  • Save fundon/d3c97c5a3a1acf1b8c539365f631fa9e to your computer and use it in GitHub Desktop.
Save fundon/d3c97c5a3a1acf1b8c539365f631fa9e to your computer and use it in GitHub Desktop.

Revisions

  1. fundon created this gist Mar 4, 2020.
    182 changes: 182 additions & 0 deletions oc.fish
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,182 @@
    #!/usr/bin/env fish

    function build
    set -l mode $argv[1]; set -q $mode ; and set mode Debug
    xcodebuild -configuration $mode > /dev/null
    end

    function package
    set -l mode $argv[1]
    set -l repo $argv[2]
    set -l require $argv[3]; set -q $require; and set require Lilu
    set -l arr (string split / $repo)
    set -l org $arr[1]
    set -l name $arr[2];

    if test -d $name
    cd $name && git pull
    else
    git clone https://github.com/$repo.git && cd $name
    end

    if test $require = Lilu
    cp -r ../Lilu/build/Debug/Lilu.kext ./
    end

    echo "Building $name $mode"
    build $mode
    cd ..
    end

    function build_kexts
    set -l mode $argv[1]; set -q $mode ; and set mode Debug

    if test $mode = 'RELEASE'
    set mode Release
    end

    package $mode acidanthera/Lilu

    package $mode acidanthera/CPUFriend

    package $mode acidanthera/AppleALC

    package $mode acidanthera/WhateverGreen

    package $mode acidanthera/VirtualSMC

    package $mode acidanthera/HibernationFixup

    package $mode acidanthera/IntelMausi NO

    #package $mode RehabMan/OS-X-USB-Inject-All NO

    set -l target (realpath EFI/EFI)

    cp -r Lilu/build/$mode/Lilu.kext $target/OC/Kexts/
    cp -r CPUFriend/build/$mode/CPUFriend.kext $target/OC/Kexts/
    cp -r AppleALC/build/$mode/AppleALC.kext $target/OC/Kexts/
    cp -r WhateverGreen/build/$mode/WhateverGreen.kext $target/OC/Kexts/
    cp -r VirtualSMC/build/$mode/*.kext $target/OC/Kexts/
    cp -r HibernationFixup/build/$mode/HibernationFixup.kext $target/OC/Kexts/
    cp -r IntelMausi/build/$mode/IntelMausi.kext $target/OC/Kexts/

    rm -rf $target/OC/Kexts/*.kext/Contents/_CodeSignature
    end

    function build_basic
    set -l mode $argv[1]; set -q $mode ; and set mode DEBUG

    if test -d ocbuild
    cd ocbuild && git pull
    else
    git clone https://github.com/acidanthera/ocbuild.git && cd ocbuild
    end

    cd ..

    build_as

    build_oc

    build_oc_s

    mkdir -p EFI/{Docs,Utilities,EFI/{BOOT,OC/{ACPI,Drivers,Kexts,Tools}}}

    set -l target (realpath EFI)

    cd OpenCorePkg

    cp Changelog.md $target/Docs/

    cp Docs/{Configuration.pdf,Differences/Differences.pdf,Sample.plist,SampleFull.plist} $target/Docs/

    cp -r Docs/AcpiSamples $target/Docs/

    cp -r Utilities/{BootInstall,CreateVault,LogoutHook} $target/Utilities/

    cd Binaries/$mode/

    cp BOOTx64.efi $target/EFI/BOOT/
    cp OpenCore.efi $target/EFI/OC/
    cp {AppleUsbKbDxe,FwRuntimeServices,HiiDatabase,NvmExpressDxe,XhciDxe}.efi $target/EFI/OC/Drivers/
    cp {BootKicker,CleanNvram,GopStop,HdaCodecDump,VerifyMsrE2}.efi $target/EFI/OC/Tools/

    cd $target/../

    cd AppleSupportPkg/Binaries/$mode/

    cp {ApfsDriverLoader,AppleImageLoader,AudioDxe}.efi $target/EFI/OC/Drivers/

    cd $target/../

    if test -d
    cd OcBinaryData && git pull
    else
    git clone https://github.com/acidanthera/OcBinaryData.git && cd OcBinaryData
    end

    cp Drivers/HfsPlus.efi $target/EFI/OC/Drivers/

    cd $target/../

    cd OpenCoreShell/Binaries/$mode/

    cp Shell_EA4BB293-2D7F-4456-A681-1F22F42CD0BC.efi $target/EFI/OC/Tools/Shell.efi

    cd $target/../
    end

    function build_oc
    if test -d OpenCorePkg
    cd OpenCorePkg && git pull
    else
    git clone https://github.com/acidanthera/OpenCorePkg.git && cd OpenCorePkg
    end

    if test ! -L efibuild.sh
    ln -sf ../ocbuild/efibuild.sh ./
    end

    echo 'Building OpenCore'
    ./macbuild.tool

    cd ..
    end

    function build_as
    if test -d AppleSupportPkg
    cd AppleSupportPkg && git pull
    else
    git clone https://github.com/acidanthera/AppleSupportPkg.git && cd AppleSupportPkg
    end

    if test ! -L efibuild.sh
    ln -sf ../ocbuild/efibuild.sh ./
    end

    echo 'Building AppleSupport'
    ./macbuild.tool

    cd ..
    end

    function build_oc_s
    if test -d OpenCoreShell
    cd OpenCoreShell && git pull
    else
    git clone https://github.com/acidanthera/OpenCoreShell.git && cd OpenCoreShell
    end

    if test ! -L efibuild.sh
    ln -sf ../ocbuild/efibuild.sh ./
    end

    echo 'Building OpenCoreShell'
    ./macbuild.tool

    cd ..
    end

    build_basic RELEASE
    build_kexts RELEASE