File: win-prebuild.php

package info (click to toggle)
packetsender 8.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,532 kB
  • sloc: cpp: 12,123; sh: 80; xml: 75; php: 47; makefile: 13
file content (41 lines) | stat: -rw-r--r-- 1,476 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php


$buildversion = trim(file_get_contents("buildversion.txt"));
echo "Replacing version with $buildversion\n";
$wininstallertemplate = "/mnt/c/Users/danie/github/naglecode-installers/packetsenderinstaller/packetsender64bit.iss.template";
$wininstallerfile = "/mnt/c/Users/danie/github/naglecode-installers/packetsenderinstaller/packetsender64bit.iss";
$versionflag = "VERSION_GOES_HERE";

echo "Replacing installer script with $buildversion\n";
$str=file_get_contents($wininstallertemplate);
$str=str_replace($versionflag, $buildversion,$str);
if(file_put_contents($wininstallerfile, $str) < 5) {
	echo "Could not write to $wininstallerfile\n";
	exit(1);
}


$cppfile = "src/globals.h";

echo "Replacing $cppfile script with $buildversion\n";
$str=file_get_contents($cppfile);

$buildversioncommas = str_replace(".", "," , $buildversion).",0";

$str=replace_between($str, "//BEGIN SW VERSION", "//END SW VERSION", "\n#define SW_VERSION \"$buildversion\"\n");
$str=replace_between($str, "//BEGIN FILE VERSION", "//END FILE VERSION", "\n#define VER_FILEVERSION $buildversioncommas\n");

file_put_contents($cppfile, $str);



function replace_between($str, $needle_start, $needle_end, $replacement) {
    $pos = strpos($str, $needle_start);
    $start = $pos === false ? 0 : $pos + strlen($needle_start);

    $pos = strpos($str, $needle_end, $start);
    $end = $pos === false ? strlen($str) : $pos;

    return substr_replace($str, $replacement, $start, $end - $start);
}