diff --git a/cffi_dist/Dockerfile.alpine.compile b/cffi_dist/Dockerfile.alpine.compile deleted file mode 100644 index 6f67aa6..0000000 --- a/cffi_dist/Dockerfile.alpine.compile +++ /dev/null @@ -1,6 +0,0 @@ -FROM golang:1.18-alpine3.16 -RUN apk add --no-cache \ - git \ - gcc \ - g++ \ - bash diff --git a/cffi_dist/Dockerfile.ubuntu.compile b/cffi_dist/Dockerfile.ubuntu.compile deleted file mode 100644 index 273e5fd..0000000 --- a/cffi_dist/Dockerfile.ubuntu.compile +++ /dev/null @@ -1,13 +0,0 @@ -FROM ubuntu:20.04 - -# Update and upgrade repo -RUN apt-get update -y -q && apt-get upgrade -y -q - -# Install tools we might need -RUN apt-get install --no-install-recommends -y -q curl build-essential ca-certificates git gcc g++ bash - -# Download Go 1.18 and install it to /usr/local/go -RUN curl -s https://dl.google.com/go/go1.18.3.linux-amd64.tar.gz | tar -v -C /usr/local -xz - -# Let's people find our Go binaries -ENV PATH $PATH:/usr/local/go/bin diff --git a/cffi_dist/build.sh b/cffi_dist/build.sh index 9ce5541..259eca5 100755 --- a/cffi_dist/build.sh +++ b/cffi_dist/build.sh @@ -1,35 +1,18 @@ -#!/bin/sh +#!/bin/bash +# Requires xgo: https://github.com/techknowlogick/xgo -# This build.sh file was created on a OSX host system. If you are running on windows / unix you need to adjust the commands accordingly. - -echo 'Build OSX' -GOOS=darwin CGO_ENABLED=1 GOARCH=arm64 go build -buildmode=c-shared -o ./dist/tls-client-darwin-arm64-$1.dylib -GOOS=darwin CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o ./dist/tls-client-darwin-amd64-$1.dylib - -echo 'Build Linux ARM64' -# CC is needed when you cross compile from OSX to Linux -GOOS=linux CGO_ENABLED=1 GOARCH=arm64 CC="aarch64-unknown-linux-gnu-gcc" go build -buildmode=c-shared -o ./dist/tls-client-linux-arm64-$1.so +set -e +mkdir dist -# CC is needed when you cross compile from OSX to Linux -echo 'Build Linux Alpine' -# For some reason my OSX gcc cross compiler does not work. Therefore i use a alpine docker image -# GOOS=linux CGO_ENABLED=1 GOARCH=amd64 CC="x86_64-linux-musl-gcc" go build -buildmode=c-shared -o ./dist/tls-client-linux-amd64.so -# Make sure to first build the image based on the Dockerfile.alpine.compile in this directory. -docker run -v $PWD/../:/tls-client tls-client-alpine-go-1.18 bash -c "cd /tls-client/cffi_dist && GOOS=linux CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o /tls-client/cffi_dist/dist/tls-client-linux-alpine-amd64-$1.so" - -# CC is needed when you cross compile from OSX to Linux -echo 'Build Linux Ubuntu' -# For some reason my OSX gcc cross compiler does not work. Therefore i use a ubuntu docker image -# GOOS=linux CGO_ENABLED=1 GOARCH=amd64 CC="x86_64-linux-musl-gcc" go build -buildmode=c-shared -o ./dist/tls-client-linux-amd64.so -# Make sure to first build the image based on the Dockerfile.ubuntu.compile in this directory. -docker run -v $PWD/../:/tls-client tls-client-ubuntu-go-1.18 bash -c "cd /tls-client/cffi_dist && GOOS=linux CGO_ENABLED=1 GOARCH=amd64 go build -buildmode=c-shared -o /tls-client/cffi_dist/dist/tls-client-linux-ubuntu-amd64-$1.so" - +echo 'Build OSX' +xgo -buildmode=c-shared -out dist/tls-client --targets=darwin/arm64 . +xgo -buildmode=c-shared -out dist/tls-client --targets=darwin/amd64 . -# CC is needed when you cross compile from OSX to Windows -echo 'Build Windows 32 Bit' -GOOS=windows CGO_ENABLED=1 GOARCH=386 CC="i686-w64-mingw32-gcc" go build -buildmode=c-shared -o ./dist/tls-client-windows-32-$1.dll +echo 'Build Linux' +xgo -buildmode=c-shared -out dist/tls-client --targets=linux/arm64 . +xgo -buildmode=c-shared -out dist/tls-client --targets=linux/amd64 . -# CC is needed when you cross compile from OSX to Windows -echo 'Build Windows 64 Bit' -GOOS=windows CGO_ENABLED=1 GOARCH=amd64 CC="x86_64-w64-mingw32-gcc" go build -buildmode=c-shared -o ./dist/tls-client-windows-64-$1.dll \ No newline at end of file +echo 'Build Windows' +xgo -buildmode=c-shared -out dist/tls-client --targets=windows/386 . +xgo -buildmode=c-shared -out dist/tls-client --targets=windows/amd64 . diff --git a/cffi_dist/example_python/example.py b/cffi_dist/example_python/example.py index 76342ad..7c1c8a0 100644 --- a/cffi_dist/example_python/example.py +++ b/cffi_dist/example_python/example.py @@ -2,7 +2,7 @@ import json # load the tls-client shared package for your OS you are currently running your python script (i'm running on mac) -library = ctypes.cdll.LoadLibrary('./../dist/tls-client-darwin-amd64-1.3.12.dylib') +library = ctypes.cdll.LoadLibrary(f'./../dist/tls-client-darwin-10.12-amd64.dylib') # extract the exposed request function from the shared package request = library.request