diff options
author | Arno <arno@disconnect.de> | 2016-10-03 07:25:22 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2016-10-03 07:25:22 +0200 |
commit | d6705df21f9c2edca5b4b7a4594815d18ba4469f (patch) | |
tree | e2ba3676bae26f2769735c4afa17226159499efe | |
parent | a48e39d830a27ed89fe4e826fa4f82acb044b4c2 (diff) | |
download | ShemovCleaner-d6705df21f9c2edca5b4b7a4594815d18ba4469f.tar.gz ShemovCleaner-d6705df21f9c2edca5b4b7a4594815d18ba4469f.tar.bz2 ShemovCleaner-d6705df21f9c2edca5b4b7a4594815d18ba4469f.zip |
Add build+release script
It's perl, because neither Powershell nor cmd.exe can do this
without jumping through too many loops... :(
-rw-r--r-- | buildinfo.pl | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/buildinfo.pl b/buildinfo.pl new file mode 100644 index 0000000..057a76c --- /dev/null +++ b/buildinfo.pl @@ -0,0 +1,81 @@ +#!/usr/bin/perl -w + +use strict; + +my $git = "C:\\Program Files\\Git\\bin\\git.exe"; +my $repo = "C:\\Users\\am\\Documents\\ShemovCleaner"; +my $builddir = 'C:\Users\am\Documents\ShemovCleaner-Release'; +my $sevenzip = 'C:\Program Files\7-Zip\7z.exe'; +my $finaldest = 'C:\Users\am\bin\ShemovCleaner\ShemovCleaner.exe'; + +chdir $repo; +my $branchcmd = "\"$git\" branch"; +my $branch; + +open (my $bfh, '-|', $branchcmd); +while(<$bfh>){ + if(m#\*\s*(.*)#){ + $branch = $1; + } +} +close($bfh); + +my $commitcmd = "\"$git\" log -n 1 --format=" . '"%h - %aD" --abbrev-commit --abbrev=12'; +open (my $cfh, '-|', $commitcmd); +my $commit = <$cfh>; +close ($cfh); +chomp($commit); + +chdir $builddir; +unlink glob "*.*"; +chdir "$builddir\\release" or die "horribly"; +unlink glob "*.*"; +chdir $repo; + +my $archivecmd = "\"$git\" archive --format zip -o $builddir\\smc.zip HEAD"; +system($archivecmd); + +chdir $builddir; +my $unzipcmd = "\"$sevenzip\" x $builddir\\smc.zip"; +system($unzipcmd); + +open (my $main, '<', "main.cpp"); +open (my $main2, '>', "main2.cpp"); +while(<$main>){ + if(m#__build_info__#){ + my $new = $_; + $new =~ s#__build_info__#$branch branch#; + print $main2 $new; + }else{ + print $main2 $_; + } +} +close ($main); +close ($main2); +unlink ("main.cpp"); +rename ("main2.cpp", "main.cpp"); + +open (my $cleaner, '<', "shemovcleaner.cpp"); +open (my $cleaner2, '>', "shemovcleaner2.cpp"); +while(<$cleaner>){ + if(m#/\* __debug build__ \*/#){ + my $new = $_; + $new =~ s#/\* __debug build__ \*/#$commit#; + print $cleaner2 $new; + }else{ + print $cleaner2 $_; + } +} +close ($cleaner); +close ($cleaner2); +unlink ("shemovclenaner.cpp"); +rename ("shemovcleaner2.cpp", "shemovcleaner.cpp"); + +open (my $batch, '>', "make.cmd"); +print $batch 'PATH="C:\Qt\5.6\mingw49_32\bin;C:\Qt\Tools\mingw492_32\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\OpenVPN\bin;C:\Progr Files (x86)\GNU\GnuPG\pub;C:\Program Files\Git\cmd;C:\psql\9.5\lib;C:\psql\9.5\bin;C:\psql\9.5\include"', "\n"; +print $batch 'C:\Qt\5.6\mingw49_32\bin\qmake.exe ShemovCleaner.pro -r -spec win32-g++', "\n"; +print $batch 'C:\Qt\Tools\mingw492_32\bin\mingw32-make.exe -j 5', "\n"; +print $batch 'copy /Y release\ShemovCleaner.exe ', $finaldest; +close($batch); + +system("make.cmd"); |