File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
use bindgen:: callbacks:: IntKind ;
2
2
use std:: collections:: HashSet ;
3
- use std:: env;
3
+ use std:: { env, fs } ;
4
4
use std:: path:: Path ;
5
5
use std:: path:: PathBuf ;
6
6
use std:: process:: Command ;
@@ -21,6 +21,14 @@ fn main() {
21
21
}
22
22
}
23
23
24
+ // Read the version from the VERSION file
25
+ let version = fs:: read_to_string ( "../VERSION" )
26
+ . expect ( "Failed to read VERSION file" )
27
+ . trim ( )
28
+ . to_string ( ) ;
29
+ println ! ( "cargo:rustc-env=PROFILER_VERSION={}" , version) ;
30
+ println ! ( "cargo:rerun-if-changed=../VERSION" ) ;
31
+
24
32
let php_config_includes = std:: str:: from_utf8 ( php_config_includes_output. stdout . as_slice ( ) )
25
33
. expect ( "`php-config`'s stdout to be valid utf8" ) ;
26
34
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ static PROFILER_NAME_CSTR: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(
58
58
59
59
/// Version of the profiling module and zend_extension. Must not contain any
60
60
/// interior null bytes and must be null terminated.
61
- static PROFILER_VERSION : & [ u8 ] = concat ! ( include_str !( "../../VERSION " ) , "\0 " ) . as_bytes ( ) ;
61
+ static PROFILER_VERSION : & [ u8 ] = concat ! ( env !( "PROFILER_VERSION " ) , "\0 " ) . as_bytes ( ) ;
62
62
63
63
/// Version ID of PHP at run-time, not the version it was built against at
64
64
/// compile-time. Its value is overwritten during minit.
@@ -82,7 +82,7 @@ lazy_static! {
82
82
static ref LAZY_STATICS_TAGS : Vec <Tag > = {
83
83
vec![
84
84
tag!( "language" , "php" ) ,
85
- tag!( "profiler_version" , include_str !( "../../VERSION " ) ) ,
85
+ tag!( "profiler_version" , env !( "PROFILER_VERSION " ) ) ,
86
86
// Safety: calling getpid() is safe.
87
87
Tag :: new( "process_id" , unsafe { libc:: getpid( ) } . to_string( ) )
88
88
. expect( "process_id tag to be valid" ) ,
You can’t perform that action at this time.
0 commit comments