From 20ea8ef742c2ad2fdb6c58607a8448ae550e417b Mon Sep 17 00:00:00 2001 From: brett Date: Thu, 28 May 2020 10:56:38 -0700 Subject: [PATCH] AT-8842: README + SWIG 4.0.1 * Add Airspace README * Use SWIG 4.0.1 for Debian release * go.Dockerfile cleanup --- AIRSPACE-README.md | 40 +++++++++++++++++++++++++++ makefiles/docker/debian/Dockerfile | 28 +++++++++++-------- makefiles/docker/debian/go.Dockerfile | 10 ++----- 3 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 AIRSPACE-README.md diff --git a/AIRSPACE-README.md b/AIRSPACE-README.md new file mode 100644 index 00000000000..206891996a2 --- /dev/null +++ b/AIRSPACE-README.md @@ -0,0 +1,40 @@ +# Airspace Golang Wrapper Repo for OR-Tools + +This is a fork of [Google's OR-Tools repo](https://github.com/google/or-tools). +It has Go bindings and binaries for use with Go projects. + +## Mac Setup for Local Go Development + 1. Download binaries for Mac: + `https://github.com/AirspaceTechnologies/or-tools/releases/download/v7.6-go1.14.1/or-tools_MacOsX-10.15.4_v7.6.7696.tar.gz` + 1. Install/extract to rpath (e.g. `/usr/local`) + 1. Download and install Go package `go get github.com/airspace/technologies/or-tools/gen/ortools/go/constraintsolver` + 1. Use in Go code. E.g. `import github.com/airspacetechnologies/or-tools/gen/ortools/go/constraintsolver` + +## Mac Setup for Local OR-tools Development (Extending/Wrapping OR-tools) + 1. Install XCode: + `xcode-select install` + 1. Install C++ tools: + `brew install cmake wget pkg-config` + 1. Install SWIG 4.0.1: + `brew install swig` + 1. Install protobuf for Go: + `go get github.com/golang/protobuf/protoc-gen-go@v1.3` + 1. Clone Airspace OR-tools: + `git clone git@github.com:AirspaceTechnologies/or-tools.git` + 1. Make third party: + `make third_party` + 1. Make go: + `make clean_go go` + 1. Make go tests: + `make test_go` + +## Build and Release + 1. Follow steps above (`Mac Setup for Local OR-tools Development`) + 1. Make Debian binary archive (takes ~45 mins, uses Docker to build everything from scratch): + `make --directory=makefiles debian_go_export` + 1. Make local Mac binary archive: + `make golib_archive` + 1. Log into Github and create a release with the resulting binaries + +## TODO + 1. Make `IntVar`->`IntExpr` casting cleaner diff --git a/makefiles/docker/debian/Dockerfile b/makefiles/docker/debian/Dockerfile index 75587c0ffcf..957b4b91e5e 100644 --- a/makefiles/docker/debian/Dockerfile +++ b/makefiles/docker/debian/Dockerfile @@ -5,20 +5,26 @@ LABEL maintainer="corentinl@google.com" # Install system build dependencies ENV PATH=/usr/local/bin:$PATH RUN apt-get update -qq \ -&& apt-get install -yq \ - git wget libssl-dev pkg-config build-essential \ - autoconf libtool zlib1g-dev lsb-release \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + && apt-get install -yq \ + git wget libssl-dev pkg-config build-essential \ + autoconf libtool zlib1g-dev lsb-release \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Install CMake 3.16.4 RUN wget "https://cmake.org/files/v3.16/cmake-3.16.4-Linux-x86_64.sh" \ -&& chmod a+x cmake-3.16.4-Linux-x86_64.sh \ -&& ./cmake-3.16.4-Linux-x86_64.sh --prefix=/usr/local/ --skip-license \ -&& rm cmake-3.16.4-Linux-x86_64.sh + && chmod a+x cmake-3.16.4-Linux-x86_64.sh \ + && ./cmake-3.16.4-Linux-x86_64.sh --prefix=/usr/local/ --skip-license \ + && rm cmake-3.16.4-Linux-x86_64.sh CMD [ "/bin/bash" ] +# Install SWIG 4.0.1 (currently testing) FROM base AS swig +RUN echo 'Package: * \nPin: release a=stable \nPin-Priority: 900' > /etc/apt/preferences.d/stable.pref \ + && echo 'Package: * \nPin: release a=testing \nPin-Priority: 400' > /etc/apt/preferences.d/testing.pref \ + && mv /etc/apt/sources.list /etc/apt/sources.list.d/stable.list \ + && echo 'deb http://deb.debian.org/debian testing main \ndeb http://deb.debian.org/debian testing-updates main' \ + > /etc/apt/sources.list.d/testing.list RUN apt-get update -qq \ -&& apt-get install -yq swig \ -&& apt-get clean \ -&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + && apt-get install -yq swig/testing \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/makefiles/docker/debian/go.Dockerfile b/makefiles/docker/debian/go.Dockerfile index 09f01b5636e..2576aa6d165 100644 --- a/makefiles/docker/debian/go.Dockerfile +++ b/makefiles/docker/debian/go.Dockerfile @@ -3,16 +3,12 @@ ENV GOROOT=/usr/local/go ENV GOPATH=/home/go ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin ENV GO111MODULE=on -RUN apt-get update -qq \ - && wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz \ +RUN wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz \ && mkdir -p /usr/local/go \ && mkdir -p /home/go \ && tar -xvf go1.14.1.linux-amd64.tar.gz -C /usr/local \ && rm -rf go1.14.1.linux-amd64.tar.gz \ - && go get github.com/golang/protobuf/protoc-gen-go@v1.3 \ - && apt-get install -yq \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + && go get github.com/golang/protobuf/protoc-gen-go@v1.3 RUN make -version FROM env AS devel @@ -21,7 +17,7 @@ COPY . . FROM devel AS build RUN make third_party -RUN make clean_go install_go +RUN make clean_go go RUN ldconfig FROM build AS test