File: linux-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 (35 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download | duplicates (5)
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
<?php


$buildversion = $argv[1];
echo "Build version is $buildversion\n";
$versionflag = "VERSION_GOES_HERE";

if(empty($buildversion)) {
    echo "Could not find build version!";
    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);
}