diff options
| author | Phillip Lord | 2021-01-07 22:06:53 +0000 |
|---|---|---|
| committer | Phillip Lord | 2021-01-09 19:25:51 +0000 |
| commit | 2bf9ee9b997a688fdd6cfbcb0e60db465e76acda (patch) | |
| tree | e3c8c327b6a24cfc9ec5efecfbab03d5b772b423 | |
| parent | cd56406b621bebff484a2978662c98f7689540bf (diff) | |
| download | emacs-feature/dll-only-windows.tar.gz emacs-feature/dll-only-windows.zip | |
Update dependency capturefeature/dll-only-windows
* admin/nt/dist-build/build-dep-zips.py: Use ntldd to directly
determine DLL dependencies
| -rwxr-xr-x | admin/nt/dist-build/build-dep-zips.py | 122 | ||||
| -rwxr-xr-x | admin/nt/dist-build/build-zips.sh | 6 |
2 files changed, 76 insertions, 52 deletions
diff --git a/admin/nt/dist-build/build-dep-zips.py b/admin/nt/dist-build/build-dep-zips.py index 47185dbb1ba..ec99bd606d8 100755 --- a/admin/nt/dist-build/build-dep-zips.py +++ b/admin/nt/dist-build/build-dep-zips.py | |||
| @@ -40,10 +40,77 @@ mingw-w64-x86_64-libtiff | |||
| 40 | mingw-w64-x86_64-libxml2 | 40 | mingw-w64-x86_64-libxml2 |
| 41 | mingw-w64-x86_64-xpm-nox'''.split() | 41 | mingw-w64-x86_64-xpm-nox'''.split() |
| 42 | 42 | ||
| 43 | DLL_REQ='''libgif | ||
| 44 | libgnutls | ||
| 45 | libharfbuzz | ||
| 46 | libjansson | ||
| 47 | liblcms2 | ||
| 48 | libturbojpeg | ||
| 49 | libpng | ||
| 50 | librsvg | ||
| 51 | libtiff | ||
| 52 | libxml | ||
| 53 | libXpm'''.split() | ||
| 54 | |||
| 43 | 55 | ||
| 44 | ## Options | 56 | ## Options |
| 45 | DRY_RUN=False | 57 | DRY_RUN=False |
| 46 | 58 | ||
| 59 | |||
| 60 | def check_output_maybe(*args,**kwargs): | ||
| 61 | if(DRY_RUN): | ||
| 62 | print("Calling: {}{}".format(args,kwargs)) | ||
| 63 | else: | ||
| 64 | return check_output(*args,**kwargs) | ||
| 65 | |||
| 66 | ## DLL Capture | ||
| 67 | def gather_deps(arch, directory): | ||
| 68 | os.mkdir(arch) | ||
| 69 | os.chdir(arch) | ||
| 70 | |||
| 71 | for dep in full_dll_dependency(directory): | ||
| 72 | check_output_maybe(["cp /{}/bin/{}*.dll .".format(directory, dep)], | ||
| 73 | shell=True) | ||
| 74 | |||
| 75 | ## And package them up | ||
| 76 | ## os.chdir(arch) | ||
| 77 | print("Zipping: {}".format(arch)) | ||
| 78 | check_output_maybe("zip -9r ../emacs-{}-{}{}-deps.zip *" | ||
| 79 | .format(EMACS_MAJOR_VERSION, DATE, arch), | ||
| 80 | shell=True) | ||
| 81 | os.chdir("../") | ||
| 82 | |||
| 83 | ## Return all Emacs dependencies | ||
| 84 | def full_dll_dependency(directory): | ||
| 85 | deps = [dll_dependency(dep, directory) for dep in DLL_REQ] | ||
| 86 | return set(sum(deps, []) + DLL_REQ) | ||
| 87 | |||
| 88 | ## Dependencies for a given DLL | ||
| 89 | def dll_dependency(dll, directory): | ||
| 90 | output = check_output(["/mingw64/bin/ntldd", "--recursive", | ||
| 91 | "/{}/bin/{}*.dll".format(directory, dll)]).decode("utf-8") | ||
| 92 | ## munge output | ||
| 93 | return ntldd_munge(output) | ||
| 94 | |||
| 95 | def ntldd_munge(out): | ||
| 96 | deps = out.splitlines() | ||
| 97 | rtn = [] | ||
| 98 | for dep in deps: | ||
| 99 | ## Output looks something like this | ||
| 100 | |||
| 101 | ## KERNEL32.dll => C:\Windows\SYSTEM32\KERNEL32.dll (0x0000000002a30000) | ||
| 102 | ## libwinpthread-1.dll => C:\msys64\mingw64\bin\libwinpthread-1.dll (0x0000000000090000) | ||
| 103 | |||
| 104 | ## if it's the former, we want it, if its the later we don't | ||
| 105 | splt = dep.split() | ||
| 106 | if len(splt) > 2 and "msys64" in splt[2]: | ||
| 107 | print("Adding dep", splt[0]) | ||
| 108 | rtn.append(splt[0].split(".")[0]) | ||
| 109 | |||
| 110 | return rtn | ||
| 111 | |||
| 112 | #### Source Capture | ||
| 113 | |||
| 47 | ## Packages to fiddle with | 114 | ## Packages to fiddle with |
| 48 | ## Source for gcc-libs is part of gcc | 115 | ## Source for gcc-libs is part of gcc |
| 49 | SKIP_SRC_PKGS=["mingw-w64-gcc-libs"] | 116 | SKIP_SRC_PKGS=["mingw-w64-gcc-libs"] |
| @@ -62,12 +129,6 @@ ARCH_PKGS=[] | |||
| 62 | SRC_REPO="https://sourceforge.net/projects/msys2/files/REPOS/MINGW/Sources" | 129 | SRC_REPO="https://sourceforge.net/projects/msys2/files/REPOS/MINGW/Sources" |
| 63 | 130 | ||
| 64 | 131 | ||
| 65 | def check_output_maybe(*args,**kwargs): | ||
| 66 | if(DRY_RUN): | ||
| 67 | print("Calling: {}{}".format(args,kwargs)) | ||
| 68 | else: | ||
| 69 | return check_output(*args,**kwargs) | ||
| 70 | |||
| 71 | def immediate_deps(pkg): | 132 | def immediate_deps(pkg): |
| 72 | package_info = check_output(["pacman", "-Si", pkg]).decode("utf-8").split("\n") | 133 | package_info = check_output(["pacman", "-Si", pkg]).decode("utf-8").split("\n") |
| 73 | 134 | ||
| @@ -87,6 +148,7 @@ def immediate_deps(pkg): | |||
| 87 | return dependencies | 148 | return dependencies |
| 88 | 149 | ||
| 89 | 150 | ||
| 151 | ## Extract all the msys2 packages that are dependencies of our direct dependencies | ||
| 90 | def extract_deps(): | 152 | def extract_deps(): |
| 91 | 153 | ||
| 92 | print( "Extracting deps" ) | 154 | print( "Extracting deps" ) |
| @@ -105,44 +167,6 @@ def extract_deps(): | |||
| 105 | 167 | ||
| 106 | return sorted(pkgs) | 168 | return sorted(pkgs) |
| 107 | 169 | ||
| 108 | def gather_deps(deps, arch, directory): | ||
| 109 | |||
| 110 | os.mkdir(arch) | ||
| 111 | os.chdir(arch) | ||
| 112 | |||
| 113 | ## Replace the architecture with the correct one | ||
| 114 | deps = [re.sub(r"x86_64",arch,x) for x in deps] | ||
| 115 | |||
| 116 | ## find all files the transitive dependencies | ||
| 117 | deps_files = check_output( | ||
| 118 | ["pacman", "-Ql"] + deps | ||
| 119 | ).decode("utf-8").split("\n") | ||
| 120 | |||
| 121 | ## Produces output like | ||
| 122 | ## mingw-w64-x86_64-zlib /mingw64/lib/libminizip.a | ||
| 123 | |||
| 124 | ## drop the package name | ||
| 125 | tmp = deps_files.copy() | ||
| 126 | deps_files=[] | ||
| 127 | for d in tmp: | ||
| 128 | slt = d.split() | ||
| 129 | if(not slt==[]): | ||
| 130 | deps_files.append(slt[1]) | ||
| 131 | |||
| 132 | ## sort uniq | ||
| 133 | deps_files = sorted(list(set(deps_files))) | ||
| 134 | ## copy all files into local | ||
| 135 | print("Copying dependencies: {}".format(arch)) | ||
| 136 | check_output_maybe(["rsync", "-R"] + deps_files + ["."]) | ||
| 137 | |||
| 138 | ## And package them up | ||
| 139 | os.chdir(directory) | ||
| 140 | print("Zipping: {}".format(arch)) | ||
| 141 | check_output_maybe("zip -9r ../../emacs-{}-{}{}-deps.zip *" | ||
| 142 | .format(EMACS_MAJOR_VERSION, DATE, arch), | ||
| 143 | shell=True) | ||
| 144 | os.chdir("../../") | ||
| 145 | |||
| 146 | 170 | ||
| 147 | def download_source(tarball): | 171 | def download_source(tarball): |
| 148 | print("Acquiring {}...".format(tarball)) | 172 | print("Acquiring {}...".format(tarball)) |
| @@ -160,6 +184,7 @@ def download_source(tarball): | |||
| 160 | ) | 184 | ) |
| 161 | print("Downloading {}... done".format(tarball)) | 185 | print("Downloading {}... done".format(tarball)) |
| 162 | 186 | ||
| 187 | ## Fetch all the source code | ||
| 163 | def gather_source(deps): | 188 | def gather_source(deps): |
| 164 | 189 | ||
| 165 | 190 | ||
| @@ -206,7 +231,7 @@ def gather_source(deps): | |||
| 206 | to_download.append(tarball) | 231 | to_download.append(tarball) |
| 207 | 232 | ||
| 208 | ## Download in parallel or it is just too slow | 233 | ## Download in parallel or it is just too slow |
| 209 | p = mp.Pool(16) | 234 | p = mp.Pool(1) |
| 210 | p.map(download_source,to_download) | 235 | p.map(download_source,to_download) |
| 211 | 236 | ||
| 212 | print("Zipping") | 237 | print("Zipping") |
| @@ -255,7 +280,7 @@ parser.add_argument("-l", help="list dependencies only", | |||
| 255 | args = parser.parse_args() | 280 | args = parser.parse_args() |
| 256 | do_all=not (args.c or args.r or args.f or args.t) | 281 | do_all=not (args.c or args.r or args.f or args.t) |
| 257 | 282 | ||
| 258 | deps=extract_deps() | 283 | |
| 259 | 284 | ||
| 260 | DRY_RUN=args.d | 285 | DRY_RUN=args.d |
| 261 | 286 | ||
| @@ -270,12 +295,13 @@ else: | |||
| 270 | DATE="" | 295 | DATE="" |
| 271 | 296 | ||
| 272 | if( do_all or args.t ): | 297 | if( do_all or args.t ): |
| 273 | gather_deps(deps,"i686","mingw32") | 298 | gather_deps("i686","mingw32") |
| 274 | 299 | ||
| 275 | if( do_all or args.f ): | 300 | if( do_all or args.f ): |
| 276 | gather_deps(deps,"x86_64","mingw64") | 301 | gather_deps("x86_64","mingw64") |
| 277 | 302 | ||
| 278 | if( do_all or args.r ): | 303 | if( do_all or args.r ): |
| 304 | deps=extract_deps() | ||
| 279 | gather_source(deps) | 305 | gather_source(deps) |
| 280 | 306 | ||
| 281 | if( args.c ): | 307 | if( args.c ): |
diff --git a/admin/nt/dist-build/build-zips.sh b/admin/nt/dist-build/build-zips.sh index 4a9a7b596e7..fbb98895384 100755 --- a/admin/nt/dist-build/build-zips.sh +++ b/admin/nt/dist-build/build-zips.sh | |||
| @@ -64,10 +64,8 @@ function build_zip { | |||
| 64 | make -j 4 $INSTALL_TARGET \ | 64 | make -j 4 $INSTALL_TARGET \ |
| 65 | prefix=$HOME/emacs-build/install/emacs-$VERSION/$ARCH | 65 | prefix=$HOME/emacs-build/install/emacs-$VERSION/$ARCH |
| 66 | cd $HOME/emacs-build/install/emacs-$VERSION/$ARCH | 66 | cd $HOME/emacs-build/install/emacs-$VERSION/$ARCH |
| 67 | cp $HOME/emacs-build/deps/libXpm/$ARCH/libXpm-noX4.dll bin | ||
| 68 | zip -r -9 emacs-$OF_VERSION-$ARCH-no-deps.zip * | 67 | zip -r -9 emacs-$OF_VERSION-$ARCH-no-deps.zip * |
| 69 | mv emacs-$OF_VERSION-$ARCH-no-deps.zip $HOME/emacs-upload | 68 | mv emacs-$OF_VERSION-$ARCH-no-deps.zip $HOME/emacs-upload |
| 70 | rm bin/libXpm-noX4.dll | ||
| 71 | 69 | ||
| 72 | if [ -z $SNAPSHOT ]; | 70 | if [ -z $SNAPSHOT ]; |
| 73 | then | 71 | then |
| @@ -78,7 +76,7 @@ function build_zip { | |||
| 78 | fi | 76 | fi |
| 79 | 77 | ||
| 80 | echo [build] Using $DEPS_FILE | 78 | echo [build] Using $DEPS_FILE |
| 81 | unzip $DEPS_FILE | 79 | unzip -d bin $DEPS_FILE |
| 82 | 80 | ||
| 83 | zip -r -9 emacs-$OF_VERSION-$ARCH.zip * | 81 | zip -r -9 emacs-$OF_VERSION-$ARCH.zip * |
| 84 | mv emacs-$OF_VERSION-$ARCH.zip ~/emacs-upload | 82 | mv emacs-$OF_VERSION-$ARCH.zip ~/emacs-upload |
| @@ -208,7 +206,7 @@ then | |||
| 208 | else | 206 | else |
| 209 | BRANCH=$REQUIRED_BRANCH | 207 | BRANCH=$REQUIRED_BRANCH |
| 210 | echo [build] Building from Branch $BRANCH | 208 | echo [build] Building from Branch $BRANCH |
| 211 | VERSION=$VERSION-$BRANCH | 209 | VERSION=$VERSION-${BRANCH/\//_} |
| 212 | OF_VERSION="$VERSION-`date +%Y-%m-%d`" | 210 | OF_VERSION="$VERSION-`date +%Y-%m-%d`" |
| 213 | ## Use snapshot dependencies | 211 | ## Use snapshot dependencies |
| 214 | SNAPSHOT=1 | 212 | SNAPSHOT=1 |