|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * ██╗ ██╗██████╗ ██╗ ██╗██████╗ ███╗ ███╗ |
| 5 | + * ██║ ██║██╔══██╗╚██╗██╔╝██╔══██╗████╗ ████║ |
| 6 | + * ██║ ██║██████╔╝ ╚███╔╝ ██████╔╝██╔████╔██║ |
| 7 | + * ██║ ██║██╔══██╗ ██╔██╗ ██╔═══╝ ██║╚██╔╝██║ |
| 8 | + * ███████╗██║██████╔╝██╔╝ ██╗██║ ██║ ╚═╝ ██║ |
| 9 | + * ╚══════╝╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ |
| 10 | + */ |
| 11 | + |
| 12 | + |
| 13 | +$path = ARCH_PATH . $lib->name . '-' . $lib->version . '\\'; |
| 14 | +$xpmlog = LOG . 'libxpm.log'; |
| 15 | + |
| 16 | + |
| 17 | +// Verify if libxpm is installed |
| 18 | +if (is_dir($path) && is_file($path . 'windows\builds\x64\Static Release\libxpm_a.lib') && is_file(DEPS_PATH . 'lib\libxpm_a.lib')) { |
| 19 | + draw_status($lib->name . '-' . $lib->version, "installed", Green); |
| 20 | + return; |
| 21 | +} |
| 22 | + |
| 23 | + |
| 24 | +// Download and unzip libxpm |
| 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(!unzip(__DIR__ . '\libxpm-msvc.zip', $path)) exit_error("Can't unzip msvc project"); |
| 31 | + |
| 32 | + |
| 33 | +// Fix X11 version |
| 34 | +list($major, $minor, $revision) = explode('.', $lib->version); |
| 35 | +$contents = file_get_contents($path . 'include\X11\xpm.h'); |
| 36 | +$contents = preg_replace('/#define XpmFormat\s+[0-9a-f]+/i', '#define XpmFormat ' . $major, $contents); |
| 37 | +$contents = preg_replace('/#define XpmVersion\s+[0-9a-f]+/i', '#define XpmVersion ' . $minor, $contents); |
| 38 | +$contents = preg_replace('/#define XpmRevision\s+[0-9a-f]+/i', '#define XpmRevision ' . $revision, $contents); |
| 39 | +file_put_contents($path . 'include\X11\xpm.h', $contents); |
| 40 | + |
| 41 | + |
| 42 | +// Compile static libxpm |
| 43 | +$label = "Compile " . $lib->name . '-' . $lib->version; |
| 44 | +draw_line($label, "running", Yellow); |
| 45 | +$bat = '@echo off'.RN; |
| 46 | +$bat .= 'cd ' . escapeshellarg($path . 'windows\vs16').RN; |
| 47 | +$bat .= 'DEVENV libxpm.sln /rebuild "Static Release|x64"'; |
| 48 | +$batfile = TMP . 'build_libxpm.bat'; |
| 49 | +file_put_contents($batfile, $bat); |
| 50 | +$ret = shell_exec_vs16($batfile); |
| 51 | +file_put_contents($xpmlog, $ret); |
| 52 | + |
| 53 | + |
| 54 | +// Verify if the build works |
| 55 | +if(!is_file($path . 'windows\builds\x64\Static Release\libxpm_a.lib')) draw_status($label, "failed", Red, true, 'SEE: ' . $xpmlog); |
| 56 | +else draw_status($label, "complete", Green); |
| 57 | + |
| 58 | + |
| 59 | +// Download proto headers |
| 60 | +$protofile = TMP.pathinfo($lib->xorgproto, PATHINFO_BASENAME); |
| 61 | +if(!download_file($lib->xorgproto, $protofile, pathinfo($protofile, PATHINFO_BASENAME))) exit_error("Can't download proto headers"); |
| 62 | + |
| 63 | + |
| 64 | +// Download libx11 headers |
| 65 | +$libx11file = TMP.pathinfo($lib->libx11, PATHINFO_BASENAME); |
| 66 | +if(!download_file($lib->libx11, $libx11file, pathinfo($libx11file, PATHINFO_BASENAME))) exit_error("Can't download proto headers"); |
| 67 | + |
| 68 | + |
| 69 | +// Install libxpm |
| 70 | +$label = "Install " . $lib->name . '-' . $lib->version; |
| 71 | +draw_line($label, "running", Yellow); |
| 72 | +$builddir = $path . 'build\\'; |
| 73 | +$files[$path . 'windows\builds\x64\Static Release\libxpm_a.lib'] = 'lib\libxpm_a.lib'; |
| 74 | +$files[$path . 'include\X11\xpm.h'] = 'include\X11\xpm.h'; |
| 75 | +if(!create_build($builddir, $files)) draw_status($label, "failed", Red, true); |
| 76 | + |
| 77 | + |
| 78 | +// Install proto headers |
| 79 | +$zip = new ZipArchive; |
| 80 | +if ($zip->open($protofile) !== TRUE) draw_status($label, "failed", Red, true, "Invalid proto headers archive"); |
| 81 | +if(!$contents = $zip->getFromName('xorgproto-master/include/X11/keysym.h')) draw_status($label, "failed", Red, true, "Invalid proto headers archive"); |
| 82 | +else file_put_contents($builddir . 'include\X11\keysym.h', $contents); |
| 83 | +if(!$contents = $zip->getFromName('xorgproto-master/include/X11/keysymdef.h')) draw_status($label, "failed", Red, true, "Invalid proto headers archive"); |
| 84 | +else file_put_contents($builddir . 'include\X11\keysymdef.h', $contents); |
| 85 | +if(!$contents = $zip->getFromName('xorgproto-master/include/X11/X.h')) draw_status($label, "failed", Red, true, "Invalid proto headers archive"); |
| 86 | +else file_put_contents($builddir . 'include\X11\X.h', $contents); |
| 87 | +if(!$contents = $zip->getFromName('xorgproto-master/include/X11/Xfuncproto.h')) draw_status($label, "failed", Red, true, "Invalid proto headers archive"); |
| 88 | +else file_put_contents($builddir . 'include\X11\Xfuncproto.h', $contents); |
| 89 | +if(!$contents = $zip->getFromName('xorgproto-master/include/X11/Xosdefs.h')) draw_status($label, "failed", Red, true, "Invalid proto headers archive"); |
| 90 | +else file_put_contents($builddir . 'include\X11\Xosdefs.h', $contents); |
| 91 | +$zip->close(); |
| 92 | + |
| 93 | + |
| 94 | +// Install libX11 headers |
| 95 | +$zip = new ZipArchive; |
| 96 | +if ($zip->open($libx11file) !== TRUE) draw_status($label, "failed", Red, true, "Invalid libX11 headers archive"); |
| 97 | +if(!$contents = $zip->getFromName('libx11-master/include/X11/Xlib.h')) draw_status($label, "failed", Red, true, "Invalid libX11 headers archive"); |
| 98 | +else file_put_contents($builddir . 'include\X11\Xlib.h', $contents); |
| 99 | +if(!$contents = $zip->getFromName('libx11-master/include/X11/Xutil.h')) draw_status($label, "failed", Red, true, "Invalid libX11 headers archive"); |
| 100 | +else file_put_contents($builddir . 'include\X11\Xutil.h', $contents); |
| 101 | +$zip->close(); |
| 102 | + |
| 103 | + |
| 104 | +// Finish install |
| 105 | +if(!install_deps($builddir)) draw_status($label, "failed", Red, true); |
| 106 | +else draw_status($label, "complete", Green); |
| 107 | + |
| 108 | +delete_parent_deps($lib->name); |
0 commit comments