Skip to content

Commit

Permalink
feat: improve build script
Browse files Browse the repository at this point in the history
  • Loading branch information
takuya-takeuchi committed Jul 12, 2019
1 parent ba10dc5 commit 3f0e0b8
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 265 deletions.
2 changes: 1 addition & 1 deletion nuget/BuildOSX.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ foreach($BuildTarget in $BuildTargets)

$Config = [Config]::new("Release", $target, $architecture, $option)
$libraryDir = Join-Path "artifacts" $Config.GetArtifactDirectoryName()
$build = $Config.GetBuildDirectoryName()
$build = $Config.GetBuildDirectoryName($OperatingSystem)

foreach ($key in $BuildSourceHash.keys)
{
Expand Down
2 changes: 1 addition & 1 deletion nuget/BuildUbuntu16.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ foreach($BuildTarget in $BuildTargets)

$Config = [Config]::new("Release", $target, $architecture, $option)
$libraryDir = Join-Path "artifacts" $Config.GetArtifactDirectoryName()
$build = $Config.GetBuildDirectoryName()
$build = $Config.GetBuildDirectoryName($OperatingSystem)

Write-Host "Start 'docker build -t $dockername $DockerFileDir --build-arg IMAGE_NAME=""$imagename""'" -ForegroundColor Green
docker build --force-rm=true -t $dockername $DockerFileDir --build-arg IMAGE_NAME="$imagename"
Expand Down
14 changes: 11 additions & 3 deletions nuget/BuildUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,17 @@ class Config
return $arch
}

[string] GetBuildDirectoryName()
[string] GetBuildDirectoryName([string]$os="")
{
$osname = $this.GetOSName()
if ($os)
{
$osname = $os
}
else
{
$osname = $this.GetOSName()
}

$target = $this._Target
$architecture = $this.GetArchitectureName()

Expand Down Expand Up @@ -382,7 +390,7 @@ function Build([Config]$Config)
{
$Current = Get-Location

$Output = $Config.GetBuildDirectoryName()
$Output = $Config.GetBuildDirectoryName("")
if ((Test-Path $Output) -eq $False)
{
New-Item $Output -ItemType Directory
Expand Down
2 changes: 1 addition & 1 deletion nuget/BuildWindows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ foreach ($BuildTarget in $BuildTargets)

$Config = [Config]::new("Release", $target, $architecture, $option)
$libraryDir = Join-Path "artifacts" $Config.GetArtifactDirectoryName()
$build = $Config.GetBuildDirectoryName()
$build = $Config.GetBuildDirectoryName($OperatingSystem)

foreach ($key in $BuildSourceHash.keys)
{
Expand Down
10 changes: 10 additions & 0 deletions nuget/docker/build/ubuntu/16/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ ARG IMAGE_NAME
FROM ${IMAGE_NAME}:latest
LABEL maintainer "Takuya Takeuchi <[email protected]>"

# Register Microsoft key and feed
RUN apt-get update && apt-get install -y \
wget \
apt-transport-https
RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb
RUN apt-get update && apt-get install -y \
powershell \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# copy build script and run
COPY runBuild.sh /runBuild.sh
RUN chmod 744 /runBuild.sh
Expand Down
51 changes: 2 additions & 49 deletions nuget/docker/build/ubuntu/16/runBuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,10 @@ if [ $# -eq 3 ]; then
CUDA=$3
fi

if [ "${TARGET}" == 'cpu' ] ; then

if [ "$2" == "32" ]; then
OUTDIR=${DDNROOT}/nuget/artifacts/${TARGET}/runtimes/linux-x86/native
BUILDDIR=build_linux_${TARGET}_x86
elif [ "$2" == "64" ]; then
OUTDIR=${DDNROOT}/nuget/artifacts/${TARGET}/runtimes/linux-x64/native
BUILDDIR=build_linux_${TARGET}_x64
fi

elif [ "${TARGET}" == 'mkl' ] ; then

if [ "$2" == "32" ]; then
OUTDIR=${DDNROOT}/nuget/artifacts/${TARGET}/runtimes/linux-x86/native
BUILDDIR=build_linux_${TARGET}_x86
elif [ "$2" == "64" ]; then
OUTDIR=${DDNROOT}/nuget/artifacts/${TARGET}/runtimes/linux-x64/native
BUILDDIR=build_linux_${TARGET}_x64
fi

elif [ "${TARGET}" == 'cuda' ]; then

if [ "$2" == "32" ]; then
OUTDIR=${DDNROOT}/nuget/artifacts/${TARGET}-${CUDA}/runtimes/linux-x86/native
BUILDDIR=build_linux_${TARGET}-${CUDA}_x86
elif [ "$2" == "64" ]; then
OUTDIR=${DDNROOT}/nuget/artifacts/${TARGET}-${CUDA}/runtimes/linux-x64/native
BUILDDIR=build_linux_${TARGET}-${CUDA}_x64
fi

elif [ "${TARGET}" == 'arm' ]; then

if [ "$2" == "32" ]; then
OUTDIR=${DDNROOT}/nuget/artifacts/${TARGET}/runtimes/linux-arm/native
BUILDDIR=build_linux_${TARGET}_x86
elif [ "$2" == "64" ]; then
OUTDIR=${DDNROOT}/nuget/artifacts/${TARGET}/runtimes/linux-arm64/native
BUILDDIR=build_linux_${TARGET}_x64
fi

else
echo "Specified architecture '${TARGET}' is not supported."
exit 1
fi

CONFIG=Release

cd ${DDNROOT}/src/DlibDotNet.Native
./BuildUnix.sh ${CONFIG} ${TARGET} ${ARCH} ${CUDA}
cp ${BUILDDIR}/*.so ${OUTDIR}
pwsh Build.ps1 ${CONFIG} ${TARGET} ${ARCH} ${CUDA}

cd ${DDNROOT}/src/DlibDotNet.Native.Dnn
./BuildUnix.sh ${CONFIG} ${TARGET} ${ARCH} ${CUDA}
cp ${BUILDDIR}/*.so ${OUTDIR}
pwsh Build.ps1 ${CONFIG} ${TARGET} ${ARCH} ${CUDA}
105 changes: 0 additions & 105 deletions src/DlibDotNet.Native.Dnn/BuildUnix.sh

This file was deleted.

105 changes: 0 additions & 105 deletions src/DlibDotNet.Native/BuildUnix.sh

This file was deleted.

0 comments on commit 3f0e0b8

Please sign in to comment.