diff --git a/README.md b/README.md index 55e12ec4..136773d2 100644 --- a/README.md +++ b/README.md @@ -73,3 +73,43 @@ GOARM, PLATFORM_ID, CC, and CXX. 1. Build the images from the project's root with `make`. 1. Get a logon token for the container registry by visiting . 1. Publish the images with `make push`. + +## Packaging MacOS SDK + +The osxcross repository used to cross compile for MacOSX has [instructions for packaging the SDK](https://github.com/tpoechtrager/osxcross#packaging-the-sdk). + +The instructions for packaging the SDK on a Linux instance are: + +1. Clone the [osxcross](https://github.com/tpoechtrager/osxcross) repo. +1. Install `clang`, `make`, `libssl-dev`, `lzma-dev`, `libxml2-dev`, `libbz2-dev`. +1. Download [Xcode from Apple](Download Xcode: https://developer.apple.com/download/more]). +1. Run `./tools/gen_sdk_package_pbzx.sh .xip`. + +### bzip2 issues + +If the `gen_sdk_package_pbza.sh` script gives an error that reads: + +``` +Error while extracting archive:(Metadata): bzip2 support not compiled in. (Success) +``` + +A manual work-around is needed in order to create the SDK (other people have reported that installing `libbz2-dev` fixed this issue). + +First edit `osxcross/tools/tools.sh` to remove the `trap` line from the `create_tmp_dir` function (currently line 264). + +Then re-run `./tools/gen_sdk_package_pbzx.sh .xip`. + +Go to the tmp dir created in the build dir: `cd osxcross/build/tmp_`. + +Then run: +``` +../../target/SDK/tools/bin/pbzx -n Content | cpio -i +cd ../.. +XCODEDIR=osxcross/build/tmp_ ./tools/gen_sdk_package.sh +``` + +The SDK should be in the working directory. +The tmp dir can be safely deleted after this. + +The SDKs should be uploaded into the `gs://obs-ci-cache` bucket on GCP (Google Cloud Platform). +This is accessible to authorized users in the `elastic-observability` project [here](https://console.cloud.google.com/storage/browser/obs-ci-cache). diff --git a/go1.16/darwin/Dockerfile.tmpl b/go1.16/darwin/Dockerfile.tmpl index f1bf226a..90dda583 100644 --- a/go1.16/darwin/Dockerfile.tmpl +++ b/go1.16/darwin/Dockerfile.tmpl @@ -8,14 +8,31 @@ RUN \ && apt-get install -qq -y --no-install-recommends --allow-unauthenticated \ clang \ llvm \ + cmake \ + patch \ + python \ + libssl-dev \ + libxml2-dev \ + lzma-dev \ + llvm-dev \ + uuid-dev \ && rm -rf /var/lib/apt/lists/* -ARG OSXCROSS_SDK_URL=https://s3.amazonaws.com/beats-files/deps/MacOSX10.11.sdk.tar.xz +{{if eq .DEBIAN_VERSION "10"}} +ARG OSXCROSS_SDK_URL=https://storage.googleapis.com/obs-ci-cache/beats/MacOSX10.14.sdk.tar.xz +ARG OSXCROSS_PATH=/usr/osxcross +ARG OSXCROSS_REV=8a716a43a72dab1db9630d7824ee0af3730cb8f9 +ARG SDK_VERSION=10.14 +ARG DARWIN_VERSION=17 +ARG OSX_VERSION_MIN=10.14 +{{ else }} +ARG OSXCROSS_SDK_URL=https://storage.googleapis.com/obs-ci-cache/beats/MacOSX10.11.sdk.tar.xz ARG OSXCROSS_PATH=/usr/osxcross ARG OSXCROSS_REV=3034f7149716d815bc473d0a7b35d17e4cf175aa ARG SDK_VERSION=10.11 ARG DARWIN_VERSION=15 ARG OSX_VERSION_MIN=10.10 +{{ end }} RUN \ mkdir -p /tmp/osxcross && cd /tmp/osxcross \ @@ -27,6 +44,8 @@ RUN \ && rm -rf /tmp/osxcross "/usr/osxcross/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man" ENV PATH $OSXCROSS_PATH/bin:$PATH +# Add osxcross libraries to the library PATH +ENV LD_LIBRARY_PATH /usr/osxcross/lib:$LD_LIBRARY_PATH COPY rootfs / @@ -36,11 +55,14 @@ RUN cd / \ && file helloWorld \ && file helloWorld | grep -c 'Mach-O 64-bit x86_64' +# MacOSX10.14 SDK does not have 32bits compiler +{{if ne .DEBIAN_VERSION "10"}} RUN cd / \ && o32-clang helloWorld.c -o helloWorld \ && file helloWorld \ && file helloWorld | grep -c 'Mach-O i386' \ && rm helloWorld.c helloWorld +{{ end }} # Build-time metadata as defined at http://label-schema.org. ARG BUILD_DATE