Skip to content

Commit

Permalink
Merge pull request #140 from tonistiigi/ld64-update
Browse files Browse the repository at this point in the history
ld: update ld64 and dependencies
  • Loading branch information
crazy-max authored Jan 9, 2024
2 parents 8db003e + 38acd46 commit 6c33ebf
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 194 deletions.
79 changes: 50 additions & 29 deletions .github/workflows/ld.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,33 +77,8 @@ jobs:
*.cache-from=type=gha,scope=${{ matrix.target }}
*.cache-to=type=gha,scope=${{ matrix.target }}
ld64-targets:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.targets.outputs.matrix }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Create targets matrix
id: targets
run: |
matrix=$(docker buildx bake ld64-static-tgz --print | jq -cr '.group."ld64-static-tgz".targets')
echo "matrix=${matrix}" >> ${GITHUB_OUTPUT}
-
name: Show matrix
run: |
echo ${{ steps.targets.outputs.matrix }}
ld64:
runs-on: ubuntu-latest
needs:
- ld64-targets
strategy:
fail-fast: false
matrix:
target: ${{ fromJson(needs.ld64-targets.outputs.matrix) }}
steps:
-
name: Checkout
Expand All @@ -120,11 +95,11 @@ jobs:
name: Build
uses: docker/bake-action@v2
with:
targets: ${{ matrix.target }}
targets: ld64-static-tgz
set: |
*.cache-from=type=gha,scope=${{ matrix.target }}
*.cache-to=type=gha,scope=${{ matrix.target }}
*.output=type=local,dest=./dist,platform-split=false
ld64-static-tgz.cache-from=type=gha,scope=ld64-static-tgz
ld64-static-tgz.cache-to=type=gha,scope=ld64-static-tgz
ld64-static-tgz.output=type=local,dest=./dist,platform-split=false
-
name: List artifacts
run: |
Expand Down Expand Up @@ -201,6 +176,52 @@ jobs:
if-no-files-found: error
retention-days: 1

utils-lipo:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: image=${{ env.BUILDKIT_IMAGE }}
-
name: Build
uses: docker/bake-action@v2
with:
targets: lipo
set: |
lipo.cache-from=type=gha,scope=lipo
lipo.cache-to=type=gha,scope=lipo
utils-sigtool:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: image=${{ env.BUILDKIT_IMAGE }}
-
name: Build
uses: docker/bake-action@v2
with:
targets: sigtool
set: |
sigtool.cache-from=type=gha,scope=sigtool
sigtool.cache-to=type=gha,scope=sigtool
release:
runs-on: ubuntu-latest
if: ${{ inputs.release }}
Expand Down
56 changes: 37 additions & 19 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ variable "DEV_SDK_PLATFORM" {
default = null
}

variable "DEV_WITH_LD64" {}

// Special target: https://github.com/docker/metadata-action#bake-definition
target "meta-helper" {
tags = ["${XX_REPO}:test"]
Expand Down Expand Up @@ -236,32 +238,21 @@ target "binutils" {
tags = binutilsTag(XX_REPO, BINUTILS_VERSION, BINUTILS_VERSION_ONLY, tgt)
}

target "ld64-static-tgz" {
name = "ld64-${tgt}-static-tgz"
target "ld64" {
inherits = ["_ld-base"]
matrix = {
tgt = [
"linux-386",
"linux-amd64",
"linux-arm64",
"linux-armv6",
"linux-armv7"
]
}
target = "ld64-static-tgz"
args = {
LD_TARGET = tgt
}
target = "ld64-signed-static"
}

target "ld64-static-tgz" {
inherits = ["ld64"]
platforms = [
"linux/386",
"linux/amd64",
"linux/arm64",
"linux/arm/v6",
"linux/arm/v7"
"linux/arm/v7",
]
cache-from = [join("", ["type=registry,ref=", binutilsTag(XX_REPO, BINUTILS_VERSION, "1", tgt)[0]])]
cache-to = ["type=inline"]
output = ["./bin/ld-static-tgz"]
target = "ld64-static-tgz"
}

target "ld-static-tgz" {
Expand Down Expand Up @@ -330,6 +321,7 @@ target "dev" {
contexts = {
"tonistiigi/xx" = "target:xx"
"sdk-extras" = DEV_SDK_PLATFORM != null ? "target:sdk-extras-dev" : "docker-image://scratch"
"ld64" = DEV_WITH_LD64 != "" ? "target:ld64" : "docker-image://scratch"
}
args = {
TEST_BASE_TYPE = TEST_BASE_TYPE
Expand All @@ -339,4 +331,30 @@ target "dev" {
output = [
"type=docker"
]
}

target "lipo" {
context = "src/ld"
target = "lipo-static"
contexts = {
"tonistiigi/xx" = "target:xx"
}
platforms = [
"linux/amd64",
"linux/arm64",
"linux/arm/v7",
]
}

target "sigtool" {
context = "src/ld"
target = "sigtool-static"
contexts = {
"tonistiigi/xx" = "target:xx"
}
platforms = [
"linux/amd64",
"linux/arm64",
"linux/arm/v7",
]
}
3 changes: 3 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ COPY test-cargo.bats test_helper.bash ./
RUN --mount=type=cache,target=/pkg-cache,sharing=locked ./test-cargo.bats


# these targets can be overwritten with build contexts
FROM scratch AS sdk-extras
FROM scratch AS ld64

# dev can be used for debugging during development
FROM test-base AS dev
COPY --link --from=sdk-extras / /
COPY --link --from=ld64 / /usr/bin/
COPY --link --from=xx / /
COPY fixtures fixtures
COPY *.bats test_helper.bash ./
Expand Down
Loading

0 comments on commit 6c33ebf

Please sign in to comment.