Skip to content

Commit

Permalink
helper added
Browse files Browse the repository at this point in the history
  • Loading branch information
jacano committed Oct 25, 2017
1 parent 7aa40ba commit 8525494
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 177 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ crunch.build/
xcuserdata/
secrets/
libs/
build/

*.suo
*.user
Expand Down
19 changes: 5 additions & 14 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
function PrepareVSEnviroment()
{
# https://stackoverflow.com/a/2124759/104185
. ".\helper.ps1"

pushd "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Enterprise\Common7\Tools"
cmd /c "VsDevCmd.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
}
DownloadFromDropboxAndUnzip ("crunch") ("output\") ("uwp.zip")
DownloadFromDropboxAndUnzip ("crunch") ("output\") ("windows.zip")
DownloadFromDropboxAndUnzip ("crunch") ("output\") ("android.zip")
DownloadFromDropboxAndUnzip ("crunch") ("output\") ("ios.zip")

PrepareVSEnviroment

#Invoke-Expression ".src\ManagedCrunch\"

pushd src

nuget.exe restore ManagedCrunch.sln
Expand Down
6 changes: 5 additions & 1 deletion build_android.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
sh helper.sh

pushd src/crunch.Android

ndk-build NDK_PROJECT_PATH=. NDK_APPLICATION_MK=./Application.mk

popd
popd

ZipAndUploadToDropbox "crunch" "android.zip" "src/crunch.android/build"
3 changes: 3 additions & 0 deletions build_ios.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
sh helper.sh

pushd src/crunch.iOS

xcodebuild -configuration Release -sdk iphonesimulator clean build
Expand All @@ -6,3 +8,4 @@ lipo -create -output "build/libcrunch.a" "build/Release-iphoneos/libcrunch.a" "b

popd

ZipAndUploadToDropbox "crunch" "ios.zip" "src/crunch.ios/build"
19 changes: 5 additions & 14 deletions build_uwp.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
function PrepareVSEnviroment()
{
# https://stackoverflow.com/a/2124759/104185

pushd "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Enterprise\Common7\Tools"
cmd /c "VsDevCmd.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
}
. ".\helper.ps1"

PrepareVSEnviroment

Expand All @@ -24,4 +12,7 @@ xcopy /F /R /Y /I Win32\Release\libcrunch.dll build\x86\*
xcopy /F /R /Y /I x64\Release\libcrunch.dll build\x64\*
xcopy /F /R /Y /I ARM\Release\libcrunch.dll build\arm\*

popd
popd

ZipAndUploadToDropbox ("crunch") ("uwp.zip") ("src/crunch.Windows/universal/build")

18 changes: 4 additions & 14 deletions build_windows.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
function PrepareVSEnviroment()
{
# https://stackoverflow.com/a/2124759/104185

pushd "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Enterprise\Common7\Tools"
cmd /c "VsDevCmd.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
}
. ".\helper.ps1"

PrepareVSEnviroment

Expand All @@ -22,4 +10,6 @@ msbuild crunchlibClassic.vcxproj /p:Configuration="Release" /p:Platform="x64"
xcopy /F /R /Y /I Win32\Release\libcrunch.dll build\x86\*
xcopy /F /R /Y /I x64\Release\libcrunch.dll build\x64\*

popd
popd

ZipAndUploadToDropbox ("crunch") ("windows.zip") ("src/crunch.Windows/classic/build")
24 changes: 0 additions & 24 deletions grab_android_artifact.ps1

This file was deleted.

24 changes: 0 additions & 24 deletions grab_ios_artifact.ps1

This file was deleted.

60 changes: 60 additions & 0 deletions helper.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
function PrepareVSEnviroment()
{
# https://stackoverflow.com/a/2124759/104185

pushd "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\Enterprise\Common7\Tools"
cmd /c "VsDevCmd.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
}

function ZipAndUploadToDropbox([string]$REMOTE_FOLDER, [string]$ARTIFACT_NAME, [string]$BUILD_DIR)
{
$DROPBOX_KEY = $env:DROPBOX_KEY
if([string]::IsNullOrEmpty($DROPBOX_KEY))
{
$DROPBOX_KEY = Get-Content ".\secrets\dropboxkey.txt"
}

$DROPBOX_URL="https://content.dropboxapi.com/2/files/upload"
$AUTHORIZATION_TOKEN="Authorization: Bearer $DROPBOX_KEY"
$ARTIFACT_REMOTEPATH="/$REMOTE_FOLDER/$ARTIFACT_NAME"
$DROPBOX_ARGS="Dropbox-API-Arg: {\""path\"":\""$ARTIFACT_REMOTEPATH\"", \""mode\"":\""overwrite\""}"
$CONTENT_TYPE="Content-Type: application/octet-stream"

pushd $BUILD_DIR

Compress-Archive -DestinationPath $ARTIFACT_NAME -Path "*" -Force

curl.exe -f -X POST --header $AUTHORIZATION_TOKEN --header $CONTENT_TYPE --header $DROPBOX_ARGS --data-binary @$ARTIFACT_NAME $DROPBOX_URL

popd
}

function DownloadFromDropboxAndUnzip([string]$REMOTE_FOLDER, [string]$ARTIFACT_FOLDER, [string]$ARTIFACT_NAME)
{
$DROPBOX_KEY = $env:DROPBOX_KEY
if([string]::IsNullOrEmpty($DROPBOX_KEY))
{
$DROPBOX_KEY = Get-Content ".\secrets\dropboxkey.txt"
}

$DROPBOX_URL="https://content.dropboxapi.com/2/files/download"
$AUTHORIZATION_TOKEN="Authorization: Bearer $DROPBOX_KEY"
$ARTIFACT_REMOTEPATH="/$REMOTE_FOLDER/$ARTIFACT_NAME"
$DROPBOX_ARGS="Dropbox-API-Arg: {\""path\"":\""$ARTIFACT_REMOTEPATH\""}"

New-Item $ARTIFACT_FOLDER -type directory -force

pushd $ARTIFACT_FOLDER

curl.exe -f -X POST --header $AUTHORIZATION_TOKEN --header "$DROPBOX_ARGS" -o $ARTIFACT_NAME $DROPBOX_URL

Expand-Archive -Path $ARTIFACT_NAME -Force

popd
}
24 changes: 24 additions & 0 deletions helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ZipAndUploadToDropbox () {

REMOTE_FOLDER=$1
ARTIFACT_NAME=$2
BUILD_DIR=$3

if [ -z "$DROPBOX_KEY" ]
then
DROPBOX_KEY=$(<secrets/dropboxkey.txt)
fi

DROPBOX_ARGS="Dropbox-API-Arg: {\"path\":\"$REMOTE_FOLDER/$ARTIFACT_NAME\", \"mode\":\"overwrite\"}"
DROPBOX_URL="https://content.dropboxapi.com/2/files/upload"
AUTHORIZATION_TOKEN="Authorization: Bearer $DROPBOX_KEY"
CONTENT_TYPE="Content-Type: application/octet-stream"

pushd $BUILD_DIR

zip -r $ARTIFACT_NAME $ARTIFACT_NAME

curl -f -X POST --header "$AUTHORIZATION_TOKEN" --header "$CONTENT_TYPE" --header "$DROPBOX_ARGS" --data-binary @"$ARTIFACT_NAME" "$DROPBOX_URL"

popd
}
20 changes: 0 additions & 20 deletions upload_android_build.sh

This file was deleted.

20 changes: 0 additions & 20 deletions upload_ios_build.sh

This file was deleted.

23 changes: 0 additions & 23 deletions upload_uwp_build.ps1

This file was deleted.

23 changes: 0 additions & 23 deletions upload_windows_build.ps1

This file was deleted.

0 comments on commit 8525494

Please sign in to comment.