mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-24 10:33:22 +03:00
Build Linux static executables. (#2120)
This commit is contained in:
parent
4d3fc857ff
commit
fcae7e6587
15
.travis.yml
15
.travis.yml
@ -1,10 +1,9 @@
|
||||
# TODO Only do release builds on the `pull` branch?
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- os: linux
|
||||
language: nix
|
||||
nix: 2.1.3
|
||||
env: STACK_YAML=pkg/hs/stack.yaml
|
||||
before_install:
|
||||
- git lfs pull
|
||||
- sh/travis-install-stack
|
||||
@ -16,13 +15,15 @@ jobs:
|
||||
script:
|
||||
- cachix use urbit2
|
||||
- ./sh/cachix
|
||||
- make build-fast
|
||||
- make build
|
||||
- make release
|
||||
- sh/release-king-linux64-dynamic
|
||||
- sh/ci-tests
|
||||
|
||||
- os: osx
|
||||
language: generic
|
||||
sudo: required
|
||||
env: STACK_YAML=pkg/hs/stack.yaml
|
||||
|
||||
before_install:
|
||||
- sh/travis-install-stack
|
||||
@ -31,13 +32,7 @@ jobs:
|
||||
- stack --no-terminal --install-ghc build king --only-dependencies
|
||||
|
||||
script:
|
||||
- ver="$(git rev-parse HEAD)"
|
||||
- if [ -n "${TRAVIS_COMMIT-}" ]; then ver="$TRAVIS_COMMIT"; fi
|
||||
- if [ -n "${TRAVIS_TAG-}" ]; then ver="$TRAVIS_TAG"; fi
|
||||
- stack clean
|
||||
- stack install king --local-bin-path ./release
|
||||
- mv release/king release/king-darwin-$ver
|
||||
- otool -L release/king-darwin-$ver
|
||||
- sh/release-king-darwin-dynamic
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
5
Makefile
5
Makefile
@ -2,11 +2,6 @@
|
||||
|
||||
build:
|
||||
nix-build -A urbit -A herb --no-out-link
|
||||
stack build king
|
||||
|
||||
build-fast:
|
||||
nix-build -A urbit -A herb --no-out-link
|
||||
stack build king --fast
|
||||
|
||||
build-all:
|
||||
nix-build --no-out-link
|
||||
|
52
pkg/hs/default.nix
Normal file
52
pkg/hs/default.nix
Normal file
@ -0,0 +1,52 @@
|
||||
# Run using:
|
||||
#
|
||||
# $(nix-build --no-link -A fullBuildScript)
|
||||
{
|
||||
stack2nix-output-path ? "custom-stack2nix-output.nix",
|
||||
}:
|
||||
let
|
||||
cabalPackageName = "king";
|
||||
compiler = "ghc865"; # matching stack.yaml
|
||||
|
||||
# Pin static-haskell-nix version.
|
||||
static-haskell-nix =
|
||||
if builtins.pathExists ../.in-static-haskell-nix
|
||||
then toString ../. # for the case that we're in static-haskell-nix itself, so that CI always builds the latest version.
|
||||
# Update this hash to use a different `static-haskell-nix` version:
|
||||
else fetchTarball https://github.com/nh2/static-haskell-nix/archive/b402b38c3af2300e71caeebe51b5e4e1ae2e924c.tar.gz;
|
||||
|
||||
# Pin nixpkgs version
|
||||
# By default to the one `static-haskell-nix` provides, but you may also give
|
||||
# your own as long as it has the necessary patches, using e.g.
|
||||
# pkgs = import (fetchTarball https://github.com/nh2/nixpkgs/archive/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa123.tar.gz) {};
|
||||
pkgs = import "${static-haskell-nix}/nixpkgs.nix";
|
||||
|
||||
stack2nix-script = import "${static-haskell-nix}/static-stack2nix-builder/stack2nix-script.nix" {
|
||||
inherit pkgs;
|
||||
stack-project-dir = toString ./.; # where stack.yaml is
|
||||
hackageSnapshot = "2019-12-19T00:00:00Z"; # pins e.g. extra-deps without hashes or revisions
|
||||
};
|
||||
|
||||
static-stack2nix-builder = import "${static-haskell-nix}/static-stack2nix-builder/default.nix" {
|
||||
normalPkgs = pkgs;
|
||||
inherit cabalPackageName compiler stack2nix-output-path;
|
||||
# disableOptimization = true; # for compile speed
|
||||
};
|
||||
|
||||
# Full invocation, including pinning `nix` version itself.
|
||||
fullBuildScript = pkgs.writeScript "stack2nix-and-build-script.sh" ''
|
||||
#!/usr/bin/env bash
|
||||
set -eu -o pipefail
|
||||
STACK2NIX_OUTPUT_PATH=$(${stack2nix-script})
|
||||
export NIX_PATH=nixpkgs=${pkgs.path}
|
||||
${pkgs.nix}/bin/nix-build --no-link -A static_package --argstr stack2nix-output-path "$STACK2NIX_OUTPUT_PATH" "$@"
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
static_package = static-stack2nix-builder.static_package;
|
||||
inherit fullBuildScript;
|
||||
# For debugging:
|
||||
inherit stack2nix-script;
|
||||
inherit static-stack2nix-builder;
|
||||
}
|
@ -73,7 +73,7 @@ goldenFile :: String -> String -> (FilePath -> IO L.ByteString) -> TestTree
|
||||
goldenFile testName testFileName action =
|
||||
goldenVsString testName gold (action pill)
|
||||
where
|
||||
root = "pkg/king/test/gold" </> testFileName
|
||||
root = "pkg/hs/king/test/gold" </> testFileName
|
||||
gold = root <.> "gold"
|
||||
pill = root <.> "pill"
|
||||
|
@ -24,7 +24,7 @@ import qualified NounConversionTests
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
makeAbsolute "../.." >>= setCurrentDirectory
|
||||
makeAbsolute "../../.." >>= setCurrentDirectory
|
||||
setEnv "TASTY_NUM_THREADS" "1"
|
||||
runInBoundThread $ defaultMain $ testGroup "Urbit"
|
||||
[ AmesTests.tests
|
@ -1,9 +1,9 @@
|
||||
resolver: lts-14.4
|
||||
|
||||
packages:
|
||||
- pkg/proto
|
||||
- pkg/king
|
||||
- pkg/lmdb-static
|
||||
- proto
|
||||
- king
|
||||
- lmdb-static
|
||||
|
||||
extra-deps:
|
||||
- flat-0.3.4@sha256:002a0e0ae656ea8cc02a772d0bcb6ea7dbd7f2e79070959cc748ad1e7138eb38
|
@ -2,7 +2,9 @@
|
||||
|
||||
set -ex
|
||||
|
||||
stack test king --fast
|
||||
export STACK_YAML="`pwd`/pkg/hs/stack.yaml"
|
||||
|
||||
stack test king
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" = false ]
|
||||
then
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
if [ -n "${TRAVIS_TAG-}" ]
|
||||
then
|
||||
@ -14,13 +14,6 @@ fi
|
||||
|
||||
mkdir -p release
|
||||
|
||||
stack clean # Make sure we optimize
|
||||
stack install king --local-bin-path ./release
|
||||
mv release/king release/king-linux64-$ver
|
||||
|
||||
# OSX
|
||||
# otool -L ./release/king-darwin-$ver
|
||||
|
||||
for plat in linux64 darwin
|
||||
do
|
||||
sh/cross urbit "$plat"
|
||||
|
29
sh/release-king-darwin-dynamic
Executable file
29
sh/release-king-darwin-dynamic
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
if [ -n "${TRAVIS_TAG-}" ]
|
||||
then
|
||||
ver="$TRAVIS_TAG"
|
||||
elif [ -n "${TRAVIS_COMMIT-}" ]
|
||||
then
|
||||
ver="$TRAVIS_COMMIT"
|
||||
else
|
||||
ver="$(git rev-parse HEAD)"
|
||||
fi
|
||||
|
||||
export STACK_YAML="`pwd`/pkg/hs/stack.yaml"
|
||||
|
||||
mkdir -p release
|
||||
|
||||
stack clean # Make sure we optimize
|
||||
|
||||
stack install king \
|
||||
--local-bin-path "`pwd`/release" \
|
||||
--test --no-run-tests
|
||||
|
||||
out="release/king-darwin-dynamic-$ver"
|
||||
|
||||
mv release/king "$out"
|
||||
|
||||
otool -L "$out"
|
29
sh/release-king-linux64-dynamic
Executable file
29
sh/release-king-linux64-dynamic
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
if [ -n "${TRAVIS_TAG-}" ]
|
||||
then
|
||||
ver="$TRAVIS_TAG"
|
||||
elif [ -n "${TRAVIS_COMMIT-}" ]
|
||||
then
|
||||
ver="$TRAVIS_COMMIT"
|
||||
else
|
||||
ver="$(git rev-parse HEAD)"
|
||||
fi
|
||||
|
||||
export STACK_YAML="`pwd`/pkg/hs/stack.yaml"
|
||||
|
||||
mkdir -p release
|
||||
|
||||
stack clean # Make sure we optimize
|
||||
|
||||
stack install king \
|
||||
--local-bin-path "`pwd`/release" \
|
||||
--test --no-run-tests
|
||||
|
||||
out="release/king-linux64-dynamic-$ver"
|
||||
|
||||
mv release/king "$out"
|
||||
|
||||
ldd "$out"
|
25
sh/release-king-linux64-static
Executable file
25
sh/release-king-linux64-static
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
if [ -n "${TRAVIS_TAG-}" ]
|
||||
then
|
||||
ver="$TRAVIS_TAG"
|
||||
elif [ -n "${TRAVIS_COMMIT-}" ]
|
||||
then
|
||||
ver="$TRAVIS_COMMIT"
|
||||
else
|
||||
ver="$(git rev-parse HEAD)"
|
||||
fi
|
||||
|
||||
pushd pkg/hs
|
||||
|
||||
king=$(bash $(nix-build --no-link -A fullBuildScript))
|
||||
|
||||
popd
|
||||
|
||||
out="release/king-linux64-static-$ver"
|
||||
|
||||
cp "$king"/bin/king "$out"
|
||||
|
||||
ldd "$out"
|
Loading…
Reference in New Issue
Block a user