Linux build, windows init.sh fixes (#238)
This commit is contained in:
parent
ae67c60478
commit
edc69bd775
10 changed files with 96 additions and 93 deletions
|
@ -6,7 +6,7 @@ os:
|
|||
language: c
|
||||
|
||||
env:
|
||||
- BRANCH=1.2.6
|
||||
- BRANCH=1.2.8
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
@ -18,6 +18,11 @@ addons:
|
|||
packages:
|
||||
- musl-tools
|
||||
|
||||
# Don't rebuild autotagged
|
||||
branches:
|
||||
except:
|
||||
- /^v[0-9.]+-[0-9]+-[0-9a-f]+$/
|
||||
|
||||
script:
|
||||
- source ./scripts/build.sh
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "0.7.4"
|
||||
version = "0.7.5"
|
||||
author = "Dominik Picheta"
|
||||
description = "The Nim toolchain installer."
|
||||
license = "MIT"
|
||||
|
@ -18,7 +18,3 @@ requires "nimterop >= 0.6.12", "nimarchive >= 0.5.3"
|
|||
#requires "libcurl >= 1.0.0" - OSX now uses httpclient
|
||||
requires "analytics >= 0.2.0"
|
||||
requires "osinfo >= 0.3.0"
|
||||
|
||||
task test, "Run the choosenim tester!":
|
||||
withDir "tests":
|
||||
exec "nim c -r tester"
|
||||
|
|
107
scripts/build.sh
107
scripts/build.sh
|
@ -6,63 +6,60 @@ source travis.sh
|
|||
|
||||
# Skip building autotagged version
|
||||
export COMMIT_TAG=`git tag --points-at HEAD | head -n 1`
|
||||
export COMMIT_HASH=`git rev-parse --short HEAD`
|
||||
export CURRENT_BRANCH="${TRAVIS_BRANCH}"
|
||||
echo "Commit tag: ${COMMIT_TAG}"
|
||||
echo "Commit hash: ${COMMIT_HASH}"
|
||||
echo "Current branch: ${CURRENT_BRANCH}"
|
||||
if [[ "${COMMIT_TAG}" =~ ^v[0-9.]+-[0-9]+$ ]]; then
|
||||
echo "Skipping build since autotagged version"
|
||||
|
||||
# Environment vars
|
||||
if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
|
||||
export EXT=".exe"
|
||||
else
|
||||
# Environment vars
|
||||
if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
|
||||
export EXT=".exe"
|
||||
else
|
||||
export EXT=""
|
||||
fi
|
||||
|
||||
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
export OSNAME="macosx"
|
||||
else
|
||||
export OSNAME="$TRAVIS_OS_NAME"
|
||||
fi
|
||||
|
||||
# Build and test
|
||||
nimble install -y -d
|
||||
nim c src/choosenim
|
||||
|
||||
# Set version and tag info
|
||||
export CHOOSENIM_VERSION="$(./src/choosenim --version | cut -f2,2 -d' ' | sed 's/v//')"
|
||||
echo "Version: v${CHOOSENIM_VERSION}"
|
||||
if [[ -z "${COMMIT_TAG}" ]]; then
|
||||
# Create tag with date, not an official tagged release
|
||||
export VERSION_TAG="${CHOOSENIM_VERSION}-$(date +'%Y%m%d')"
|
||||
if [[ "${CURRENT_BRANCH}" == "master" ]]; then
|
||||
# Deploy only on main branch
|
||||
export TRAVIS_TAG="v${VERSION_TAG}"
|
||||
export PRERELEASE=true
|
||||
fi
|
||||
elif [[ "${COMMIT_TAG}" == "v${CHOOSENIM_VERSION}" ]]; then
|
||||
# Official tagged release
|
||||
export VERSION_TAG="${CHOOSENIM_VERSION}"
|
||||
export TRAVIS_TAG="${COMMIT_TAG}"
|
||||
else
|
||||
echo "Tag does not match choosenim version"
|
||||
echo " Commit tag: ${COMMIT_TAG}"
|
||||
echo " Version: v${CHOOSENIM_VERSION}"
|
||||
echo " Current branch: ${CURRENT_BRANCH}"
|
||||
travis_terminate 1
|
||||
fi
|
||||
echo "Travis tag: ${TRAVIS_TAG}"
|
||||
echo "Prerelease: ${PRERELEASE}"
|
||||
export FILENAME="bin/choosenim-${VERSION_TAG}_${OSNAME}_${TRAVIS_CPU_ARCH}"
|
||||
echo "Filename: ${FILENAME}"
|
||||
|
||||
# Run tests
|
||||
nimble test
|
||||
yes | ./bin/choosenim stable # Workaround tester overwriting our Nimble install.
|
||||
mv "bin/choosenim${EXT}" "${FILENAME}_debug${EXT}"
|
||||
|
||||
# Build release version
|
||||
nimble build -d:release
|
||||
strip "bin/choosenim${EXT}"
|
||||
mv "bin/choosenim${EXT}" "${FILENAME}${EXT}"
|
||||
export EXT=""
|
||||
fi
|
||||
|
||||
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
export OSNAME="macosx"
|
||||
else
|
||||
export OSNAME="$TRAVIS_OS_NAME"
|
||||
fi
|
||||
|
||||
# Build release version
|
||||
nimble build -y -d:release -d:staticBuild
|
||||
|
||||
# Set version and tag info
|
||||
export CHOOSENIM_VERSION="$(./bin/choosenim --version | cut -f2,2 -d' ' | sed 's/v//')"
|
||||
echo "Version: v${CHOOSENIM_VERSION}"
|
||||
if [[ -z "${COMMIT_TAG}" ]]; then
|
||||
# Create tag with date and hash, not an official tagged release
|
||||
export VERSION_TAG="${CHOOSENIM_VERSION}-$(date +'%Y%m%d')-${COMMIT_HASH}"
|
||||
if [[ "${CURRENT_BRANCH}" == "master" ]]; then
|
||||
# Deploy only on main branch
|
||||
export TRAVIS_TAG="v${VERSION_TAG}"
|
||||
export PRERELEASE=true
|
||||
fi
|
||||
elif [[ "${COMMIT_TAG}" == "v${CHOOSENIM_VERSION}" ]]; then
|
||||
# Official tagged release
|
||||
export VERSION_TAG="${CHOOSENIM_VERSION}"
|
||||
export TRAVIS_TAG="${COMMIT_TAG}"
|
||||
else
|
||||
# Other tag, mostly autotagged rebuild
|
||||
export VERSION_TAG="${COMMIT_TAG:1}"
|
||||
export TRAVIS_TAG="${COMMIT_TAG}"
|
||||
export PRERELEASE=true
|
||||
fi
|
||||
echo "Travis tag: ${TRAVIS_TAG}"
|
||||
echo "Prerelease: ${PRERELEASE}"
|
||||
export FILENAME="bin/choosenim-${VERSION_TAG}_${OSNAME}_${TRAVIS_CPU_ARCH}"
|
||||
echo "Filename: ${FILENAME}"
|
||||
|
||||
# Run tests
|
||||
nimble test -d:release -d:staticBuild
|
||||
strip "bin/choosenim${EXT}"
|
||||
mv "bin/choosenim${EXT}" "${FILENAME}${EXT}"
|
||||
|
||||
# Build debug version
|
||||
nimble build -g -d:staticBuild
|
||||
./bin/choosenim${EXT} -v
|
||||
mv "bin/choosenim${EXT}" "${FILENAME}_debug${EXT}"
|
||||
|
|
|
@ -37,14 +37,16 @@ install() {
|
|||
fi
|
||||
local filename="choosenim-$stable_version"_"$platform"
|
||||
local url="$url_prefix"v"$stable_version/$filename"
|
||||
local ext=""
|
||||
|
||||
case $platform in
|
||||
*macosx_amd64* | *linux_amd64* )
|
||||
;;
|
||||
*windows_amd64* )
|
||||
# Download ZIP for Windows
|
||||
local filename="$filename.zip"
|
||||
local url="$url.zip"
|
||||
local ext=".exe"
|
||||
local filename="$filename$ext"
|
||||
local url="$url$ext"
|
||||
;;
|
||||
* )
|
||||
say_err "Sorry, your platform ($platform) is not supported by choosenim."
|
||||
|
@ -61,11 +63,6 @@ install() {
|
|||
wget -qO "$temp_prefix/$filename" "$url"
|
||||
fi
|
||||
chmod +x "$temp_prefix/$filename"
|
||||
if [ "$platform" = "windows_amd64" ]; then
|
||||
# Extract ZIP for Windows
|
||||
unzip -j -o -d $temp_prefix/choosenim $temp_prefix/$filename
|
||||
local filename="choosenim/choosenim.exe"
|
||||
fi
|
||||
|
||||
if [ "$need_tty" = "yes" ]; then
|
||||
# The installer is going to want to ask for confirmation by
|
||||
|
@ -84,11 +81,7 @@ install() {
|
|||
|
||||
# Copy choosenim binary to Nimble bin.
|
||||
local nimbleBinDir=`"$temp_prefix/$filename" --getNimbleBin`
|
||||
if [ "$platform" = "windows_amd64" ]; then
|
||||
cp "$temp_prefix/$filename" "$nimbleBinDir/."
|
||||
else
|
||||
cp "$temp_prefix/$filename" "$nimbleBinDir/choosenim"
|
||||
fi
|
||||
cp "$temp_prefix/$filename" "$nimbleBinDir/choosenim$ext"
|
||||
say "ChooseNim installed in $nimbleBinDir"
|
||||
say "You must now ensure that the Nimble bin dir is in your PATH."
|
||||
if [ "$platform" != "windows_amd64" ]; then
|
||||
|
|
|
@ -1,23 +1,14 @@
|
|||
when findExe("musl-gcc").len != 0:
|
||||
# Use musl-gcc when available
|
||||
putEnv("CC", "musl-gcc")
|
||||
switch("gcc.exe", "musl-gcc")
|
||||
switch("gcc.linkerexe", "musl-gcc")
|
||||
|
||||
# Statically linking everything
|
||||
when not defined(OSX):
|
||||
switch("passL", "-static")
|
||||
|
||||
switch("define", "ssl")
|
||||
|
||||
when defined(windows):
|
||||
# TODO: change once issue nim#15520 is resolved
|
||||
# TODO: change once issue nim#15220 is resolved
|
||||
switch("define", "noOpenSSLHacks")
|
||||
switch("dynlibOverride", "ssl-")
|
||||
switch("dynlibOverride", "crypto-")
|
||||
switch("define", "sslVersion:(")
|
||||
|
||||
switch("passL", "-lws2_32")
|
||||
else:
|
||||
switch("dynlibOverride", "ssl")
|
||||
switch("dynlibOverride", "crypto")
|
||||
|
||||
when defined(staticBuild):
|
||||
import "choosenimpkg/proxyexe.nims"
|
||||
|
|
|
@ -4,7 +4,7 @@ type
|
|||
ChooseNimError* = object of NimbleError
|
||||
|
||||
const
|
||||
chooseNimVersion* = "0.7.4"
|
||||
chooseNimVersion* = "0.7.5"
|
||||
|
||||
proxies* = [
|
||||
"nim",
|
||||
|
|
7
src/choosenimpkg/proxyexe.nims
Normal file
7
src/choosenimpkg/proxyexe.nims
Normal file
|
@ -0,0 +1,7 @@
|
|||
when defined(staticBuild):
|
||||
when defined(linux):
|
||||
putEnv("CC", "musl-gcc")
|
||||
switch("gcc.exe", "musl-gcc")
|
||||
switch("gcc.linkerexe", "musl-gcc")
|
||||
when not defined(OSX):
|
||||
switch("passL", "-static")
|
|
@ -1,6 +1,8 @@
|
|||
{.used}
|
||||
|
||||
import strutils
|
||||
|
||||
import nimterop/[build, cimport]
|
||||
import nimterop/build
|
||||
|
||||
# Download openssl from JuliaBinaryWrappers
|
||||
setDefines(@[
|
||||
|
@ -18,3 +20,9 @@ const
|
|||
|
||||
# Link static binaries
|
||||
{.passL: sslLPath & " " & cryptoLPath.}
|
||||
|
||||
# Deps for openssl
|
||||
when defined(linux):
|
||||
{.passL: "-lpthread".}
|
||||
elif defined(windows):
|
||||
{.passL: "-lws2_32".}
|
||||
|
|
|
@ -12,6 +12,8 @@ proc compileProxyexe() =
|
|||
var cmd = "nim c"
|
||||
when defined(release):
|
||||
cmd.add " -d:release"
|
||||
when defined(staticBuild):
|
||||
cmd.add " -d:staticBuild"
|
||||
cmd.add " proxyexe"
|
||||
let (output, exitCode) = gorgeEx(cmd)
|
||||
doAssert exitCode == 0, $(output, cmd)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Copyright (C) Dominik Picheta. All rights reserved.
|
||||
# BSD-3-Clause License. Look at license.txt for more info.
|
||||
import osproc, streams, unittest, strutils, os, sequtils, future
|
||||
import osproc, streams, unittest, strutils, os, sequtils, sugar
|
||||
|
||||
var rootDir = getCurrentDir().parentDir()
|
||||
var rootDir = getCurrentDir()
|
||||
var exePath = rootDir / "bin" / addFileExt("choosenim", ExeExt)
|
||||
var nimbleDir = rootDir / "tests" / "nimbleDir"
|
||||
var choosenimDir = rootDir / "tests" / "choosenimDir"
|
||||
|
@ -107,9 +107,13 @@ proc hasLine(lines: seq[string], line: string): bool =
|
|||
if i.normalize.strip() == line.normalize(): return true
|
||||
|
||||
test "can compile choosenim":
|
||||
cd "..":
|
||||
let (_, exitCode) = exec("build", exe="nimble", global=true, liveOutput=true)
|
||||
check exitCode == QuitSuccess
|
||||
var args = @["build"]
|
||||
when defined(release):
|
||||
args.add "-d:release"
|
||||
when defined(staticBuild):
|
||||
args.add "-d:staticBuild"
|
||||
let (_, exitCode) = exec(args, exe="nimble", global=true, liveOutput=true)
|
||||
check exitCode == QuitSuccess
|
||||
|
||||
test "refuses invalid path":
|
||||
beginTest()
|
||||
|
|
Loading…
Reference in a new issue