@@ -13,8 +13,26 @@ const appAuthor = process.env.NATIVEPHP_APP_AUTHOR;
13
13
const phpBinaryPath = process . env . NATIVEPHP_PHP_BINARY_PATH ;
14
14
const certificatePath = process . env . NATIVEPHP_CERTIFICATE_FILE_PATH ;
15
15
const isArm64 = process . argv . includes ( '--arm64' ) ;
16
+ const isWindows = process . platform === 'win32' ;
17
+ const isDarwin = process . platform === 'darwin' ;
18
+ let binaryArch = process . arch
19
+ let phpBinaryFilename = 'php' ;
20
+ if ( isWindows ) phpBinaryFilename += '.exe' ;
21
+ // Override for Darwin on x64 to use standard 32-bit PHP binary
22
+ if ( isDarwin && binaryArch == 'x64' ) binaryArch = 'x86' ;
16
23
let updaterConfig = { } ;
17
24
25
+ // console.log('Env Vars: ', process.env)
26
+ console . log ( 'Binary Source: ' , phpBinaryPath ) ;
27
+ console . log ( 'Binary Filename: ' , phpBinaryFilename ) ;
28
+
29
+ const binarySrcDir = join ( phpBinaryPath , binaryArch ) ;
30
+ const binarySrcExecutable = join ( phpBinaryPath , binaryArch , phpBinaryFilename ) ;
31
+ // const binaryDest = join(__dirname, 'resources', phpBinaryFilename);
32
+ const binaryDestDir = join ( __dirname , 'resources/php' ) ;
33
+
34
+ console . log ( "Arch: " , process . arch )
35
+ console . log ( "Platform: " , process . platform )
18
36
try {
19
37
updaterConfig = process . env . NATIVEPHP_UPDATER_CONFIG ;
20
38
updaterConfig = JSON . parse ( updaterConfig ) ;
@@ -24,39 +42,43 @@ try {
24
42
25
43
if ( phpBinaryPath ) {
26
44
try {
27
- copySync ( join ( phpBinaryPath , ( isArm64 ? 'arm64' : 'x86' ) , 'php' ) , join ( __dirname , 'resources' , 'php' ) ) ;
45
+ console . log ( 'Copying PHP file(s) from ' + binarySrcDir + ' to ' + binaryDestDir ) ;
46
+ copySync ( binarySrcDir , binaryDestDir ) ;
47
+ console . log ( 'Copied PHP binary to ' , binaryDestDir ) ;
28
48
} catch ( e ) {
29
- console . log ( 'Error copying PHP binary' , e ) ;
49
+ console . error ( 'Error copying PHP binary' , e ) ;
30
50
}
31
51
}
32
52
33
53
if ( certificatePath ) {
34
54
try {
35
- copySync ( certificatePath , join ( __dirname , 'resources' , 'cacert.pem' ) ) ;
55
+ let certDest = join ( __dirname , 'resources' , 'cacert.pem' ) ;
56
+ copySync ( certificatePath , certDest ) ;
57
+ console . log ( 'Copied certificate file to' , certDest ) ;
36
58
} catch ( e ) {
37
- console . log ( 'Error copying certificate file' , e ) ;
59
+ console . error ( 'Error copying certificate file' , e ) ;
38
60
}
39
61
}
40
62
41
63
if ( isBuilding ) {
42
64
console . log ( '=====================' ) ;
43
65
if ( isArm64 ) {
44
66
console . log ( 'Building for ARM64' ) ;
45
- console . log ( join ( __dirname , '..' , '..' , 'bin' , ( isArm64 ? 'arm64' : 'x86' ) , 'php' ) ) ;
67
+ console . log ( join ( __dirname , '..' , '..' , 'bin' , binaryArch , phpBinaryFilename ) ) ;
46
68
} else {
47
69
console . log ( 'Building for x86' ) ;
48
- console . log ( join ( __dirname , '..' , '..' , 'bin' , ( isArm64 ? 'arm64' : 'x86' ) , 'php' ) ) ;
70
+ console . log ( join ( __dirname , '..' , '..' , 'bin' , binaryArch , phpBinaryFilename ) ) ;
49
71
}
50
72
console . log ( '=====================' ) ;
51
73
console . log ( 'updater config' , updaterConfig ) ;
52
74
console . log ( '=====================' ) ;
53
75
54
76
try {
55
77
removeSync ( join ( __dirname , 'resources' , 'app' ) ) ;
56
- removeSync ( join ( __dirname , 'resources' , 'php' ) ) ;
78
+ removeSync ( binaryDestDir ) ;
57
79
58
- let phpBinary = join ( phpBinaryPath , ( isArm64 ? 'arm64' : 'x86' ) , 'php' ) ;
59
- copySync ( phpBinary , join ( __dirname , 'resources' , 'php' ) ) ;
80
+ // let phpBinary = join(phpBinaryPath, binaryArch, phpBinaryFilename );
81
+ copySync ( binarySrcDir , binaryDestDir ) ;
60
82
61
83
// As we can't copy into a subdirectory of ourself we need to copy to a temp directory
62
84
let tmpDir = mkdtempSync ( join ( os . tmpdir ( ) , 'nativephp' ) ) ;
@@ -106,12 +128,12 @@ if (isBuilding) {
106
128
console . log ( join ( process . env . APP_PATH , 'dist' ) ) ;
107
129
console . log ( '=====================' ) ;
108
130
109
- execSync ( `${ phpBinary } ${ join ( __dirname , 'resources' , 'app' , 'artisan' ) } native:minify ${ join ( __dirname , 'resources' , 'app' ) } ` ) ;
131
+ execSync ( `${ binarySrcExecutable } ${ join ( __dirname , 'resources' , 'app' , 'artisan' ) } native:minify ${ join ( __dirname , 'resources' , 'app' ) } ` ) ;
110
132
} catch ( e ) {
111
- console . log ( '=====================' ) ;
112
- console . log ( 'Error copying app to resources' ) ;
113
- console . log ( e ) ;
114
- console . log ( '=====================' ) ;
133
+ console . error ( '=====================' ) ;
134
+ console . error ( 'Error copying app to resources' ) ;
135
+ console . error ( e ) ;
136
+ console . error ( '=====================' ) ;
115
137
}
116
138
117
139
}
0 commit comments