theos / orion

Elegant tweak development in pure Swift
https://orion.theos.dev
MIT License
216 stars 15 forks source link

pre-build orion pre-processor #36

Closed castdrian closed 5 months ago

castdrian commented 5 months ago

is there a way to pre-build the pre-processor? when compiling a tweak via github-actions this step seems to take the longest and I already wrote a docker image that comes with theos and swift, I'd like to ideally also have it have orion precompiled

Luki120 commented 5 months ago

Cache it

castdrian commented 5 months ago

I'm aware of that, that does not really answer the question if it can be pre-built via cli invocation

the compilation steps that take up the most time are ArgumentParser and a few other dependencies which seem tweak agnostic. So it should seem logical to be able to build those beforehand

L1ghtmann commented 5 months ago

Not super familiar with our Swift tooling but it looks like you should be able to pre-build the preprocessor via the swift-bootstraper.pl script.

Example invocation: https://github.com/theos/theos/blob/16f19fb1da4322513a9ad0283c12f418121773d1/makefiles/instance/rules.mk#L246

castdrian commented 5 months ago

Thank you

kabiroberai commented 5 months ago

FWIW invoking swift-bootstrapper yourself may work for now but it’s an implementation detail so I wouldn’t recommend relying on it. Consider instead creating a new (temporary) Orion tweak, running make, and then deleting the tweak dir. That should be sufficient to cache the preprocessor in a stable manner.

Mukul1127 commented 5 months ago

Cache it

I already have this and it does nothing to cache swift preprocessor

Luki120 commented 5 months ago

Yes, it does, I don’t suggest broken code. Your build obviously has to succeed first in order to cache something

Mukul1127 commented 5 months ago

Yes, it does, I don’t suggest broken code. Your build obviously has to succeed first in order to cache something

I have a cache for the entire theos directory, infact my caching code is pretty much the same as yours, so I don't know why yours works but mine doesn't.

Heres my cache if that helps:

      - name: Check cache
        run: |
          echo upstream_heads=`git ls-remote https://github.com/theos/theos | head -n 1 | cut -f 1`-`git ls-remote https://github.com/theos/sdks | head -n 1 | cut -f 1` >> $GITHUB_ENV

      - name: Restore cache if available
        id: cache
        uses: actions/cache/restore@v4.0.2
        with:
          path: ${{ github.workspace }}/theos
          key: ${{ env.upstream_heads }}

      - name: Setup Theos
        if: steps.cache.outputs.cache-hit != 'true'
        uses: actions/checkout@v4.1.7
        with:
          repository: theos/theos
          path: theos
          submodules: recursive

      - name: Setup iOS SDK
        if: steps.cache.outputs.cache-hit != 'true'
        uses: actions/checkout@v4.1.7
        with:
          repository: theos/sdks
          path: theos/sdks
          sparse-checkout: "iPhoneOS16.5.sdk"
          sparse-checkout-cone-mode: false

      - name: Save cache if needed
        if: steps.cache.outputs.cache-hit != 'true'
        uses: actions/cache/save@v4.0.2
        with:
          path: ${{ github.workspace }}/theos
          key: ${{ env.upstream_heads }}

I even used cache/save to save the cache even if the run fails but downloading theos and it's sdk succeeds.