1+ <?php
2+
3+ /**
4+ * ██╗██████╗ ██████╗ ██╗ ██████╗ ██████╗ █████╗ ████████╗██╗ ██████╗ ███╗ ██╗
5+ * ██║██╔══██╗╚════██╗██║ ██╔═══██╗██╔════╝██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║
6+ * ██║██████╔╝ █████╔╝██║ ██║ ██║██║ ███████║ ██║ ██║██║ ██║██╔██╗ ██║
7+ * ██║██╔═══╝ ██╔═══╝ ██║ ██║ ██║██║ ██╔══██║ ██║ ██║██║ ██║██║╚██╗██║
8+ * ██║██║ ███████╗███████╗╚██████╔╝╚██████╗██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║
9+ * ╚═╝╚═╝ ╚══════╝╚══════╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
10+ */
11+
12+
13+ $ path = ARCH_PATH . $ lib ->name . '- ' . $ lib ->version . '\\' ;
14+ $ ip2log = LOG . 'ip2location.log ' ;
15+
16+
17+ // Verify if libevent is installed
18+ if (is_dir ($ path ) && is_file ($ path . 'build\lib\IP2Location.lib ' ) && is_file (DEPS_PATH . 'lib\IP2Location.lib ' )) {
19+ draw_status ($ lib ->name . '- ' . $ lib ->version , "installed " , Green);
20+ return ;
21+ }
22+
23+
24+ // Download and unzip ip2location
25+ $ tmpfile = TMP .pathinfo ($ lib ->download_url , PATHINFO_BASENAME );
26+ if (!download_file ($ lib ->download_url , $ tmpfile , pathinfo ($ tmpfile , PATHINFO_BASENAME ))) exit_error ();
27+ if (!$ firstdir = zip_first_dir ($ tmpfile )) exit_error ("Invalid zip archive " );
28+ if (!unzip ($ tmpfile , ARCH_PATH )) exit_error ();
29+ if (!rename_wait (ARCH_PATH . $ firstdir , $ path )) exit_error ("Can't rename library path " );
30+ if (!$ contents = curl_get_contents ($ lib ->win_patch_url )) exit_error ("Can't download patch " );
31+ file_put_contents ($ path . 'libIP2Location\IP2Location.c ' , $ contents );
32+
33+
34+ // Compile ip2location
35+ $ label = "Compile " . $ lib ->name . '- ' . $ lib ->version ;
36+ draw_line ($ label , "running " , Yellow);
37+ $ bat = '@echo off ' .RN ;
38+ $ bat .= 'cd ' . escapeshellarg ($ path ).RN ;
39+ $ bat .= 'nmake Makefile.win ' .RN ;
40+ $ batfile = TMP . 'build_ip2location.bat ' ;
41+ file_put_contents ($ batfile , $ bat );
42+ $ ret = shell_exec_vs16 ($ batfile );
43+ file_put_contents ($ ip2log , $ ret );
44+
45+
46+ // Verify if the build works
47+ if (!is_file ($ path . 'libIP2Location\IP2Location.lib ' )) draw_status ($ label , "failed " , Red, true , 'SEE: ' . $ ip2log );
48+ else draw_status ($ label , "complete " , Green);
49+
50+
51+ // Install ip2location
52+ $ label = "Install " . $ lib ->name . '- ' . $ lib ->version ;
53+ draw_line ($ label , "running " , Yellow);
54+ $ builddir = $ path . 'build \\' ;
55+
56+ $ files [$ path . 'libIP2Location\IP2Location.lib ' ] = 'lib\IP2Location.lib ' ;
57+ $ files [$ path . 'libIP2Location\IP2Location.h ' ] = 'include\IP2Location.h ' ;
58+
59+ if (!create_build ($ builddir , $ files )) draw_status ($ label , "failed " , Red, true );
60+ if (!install_deps ($ builddir )) draw_status ($ label , "failed " , Red, true );
61+ else draw_status ($ label , "complete " , Green);
62+
63+ delete_parent_deps ($ lib ->name );
0 commit comments