├── .gitattributes
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── generic_bug_report.md
│ └── request.md
├── PULL_REQUEST_TEMPLATE.md
└── PULL_REQUEST_TEMPLATE
│ ├── fix.md
│ ├── new.md
│ └── update.md
├── .gitignore
├── LICENSE
├── README.md
├── build
├── bash.sh
├── media-suite_compile.sh
├── media-suite_deps.sh
├── media-suite_helper.sh
└── media-suite_update.sh
├── doc
├── forcing-recompilations.md
├── getting-started.md
└── updating.md
└── media-autobuild_suite.bat
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 | *.bat text eol=crlf
4 | *.sh text eol=lf
5 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 'Build Bug report'
3 | about: 'Repo bug report'
4 | title: '[mingw32|mingw64] [repo]'
5 | labels: 'Bug Report'
6 | assignees: ''
7 |
8 | ---
9 |
20 |
21 | ``` bash
22 | Paste output of the suite here
23 | ```
24 |
25 | [logs.zip](https://github.com/jb-alvarado/media-autobuild_suite)
26 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/generic_bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 'Generic/Suite bug report'
3 | about: 'Generic/Suite bug report'
4 | title: ''
5 | labels: 'Bug Report'
6 | assignees: ''
7 |
8 | ---
9 |
17 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 'Feature Request'
3 | about: 'Feature Request'
4 | title: 'Request: [Description]'
5 | labels: 'Feature Request'
6 | assignees: ''
7 |
8 | ---
9 |
13 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE/fix.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 'Bug Fix'
3 | about: 'Bug Fix'
4 | title: '[file]: Fix [issue]'
5 | labels: 'Bug Fix'
6 | assignees: 'wiiaboo'
7 |
8 | ---
9 |
14 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE/new.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 'New Package'
3 | about: 'Add a new package'
4 | title: '[repo]: Add [repo]'
5 | labels: 'New Package'
6 | assignees: 'wiiaboo'
7 |
8 | ---
9 | Add [repo] to the suite.
10 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE/update.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 'Update Package'
3 | about: 'Update a package'
4 | title: '[repo]: update to [version]'
5 | labels: 'Update'
6 | assignees: 'wiiaboo'
7 |
8 | ---
9 | Update [repo] to [version]
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## media-autobuild_suite
3 | #################
4 |
5 | ## ignore media-autobuild_suite folders and local specific files
6 |
7 | /build/*
8 | /local32/
9 | /local64/
10 | /msys64/
11 | /msys32/
12 |
13 | mintty.lnk
14 | update_suite.sh
15 | !build/bash.ps1
16 | !build/*.sh
17 | !build/patches/
18 | !build/extras/
19 | /build/post_suite.sh
20 |
21 | ## VS Code
22 | .vscode
23 |
24 | #############
25 | ## Windows detritus
26 | #############
27 |
28 | # Windows image file caches
29 | Thumbs.db
30 | ehthumbs.db
31 |
32 | # Folder config file
33 | Desktop.ini
34 |
35 | # Recycle Bin used on file shares
36 | $RECYCLE.BIN/
37 |
38 | # Mac crap
39 | .DS_Store
40 |
41 | # Ignore extra files
42 | *_extra.sh
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # media-autobuild_suite
2 |
3 | Before opening an issue, check if it's an issue directly from executing the suite. This isn't Doom9, reddit, stackoverflow or any other forum for general questions about the things being compiled. This script builds them, that's all.
4 |
5 | This source code is also mirrored in [GitLab](https://gitlab.com/RiCON/media-autobuild_suite).
6 |
7 | Most git sources in the suite use GitHub, so if it's down, it's probably useless to run the suite at that time.
8 |
9 | ## Download
10 |
11 | **[Click here to download latest version](https://github.com/m-ab-s/media-autobuild_suite/archive/master.zip)**
12 |
13 | For information about the compiler environment see the wiki, there you also have a example of how to compile your own tools.
14 |
15 | ## Included Tools And Libraries
16 |
17 | ### [Information about FFmpeg external libraries](https://github.com/m-ab-s/media-autobuild_suite/wiki/ffmpeg_options.txt)
18 |
19 | - FFmpeg (shared or static) with these libraries (all optional, but compiled by default unless said otherwise):
20 | - Light build:
21 | - amd amf encoders (built-in)
22 | - cuda (built-in)
23 | - cuda-llvm (built-in)
24 | - cuvid (built-in)
25 | - ffnvcodec (git)
26 | - libaom (git)
27 | - libdav1d (git)
28 | - libfdk-aac (git)
29 | - needs non-free license if not LGPL
30 | - libmp3lame (mingw-w64)
31 | - libopus (mingw-w64)
32 | - libvorbis (mingw-w64)
33 | - libvpx (git)
34 | - libx264 (git)
35 | - libx265 (git)
36 | - nvdec (built-in)
37 | - nvenc (built-in)
38 | - schannel with gmp (mingw-w64)
39 | - enabled by default if openssl, libtls, mbedtls or gnutls aren't enabled
40 | - gmp can be switched by gcrypt (mingw-w64) with --enable-gcrypt
41 | - sdl2 (git tag) (needed for ffplay)
42 | - enabled by default, use --disable-sdl2 if unneeded
43 | - Zeranoe-emulating build (in addition to Light)
44 | - avisynthplus (needs avisynth dll installed)
45 | - fontconfig (latest release)
46 | - only one of these TLS libs (including schannel) can be enabled at once:
47 | - openssl (mingw-w64)
48 | - preferred to gnutls and to libtls if all three are in options
49 | - needs non-GPL license
50 | - libtls (from libressl) (latest release)
51 | - needs non-GPL license
52 | - mbedtls (mingw-w64)
53 | - preferred to gnutls if GPLv3 license is chosen
54 | - gnutls (3.8.9)
55 | - libass (git)
56 | - by default with DirectWrite backend
57 | - if --enable-fontconfig, fontconfig backend included
58 | - with harfbuzz (git)
59 | - libbluray (git)
60 | - BD-J support requires installation of Java JDK
61 | - BD-J support after compilation probably only requires JRE (untested)
62 | - libfreetype (latest release)
63 | - libgsm (mingw-w64)
64 | - libmfx (git)
65 | - libmodplug (mingw-w64)
66 | - libopencore-amr(nb/wb) (mingw-w64)
67 | - libopenjpeg2 (mingw-w64)
68 | - libopenmpt (git tag)
69 | - librav1e (git)
70 | - libsnappy (mingw-w64)
71 | - libsoxr (git)
72 | - libspeex (mingw-w64)
73 | - libsrt (git)
74 | - libsvtav1 (git)
75 | - libtheora (mingw-w64)
76 | - libtwolame (mingw-w64)
77 | - libvidstab (git)
78 | - libvmaf (git)
79 | - libvo-amrwbenc (0.1.3)
80 | - libwebp (git)
81 | - libxml2 (mingw-w64)
82 | - libxvid (git)
83 | - libzimg (git)
84 | - Full build (in addition to Zeranoe)
85 | - chromaprint (mingw-w64)
86 | - cuda filters (needs CUDA SDK installed)
87 | - needs non-free license
88 | - decklink (12.5.1)
89 | - needs non-free license
90 | - frei0r (git)
91 | - ladspa (mingw-w64)
92 | - libaribb24 (git)
93 | - libbs2b (3.1.0)
94 | - libcaca (mingw-w64)
95 | - libcdio (mingw-w64)
96 | - libcodec2 (git)
97 | - libdavs2 (git)
98 | - libflite (git)
99 | - libfribidi (git)
100 | - libglslang (git)
101 | - libgme (0.6.3)
102 | - libilbc (git)
103 | - libjxl (git)
104 | - libkvazaar (git)
105 | - libmysofa (git)
106 | - needed for sofalizer filter
107 | - libnpp (needs CUDA SDK installed)
108 | - needs non-free license
109 | - libopenh264 (official binaries)
110 | - librist (git)
111 | - librtmp (git)
112 | - librubberband (git)
113 | - libssh (broken)
114 | - libsvthevc (git) (using non-upstream patch)
115 | - libsvtvp9 (git) (using non-upstream patch)
116 | - libtesseract (git)
117 | - libuavs3d (git)
118 | - libxavs (git)
119 | - libxavs2 (git)
120 | - libzmq (mingw-w64)
121 | - libzvbi (git)
122 | - openal (git)
123 | - opencl (from system)
124 | - opengl (from system)
125 | - vapoursynth (R70)
126 | - vulkan (git)
127 |
128 | - other tools
129 | - aom (git)
130 | - av1an (git)
131 | - requires an installed or portable copy of [64-bit Python 3.12.x](https://www.python.org/downloads/) and [Vapoursynth](https://github.com/vapoursynth/vapoursynth/releases/latest)
132 | - bmx (git)
133 | - curl (git) with WinSSL/LibreSSL/OpenSSL/mbedTLS/GnuTLS backend
134 | - cyanrip (git)
135 | - dav1d (git)
136 | - dssim (git)
137 | - exhale (git)
138 | - faac (git)
139 | - fdk-aac (git)
140 | - ffmbc (git) (unsupported)
141 | - flac (git)
142 | - gifski (git)
143 | - with optional built-in video support (ffmpeg 6.1)
144 | - haisrt tools (git)
145 | - jo (git)
146 | - jpeg-xl tools (git)
147 | - jq (git)
148 | - kvazaar (git)
149 | - lame (3.100)
150 | - libaacs (git) (shared)
151 | - libavif (git) with following encoders/decoders:
152 | - aom (enc/dec)
153 | - dav1d (dec only)
154 | - rav1e (enc only)
155 | - svt-av1 (enc only)
156 | - libheif (git) with following encoders/decoders:
157 | - x265 (enc only)
158 | - kvazaar (enc only)
159 | - libde265 (dec only)
160 | - aom (enc/dec)
161 | - dav1d (dec only)
162 | - svt-av1 (enc only)
163 | - vvenc & vvdec
164 | - uvg266 (enc only)
165 | - libjpeg (enc/dec)
166 | - openh264 (dec only)
167 | - uncompressed
168 | - libbdplus (git) (shared)
169 | - mediainfo cli (git)
170 | - mp4box (git)
171 | - mplayer (svn) (unsupported)
172 | - mpv (git) including in addition to ffmpeg libs:
173 | - Base build (ffmpegChoice=2 or 3)
174 | - ANGLE Headers (git)
175 | - requires ANGLE shared libraries from somewhere else (i.e. Chrome, Firefox) for gpu-context=angle support
176 | - lcms2 (mingw-w64)
177 | - libass (git)
178 | - libbluray (git)
179 | - BD-J support requires installation of Java JDK
180 | - BD-J support after compilation probably only requires JRE (untested)
181 | - luajit (git)
182 | - mujs (git)
183 | - rubberband (git snapshot)
184 | - uchardet (mingw-w64)
185 | - vulkan, shaderc, spirv-cross, libplacebo (git)
186 | - vapoursynth (R70)
187 | - Full build (ffmpegChoice=4)
188 | - dvdnav (git)
189 | - libarchive (mingw-w64)
190 | - shared libmpv
191 | - openal (git)
192 | - opus-tools (git)
193 | - rav1e (git)
194 | - ripgrep (git)
195 | - rtmpdump (git)
196 | - sox (git)
197 | - speex (git)
198 | - svt-av1 (git)
199 | - svt-hevc (git)
200 | - tesseract (git)
201 | - uvg266 (git)
202 | - vlc (git) (broken)
203 | - vvenc & vvdec (git)
204 | - vorbis-tools (git)
205 | - vpx (VP8 and VP9 8, 10 and 12 bit) (git)
206 | - vvc tools (git)
207 | - webp tools (git)
208 | - x264 (8 and 10 bit, with l-smash [mp4 output], lavf and ffms2) (git)
209 | - x265 (8, 10 and 12 bit) (git)
210 | - xvc (git) (unsupported)
211 | - xvid (git)
212 | - zlib (git or mingw-w64)
213 | - minizip, miniunzip (git)
214 | - zlib (Chromium fork, git)
215 | - minizip, minigzip (git)
216 | - zlib (Cloudflare fork, git)
217 | - minigzip (git)
218 | - zlib-ng (git)
219 | - minizip, minigzip (minizip-ng, git)
220 | - zlib-rs (git)
221 |
222 | --------
223 |
224 | ## Requirements
225 |
226 | --------
227 |
228 | - Windows 64-bits (tested with Win10 & Win11 64-bits)
229 | - 32-bit hosts are not supported.
230 | - NTFS drive
231 | - 23GB+ disk space for a full 32 and 64-bit build, 18GB+ for 64-bit
232 | - 4GB+ RAM
233 | - At least Powershell 4, Powershell core is not supported at this time
234 | - Powershell 5.1 can be downloaded [here](https://www.microsoft.com/en-us/download/details.aspx?id=54616)
235 |
236 | --------
237 |
238 | ## Information
239 |
240 | --------
241 |
242 | This tool is inspired by the very nice, linux cross-compiling tool from Roger Pack (rdp):
243 |
244 |
245 | It is based on msys2 and tested under Windows 8.1, 10 and 11.
246 |
247 |
248 | I use some jscript parts from nu774:
249 |
250 |
251 | Thanks to all of them!
252 |
253 | This Windows Batchscript setups a Mingw-w64/GCC compiler environment for building ffmpeg and other media tools under Windows.
254 | After building the environment it retrieves and compiles all tools. All tools get static compiled, no external .dlls needed (with some optional exceptions)
255 |
256 | How to use it:
257 |
258 | - Download the file, and extract it to your target folder or `git clone` the project. Compilers and tools will get installed there. Please make sure you use a folder with a short path and without space characters. A good place might be: C:\mabs
259 | - Double click the media-autobuild_suite.bat file
260 | - Select if you want to compile for Windows 32-bit, 64-bit or both
261 | - Select if you want to compile non-free tools like "fdk-aac"
262 | - Select the numbers of CPU (cores) you want to use
263 | - Wait a little bit, and hopefully after a while you'll find all your "*.exe" tools under local[32|64]\bin-(audio|global|video)
264 |
265 | The script writes an .ini file at /build/media-autobuild_suite.ini, so you only need to make these choices the first time what you want to build.
266 |
267 | The script doesn't build any registry key or system variables, when you don't need it any more you can delete the folder and your system will be clean. Building everything from scratch takes about ~3 hours depending on how many CPU cores are utilized and what is enabled.
268 |
269 | Check [forcing-recompilations](./doc/forcing-recompilations.md) for documentation on how you can force a rebuild of all libs/binaries.
270 |
271 | To save a bit of space after compiling, you can delete all source folders (except the folders with a "-git" or "-svn" on end) in /build. There's an option in the .bat for the script to remove these folders automatically. To save even more space, you can delete /msys64 after compiling. If the suite is run after /msys64 has been deleted, it will download again.
272 |
273 | Have fun!
274 |
275 | ## Troubleshooting
276 |
277 | --------
278 |
279 | If there's some error during compilation follow these steps:
280 |
281 | 1. Make sure you're using the latest version of this suite by downloading the [latest version](https://github.com/m-ab-s/media-autobuild_suite/archive/master.zip) and replacing all files with the new ones;
282 | 2. If you know which part it's crashing on, delete that project's folder in /build and run the script again (ex: if x264 is failing, try deleting x264-git folder in /build);
283 | 3. If it still doesn't work, [create an issue](https://github.com/m-ab-s/media-autobuild_suite/issues/new) and paste the URL to `logs.zip` that the script gives or attach the file yourself to the issue page.
284 | 4. If the problem isn't reproducible by the contributors of the suite, it's probably a problem on your side. Delete /msys64 and /local[32|64] if they exist. /build is usually safe to keep and saves time;
285 | 5. If the problem is reproducible, it could be a problem with the package itself or the contributors will find a way to probably make it work.
286 | 6. If you compile with `--enable-libnpp` and/or `--enable-cuda-nvcc`, see [Notes about CUDA SDK](#notes-about-cuda-sdk)
287 |
288 | ## What The Individual Files Do
289 |
290 | --------
291 |
292 | `media-autobuild_suite.bat`
293 |
294 | - This file sets up the msys2 system and the compiler environment. For normal use you only have to start this file. Every time you start this batch file it runs through the process, but after the first time it only checks some variables and run updates to the MinGW environment. After that it only compiles the tools that get updates from git.
295 |
296 | `/build/media-autobuild_suite.ini`
297 |
298 | - This file get generated after the first start and saves the settings that you have selected. Before the next run you can edit it.
299 |
300 | `/build/media-suite_compile.sh`
301 |
302 | - This is the compiling script, it builds all the libs and tools we want, like ffmpeg; mplayer; etc. You can also inspect it and see how to compile your own tools. Normally you can copy the code and paste it in the mintty shell (except `make -j $cpuCount`, here you need to put your cpu count). You don't need to start this script, it's called by the batch script.
303 |
304 | `/build/media-suite_update.sh`
305 |
306 | - This script runs every time you run the batch file. It checks for updates from msys2's pacman etc.
307 |
308 | `/build/media-suite_helper.sh`
309 |
310 | - This script contains helper functions used by compile and update that can also be `source`'d by the user if desired.
311 |
312 | `/build/media-suite_deps.sh`
313 |
314 | - This script contains the URLs for each git repo used by `build/media-suite_compile.sh`. These URLs can be appended with `#branch=BRANCH`, `#commit=COMMITHASH`, or `#tag=TAG` to build from a branch, commit, or tag respectively. They can also be replaced to build from forked repositories (For example, changing `SOURCE_REPO_SVTAV1=https://gitlab.com/AOMediaCodec/SVT-AV1.git` to `SOURCE_REPO_SVTAV1=https://github.com/gianni-rosato/svt-av1-psy.git`).
315 |
316 | `/build/ffmpeg_options.txt` & `/build/mpv_options.txt`
317 |
318 | - If you select the option to choose your own FFmpeg/mpv optional libraries, these files will contain options that get sent to FFmpeg/mpv's configure script before compiling. Edit them as you wish to get a custom FFmpeg/mpv with or without any features available, if supported by the suite.
319 |
320 | ## Optional User Files
321 |
322 | --------
323 |
324 | `/local32|64/etc/custom_profile` & `$HOME/custom_build_options`
325 |
326 | - Put here any general/platform tweaks that you need for _your_ specific environment. See `/local32|64/etc/profile2.local` for example usage.
327 |
328 | ## Custom Patches
329 |
330 | --------
331 |
332 | Using custom patches is not officially supported, if you do use custom patches, do not expect much support from this suite. Either go to the patch's author or to a forum for help
333 |
334 | - It is assumed that you, the reader, have enough knowledge of bash specifically in order to understand some basic terminology. If not, please look up what you do not know.
335 | - It is highly recommended to look through the [compile script](build/media-suite_compile.sh) for the exact package you want to modify and cross-reference the functions with the [helper script](build/media-suite_compile.sh) to see what is actually being done.
336 | - Although it is recommended to use the functions provided in the helper script, there is nothing stopping you from using the actual commands.
337 |
338 | --------
339 |
340 | - To use a custom patch, within the build folder, create a script with the filename: `_extra.sh`.
341 | - For ffmpeg, the folder name is ffmpeg-git, but the repository's name would be ffmpeg: `ffmpeg_extra.sh`.
342 | - For game-music-emu, the folder name is game-music-emu-0.6.2, but the repository's name would be game-music-emu: `game-music-emu_extra.sh`
343 | - Case-sensitivity applies, so for the folder name SVT-VP9-git (repo name SVT-VP9), the script filename would be: `SVT-VP9_extra.sh`
344 |
345 | - The commands will run in the cloned/unzipped folder unless otherwise stated. (flac_extra.sh would run commands within flac-git)
346 |
347 | To reference the cloned folder itself (`flac-git` `ffmpeg-git`) you can use the variable `${REPO_DIR}`.
348 | To reference the generated build folder, you would need to use `${REPO_DIR}/build-${bits}` to reference the build-64bit folder for 64 bit builds or build-32bit folder for 32 bit builds.
349 |
350 | - For some packages, the build folder may be slightly different (`build-shared-${bits}` for shared ffmpeg or `build-light-${bits}` for light build, etc. Try to compile at least once to see what folders are generated or look through the [compile script](build/media-suite_compile.sh))
351 |
352 | If you are building for both 32 and 64-bit, you can gate certain commands using `if [[ $bits = 64bit ]]; then ; fi` to only run them when building for 64 bits.\
353 | Be careful with certain packages due to their unique build process (x265, x264, and some others) so make sure to check the compile script
354 |
355 | Example Script: `/build/aom_extra.sh` for `aom-git`
356 |
357 | ``` bash
358 | #!/bin/bash
359 |
360 | # Don't automatically run cmake || configure
361 | touch do_not_reconfigure
362 |
363 | # Commands to run before running cmake
364 | _pre_cmake(){
365 | # Installs libwebp
366 | do_pacman_install libwebp
367 | # Downloads the patch and then applies the patch
368 | do_patch "https://gist.githubusercontent.com/1480c1/9fa9292afedadcea2b3a3e067e96dca2/raw/50a3ed39543d3cf21160f9ad38df45d9843d8dc5/0001-Example-patch-for-learning-purpose.patch"
369 | # Change directory to the build folder
370 | cd_safe "build-${bits}"
371 | # Run cmake with custom options. This will override the previous cmake commands.
372 | # $LOCALDESTDIR refers to local64 or local32
373 | cmake .. -G"Ninja" -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" \
374 | -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang \
375 | -DBUILD_SHARED_LIBS=off -DENABLE_TOOLS=off
376 | }
377 |
378 | _post_cmake(){
379 | # post cmake and post configure will be unavailable due to "touch do_not_reconfigure"
380 | # as the do_not_reconfigure flag will skip the post commands.
381 | }
382 |
383 | # Commands to run before building using ninja
384 | _pre_ninja(){
385 | # Change directory to the build folder (Absolute path or relative to aom-git)
386 | cd_safe "build-${bits}"
387 | # applies a local patch (Absolute or relative to aom-git)
388 | do_patch "My-Custom-Patches/test-diff-files.diff"
389 | # run a custom ninja command.
390 | ninja aom_version_check
391 | # Not necessary, but just for readability sake
392 | cd_safe ..
393 | }
394 |
395 | ```
396 |
397 | Example Script: `/build/ffmpeg_extra.sh` for `ffmpeg-git`
398 |
399 | ``` bash
400 | #!/bin/bash
401 |
402 | # Force to the suite to think the package has updates to recompile.
403 | # Alternatively, you can use "touch recompile" for a similar effect.
404 | touch custom_updated
405 |
406 | _pre_configure(){
407 | #
408 | # Apply a patch from ffmpeg's patchwork site.
409 | do_patch "https://patchwork.ffmpeg.org/patch/12563/mbox/" am
410 | #
411 | # Apply a local patch inside the directory where is "ffmpeg_extra.sh"
412 | patch -p1 -i "$LOCALBUILDDIR/ffmpeg-0001-my_patch.patch"
413 | #
414 | # Add extra configure options to ffmpeg (ffmpeg specific)
415 | # If you want to add something to ffmpeg not within the suite already
416 | # you will need to install it yourself, either through pacman
417 | # or compiling from source.
418 | FFMPEG_OPTS+=(--enable-libsvthevc)
419 | #
420 | }
421 |
422 | _post_make(){
423 | # Don't run configure again.
424 | touch "$(get_first_subdir -f)/do_not_reconfigure"
425 | # Don't clean the build folder on each successive run.
426 | # This is for if you want to keep the current build folder as is and just recompile only.
427 | touch "$(get_first_subdir -f)/do_not_clean"
428 | }
429 | ```
430 |
431 | For a list of possible directive, look under `unset_extra_script` in [media-suite_helper.sh](build/media-suite_helper.sh).
432 | Beware as they may change in the future.
433 |
434 | ## Notes about CUDA SDK
435 |
436 | --------
437 |
438 | ### This is for cuda-nvcc and libnpp, not for NVENC, it is built with ffmpeg by default
439 |
440 | For `--enable-cuda-nvcc` and `--enable-libnpp` to work, you need NVIDIA's [CUDA SDK](https://developer.nvidia.com/cuda-toolkit) installed with `CUDA_PATH` variable to be set system-wide (Usually set by default on CUDA SDK install) and VS2017 or better installed which should come with `vswhere.exe`.\
441 | If for some reason `CUDA_PATH` isn't set and/or `vswhere.exe` isn't installed, you need to export the `CUDA_PATH` variable path using the above mentioned user files and manually export the correct `PATH` including the absolute `cygpath` converted path to MSVC's `cl.exe`.
442 |
443 | ### You do not need to do the following if you installed the SDK with the default locations etc and you have 8.3 short paths enabled or if you installed to a directory without any spaces
444 |
445 | If you did not understand any of the words above, assume the best and hope the compilation will succeed the first time, else try reinstalling the SDK and MSVC to a path without any spaces.
446 |
447 | You will only need to be worried if running the following command in the mintty terminal produces a path with a space or if you have 8.3 short paths disabled.
448 |
449 | ```bash
450 | cygpath -sm "$CUDA_PATH"
451 | ```
452 |
453 | If running the above command produces a path with a space, you will need to either disable cuda/npp stuff or reinstall your cuda sdk to a path without spaces.
454 |
455 | ### Nothing should be disabled manually when installing CUDA SDK as disabling random things can cause the compilation to fail
456 |
457 | For example, if you need to manually set the `CUDA_PATH` and include in the `PATH` the binaries for MSVC `cl.exe` and `nvcc.exe`, add this bit of bash script inside a text file in `/local64/etc/custom_profile`:
458 |
459 | ```bash
460 | # adapt these to your environment
461 | _cuda_basepath="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA"
462 | _cuda_version=10.0
463 |
464 | _msvc_basepath="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC"
465 | _msvc_version=14.15.26726
466 | _msvc_hostarch=x64
467 | _msvc_targetarch=x64
468 |
469 | # you shouldn't need to change these unless your environment is weird or you know what you're doing
470 | export CUDA_PATH=$(cygpath -sm "${_cuda_basepath}")/${_cuda_version}
471 | export PATH=$PATH:$(dirname "$(cygpath -u "\\${_msvc_basepath}\\${_msvc_version}\bin\Host\\${_msvc_hostarch}\\${_msvc_targetarch}\cl.exe")")
472 | export PATH=$PATH:$CUDA_PATH/bin
473 | ```
474 |
--------------------------------------------------------------------------------
/build/bash.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | logFile=$(cygpath -u "$1" 2> /dev/null)
3 | command=$2
4 | shift 2
5 | [[ -z $logFile || -z $command ]] && exit 1
6 | script -eqf --command "/usr/bin/bash -o pipefail -lc '$command $*'" /dev/null | tee "$logFile"
7 | exit "${PIPESTATUS[0]}"
8 |
--------------------------------------------------------------------------------
/build/media-suite_deps.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Dependency References
4 | SOURCE_REPO_AMF=https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git
5 | SOURCE_REPO_ANGLE=https://chromium.googlesource.com/angle/angle
6 | SOURCE_REPO_ARRIB24=https://github.com/nkoriyama/aribb24.git
7 | SOURCE_REPO_AUDIOTOOLBOX=https://github.com/cynagenautes/AudioToolboxWrapper.git
8 | SOURCE_REPO_AV1AN=https://github.com/master-of-zen/Av1an.git
9 | SOURCE_REPO_AVISYNTH=https://github.com/AviSynth/AviSynthPlus.git
10 | SOURCE_REPO_CODEC2=https://github.com/drowe67/codec2.git
11 | SOURCE_REPO_CURL=https://github.com/curl/curl.git
12 | SOURCE_REPO_CYANRIP=https://github.com/cyanreg/cyanrip.git
13 | SOURCE_REPO_DAV1D=https://code.videolan.org/videolan/dav1d.git
14 | SOURCE_REPO_DAVS=https://github.com/pkuvcl/davs2.git
15 | SOURCE_REPO_DECKLINK=https://gitlab.com/m-ab-s/decklink-headers.git
16 | SOURCE_REPO_DLFCN=https://github.com/dlfcn-win32/dlfcn-win32.git
17 | SOURCE_REPO_DOVI_TOOL=https://github.com/quietvoid/dovi_tool.git
18 | SOURCE_REPO_DSSIM=https://github.com/kornelski/dssim.git
19 | SOURCE_REPO_EXHALE=https://gitlab.com/ecodis/exhale.git
20 | SOURCE_REPO_FAAC=https://github.com/knik0/faac.git
21 | SOURCE_REPO_FDKAAC=https://github.com/mstorsjo/fdk-aac
22 | SOURCE_REPO_FDKAACEXE=https://github.com/nu774/fdkaac
23 | SOURCE_REPO_FFMBC=https://github.com/bcoudurier/FFmbc.git#branch=ffmbc # no other branch
24 | SOURCE_REPO_FFMS2=https://github.com/FFMS/ffms2.git
25 | SOURCE_REPO_FFNVCODEC=https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
26 | SOURCE_REPO_FLAC=https://github.com/xiph/flac.git
27 | SOURCE_REPO_FLITE=https://github.com/festvox/flite.git
28 | SOURCE_REPO_FONTCONFIG=https://gitlab.freedesktop.org/fontconfig/fontconfig.git#tag=LATEST
29 | SOURCE_REPO_FREETYPE=https://github.com/freetype/freetype.git#tag=LATEST
30 | SOURCE_REPO_FREI0R=https://github.com/dyne/frei0r.git
31 | SOURCE_REPO_FRIBIDI=https://github.com/fribidi/fribidi.git
32 | SOURCE_REPO_GFLAGS=https://github.com/gflags/gflags.git
33 | SOURCE_REPO_GIFSKI=https://github.com/ImageOptim/gifski.git
34 | SOURCE_REPO_GLSLANG=https://github.com/KhronosGroup/glslang.git
35 | SOURCE_REPO_GPAC=https://github.com/gpac/gpac.git
36 | SOURCE_REPO_HARFBUZZ=https://github.com/harfbuzz/harfbuzz.git
37 | SOURCE_REPO_HDR10PLUS_TOOL=https://github.com/quietvoid/hdr10plus_tool.git
38 | SOURCE_REPO_JO=https://github.com/jpmens/jo.git
39 | SOURCE_REPO_JQ=https://github.com/jqlang/jq.git
40 | SOURCE_REPO_LENSFUN=https://github.com/lensfun/lensfun.git
41 | SOURCE_REPO_LEPT=https://github.com/DanBloomberg/leptonica.git
42 | SOURCE_REPO_LIBAACS=https://code.videolan.org/videolan/libaacs.git
43 | SOURCE_REPO_LIBAOM=https://aomedia.googlesource.com/aom
44 | SOURCE_REPO_LIBASS=https://github.com/libass/libass.git
45 | SOURCE_REPO_LIBAVIF=https://github.com/AOMediaCodec/libavif.git
46 | SOURCE_REPO_LIBBDPLUS=https://code.videolan.org/videolan/libbdplus.git
47 | SOURCE_REPO_LIBBLURAY=https://code.videolan.org/videolan/libbluray.git
48 | SOURCE_REPO_LIBBMX=https://github.com/bbc/bmx.git
49 | SOURCE_REPO_LIBDE265=https://github.com/strukturag/libde265.git
50 | SOURCE_REPO_LIBDVDNAV=https://code.videolan.org/videolan/libdvdnav.git
51 | SOURCE_REPO_LIBDVDREAD=https://code.videolan.org/videolan/libdvdread.git
52 | SOURCE_REPO_LIBGLUT=https://github.com/dcnieho/FreeGLUT.git
53 | SOURCE_REPO_LIBHEIF=https://github.com/strukturag/libheif.git
54 | SOURCE_REPO_LIBILBC=https://github.com/TimothyGu/libilbc.git
55 | SOURCE_REPO_LIBJXL=https://github.com/libjxl/libjxl.git
56 | SOURCE_REPO_LIBKVAZAAR=https://github.com/ultravideo/kvazaar.git
57 | SOURCE_REPO_LIBLC3=https://github.com/google/liblc3.git
58 | SOURCE_REPO_LIBLSMASH=https://github.com/l-smash/l-smash.git
59 | SOURCE_REPO_LIBMEDIAINFO=https://github.com/MediaArea/MediaInfoLib.git
60 | SOURCE_REPO_LIBMFX=https://github.com/lu-zero/mfx_dispatch.git
61 | SOURCE_REPO_LIBMUSICBRAINZ=https://github.com/metabrainz/libmusicbrainz.git
62 | SOURCE_REPO_LIBMYSOFA=https://github.com/hoene/libmysofa.git
63 | SOURCE_REPO_LIBOGG=https://github.com/xiph/ogg.git
64 | SOURCE_REPO_LIBOPENMPT=https://github.com/OpenMPT/openmpt.git#branch=OpenMPT-1.30
65 | SOURCE_REPO_LIBOPUSENC=https://gitlab.xiph.org/xiph/libopusenc.git
66 | SOURCE_REPO_LIBPLACEBO=https://code.videolan.org/videolan/libplacebo.git
67 | SOURCE_REPO_LIBPNG=https://github.com/glennrp/libpng.git
68 | SOURCE_REPO_LIBRAV1E=https://github.com/xiph/rav1e.git
69 | SOURCE_REPO_LIBRESSL=https://github.com/libressl-portable/portable.git#tag=LATEST
70 | SOURCE_REPO_LIBRIST=https://code.videolan.org/rist/librist.git
71 | SOURCE_REPO_LIBRTMP=https://gitlab.com/m-ab-s/rtmpdump.git
72 | SOURCE_REPO_LIBSOXR=https://gitlab.com/m-ab-s/libsoxr.git
73 | SOURCE_REPO_LIBTIFF=https://gitlab.com/libtiff/libtiff.git
74 | SOURCE_REPO_LIBVMAF=https://github.com/Netflix/vmaf.git
75 | SOURCE_REPO_LIBVORBIS=https://github.com/xiph/vorbis.git
76 | SOURCE_REPO_LIBVPL=https://github.com/intel/libvpl.git
77 | SOURCE_REPO_LIBVVDEC=https://github.com/fraunhoferhhi/vvdec.git
78 | SOURCE_REPO_LIBVVENC=https://github.com/fraunhoferhhi/vvenc.git
79 | SOURCE_REPO_LIBWEBP=https://chromium.googlesource.com/webm/libwebp
80 | SOURCE_REPO_LIBXML2=https://gitlab.gnome.org/GNOME/libxml2.git
81 | SOURCE_REPO_LIBZEN=https://github.com/MediaArea/ZenLib.git
82 | SOURCE_REPO_LUAJIT=https://github.com/LuaJIT/LuaJIT.git
83 | SOURCE_REPO_MABS=https://github.com/m-ab-s/media-autobuild_suite.git
84 | SOURCE_REPO_MEDIAINFO=https://github.com/MediaArea/MediaInfo.git
85 | SOURCE_REPO_MINIZIPNG=https://github.com/zlib-ng/minizip-ng.git
86 | SOURCE_REPO_MPV=https://github.com/mpv-player/mpv.git
87 | SOURCE_REPO_MUJS=https://github.com/ccxvii/mujs.git
88 | SOURCE_REPO_NEON=https://github.com/notroj/neon.git
89 | SOURCE_REPO_OPENAL=https://github.com/kcat/openal-soft.git
90 | SOURCE_REPO_OPENAPV=https://github.com/AcademySoftwareFoundation/openapv.git
91 | SOURCE_REPO_OPENCLHEADERS=https://github.com/KhronosGroup/OpenCL-Headers.git
92 | SOURCE_REPO_OPUS=https://gitlab.xiph.org/xiph/opus.git
93 | SOURCE_REPO_OPUSEXE=https://gitlab.xiph.org/xiph/opus-tools.git
94 | SOURCE_REPO_OPUSFILE=https://gitlab.xiph.org/xiph/opusfile.git
95 | SOURCE_REPO_RIPGREP=https://github.com/BurntSushi/ripgrep.git
96 | SOURCE_REPO_RUBBERBAND=https://github.com/m-ab-s/rubberband.git
97 | SOURCE_REPO_SDL2=https://github.com/libsdl-org/SDL.git#SDL2
98 | SOURCE_REPO_SHADERC=https://github.com/google/shaderc.git
99 | SOURCE_REPO_SHINE=https://github.com/toots/shine.git
100 | SOURCE_REPO_SNDFILE=https://github.com/libsndfile/libsndfile.git
101 | SOURCE_REPO_SOX=https://git.code.sf.net/p/sox/code
102 | SOURCE_REPO_SPEEX=https://github.com/xiph/speex.git
103 | SOURCE_REPO_SPIRV_CROSS=https://github.com/KhronosGroup/SPIRV-Cross.git
104 | SOURCE_REPO_SPIRV_HEADERS=https://github.com/KhronosGroup/SPIRV-Headers.git
105 | SOURCE_REPO_SPIRV_TOOLS=https://github.com/KhronosGroup/SPIRV-Tools.git
106 | SOURCE_REPO_SRT=https://github.com/Haivision/srt.git
107 | SOURCE_REPO_SVTAV1=https://gitlab.com/AOMediaCodec/SVT-AV1.git
108 | SOURCE_REPO_SVTHEVC=https://github.com/OpenVisualCloud/SVT-HEVC.git
109 | SOURCE_REPO_SVTVP9=https://github.com/OpenVisualCloud/SVT-VP9.git
110 | SOURCE_REPO_TESSERACT=https://github.com/tesseract-ocr/tesseract.git
111 | SOURCE_REPO_UAVS3D=https://github.com/uavs3/uavs3d.git
112 | SOURCE_REPO_URIPARSER=https://github.com/uriparser/uriparser.git
113 | SOURCE_REPO_UVG266=https://github.com/ultravideo/uvg266.git
114 | SOURCE_REPO_VIDSTAB=https://github.com/georgmartius/vid.stab.git
115 | SOURCE_REPO_VORBIS_TOOLS=https://github.com/xiph/vorbis-tools.git
116 | SOURCE_REPO_VPX=https://chromium.googlesource.com/webm/libvpx
117 | SOURCE_REPO_VULKANLOADER=https://github.com/KhronosGroup/Vulkan-Loader.git
118 | SOURCE_REPO_VVC=https://gitlab.com/m-ab-s/VVCSoftware_VTM.git
119 | SOURCE_REPO_X264=https://code.videolan.org/videolan/x264.git
120 | SOURCE_REPO_X265=https://bitbucket.org/multicoreware/x265_git.git
121 | SOURCE_REPO_XAVS=https://github.com/Distrotech/xavs.git
122 | SOURCE_REPO_XAVS2=https://github.com/pkuvcl/xavs2.git
123 | SOURCE_REPO_XEVD=https://github.com/mpeg5/xevd.git
124 | SOURCE_REPO_XEVE=https://github.com/mpeg5/xeve.git
125 | SOURCE_REPO_XVC=https://github.com/divideon/xvc.git
126 | SOURCE_REPO_XVID=https://github.com/m-ab-s/xvid.git
127 | SOURCE_REPO_ZIMG=https://github.com/sekrit-twc/zimg.git
128 | SOURCE_REPO_ZLIB=https://github.com/madler/zlib.git
129 | SOURCE_REPO_ZLIBCHROMIUM=https://chromium.googlesource.com/chromium/src/third_party/zlib
130 | SOURCE_REPO_ZLIBCLOUDFLARE=https://github.com/cloudflare/zlib.git
131 | SOURCE_REPO_ZLIBNG=https://github.com/zlib-ng/zlib-ng.git
132 | SOURCE_REPO_ZLIBRS=https://github.com/trifectatechfoundation/zlib-rs.git
133 | SOURCE_REPO_ZVBI=https://github.com/zapping-vbi/zvbi.git
134 |
--------------------------------------------------------------------------------
/build/media-suite_helper.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # shellcheck disable=SC2154,SC2120,SC2119,SC2034,SC1090,SC1117,SC2030,SC2031
3 |
4 | if [[ -z ${MSYS+x} ]]; then
5 | export MSYS=winsymlinks:nativestrict
6 | touch linktest
7 | ln -s linktest symlinktest > /dev/null 2>&1
8 | ln linktest hardlinktest > /dev/null 2>&1
9 | test -h symlinktest || unset MSYS
10 | [[ $(stat --printf '%h\n' hardlinktest) -eq 2 ]] || unset MSYS
11 | rm -f symlinktest hardlinktest linktest
12 | fi
13 |
14 | case $cpuCount in
15 | '' | *[!0-9]*) cpuCount=$(($(nproc) / 2)) ;;
16 | esac
17 | : "${bits:=64bit}"
18 | curl_opts=(/usr/bin/curl --connect-timeout 15 --retry 3
19 | --retry-delay 5 --silent --location --insecure --fail)
20 |
21 | if test -n "$(tput colors)" && test "$(tput colors)" -ge 8; then
22 | bold=$(tput bold)
23 | blue=$(tput setaf 12)
24 | orange=$(tput setaf 11)
25 | purple=$(tput setaf 13)
26 | green=$(tput setaf 2)
27 | red=$(tput setaf 1)
28 | reset=$(tput sgr0)
29 | fi
30 | ncols=72
31 |
32 | do_simple_print() {
33 | local plain=false formatString dateValue newline='\n' OPTION OPTIND
34 | while getopts ':np' OPTION; do
35 | case "$OPTION" in
36 | n) newline='' ;;
37 | p) plain=true ;;
38 | *) break ;;
39 | esac
40 | done
41 | shift "$((OPTIND - 1))"
42 |
43 | if [[ $timeStamp == y ]]; then
44 | formatString="${purple}"'%(%H:%M:%S)T'"${reset}"' '
45 | dateValue='-1'
46 | elif $plain; then
47 | formatString='\t'
48 | fi
49 | if ! $plain; then
50 | formatString+="${bold}├${reset} "
51 | fi
52 | printf "$formatString"'%b'"${reset}${newline}" $dateValue "$*"
53 | }
54 |
55 | do_print_status() {
56 | local _prefix _prefixpad=0
57 | if [[ $1 == prefix ]]; then
58 | _prefix="$2" && shift 2
59 | _prefixpad=2
60 | fi
61 | local name="$1 " color="$2" status="$3" pad
62 | eval printf -v pad ".%.s" "{1..$ncols}"
63 | if [[ $timeStamp == y ]]; then
64 | printf "${purple}"'%(%H:%M:%S)T'"${reset}"' %s%s %s [%s]\n' -1 "$_prefix" "${bold}$name${reset}" \
65 | "${pad:0:$((ncols - _prefixpad - ${#name} - ${#status} - 12))}" "${color}${status}${reset}"
66 | else
67 | printf '%s%s %s [%s]\n' "$_prefix" "${bold}$name${reset}" \
68 | "${pad:0:$((ncols - _prefixpad - ${#name} - ${#status} - 2))}" "${color}${status}${reset}"
69 | fi
70 | }
71 |
72 | do_print_progress() {
73 | case $logging$timeStamp in
74 | yy) printf "${purple}"'%(%H:%M:%S)T'"${reset}"' %s\n' -1 "$([[ $1 =~ ^[a-zA-Z] ]] && echo "${bold}├${reset} ")$*..." ;;
75 | yn)
76 | [[ $1 =~ ^[a-zA-Z] ]] &&
77 | printf '%s' "${bold}├${reset} "
78 | echo -e "$*..."
79 | ;;
80 | *)
81 | set_title "$* in $(get_first_subdir)"
82 | if [[ $timeStamp == y ]]; then
83 | printf "${purple}"'%(%H:%M:%S)T'"${reset}"' %s\n' -1 "${bold}$* in $(get_first_subdir)${reset}"
84 | else
85 | echo -e "${bold}$* in $(get_first_subdir)${reset}"
86 | fi
87 | ;;
88 | esac
89 | }
90 |
91 | set_title() {
92 | printf '\033]0;media-autobuild_suite %s\a' "($bits)${1:+: $1}"
93 | }
94 |
95 | do_exit_prompt() {
96 | if [[ -n $build32$build64 ]]; then # meaning "executing this in the suite's context"
97 | create_diagnostic
98 | zip_logs
99 | fi
100 | do_prompt "$*"
101 | [[ -n $build32$build64 ]] && exit 1
102 | }
103 |
104 | cd_safe() {
105 | cd "$1" || do_exit_prompt "Failed changing to directory $1."
106 | }
107 |
108 | test_newer() {
109 | [[ $1 == installed ]] && local installed=y && shift
110 | local file
111 | local files=("$@")
112 | local cmp="${files[-1]}"
113 | [[ $installed ]] && cmp="$(file_installed "$cmp")"
114 | [[ ${#files[@]} -gt 1 ]] && unset 'files[-1]'
115 | [[ -f $cmp ]] || return 0
116 | for file in "${files[@]}"; do
117 | [[ $installed ]] && file="$(file_installed "$file")"
118 | [[ -f $file ]] &&
119 | [[ $file -nt $cmp ]] && return
120 | done
121 | return 1
122 | }
123 |
124 | # vcs_get_current_type /build/myrepo
125 | vcs_get_current_type() {
126 | git -C "${1:-$PWD}" rev-parse --is-inside-work-tree > /dev/null 2>&1 &&
127 | echo "git" &&
128 | return 0
129 | echo "unknown"
130 | return 1
131 | }
132 |
133 | # check_valid_vcs /build/ffmpeg-git
134 | check_valid_vcs() {
135 | [[ -d ${1:-$PWD}/.git ]] &&
136 | git -C "${1:-$PWD}/.git" rev-parse HEAD > /dev/null 2>&1
137 | }
138 |
139 | # vcs_get_current_head /build/ffmpeg-git
140 | vcs_get_current_head() {
141 | git -C "${1:-$PWD}" rev-parse HEAD
142 | }
143 |
144 | # vcs_test_remote "https://github.com/m-ab-s/media-autobuild_suite.git"
145 | vcs_test_remote() {
146 | GIT_TERMINAL_PROMPT=0 git ls-remote -q --refs "$1" > /dev/null 2>&1
147 | }
148 |
149 | vcs_clean() {
150 | GIT_TERMINAL_PROMPT=0 \
151 | git -C "${1:-$PWD}" clean -dffxq \
152 | -e{recently_{updated,checked},build_successful*,*.{patch,diff},custom_updated,**/ab-suite.*.log} "$@"
153 | }
154 |
155 | # vcs_get_latest_tag "libopenmpt-*"
156 | vcs_get_latest_tag() {
157 | if ! case $1 in
158 | LATEST) git describe --abbrev=0 --tags "$(git rev-list --tags --max-count=1)" 2> /dev/null ;;
159 | GREATEST) git describe --abbrev=0 --tags 2> /dev/null ;;
160 | *\**) git describe --abbrev=0 --tags "$(git tag -l "$1" --sort=-version:refname | head -1)" 2> /dev/null ;;
161 | *) false ;;
162 | esac then
163 | echo "$1"
164 | fi
165 | }
166 |
167 | # vcs_set_url https://github.com/FFmpeg/FFmpeg.git
168 | vcs_set_url() {
169 | if vcs_test_remote "$1"; then
170 | git remote set-url origin "$1"
171 | fi
172 | git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
173 | }
174 |
175 | # vcs_clone https://gitlab.com/libtiff/libtiff.git tiff v4.1.0
176 | vcs_clone() (
177 | set -x
178 | vcsURL=$1 vcsFolder=${2:-$(basename "$vcsURL" .git)}
179 | [[ -z $vcsURL ]] && return 1
180 |
181 | check_valid_vcs "$vcsFolder-git" && return 0
182 | rm -rf "$vcsFolder-git"
183 | case $- in
184 | *i*) unset GIT_TERMINAL_PROMPT ;;
185 | *) export GIT_TERMINAL_PROMPT=0 ;;
186 | esac
187 | git clone --filter=tree:0 "$vcsURL" "$vcsFolder-git"
188 | git -C "$vcsFolder-git" reset --hard "${3:-origin/HEAD}"
189 | check_valid_vcs "$vcsFolder-git"
190 | )
191 |
192 | vcs_get_merge_base() {
193 | git merge-base HEAD "$(vcs_get_latest_tag "$1")"
194 | }
195 |
196 | vcs_reset() (
197 | set -x
198 | git checkout --no-track -fB ab-suite "$(vcs_get_latest_tag "$1")"
199 | git log --oneline --no-merges --no-color -n 1 | tee /dev/null
200 | )
201 |
202 | vcs_fetch() (
203 | set -x
204 | [[ -f $(git rev-parse --git-dir)/shallow ]] && unshallow="--unshallow" || unshallow=''
205 | git fetch --all -Ppft $unshallow
206 | git remote set-head -a origin
207 | )
208 |
209 | # do_mabs_clone "$vcsURL" "$vcsFolder" "$ref"
210 | # For internal use for fallback links
211 | do_mabs_clone() {
212 | vcs_test_remote "$1" &&
213 | log -q git.clone vcs_clone "$1" "$2" "$3"
214 | check_valid_vcs "$2-git"
215 | }
216 |
217 | vcs_ref_to_hash() (
218 | vcsURL=$1 ref=$2 vcsFolder=${3:-$(basename "$vcsURL" .git)}
219 | if _ref=$(git ls-remote --refs --exit-code -q -- "$vcsURL" "$ref"); then
220 | cut -f1 <<< "$_ref"
221 | return 0
222 | fi
223 | if git -C "$vcsFolder-git" rev-parse --verify -q --end-of-options "$ref" 2> /dev/null ||
224 | git -C "$vcsFolder" rev-parse --verify -q --end-of-options "$ref" 2> /dev/null ||
225 | git rev-parse --verify -q --end-of-options "$ref" 2> /dev/null; then
226 | return 0
227 | fi
228 | return 1
229 | )
230 |
231 | # get source from VCS
232 | # example:
233 | # do_vcs "url#branch|revision|tag|commit=NAME[ folder]" "folder"
234 | do_vcs() {
235 | local vcsURL=${1#*::} vcsFolder=$2 vcsCheck=("${_check[@]}")
236 | local vcsBranch=${vcsURL#*#} ref=origin/HEAD commit='' refmsg=''
237 | local deps=("${_deps[@]}") && unset _deps
238 | [[ $vcsBranch == "$vcsURL" ]] && unset vcsBranch
239 | local vcsPotentialFolder=${vcsURL#* }
240 | if [[ -z $vcsFolder ]] && [[ $vcsPotentialFolder != "$vcsURL" ]]; then
241 | vcsFolder=$vcsPotentialFolder # if there was a space, use the folder name
242 | fi
243 | vcsURL=${vcsURL%#*}
244 | : "${vcsFolder:=$(basename "$vcsURL" .git)}" # else just grab from the url like git normally does
245 |
246 | if [[ -n $vcsBranch ]]; then
247 | commit=${vcsBranch##*commit=}
248 | [[ $vcsBranch == "$commit" ]] && unset commit
249 | ref=${vcsBranch##*=}
250 | unset vcsBranch
251 | fi
252 |
253 | cd_safe "$LOCALBUILDDIR"
254 |
255 | rm -f "$vcsFolder-git/custom_updated"
256 |
257 | check_custom_patches "$vcsFolder-git"
258 |
259 | extra_script pre vcs
260 |
261 | # try to see if we can "resolve" the currently provided ref to a commit,
262 | # excluding special tags that we will resolve later. Ignore it if it's
263 | # a specific head. glslang's HEAD != their main branch somehow.
264 | case $ref in
265 | LATEST | GREATEST | *\**) ;;
266 | origin/HEAD | origin/* | HEAD) ;;
267 | *) ref=$(vcs_ref_to_hash "$vcsURL" "$ref" "$vcsFolder") ;;
268 | esac
269 |
270 | if [[ -n $commit ]]; then
271 | ref=$commit
272 | refmsg="with ref $ref"
273 | fi
274 |
275 | if ! check_valid_vcs "$vcsFolder-git"; then
276 | rm -rf "$vcsFolder-git"
277 | do_print_progress " Running git clone for $vcsFolder $refmsg"
278 | if ! do_mabs_clone "$vcsURL" "$vcsFolder" "$ref"; then
279 | echo "$vcsFolder git seems to be down"
280 | echo "Try again later or to continue"
281 | do_prompt "if you're sure nothing depends on it."
282 | unset_extra_script
283 | return 1
284 | fi
285 | touch "$vcsFolder-git"/recently_{updated,checked}
286 | fi
287 |
288 | cd_safe "$vcsFolder-git"
289 |
290 | if [[ $ffmpegUpdate == onlyFFmpeg && $vcsFolder != ffmpeg && $vcsFolder != mpv ]] &&
291 | files_exist "${vcsCheck[@]:-$vcsFolder.pc}"; then
292 | do_print_status "${vcsFolder} git" "$green" "Already built"
293 | unset_extra_script
294 | return 1
295 | fi
296 |
297 | vcs_set_url "$vcsURL"
298 | log -q git.fetch vcs_fetch
299 | oldHead=$(vcs_get_merge_base "$ref")
300 | do_print_progress " Running git update for $vcsFolder $refmsg"
301 | log -q git.reset vcs_reset "$ref"
302 | newHead=$(vcs_get_current_head "$PWD")
303 |
304 | vcs_clean
305 |
306 | if [[ $oldHead != "$newHead" || -f custom_updated ]]; then
307 | touch recently_updated
308 | rm -f ./build_successful{32,64}bit{,_*}
309 | if [[ $build32$build64$bits == yesyes64bit ]]; then
310 | new_updates=yes
311 | new_updates_packages="$new_updates_packages [$vcsFolder]"
312 | fi
313 | {
314 | echo "$vcsFolder"
315 | git log --no-merges --pretty="%ci: %an - %h%n %s" "$oldHead..$newHead"
316 | echo
317 | } >> "$LOCALBUILDDIR/newchangelog"
318 | do_print_status "┌ $vcsFolder git" "$orange" "Updates found"
319 | elif [[ -f recently_updated && ! -f build_successful$bits${flavor:+_$flavor} ]]; then
320 | do_print_status "┌ $vcsFolder git" "$orange" "Recently updated"
321 | elif [[ -n ${vcsCheck[*]} ]] && ! files_exist "${vcsCheck[@]}"; then
322 | do_print_status "┌ $vcsFolder git" "$orange" "Files missing"
323 | elif [[ -n ${deps[*]} ]] && test_newer installed "${deps[@]}" "${vcsCheck[0]}"; then
324 | do_print_status "┌ $vcsFolder git" "$orange" "Newer dependencies"
325 | else
326 | do_print_status "$vcsFolder git" "$green" "Up-to-date"
327 | [[ ! -f recompile ]] && {
328 | unset_extra_script
329 | return 1
330 | }
331 | do_print_status "┌ $vcsFolder git" "$orange" "Forcing recompile"
332 | do_print_status prefix "$bold├$reset " "Found recompile flag" "$orange" "Recompiling"
333 | fi
334 | extra_script post vcs
335 | return 0
336 | }
337 |
338 | # get source from VCS to a local subfolder
339 | # example:
340 | # do_vcs_local "url#branch|revision|tag|commit=NAME" "subfolder"
341 | do_vcs_local() {
342 | local vcsURL=${1#*::} vcsFolder=$2 vcsCheck=("${_check[@]}")
343 | local vcsBranch=${vcsURL#*#} ref=origin/HEAD
344 | local deps=("${_deps[@]}") && unset _deps
345 | [[ $vcsBranch == "$vcsURL" ]] && unset vcsBranch
346 | vcsURL=${vcsURL%#*}
347 | : "${vcsFolder:=$(basename "$vcsURL" .git)}"
348 |
349 | if [[ -n $vcsBranch ]]; then
350 | ref=${vcsBranch##*=}
351 | [[ ${vcsBranch%%=*}/$ref == branch/${ref%/*} ]] && ref=origin/$ref
352 | fi
353 |
354 | rm -f "$vcsFolder/custom_updated"
355 |
356 | # try to see if we can "resolve" the currently provided ref, minus the origin/ part,
357 | # if so, set ref to the ref on the origin, this might make it harder for people who
358 | # want use multiple remotes other than origin. Converts ref=develop to ref=origin/develop
359 | # ignore those that use the special tags/branches
360 | case $ref in
361 | LATEST | GREATEST | *\**) ;;
362 | *) git ls-remote --exit-code "$vcsURL" "${ref#origin/}" > /dev/null 2>&1 && ref=origin/${ref#origin/} ;;
363 | esac
364 |
365 | if ! check_valid_vcs "$vcsFolder"; then
366 | rm -rf "$vcsFolder"
367 | rm -rf "$vcsFolder-git"
368 | do_print_progress " Running git clone for $vcsFolder"
369 | if ! do_mabs_clone "$vcsURL" "$vcsFolder" "$ref"; then
370 | echo "$vcsFolder git seems to be down"
371 | echo "Try again later or to continue"
372 | do_prompt "if you're sure nothing depends on it."
373 | # unset_extra_script
374 | return 1
375 | fi
376 | mv "$vcsFolder-git" "$vcsFolder"
377 | touch "$vcsFolder"/recently_{updated,checked}
378 | fi
379 |
380 | cd_safe "$vcsFolder"
381 |
382 | vcs_set_url "$vcsURL"
383 | log -q git.fetch vcs_fetch
384 | oldHead=$(vcs_get_merge_base "$ref")
385 | do_print_progress " Running git update for $vcsFolder"
386 | log -q git.reset vcs_reset "$ref"
387 | newHead=$(vcs_get_current_head "$PWD")
388 |
389 | vcs_clean
390 |
391 | cd ..
392 |
393 | return 0
394 | }
395 |
396 | do_git_submodule() {
397 | log -q git.submodule git submodule update --jobs "$cpuCount" --filter=tree:0 --init --recursive
398 | }
399 |
400 | guess_dirname() {
401 | expr "$1" : '\(.\+\)\.\(tar\(\.\(gz\|bz2\|xz\|lz\)\)\?\|7z\|zip\)$'
402 | }
403 |
404 | check_hash() {
405 | local file="$1" check="$2" md5sum sha256sum
406 | if [[ -z $file || ! -f $file ]]; then
407 | return 1
408 | elif [[ -z $check ]]; then
409 | # if no hash to check, just check if the file exists
410 | return 0
411 | fi
412 |
413 | sha256sum=$(sha256sum "$file" | cut -d' ' -f1)
414 | if [[ $check == print ]]; then
415 | echo "$sha256sum"
416 | else
417 | md5sum=$(md5sum "$file" | cut -d' ' -f1)
418 | if [[ $sha256sum == "$check" || $md5sum == "$check" ]]; then
419 | return 0
420 | fi
421 | do_simple_print "${orange}Hash mismatch, file may be broken: ${check} != ${sha256sum} || ${md5sum}"
422 | return 1
423 | fi
424 | }
425 |
426 | # get wget download
427 | do_wget() {
428 | local nocd=false norm=false quiet=false notmodified=false noextract=false hash
429 | while true; do
430 | case $1 in
431 | -c) nocd=true && shift ;;
432 | -r) norm=true && shift ;;
433 | -q) quiet=true && shift ;;
434 | -h) hash="$2" && shift 2 ;;
435 | -z) notmodified=true && shift ;;
436 | -n) noextract=true && shift ;;
437 | --)
438 | shift
439 | break
440 | ;;
441 | *) break ;;
442 | esac
443 | done
444 | local url="$1" archive="$2" dirName="$3" response_code=000 curlcmds=("${curl_opts[@]}") tries=1 temp_file
445 | if [[ -z $archive ]]; then
446 | # remove arguments and filepath
447 | archive=${url%%\?*}
448 | archive=${archive##*/}
449 | fi
450 | if [[ -f $url ]]; then
451 | return 1
452 | fi
453 | archive=${archive:-"$(/usr/bin/curl -sI "$url" | grep -Eo 'filename=.*$' | sed 's/filename=//')"}
454 | [[ -z $dirName ]] && dirName=$(guess_dirname "$archive")
455 |
456 | $nocd || cd_safe "$LOCALBUILDDIR"
457 | $notmodified && [[ -f $archive ]] && curlcmds+=(-z "$archive" -R)
458 | [[ $hash ]] && tries=3
459 |
460 | if [[ -f $archive ]] && [[ $hash ]] && check_hash "$archive" "$hash"; then
461 | $quiet || do_print_status prefix "${bold}├${reset} " "${dirName:-$archive}" "$green" "File up-to-date"
462 | tries=0
463 | fi
464 |
465 | while [[ $tries -gt 0 ]]; do
466 | temp_file=$(mktemp)
467 | response_code=$("${curlcmds[@]}" -w "%{http_code}" -o "$temp_file" "$url")
468 |
469 | if [[ -f $archive ]] && diff -q "$archive" "$temp_file" > /dev/null 2>&1; then
470 | $quiet || do_print_status prefix "${bold}├${reset} " "${dirName:-$archive}" "$green" "File up-to-date"
471 | rm -f "$temp_file"
472 | break
473 | fi
474 |
475 | ((tries -= 1))
476 |
477 | case $response_code in
478 | 2**)
479 | $quiet || do_print_status "┌ ${dirName:-$archive}" "$orange" "Downloaded"
480 | check_hash "$temp_file" "$hash" && cp -f "$temp_file" "$archive"
481 | rm -f "$temp_file"
482 | break
483 | ;;
484 | 304)
485 | $quiet || do_print_status "┌ ${dirName:-$archive}" "$orange" "File up-to-date"
486 | rm -f "$temp_file"
487 | break
488 | ;;
489 | esac
490 |
491 | if check_hash "$archive" "$hash"; then
492 | printf '%b\n' "${orange}${archive}${reset}" \
493 | '\tFile not found online. Using local copy.'
494 | else
495 | do_print_status "└ ${dirName:-$archive}" "$red" "Failed"
496 | printf '%s\n' "Error $response_code while downloading $url" \
497 | " to cancel build or to continue"
498 | do_prompt "if you're sure nothing depends on it."
499 | rm -f "$temp_file"
500 | return 1
501 | fi
502 | done
503 |
504 | $norm || add_to_remove "$(pwd)/$archive"
505 | $noextract || do_extract "$archive" "$dirName"
506 | ! $norm && [[ -n $dirName ]] && ! $nocd && add_to_remove
507 | [[ -z $response_code || $response_code != "304" ]] && return 0
508 | }
509 |
510 | real_extract() {
511 | local archive="$1" dirName="$2" archive_type strip_comp=''
512 | [[ -z $archive ]] && return 1
513 | archive_type=$(expr "$archive" : '.\+\(tar\(\.\(gz\|bz2\|xz\|lz\)\)\?\|7z\|zip\)$')
514 | [[ ! $dirName ]] && dirName=$(guess_dirname "$archive" || echo "${archive}")
515 | case $archive_type in
516 | zip | 7z)
517 | 7z x -aoa -o"$dirName" "$archive"
518 | ;;
519 | tar*)
520 | [[ -n $dirName && ! -d $dirName ]] && mkdir -p "$dirName"
521 | case $archive_type in
522 | tar\.lz)
523 | do_pacman_install -m lzip
524 | lzip -d "$archive"
525 | ;;
526 | tar\.*) 7z x -aoa "$archive" ;;
527 | esac
528 | [[ $(tar -tf "${archive%.tar*}.tar" | cut -d'/' -f1 | sort -u | wc -l) == 1 ]] && strip_comp="--strip-components=1"
529 | if ! tar $strip_comp -C "$dirName" -xf "${1%.tar*}.tar"; then
530 | 7z x -aoa "${archive%.tar*}.tar" -o"$dirName"
531 | fi
532 | rm -f "${archive%.tar*}.tar"
533 | ;;
534 | esac
535 | local temp_dir
536 | temp_dir=$(find "$dirName/" -maxdepth 1 ! -wholename "$dirName/")
537 | if [[ -n $temp_dir && $(wc -l <<< "$temp_dir") == 1 ]]; then
538 | find "$temp_dir" -maxdepth 1 ! -wholename "$temp_dir" -exec mv -t "$dirName/" {} +
539 | rmdir "$temp_dir" 2> /dev/null
540 | fi
541 | }
542 |
543 | do_extract() {
544 | local nocd="${nocd:-false}"
545 | local archive="$1" dirName="$2"
546 | # accepted: zip, 7z, tar, tar.gz, tar.bz2 and tar.xz
547 | [[ -z $dirName ]] && dirName=$(guess_dirname "$archive")
548 | if [[ $dirName != "." && -d $dirName ]]; then
549 | if [[ $build32 == "yes" && ! -f \
550 | "$dirName/build_successful32bit${flavor:+_$flavor}" ]]; then
551 | rm -rf "$dirName"
552 | elif [[ $build64 == "yes" && ! -f \
553 | "$dirName/build_successful64bit${flavor:+_$flavor}" ]]; then
554 | rm -rf "$dirName"
555 | fi
556 | elif [[ -d $dirName ]]; then
557 | $nocd || cd_safe "$dirName"
558 | return 0
559 | elif ! expr "$archive" : '.\+\(tar\(\.\(gz\|bz2\|xz\|lz\)\)\?\|7z\|zip\)$' > /dev/null; then
560 | return 0
561 | fi
562 | log "extract" real_extract "$archive" "$dirName"
563 | $nocd || cd_safe "$dirName"
564 | }
565 |
566 | do_wget_sf() {
567 | # do_wget_sf "faac/faac-src/faac-1.28/faac-$_ver.tar.bz2" "faac-$_ver"
568 | local hash
569 | [[ $1 == "-h" ]] && hash="$2" && shift 2
570 | local url="https://download.sourceforge.net/$1"
571 | shift 1
572 | if [[ -n $hash ]]; then
573 | do_wget -h "$hash" "$url" "$@"
574 | else
575 | do_wget "$url" "$@"
576 | fi
577 | local ret=$?
578 | check_custom_patches
579 | return $ret
580 | }
581 |
582 | do_strip() {
583 | local cmd exts nostrip file
584 | local cmd=(strip)
585 | local nostrip="x265|x265-numa|ffmpeg|ffprobe|ffplay"
586 | local exts="exe|dll|com|a"
587 | [[ -f $LOCALDESTDIR/bin-video/mpv.exe.debug ]] && nostrip+="|mpv"
588 | for file; do
589 | if [[ $file =~ \.($exts)$ && ! $file =~ ($nostrip)\.exe$ ]]; then
590 | do_print_progress Stripping
591 | break
592 | fi
593 | done
594 | for file; do
595 | local orig_file="$file"
596 | if ! file="$(file_installed "$orig_file")"; then
597 | continue
598 | fi
599 | if [[ $file =~ \.(exe|com)$ ]] &&
600 | [[ ! $file =~ ($nostrip)\.exe$ ]]; then
601 | cmd+=(--strip-all)
602 | elif [[ $file =~ \.dll$ ]] ||
603 | [[ $file =~ (x265|x265-numa)\.exe$ ]]; then
604 | cmd+=(--strip-unneeded)
605 | elif ! disabled debug && [[ $file =~ \.a$ ]]; then
606 | cmd+=(--strip-debug)
607 | else
608 | file=""
609 | fi
610 | [[ $file ]] &&
611 | { eval "${cmd[@]}" "$file" 2> /dev/null ||
612 | eval "${cmd[@]}" "$file" -o "$file.stripped" 2> /dev/null; }
613 | [[ -f ${file}.stripped ]] && mv -f "${file}"{.stripped,}
614 | done
615 | }
616 |
617 | do_pack() {
618 | local file
619 | local cmd=(/opt/bin/upx -9 -qq)
620 | local nopack=""
621 | local exts="exe|dll"
622 | [[ $bits == 64bit ]] && enabled_any libtls openssl && nopack="ffmpeg|mplayer|mpv"
623 | for file; do
624 | if [[ $file =~ \.($exts)$ && ! $file =~ ($nopack)\.exe$ ]]; then
625 | do_print_progress Packing with UPX
626 | break
627 | fi
628 | done
629 | for file; do
630 | local orig_file="$file"
631 | if ! file="$(file_installed "$orig_file")"; then
632 | continue
633 | fi
634 | if [[ $file =~ \.($exts)$ ]] &&
635 | ! [[ -n $nopack && $file =~ ($nopack)\.exe$ ]]; then
636 | [[ $stripping == y ]] && cmd+=("--strip-relocs=0")
637 | else
638 | file=""
639 | fi
640 | [[ $file ]] && eval "${cmd[@]}" "$file"
641 | done
642 | }
643 |
644 | do_zipman() {
645 | local file files
646 | local man_dirs=(/local{32,64}/share/man)
647 | files=$(find "${man_dirs[@]}" -type f \! -name "*.gz" \! -name "*.db" \! -name "*.bz2" 2> /dev/null)
648 | for file in $files; do
649 | gzip -9 -n -f "$file"
650 | rm -f "$file"
651 | done
652 | }
653 |
654 | # check if compiled file exist
655 | do_checkIfExist() {
656 | local packetName
657 | packetName="$(get_first_subdir)"
658 | local packageDir="${LOCALBUILDDIR}/${packetName}"
659 | local buildSuccessFile="${packageDir}/build_successful${bits}"
660 | local dry="${dry:-n}"
661 | local check=()
662 | if [[ -n $1 ]]; then
663 | check+=("$@")
664 | else
665 | check+=("${_check[@]}")
666 | unset _check
667 | fi
668 | unset_extra_script
669 | [[ -z ${check[*]} ]] && echo "No files to check" && return 1
670 | if [[ $dry == y ]]; then
671 | files_exist -v -s "${check[@]}"
672 | return $?
673 | fi
674 | if files_exist -v "${check[@]}"; then
675 | [[ $stripping == y ]] && do_strip "${check[@]}"
676 | [[ $packing == y ]] && do_pack "${check[@]}"
677 | do_print_status "└ $packetName" "$blue" "Updated"
678 | [[ $build32 == yes || $build64 == yes ]] && [[ -d $packageDir ]] &&
679 | touch "$buildSuccessFile"
680 | else
681 | [[ $build32 == yes || $build64 == yes ]] && [[ -d $packageDir ]] &&
682 | rm -f "$buildSuccessFile"
683 | do_print_status "└ $packetName" "$red" "Failed"
684 | if ${_notrequired:-false}; then
685 | printf '%s\n' \
686 | "$orange"'Package failed to build, but is not required; proceeding with compilation.'"$reset"
687 | else
688 | printf '%s\n' \
689 | '' "Try deleting '$packageDir' and start the script again." \
690 | 'If you are sure there are no dependencies, to continue building.'
691 | do_prompt "Close this window if you wish to stop building."
692 | fi
693 | fi
694 | }
695 |
696 | file_installed() {
697 | local file silent
698 | [[ $1 == "-s" ]] && silent=true && shift
699 | case $1 in
700 | /* | ./*)
701 | file="$1"
702 | ;;
703 | *.pc)
704 | file="lib/pkgconfig/$1"
705 | ;;
706 | *.a | *.la | *.lib)
707 | file="lib/$1"
708 | ;;
709 | *.h | *.hpp | *.c)
710 | file="include/$1"
711 | ;;
712 | *)
713 | file="$1"
714 | ;;
715 | esac
716 | [[ ${file::1} != "/" ]] && file="$LOCALDESTDIR/$file"
717 | ${silent:-false} || echo "$file"
718 | test -e "$file"
719 | }
720 |
721 | files_exist() {
722 | local verbose list soft ignorebinaries term='\n' file
723 | while true; do
724 | case $1 in
725 | -v) verbose=y && shift ;;
726 | -l) list=y && shift ;;
727 | -s) soft=y && shift ;;
728 | -b) ignorebinaries=y && shift ;;
729 | -l0) list=y && term='\0' && shift ;;
730 | --)
731 | shift
732 | break
733 | ;;
734 | *) break ;;
735 | esac
736 | done
737 | [[ $list ]] && verbose= && soft=y
738 | for opt; do
739 | if file=$(file_installed "$opt"); then
740 | [[ $verbose && $soft ]] && do_print_status "├ $file" "${green}" "Found"
741 | if [[ $list ]]; then
742 | if [[ $ignorebinaries && $file =~ .(exe|com)$ ]]; then
743 | continue
744 | fi
745 | printf "%s%b" "$file" "$term"
746 | fi
747 | else
748 | [[ $verbose ]] && do_print_status prefix "${bold}├${reset} " "$file" "${red}" "Not found"
749 | [[ ! $soft ]] && return 1
750 | fi
751 | done
752 | return 0
753 | }
754 |
755 | pc_exists() {
756 | for opt; do
757 | local _pkg=${opt%% *}
758 | local _check=${opt#$_pkg}
759 | [[ $_pkg == "$_check" ]] && _check=""
760 | [[ $_pkg == *.pc ]] || _pkg="${LOCALDESTDIR}/lib/pkgconfig/${_pkg}.pc"
761 | $PKG_CONFIG --exists --silence-errors "${_pkg}${_check}" || return
762 | done
763 | }
764 |
765 | do_install() {
766 | [[ $1 == dry ]] && local dryrun=y && shift
767 | local files=("$@")
768 | local dest="${files[-1]}"
769 | [[ ${dest::1} != "/" ]] && dest="$(file_installed "$dest")"
770 | [[ ${#files[@]} -gt 1 ]] && unset 'files[-1]'
771 | [[ ${dest: -1:1} == "/" ]] && mkdir -p "$dest"
772 | if [[ -n $dryrun ]]; then
773 | echo install -D -p "${files[@]}" "$dest"
774 | else
775 | extra_script pre install
776 | [[ -f "$(get_first_subdir -f)/do_not_install" ]] &&
777 | return
778 | install -D -p "${files[@]}" "$dest"
779 | extra_script post install
780 | fi
781 | }
782 |
783 | do_uninstall() {
784 | local dry quiet all files
785 | [[ $1 == dry ]] && dry=y && shift
786 | [[ $1 == q ]] && quiet=y && shift
787 | [[ $1 == all ]] && all=y && shift
788 | if [[ $all ]]; then
789 | mapfile -t files < <(files_exist -l "$@")
790 | else
791 | mapfile -t files < <(files_exist -l -b "$@")
792 | fi
793 | if [[ -n ${files[*]} ]]; then
794 | [[ ! $quiet ]] && do_print_progress Running uninstall
795 | if [[ $dry ]]; then
796 | echo "rm -rf ${files[*]}"
797 | else
798 | rm -rf "${files[@]}"
799 | fi
800 | fi
801 | }
802 |
803 | do_pkgConfig() {
804 | local pkg="${1%% *}"
805 | local pc_check="${1#$pkg}"
806 | local pkg_and_version="$pkg"
807 | [[ $pkg == "$pc_check" ]] && pc_check=""
808 | local version=$2
809 | local deps=("${_deps[@]}") && unset _deps
810 | [[ ! $version && $pc_check ]] && version="${pc_check#*= }"
811 | [[ "$version" ]] && pkg_and_version="${pkg} ${version}"
812 | if ! pc_exists "${pkg}"; then
813 | do_print_status "${pkg_and_version}" "$red" "Not installed"
814 | elif ! pc_exists "${pkg}${pc_check}"; then
815 | do_print_status "${pkg_and_version}" "$orange" "Outdated"
816 | elif [[ -n ${deps[*]} ]] && test_newer installed "${deps[@]}" "${pkg}.pc"; then
817 | do_print_status "${pkg_and_version}" "$orange" "Newer dependencies"
818 | elif [[ -n ${_check[*]} ]] && ! files_exist "${_check[@]}"; then
819 | do_print_status "${pkg_and_version}" "$orange" "Files missing"
820 | else
821 | do_print_status "${pkg_and_version}" "$green" "Up-to-date"
822 | return 1
823 | fi
824 | }
825 |
826 | do_readoptionsfile() (
827 | filename="$1"
828 | [[ -f $filename ]] || return 1
829 | sed -E '# remove commented text
830 | s/#.*//
831 | # remove leading whitespace
832 | s/^\s+//
833 | # remove trailing whitespace
834 | s/\s+$//
835 | # strip carriage return
836 | s/\r$//
837 | # delete empty lines
838 | /^\s*$/d
839 | ' "$filename"
840 | echo "Imported options from ${filename##*/}" >&2
841 | )
842 |
843 | do_readbatoptions_inner() (
844 | sed -En "/set ${1}=/,/[^^]$/p" "$2" |
845 | sed -E "/^:/d;s/(set ${1}=| \\^|\")//g;s/ +/\n/g;s/ /\\n/g" |
846 | sed -E '/^#/d'
847 | )
848 |
849 |
850 | do_readbatoptions_ffmpeg() (
851 | do_readbatoptions_inner "$@" |
852 | sed -E '/^[^-]/{s/^/--enable-/g}'
853 | )
854 |
855 | do_readbatoptions_mpv() (
856 | do_readbatoptions_inner "$@" |
857 | sed -E '/^[^-]/{s/^(.*)$/-D\1=enabled/g}'
858 | )
859 |
860 | do_getFFmpegConfig() {
861 | local license="${1:-nonfree}"
862 |
863 | FFMPEG_DEFAULT_OPTS=()
864 | if [[ -f "/trunk/media-autobuild_suite.bat" && $ffmpegChoice =~ (n|z|f) ]]; then
865 | mapfile -t FFMPEG_DEFAULT_OPTS < <(do_readbatoptions_ffmpeg "ffmpeg_options_(builtin|basic)" /trunk/media-autobuild_suite.bat)
866 | [[ $ffmpegChoice != n ]] && mapfile -t -O "${#FFMPEG_DEFAULT_OPTS[@]}" FFMPEG_DEFAULT_OPTS < <(do_readbatoptions_ffmpeg "ffmpeg_options_zeranoe" /trunk/media-autobuild_suite.bat)
867 | [[ $ffmpegChoice == f ]] && mapfile -t -O "${#FFMPEG_DEFAULT_OPTS[@]}" FFMPEG_DEFAULT_OPTS < <(do_readbatoptions_ffmpeg "ffmpeg_options_full(|_shared)" /trunk/media-autobuild_suite.bat)
868 | echo "Imported default FFmpeg options from .bat"
869 | else
870 | if [[ -f "$LOCALBUILDDIR/ffmpeg_options_$bits.txt" ]]; then
871 | IFS=$'\n' read -d '' -r -a FFMPEG_DEFAULT_OPTS < <(do_readoptionsfile "$LOCALBUILDDIR/ffmpeg_options_$bits.txt")
872 | else
873 | IFS=$'\n' read -d '' -r -a FFMPEG_DEFAULT_OPTS < <(do_readoptionsfile "$LOCALBUILDDIR/ffmpeg_options.txt")
874 | fi
875 | unset FFMPEG_DEFAULT_OPTS_SHARED
876 | if [[ -f "$LOCALBUILDDIR/ffmpeg_options_shared.txt" ]]; then
877 | IFS=$'\n' read -d '' -r -a FFMPEG_DEFAULT_OPTS_SHARED < <(
878 | do_readoptionsfile "$LOCALBUILDDIR/ffmpeg_options_shared.txt"
879 | )
880 | fi
881 | fi
882 |
883 | FFMPEG_OPTS=()
884 | for opt in "${FFMPEG_BASE_OPTS[@]}" "${FFMPEG_DEFAULT_OPTS[@]}"; do
885 | [[ -n $opt ]] && FFMPEG_OPTS+=("$opt")
886 | done
887 |
888 | echo "License: $license"
889 |
890 | # we set these accordingly for static or shared
891 | do_removeOption "--(en|dis)able-(shared|static)"
892 |
893 | # OK to use GnuTLS for rtmpdump if not nonfree since GnuTLS was built for rtmpdump anyway
894 | # If nonfree will use SChannel if neither openssl/libtls or gnutls are in the options
895 | if ! enabled_any libtls openssl gnutls &&
896 | { enabled librtmp || [[ $rtmpdump == y ]]; }; then
897 | if [[ $license == nonfree ]] ||
898 | [[ $license == lgpl* && $rtmpdump == n ]]; then
899 | do_addOption --enable-openssl
900 | else
901 | do_addOption --enable-gnutls
902 | fi
903 | do_removeOption "--enable-(gmp|gcrypt|mbedtls)"
904 | fi
905 |
906 | local _all_tls="--enable-(mbedtls|gnutls|openssl|libtls|schannel)"
907 | if enabled_any libtls openssl && [[ $license != gpl* ]]; then
908 | # prefer openssl/libtls if both are in options and not gpl
909 |
910 | # prefer openssl over libtls if both enabled
911 | local _prefer=libtls
912 | if enabled openssl; then
913 | _prefer=openssl
914 | fi
915 |
916 | do_removeOption "${_all_tls}"
917 | do_addOption "--enable-${_prefer}"
918 | elif enabled mbedtls; then
919 | # prefer mbedtls if any other tls libs are enabled and gpl
920 | do_removeOption "${_all_tls}"
921 | do_addOption --enable-mbedtls
922 | elif enabled gnutls; then
923 | do_removeOption "${_all_tls}"
924 | do_addOption --enable-gnutls
925 | elif ! disabled schannel; then
926 | # fallback to schannel if no other tls libs are enabled
927 | do_addOption --enable-schannel
928 | fi
929 |
930 | enabled_any lib{vo-aacenc,aacplus,utvideo,dcadec,faac,ebur128,ndi_newtek,ndi-newtek,ssh,wavpack} netcdf &&
931 | do_removeOption "--enable-(lib(vo-aacenc|aacplus|utvideo|dcadec|faac|ebur128|ndi_newtek|ndi-newtek|ssh|wavpack)|netcdf)" &&
932 | sed -ri 's;--enable-(lib(vo-aacenc|aacplus|utvideo|dcadec|faac|ebur128|ndi_newtek|ndi-newtek|ssh|wavpack)|netcdf);;g' \
933 | "$LOCALBUILDDIR/ffmpeg_options.txt"
934 | }
935 |
936 | do_changeFFmpegConfig() {
937 | local license="${1:-nonfree}"
938 | do_print_progress Changing options to comply to "$license"
939 | # if w32threads is disabled, pthreads is used and needs this cflag
940 | # decklink includes zvbi, which requires pthreads
941 | if disabled w32threads || enabled pthreads || enabled_all decklink libzvbi || enabled libvmaf; then
942 | do_removeOption --enable-w32threads
943 | do_addOption --disable-w32threads
944 | fi
945 |
946 | # add options for static kvazaar
947 | enabled libkvazaar && do_addOption --extra-cflags=-DKVZ_STATIC_LIB
948 |
949 | # get libs restricted by license
950 | local config_script=configure
951 | [[ $(get_first_subdir) != "ffmpeg-git" ]] && config_script="$LOCALBUILDDIR/ffmpeg-git/configure"
952 | [[ -f $config_script ]] || do_exit_prompt "There's no configure script to retrieve libs from"
953 | eval "$(sed -n '/EXTERNAL_LIBRARY_GPL_LIST=/,/^"/p' "$config_script" | tr -s '\n' ' ')"
954 | eval "$(sed -n '/HWACCEL_LIBRARY_NONFREE_LIST=/,/^"/p' "$config_script" | tr -s '\n' ' ')"
955 | eval "$(sed -n '/EXTERNAL_LIBRARY_NONFREE_LIST=/,/^"/p' "$config_script" | tr -s '\n' ' ')"
956 | eval "$(sed -n '/EXTERNAL_LIBRARY_VERSION3_LIST=/,/^"/p' "$config_script" | tr -s '\n' ' ')"
957 |
958 | # handle (l)gplv3 libs
959 | local version3
960 | read -ra version3 <<< "${EXTERNAL_LIBRARY_VERSION3_LIST//_/-}"
961 | if [[ $license =~ (l|)gplv3 || $license == nonfree ]] && enabled_any "${version3[@]}"; then
962 | do_addOption --enable-version3
963 | else
964 | do_removeOptions "${version3[*]/#/--enable-} --enable-version3"
965 | fi
966 |
967 | local nonfreehwaccel
968 | read -ra nonfreehwaccel <<< "(${HWACCEL_LIBRARY_NONFREE_LIST//_/-}"
969 | if [[ $license == "nonfree" ]] && enabled_any "${nonfreehwaccel[@]}"; then
970 | do_addOption --enable-nonfree
971 | else
972 | do_removeOptions "${nonfreehwaccel[*]/#/--enable-} --enable-nonfree"
973 | fi
974 |
975 | # cuda-only workarounds
976 | if verify_cuda_deps; then
977 | if enabled libnpp; then
978 | echo -e "${orange}FFmpeg and related apps will depend on CUDA SDK to run!${reset}"
979 | local fixed_CUDA_PATH
980 | fixed_CUDA_PATH="$(cygpath -sm "$CUDA_PATH")"
981 | if [[ $fixed_CUDA_PATH != "${fixed_CUDA_PATH// /}" ]]; then
982 | # Assumes CUDA_PATH backwards is version/CUDA/NVIDIA GPU Computing Toolkit/rest of the path
983 | # Strips the onion to the rest of the path
984 | {
985 | cat << EOF
986 | @echo off
987 | fltmc > NUL 2>&1 || echo Elevation required, right click the script and click 'Run as administrator'. & echo/ & pause & exit /b 1
988 | cd /d "$(dirname "$(dirname "$(dirname "$(cygpath -sw "$CUDA_PATH")")")")"
989 | EOF
990 | # Generate up to 4 shortnames
991 | for _n in 1 2 3 4; do
992 | printf 'fsutil file setshortname "NVIDIA GPU Computing Toolkit" NVIDIA~%d || ' "$_n"
993 | done
994 | echo 'echo Failed to set a shortname for your CUDA_PATH'
995 | } > "$LOCALBUILDDIR/cuda.bat"
996 | do_simple_print "${orange}Spaces detected in the CUDA path"'!'"$reset"
997 | do_simple_print "Path returned by windows: ${bold}$fixed_CUDA_PATH${reset}"
998 | do_simple_print "A script to create the missing short paths for your CUDA_PATH"
999 | do_simple_print "was created at $(cygpath -m "$LOCALBUILDDIR/cuda.bat")"
1000 | do_simple_print "Please run that script as an administrator and rerun the suite"
1001 | do_simple_print "${red}This will break FFmpeg compilation, so aborting early"'!'"${reset}"
1002 | logging=n compilation_fail "do_changeFFmpegConfig"
1003 | fi
1004 | do_addOption "--extra-cflags=-I$fixed_CUDA_PATH/include"
1005 | do_addOption "--extra-ldflags=-L$fixed_CUDA_PATH/lib/x64"
1006 | fi
1007 | if enabled cuda-nvcc; then
1008 | local fixed_CUDA_PATH_UNIX
1009 | fixed_CUDA_PATH_UNIX="$(cygpath -u "$CUDA_PATH")"
1010 | nvcc.exe --help &> /dev/null || export PATH="$PATH:$fixed_CUDA_PATH_UNIX/bin"
1011 | echo -e "${orange}FFmpeg and related apps will depend on Nvidia drivers!${reset}"
1012 | fi
1013 | else
1014 | do_removeOption "--enable-(libnpp|cuda-nvcc)"
1015 | fi
1016 |
1017 | # handle gpl-incompatible libs
1018 | local nonfreegpl
1019 | read -ra nonfreegpl <<< "${EXTERNAL_LIBRARY_NONFREE_LIST//_/-}"
1020 | if enabled_any "${nonfreegpl[@]}"; then
1021 | if [[ $license == "nonfree" ]] && enabled gpl; then
1022 | do_addOption --enable-nonfree
1023 | elif [[ $license == gpl* ]]; then
1024 | do_removeOptions "${nonfreegpl[*]/#/--enable-}"
1025 | fi
1026 | # no lgpl here because they are accepted with it
1027 | fi
1028 |
1029 | if ! disabled debug "debug=gdb"; then
1030 | # fix issue with ffprobe not working with debug and strip
1031 | do_addOption --disable-stripping
1032 | fi
1033 |
1034 | # both openssl and mbedtls don't need gcrypt/gmp for rtmpe
1035 | enabled_any openssl mbedtls && do_removeOption "--enable-(gcrypt|gmp)"
1036 |
1037 | # remove libs that don't work with shared
1038 | if [[ $ffmpeg =~ "shared" || $ffmpeg =~ "both" ]]; then
1039 | FFMPEG_OPTS_SHARED=()
1040 | for opt in "${FFMPEG_OPTS[@]}" "${FFMPEG_DEFAULT_OPTS_SHARED[@]}"; do
1041 | FFMPEG_OPTS_SHARED+=("$opt")
1042 | done
1043 | fi
1044 | if [[ $ffmpeg == "bothstatic" ]]; then
1045 | do_removeOption "--enable-(opencl|opengl|cuda-nvcc|libnpp|libopenh264)"
1046 | fi
1047 | }
1048 |
1049 | opt_exists() {
1050 | local array="${1}[@]" && shift 1
1051 | local opt value
1052 | for opt; do
1053 | for value in "${!array}"; do
1054 | [[ $value =~ $opt ]] && return
1055 | done
1056 | done
1057 | return 1
1058 | }
1059 |
1060 | enabled() {
1061 | test "${FFMPEG_OPTS[*]}" != "${FFMPEG_OPTS[*]#--enable-$1}"
1062 | }
1063 |
1064 | disabled() {
1065 | test "${FFMPEG_OPTS[*]}" != "${FFMPEG_OPTS[*]#--disable-$1}"
1066 | }
1067 |
1068 | enabled_any() (
1069 | for opt; do
1070 | enabled "$opt" && return 0
1071 | done
1072 | return 1
1073 | )
1074 |
1075 | disabled_any() (
1076 | for opt; do
1077 | disabled "$opt" && return 0
1078 | done
1079 | return 1
1080 | )
1081 |
1082 | enabled_all() (
1083 | for opt; do
1084 | enabled "$opt" || return 1
1085 | done
1086 | return 0
1087 | )
1088 |
1089 | disabled_all() (
1090 | for opt; do
1091 | disabled "$opt" || return 1
1092 | done
1093 | return 0
1094 | )
1095 |
1096 | do_getMpvConfig() (
1097 | declare -a MPV_TEMP_OPTS
1098 | if [[ -f "/trunk/media-autobuild_suite.bat" && $ffmpegChoice =~ (n|z|f) ]]; then
1099 | mapfile -t MPV_TEMP_OPTS < <(do_readbatoptions_mpv "mpv_options_(builtin|basic)" /trunk/media-autobuild_suite.bat)
1100 | [[ $ffmpegChoice == f ]] && mapfile -t -O "${#MPV_TEMP_OPTS[@]}" MPV_TEMP_OPTS < <(do_readbatoptions_mpv "mpv_options_full" /trunk/media-autobuild_suite.bat)
1101 | echo "Imported default mpv options from .bat" >&2
1102 | else
1103 | IFS=$'\n' read -d '' -r -a MPV_TEMP_OPTS < <(do_readoptionsfile "$LOCALBUILDDIR/mpv_options.txt")
1104 | fi
1105 | declare -A MPV_OPTS
1106 | for opt in "${MPV_TEMP_OPTS[@]}"; do
1107 | if [[ $opt =~ ^-D ]]; then
1108 | local opt_name="${opt#-D}"
1109 | opt_name="${opt_name%%=*}"
1110 | MPV_OPTS["$opt_name"]="${opt#*=}"
1111 | elif [[ $opt =~ ^-- ]]; then
1112 | MPV_OPTS["$opt"]=""
1113 | fi
1114 | done
1115 | echo "${MPV_OPTS[@]@K}"
1116 | )
1117 |
1118 | mpv_disabled() (
1119 | # if mpv is disabled, we don't need to check for options
1120 | [[ $mpv == n ]] && return 0
1121 | # if the option is not present, we assume it's auto, which probably means enabled
1122 | [[ ${!MPV_OPTS[*]} =~ $1 ]] || return 1
1123 | [[ ${MPV_OPTS[$1]} == "disabled" ]] && return 0
1124 | [[ ${MPV_OPTS[$1]} == "false" ]] && return 0
1125 | return 1
1126 | )
1127 |
1128 | # with mpv, we will imply that something is enabled if it is not explicitly disabled
1129 | # since features can often have enabled or auto.
1130 | mpv_enabled() {
1131 | ! mpv_disabled "$1"
1132 | }
1133 |
1134 | mpv_enabled_any() (
1135 | for opt; do
1136 | mpv_enabled "$opt" && return 0
1137 | done
1138 | return 1
1139 | )
1140 |
1141 | mpv_disabled_any() (
1142 | for opt; do
1143 | mpv_disabled "$opt" && return 0
1144 | done
1145 | return 1
1146 | )
1147 |
1148 | mpv_enabled_all() (
1149 | for opt; do
1150 | mpv_enabled "$opt" || return 1
1151 | done
1152 | )
1153 |
1154 | mpv_disabled_all() (
1155 | for opt; do
1156 | mpv_disabled "$opt" || return 1
1157 | done
1158 | )
1159 |
1160 | mpv_enable() {
1161 | case "${MPV_OPTS[$1]}" in
1162 | disabled) MPV_OPTS[$1]="enabled" ;;
1163 | false) MPV_OPTS[$1]="true" ;;
1164 | enabled) ;;
1165 | true) ;;
1166 | "") MPV_OPTS[$1]="enabled" ;;
1167 | esac
1168 | }
1169 |
1170 | mpv_disable() {
1171 | case "${MPV_OPTS[$1]}" in
1172 | disabled) ;;
1173 | false) ;;
1174 | enabled) MPV_OPTS[$1]="disabled" ;;
1175 | true) MPV_OPTS[$1]="false" ;;
1176 | "") MPV_OPTS[$1]="disabled" ;;
1177 | esac
1178 | }
1179 |
1180 | mpv_build_args() (
1181 | for key in "${!MPV_OPTS[@]}"; do
1182 | val="${MPV_OPTS[$key]}"
1183 | if [[ -n "$val" ]]; then
1184 | echo "-D${key}=${val}"
1185 | else
1186 | echo "$key"
1187 | fi
1188 | done
1189 | )
1190 |
1191 | do_addOption() {
1192 | local varname="$1" array opt
1193 | if [[ ${varname#--} == "$varname" ]]; then
1194 | array="$varname" && shift 1
1195 | else
1196 | array="FFMPEG_OPTS"
1197 | fi
1198 | for opt; do
1199 | ! opt_exists "$array" "$opt" && declare -ag "$array+=(\"$opt\")"
1200 | done
1201 | }
1202 |
1203 | do_removeOption() {
1204 | local varname="$1"
1205 | local arrayname
1206 | if [[ ${varname#--} == "$varname" ]]; then
1207 | arrayname="$varname" && shift 1
1208 | else
1209 | arrayname="FFMPEG_OPTS"
1210 | fi
1211 |
1212 | local option="$1"
1213 | local basearray temp=()
1214 | basearray="${arrayname}[@]"
1215 | local orig=("${!basearray}")
1216 |
1217 | for ((i = 0; i < ${#orig[@]}; i++)); do
1218 | if [[ ! ${orig[$i]} =~ ^${option}$ ]]; then
1219 | temp+=("${orig[$i]}")
1220 | fi
1221 | done
1222 | # shellcheck disable=SC1117,SC1083
1223 | eval "$arrayname"=\(\"\${temp[@]}\"\)
1224 | }
1225 |
1226 | do_removeOptions() {
1227 | local option
1228 | local shared=$2
1229 | for option in $1; do
1230 | do_removeOption "$option" "$shared"
1231 | done
1232 | }
1233 |
1234 | do_patch() {
1235 | local binarypatch="--binary"
1236 | case $1 in -p) binarypatch="" && shift ;; esac
1237 | local patch="${1%% *}" # Location or link to patch.
1238 | local patchName="${1##* }" # Basename of file. (test-diff-files.diff)
1239 | local am=false # Use git am to apply patch. Use with .patch files
1240 | local strip=${3:-1} # Leading directories to strip. "patch -p${strip}"
1241 | [[ $patchName == "$patch" ]] && patchName="${patch##*/}"
1242 | [[ $2 == am ]] && am=true
1243 |
1244 | # hack for URLs without filename
1245 | patchName=${patchName:-"$(/usr/bin/curl -LsI "$patch" | grep -Eo 'filename=.*$' | sed 's/filename=//')"}
1246 | [[ -z $patchName ]] &&
1247 | printf '%b\n' "${red}Failed to apply patch '$patch'" \
1248 | "Patch without filename, ignoring. Specify an explicit filename.${reset}" &&
1249 | return 1
1250 |
1251 | # Just don't. Make a fork or use the suite's directory as the root for
1252 | # your diffs or manually edit the scripts if you are trying to modify
1253 | # the helper and compile scripts. If you really need to, use patch instead.
1254 | # Else create a patch file for the individual folders you want to apply
1255 | # the patch to.
1256 | [[ $PWD == "$LOCALBUILDDIR" ]] &&
1257 | do_exit_prompt "Running patches in the build folder is not supported.
1258 | Please make a patch for individual folders or modify the script directly"
1259 |
1260 | # Filter out patches that would require curl; else
1261 | # check if the patch is a local patch and copy it to the current dir
1262 | if ! do_wget -c -r -q "$patch" "$patchName" && [[ -f $patch ]]; then
1263 | patch="$(
1264 | cd_safe "$(dirname "$patch")"
1265 | printf '%s' "$(pwd -P)" '/' "$(basename -- "$patch")"
1266 |
1267 | )" # Resolve fullpath
1268 | [[ ${patch%/*} != "$PWD" ]] && cp -f "$patch" "$patchName" > /dev/null 2>&1
1269 | fi
1270 |
1271 | if [[ -f $patchName ]]; then
1272 | if $am; then
1273 | git apply -3 --check --ignore-space-change --ignore-whitespace "$patchName" > /dev/null 2>&1 &&
1274 | git am -q -3 --ignore-whitespace --no-gpg-sign "$patchName" > /dev/null 2>&1 &&
1275 | return 0
1276 | git am -q --abort > /dev/null 2>&1
1277 | else
1278 | patch --dry-run $binarypatch -s -N -p"$strip" -i "$patchName" > /dev/null 2>&1 &&
1279 | patch $binarypatch -s -N -p"$strip" -i "$patchName" &&
1280 | return 0
1281 | fi
1282 | printf '%b\n' "${orange}${patchName}${reset}" \
1283 | '\tPatch could not be applied with `'"$($am && echo "git am" || echo "patch")"'`. Continuing without patching.'
1284 | else
1285 | printf '%b\n' "${orange}${patchName}${reset}" \
1286 | '\tPatch not found anywhere. Continuing without patching.'
1287 | fi
1288 | return 1
1289 | }
1290 |
1291 | do_custom_patches() {
1292 | local patch
1293 | for patch in "$@"; do
1294 | [[ ${patch##*.} == "patch" ]] && do_patch "$patch" am
1295 | [[ ${patch##*.} == "diff" ]] && do_patch "$patch"
1296 | done
1297 | }
1298 |
1299 | do_cmake() {
1300 | local bindir=""
1301 | local root=".."
1302 | local cmake_build_dir=""
1303 | while [[ -n $* ]]; do
1304 | case "$1" in
1305 | global | audio | video)
1306 | bindir="-DCMAKE_INSTALL_BINDIR=$LOCALDESTDIR/bin-$1"
1307 | shift
1308 | ;;
1309 | builddir=*)
1310 | cmake_build_dir="${1#*=}"
1311 | shift
1312 | ;;
1313 | skip_build_dir)
1314 | local skip_build_dir=y
1315 | shift
1316 | ;;
1317 | *)
1318 | if [[ -d "./$1" ]]; then
1319 | [[ -n $skip_build_dir ]] && root="./$1" || root="../$1"
1320 | shift
1321 | elif [[ -d "../$1" ]]; then
1322 | root="../$1"
1323 | shift
1324 | fi
1325 | break
1326 | ;;
1327 | esac
1328 | done
1329 |
1330 | [[ -z $skip_build_dir ]] && create_build_dir "$cmake_build_dir"
1331 | # use this array to pass additional parameters to cmake
1332 | local cmake_extras=()
1333 | extra_script pre cmake
1334 | [[ -f "$(get_first_subdir -f)/do_not_reconfigure" ]] &&
1335 | return
1336 | # shellcheck disable=SC2086
1337 | log "cmake" cmake "$root" -G Ninja -DBUILD_SHARED_LIBS=off \
1338 | -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
1339 | -DPython3_EXECUTABLE="${MINGW_PREFIX}/bin/python.exe" \
1340 | -DCMAKE_EXPORT_COMPILE_COMMANDS=on \
1341 | -DCMAKE_TOOLCHAIN_FILE="$LOCALDESTDIR/etc/toolchain.cmake" \
1342 | -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DUNIX=on \
1343 | -DCMAKE_BUILD_TYPE=Release $bindir "$@" "${cmake_extras[@]}"
1344 | extra_script post cmake
1345 | unset cmake_extras
1346 | }
1347 |
1348 | do_ninja() {
1349 | extra_script pre ninja
1350 | [[ -f "$(get_first_subdir -f)/do_not_build" ]] &&
1351 | return
1352 | log "build" ninja "$@"
1353 | extra_script post ninja
1354 | }
1355 |
1356 | do_ninjainstall() {
1357 | extra_script pre install
1358 | [[ -f "$(get_first_subdir -f)/do_not_install" ]] &&
1359 | return
1360 | cpuCount=1 log "install" ninja install "$@"
1361 | extra_script post install
1362 | }
1363 |
1364 | do_cmakeinstall() {
1365 | do_cmake "$@"
1366 | do_ninja
1367 | do_ninjainstall
1368 | }
1369 |
1370 | do_meson() {
1371 | local bindir=""
1372 | local root=".."
1373 | case "$1" in
1374 | global | audio | video)
1375 | bindir="--bindir=bin-$1"
1376 | ;;
1377 | *)
1378 | [[ -d "./$1" ]] && root="../$1" || bindir="$1"
1379 | ;;
1380 | esac
1381 | shift 1
1382 |
1383 | create_build_dir
1384 | # use this array to pass additional parameters to meson
1385 | local meson_extras=()
1386 | extra_script pre meson
1387 | [[ -f "$(get_first_subdir -f)/do_not_reconfigure" ]] &&
1388 | return
1389 | # shellcheck disable=SC2086
1390 | PKG_CONFIG="pkgconf --static --keep-system-libs --keep-system-cflags" CC=${CC/ccache /}.bat CXX=${CXX/ccache /}.bat \
1391 | log "meson" meson setup "$root" --default-library=static --default-both-libraries=static --buildtype=release \
1392 | --prefix="$LOCALDESTDIR" --backend=ninja $bindir "$@" "${meson_extras[@]}"
1393 | extra_script post meson
1394 | unset meson_extras
1395 | }
1396 |
1397 | do_mesoninstall() {
1398 | do_meson "$@"
1399 | do_ninja
1400 | do_ninjainstall
1401 | }
1402 |
1403 | do_rust() {
1404 | log "rust.update" cargo update
1405 | # use this array to pass additional parameters to cargo
1406 | local rust_extras=()
1407 | [[ $CC =~ clang ]] && local target_suffix="llvm"
1408 | extra_script pre rust
1409 | [[ -f "$(get_first_subdir -f)/do_not_reconfigure" ]] &&
1410 | return
1411 | PKG_CONFIG_ALL_STATIC=true \
1412 | log "rust.build" cargo build \
1413 | --target="$CARCH"-pc-windows-gnu$target_suffix \
1414 | --jobs="$cpuCount" "${@:---release}" "${rust_extras[@]}"
1415 | extra_script post rust
1416 | unset rust_extras
1417 | }
1418 |
1419 | do_rustinstall() {
1420 | log "rust.update" cargo update
1421 | # use this array to pass additional parameters to cargo
1422 | local rust_extras=()
1423 | [[ $CC =~ clang ]] && local target_suffix="llvm"
1424 | extra_script pre rust
1425 | [[ -f "$(get_first_subdir -f)/do_not_reconfigure" ]] &&
1426 | return
1427 | PKG_CONFIG_ALL_STATIC=true \
1428 | PKG_CONFIG="$LOCALDESTDIR/bin/ab-pkg-config" \
1429 | log "rust.install" cargo install \
1430 | --target="$CARCH"-pc-windows-gnu$target_suffix \
1431 | --jobs="$cpuCount" "${@:---path=.}" "${rust_extras[@]}"
1432 | extra_script post rust
1433 | unset rust_extras
1434 | }
1435 |
1436 | do_rustcinstall() {
1437 | log "rust.update" cargo update
1438 | # use this array to pass additional parameters to cargo
1439 | local rust_extras=()
1440 | [[ $CC =~ clang ]] && local target_suffix="llvm"
1441 | extra_script pre rust
1442 | [[ -f "$(get_first_subdir -f)/do_not_reconfigure" ]] &&
1443 | return
1444 | PKG_CONFIG_ALL_STATIC=true \
1445 | PKG_CONFIG="$LOCALDESTDIR/bin/ab-pkg-config" \
1446 | log "rust.cinstall" cargo cinstall \
1447 | --target="$CARCH"-pc-windows-gnu$target_suffix \
1448 | --jobs="$cpuCount" --prefix="$LOCALDESTDIR" "$@" "${rust_extras[@]}"
1449 | extra_script post rust
1450 | unset rust_extras
1451 | }
1452 |
1453 | compilation_fail() {
1454 | [[ -z $build32$build64 ]] && return 1
1455 | local reason="$1"
1456 | local operation="${reason,,}"
1457 | if [[ $logging == y ]]; then
1458 | echo "Likely error (tail of the failed operation logfile):"
1459 | tail "ab-suite.${operation}.log"
1460 | echo "${red}$reason failed. Check $(pwd -W)/ab-suite.$operation.log${reset}"
1461 | fi
1462 | if ${_notrequired:-false}; then
1463 | echo "This isn't required for anything so we can move on."
1464 | return 1
1465 | else
1466 | echo "${red}This is required for other packages, so this script will exit.${reset}"
1467 | create_diagnostic
1468 | zip_logs
1469 | echo "Make sure the suite is up-to-date before reporting an issue. It might've been fixed already."
1470 | $([[ $noMintty == y ]] && echo echo || echo do_prompt) "Try running the build again at a later time."
1471 | exit 1
1472 | fi
1473 | }
1474 |
1475 | strip_ansi() {
1476 | local txtfile newfile
1477 | for txtfile; do
1478 | [[ $txtfile != "${txtfile//stripped/}" ]] && continue
1479 | local name="${txtfile%.*}" ext="${txtfile##*.}"
1480 | [[ $txtfile != "$name" ]] &&
1481 | newfile="$name.stripped.$ext" || newfile="$txtfile-stripped"
1482 | sed -E "s/\x1b[[(][0-9;?]*[a-zA-Z]|\x1b\][0-9];//g" "$txtfile" > "$newfile"
1483 | done
1484 | }
1485 |
1486 | zip_logs() {
1487 | local failed url
1488 | failed=$(get_first_subdir)
1489 | strip_ansi "$LOCALBUILDDIR"/*.log
1490 | rm -f "$LOCALBUILDDIR/logs.zip"
1491 | (
1492 | cd "$LOCALBUILDDIR" > /dev/null || do_exit_prompt "Did you delete /build?"
1493 | {
1494 | echo /trunk/media-autobuild_suite.bat
1495 | [[ $failed != . ]] && find "$failed" -name "*.log"
1496 | find . -maxdepth 1 -name "*.stripped.log" -o -name "*_options.txt" -o -name "media-suite_*.sh" \
1497 | -o -name "last_run" -o -name "media-autobuild_suite.ini" -o -name "diagnostics.txt" -o -name "patchedFolders"
1498 | } | sort -uo failedFiles
1499 | 7za -mx=9 a logs.zip -- @failedFiles > /dev/null && rm failedFiles
1500 | )
1501 | # [[ ! -f $LOCALBUILDDIR/no_logs && -n $build32$build64 && $autouploadlogs = y ]] &&
1502 | # url="$(cd "$LOCALBUILDDIR" && /usr/bin/curl -sF'file=@logs.zip' https://0x0.st)"
1503 | echo
1504 | if [[ $url ]]; then
1505 | echo "${green}All relevant logs have been anonymously uploaded to $url"
1506 | echo "${green}Copy and paste ${red}[logs.zip]($url)${green} in the GitHub issue.${reset}"
1507 | elif [[ -f "$LOCALBUILDDIR/logs.zip" ]]; then
1508 | echo "${green}Attach $(cygpath -w "$LOCALBUILDDIR/logs.zip") to the GitHub issue.${reset}"
1509 | else
1510 | echo "${red}Failed to generate logs.zip!${reset}"
1511 | fi
1512 | }
1513 |
1514 | log() {
1515 | local errorOut=true quiet=false ret OPTION OPTIND
1516 | while getopts ':qe' OPTION; do
1517 | case "$OPTION" in
1518 | e) errorOut=false ;;
1519 | q) quiet=true ;;
1520 | *) break ;;
1521 | esac
1522 | done
1523 | shift "$((OPTIND - 1))"
1524 |
1525 | [[ $1 == quiet ]] && quiet=true && shift # Temp compat with old style just in case
1526 | local name="${1// /.}" _cmd="$2" extra
1527 | shift 2
1528 | $quiet || do_print_progress Running "$name"
1529 | [[ $_cmd =~ ^(make|ninja)$ ]] && extra="-j$cpuCount"
1530 |
1531 | if [[ $logging == "y" ]]; then
1532 | printf 'CPPFLAGS: %s\nCFLAGS: %s\nCXXFLAGS: %s\nLDFLAGS: %s\n%s %s\n' "$CPPFLAGS" "$CFLAGS" "$CXXFLAGS" "$LDFLAGS" "$_cmd${extra:+ $extra}" "$*" > "ab-suite.$name.log"
1533 | $_cmd $extra "$@" >> "ab-suite.$name.log" 2>&1 ||
1534 | { [[ $extra ]] && $_cmd -j1 "$@" >> "ab-suite.$name.log" 2>&1; }
1535 | else
1536 | $_cmd $extra "$@" || { [[ $extra ]] && $_cmd -j1 "$@"; }
1537 | fi
1538 |
1539 | case ${ret:=$?} in
1540 | 0) return 0 ;;
1541 | *) $errorOut && compilation_fail "$name" || return $ret ;;
1542 | esac
1543 | }
1544 |
1545 | create_build_dir() {
1546 | local print_build_dir=false nocd=${nocd:-false} norm=false build_root build_dir getoptopt OPTARG OPTIND
1547 | while getopts ":pcrC:" getoptopt; do
1548 | case $getoptopt in
1549 | p) print_build_dir=true ;;
1550 | c) nocd=true ;;
1551 | r) norm=true ;;
1552 | C) build_root="$OPTARG" ;;
1553 | \?)
1554 | echo "Invalid Option: -$OPTARG" 1>&2
1555 | return 1
1556 | ;;
1557 | :)
1558 | echo "Invalid option: $OPTARG requires an argument" 1>&2
1559 | return 1
1560 | ;;
1561 | esac
1562 | done
1563 | shift $((OPTIND - 1))
1564 |
1565 | build_dir="${build_root:+$build_root/}build${1:+-$1}-$bits"
1566 | [[ -z $build_root && -d ../$build_dir ]] && cd_safe ..
1567 |
1568 | if [[ -d $build_dir && ! -f $(get_first_subdir -f)/do_not_clean ]]; then
1569 | $norm || rm -rf "$build_dir" ||
1570 | (cd_safe "$build_dir" && rm -rf ./*)
1571 | fi
1572 | [[ ! -d $build_dir ]] && mkdir -p "$build_dir"
1573 | $nocd || cd_safe "$build_dir"
1574 | $print_build_dir && printf '%s\n' "$build_dir"
1575 | }
1576 |
1577 | get_external_opts() {
1578 | local array="$1"
1579 | local pkgname
1580 | pkgname="$(get_first_subdir)"
1581 | local optsfile="$LOCALBUILDDIR/${pkgname%-*}_options.txt"
1582 | if [[ -n $array ]]; then
1583 | # shellcheck disable=SC2034
1584 | IFS=$'\n' read -d '' -r -a tmp < <(do_readoptionsfile "$optsfile")
1585 | declare -ag "$array+=(\"\${tmp[@]}\")"
1586 | else
1587 | do_readoptionsfile "$optsfile"
1588 | fi
1589 | }
1590 |
1591 | do_separate_conf() {
1592 | local bindir=""
1593 | local last config_path
1594 | case "$1" in
1595 | global | audio | video)
1596 | bindir="--bindir=$LOCALDESTDIR/bin-$1"
1597 | ;;
1598 | *) bindir="$1" ;;
1599 | esac
1600 | shift 1
1601 | for last; do true; done
1602 | if test -x "${last}/configure"; then
1603 | config_path="$last"
1604 | else
1605 | config_path=".."
1606 | create_build_dir
1607 | fi
1608 | do_configure --disable-shared --enable-static "$bindir" "$@"
1609 | }
1610 |
1611 | do_separate_confmakeinstall() {
1612 | do_separate_conf "$@"
1613 | do_make
1614 | do_makeinstall
1615 | cd_safe ..
1616 | }
1617 |
1618 | do_configure() {
1619 | # use this array to pass additional parameters to configure
1620 | local conf_extras=()
1621 | extra_script pre configure
1622 | [[ -f "$(get_first_subdir -f)/do_not_reconfigure" ]] &&
1623 | return
1624 | log "configure" ${config_path:-.}/configure --prefix="$LOCALDESTDIR" "$@" \
1625 | "${conf_extras[@]}"
1626 | extra_script post configure
1627 | unset conf_extras
1628 | }
1629 |
1630 | do_qmake() {
1631 | extra_script pre qmake
1632 | log "qmake" qmake "$@"
1633 | extra_script post qmake
1634 | }
1635 |
1636 | do_make() {
1637 | extra_script pre make
1638 | [[ -f "$(get_first_subdir -f)/do_not_build" ]] &&
1639 | return
1640 | log "make" make "$@"
1641 | extra_script post make
1642 | }
1643 |
1644 | do_makeinstall() {
1645 | extra_script pre install
1646 | [[ -f "$(get_first_subdir -f)/do_not_install" ]] &&
1647 | return
1648 | log "install" make install "$@"
1649 | extra_script post install
1650 | }
1651 |
1652 | do_hide_pacman_sharedlibs() {
1653 | local packages="$1"
1654 | local revert="$2"
1655 | local files
1656 | files="$(pacman -Qql "$packages" 2> /dev/null | grep .dll.a)"
1657 |
1658 | for file in $files; do
1659 | if [[ -f "${file%*.dll.a}.a" ]]; then
1660 | if [[ -z $revert ]]; then
1661 | mv -f "${file}" "${file}.dyn"
1662 | elif [[ -n $revert && -f "${file}.dyn" && ! -f ${file} ]]; then
1663 | mv -f "${file}.dyn" "${file}"
1664 | elif [[ -n $revert && -f "${file}.dyn" ]]; then
1665 | rm -f "${file}.dyn"
1666 | fi
1667 | fi
1668 | done
1669 | }
1670 |
1671 | do_hide_all_sharedlibs() {
1672 | local dryrun="${dry:-n}"
1673 | local files
1674 | files="$(find /{mingw{32,64},clang64}/lib /{mingw{32/i686,64/x86_64},clang64/x86_64}-w64-mingw32/lib -name "*.dll.a" 2> /dev/null)"
1675 | local tomove=()
1676 | for file in $files; do
1677 | [[ -f ${file%*.dll.a}.a ]] && tomove+=("$file")
1678 | done
1679 | if [[ -n ${tomove[*]} ]]; then
1680 | if [[ $dryrun == "n" ]]; then
1681 | printf '%s\0' "${tomove[@]}" | xargs -0ri mv -f '{}' '{}.dyn'
1682 | else
1683 | printf '%s\n' "${tomove[@]}"
1684 | fi
1685 | fi
1686 | }
1687 |
1688 | do_unhide_all_sharedlibs() {
1689 | local dryrun="${dry:-n}"
1690 | local files
1691 | files="$(find /{mingw{32,64},clang64}/lib /{mingw{32/i686,64/x86_64},clang64/x86_64}-w64-mingw32/lib -name "*.dll.a.dyn" 2> /dev/null)"
1692 | local tomove=()
1693 | local todelete=()
1694 | for file in $files; do
1695 | if [[ -f ${file%*.dyn} ]]; then
1696 | todelete+=("$file")
1697 | else
1698 | tomove+=("${file%*.dyn}")
1699 | fi
1700 | done
1701 | if [[ $dryrun == "n" ]]; then
1702 | printf '%s\n' "${todelete[@]}" | xargs -ri rm -f '{}'
1703 | printf '%s\n' "${tomove[@]}" | xargs -ri mv -f '{}.dyn' '{}'
1704 | else
1705 | printf 'rm %s\n' "${todelete[@]}"
1706 | printf '%s\n' "${tomove[@]}"
1707 | fi
1708 | }
1709 |
1710 | do_pacman_resolve_pkgs() (
1711 | : "${prefix=$MINGW_PACKAGE_PREFIX-}"
1712 | # Prefer exact matches, then provides
1713 | pkg=$(pacsift --exact --sync --any "${@/#/--name=$prefix}" 2>&1)
1714 | [[ -z $pkg ]] && pkg=$(pacsift --exact --sync --any "${@/#/--provides=$prefix}" 2>&1)
1715 | echo "${pkg#*/"$prefix"}"
1716 | )
1717 |
1718 | is_pkg_installed() (
1719 | : "${prefix=$MINGW_PACKAGE_PREFIX-}"
1720 | # checks if a package is installed/provided by a package that is installed
1721 | # example is omp, which is purely a provided packge, so that fails with pacman -Qe
1722 | pacsift --exact --local --any --exists --provides="$prefix$1" --name="$prefix$1" > /dev/null 2>&1
1723 | )
1724 |
1725 | do_pacman_install() (
1726 | ret=true
1727 | prefix=$MINGW_PACKAGE_PREFIX-
1728 | file=/etc/pac-mingw-extra.pk
1729 | pkgs=()
1730 | while true; do
1731 | case "$1" in
1732 | -m)
1733 | prefix=
1734 | file=/etc/pac-msys-extra.pk
1735 | shift
1736 | ;;
1737 | *) break ;;
1738 | esac
1739 | done
1740 | for pkg; do
1741 | for line in $(do_pacman_resolve_pkgs "$pkg"); do
1742 | if ! is_pkg_installed "$line"; then
1743 | pkgs+=("$line")
1744 | fi
1745 | done
1746 | done
1747 |
1748 | for pkg in "${pkgs[@]}"; do
1749 | do_simple_print -n "Installing $pkg... "
1750 | if pacman -S \
1751 | --noconfirm --ask=20 --needed \
1752 | --overwrite "/usr/*" \
1753 | --overwrite "/ucrt64/*" \
1754 | --overwrite "/mingw64/*" \
1755 | --overwrite "/mingw32/*" \
1756 | --overwrite "/clang64/*" \
1757 | "$prefix$pkg" > /dev/null 2>&1; then
1758 | pacman -D --asexplicit "$prefix$pkg" > /dev/null 2>&1
1759 | echo "$pkg" >> $file
1760 | echo "done"
1761 | else
1762 | ret=false
1763 | echo "failed"
1764 | fi
1765 | done
1766 | sort -uo $file{,} > /dev/null 2>&1
1767 | do_hide_all_sharedlibs
1768 | $ret
1769 | )
1770 |
1771 | do_pacman_remove() (
1772 | ret=true
1773 | prefix=$MINGW_PACKAGE_PREFIX-
1774 | file=/etc/pac-mingw-extra.pk
1775 | pkgs=()
1776 | while true; do
1777 | case "$1" in
1778 | -m)
1779 | prefix=
1780 | file=/etc/pac-msys-extra.pk
1781 | shift
1782 | ;;
1783 | *) break ;;
1784 | esac
1785 | done
1786 | for pkg; do
1787 | for line in $(do_pacman_resolve_pkgs "$pkg"); do
1788 | if is_pkg_installed "$line"; then
1789 | pkgs+=("$line")
1790 | fi
1791 | done
1792 | done
1793 |
1794 | for pkg in "${pkgs[@]}"; do
1795 | sed -i "/^${pkg}$/d" "$file" > /dev/null 2>&1
1796 | do_simple_print -n "Uninstalling $pkg... "
1797 | do_hide_pacman_sharedlibs "$prefix$pkg" revert
1798 | if pacman -Rs --noconfirm --ask=20 "$prefix$pkg" > /dev/null 2>&1; then
1799 | echo "done"
1800 | else
1801 | ret=false
1802 | pacman -D --asdeps "$prefix$pkg" > /dev/null 2>&1
1803 | echo "failed"
1804 | fi
1805 | done
1806 | sort -uo "$file"{,} > /dev/null 2>&1
1807 | do_hide_all_sharedlibs
1808 | $ret
1809 | )
1810 |
1811 | do_prompt() {
1812 | # from http://superuser.com/a/608509
1813 | while read -r -s -e -t 0.1; do :; done
1814 | read -r -p "$1" ret
1815 | }
1816 |
1817 | do_autoreconf() {
1818 | extra_script pre autoreconf
1819 | log "autoreconf" autoreconf -fiv "$@"
1820 | extra_script post autoreconf
1821 | }
1822 |
1823 | do_autoupdate() {
1824 | extra_script pre autoupdate
1825 | log "autoupdate" autoupdate "$@"
1826 | extra_script post autoupdate
1827 | }
1828 |
1829 | do_autogen() {
1830 | extra_script pre autogen
1831 | log "autogen" ./autogen.sh "$@"
1832 | extra_script post autogen
1833 | }
1834 |
1835 | get_first_subdir() {
1836 | local subdir="${PWD#*$LOCALBUILDDIR/}" fullpath=false OPTION OPTIND
1837 | while getopts ':f' OPTION; do
1838 | case "$OPTION" in
1839 | f) fullpath=true ;;
1840 | *) break ;;
1841 | esac
1842 | done
1843 | shift "$((OPTIND - 1))"
1844 |
1845 | if [[ $subdir != "$PWD" ]]; then
1846 | $fullpath && printf '%s' "$LOCALBUILDDIR/"
1847 | echo "${subdir%%/*}"
1848 | else
1849 | $fullpath && echo "$PWD" || echo "."
1850 | fi
1851 | }
1852 |
1853 | clean_html_index() {
1854 | local url="$1"
1855 | local filter="${2:-(?<=href=\")[^\"]+\.(tar\.(gz|bz2|xz)|7z)}"
1856 | "${curl_opts[@]}" -l "$url" | grep -ioP "$filter" | sort -uV
1857 | }
1858 |
1859 | get_last_version() {
1860 | local filelist="$1"
1861 | local filter="$2"
1862 | local version="$3"
1863 | local ret
1864 | ret="$(grep -E "$filter" <<< "$filelist" | sort -V | tail -1)"
1865 | [[ -n $version ]] && ret="$(grep -oP "$version" <<< "$ret")"
1866 | echo "$ret"
1867 | }
1868 |
1869 | create_debug_link() {
1870 | for file; do
1871 | if [[ -f $file && ! -f "$file".debug ]]; then
1872 | echo "Stripping and creating debug link for ${file##*/}..."
1873 | objcopy --only-keep-debug "$file" "$file".debug
1874 | if [[ ${file: -3} == "dll" ]]; then
1875 | strip --strip-debug "$file"
1876 | else
1877 | strip --strip-all "$file"
1878 | fi
1879 | objcopy --add-gnu-debuglink="$file".debug "$file"
1880 | fi
1881 | done
1882 | }
1883 |
1884 | # do_dlltool lib.a a.def
1885 | do_dlltool() (
1886 | if dlltool --help | grep -q llvm; then
1887 | # llvm's dlltool does not support delay import libraries.
1888 | # Until I can find a better way than just injecting `-Wl,--delayload=a.dll` into the LDFLAGS,
1889 | # ignore them for now.
1890 | exec llvm-dlltool -k -l "$1" -d "$2"
1891 | fi
1892 | exec dlltool -k -y "$1" -d "$2" -A
1893 | )
1894 |
1895 | get_vs_prefix() {
1896 | unset vsprefix
1897 | local winvsprefix
1898 | local regkey="/HKLM/software/vapoursynth/path"
1899 | local embedded
1900 | embedded="$(find "$LOCALDESTDIR"/bin-video -iname vspipe.exe)"
1901 | if [[ -n $embedded ]]; then
1902 | # look for .dlls in bin-video
1903 | vsprefix="${embedded%/*}"
1904 | elif [[ $bits == 64bit ]] && winvsprefix="$(regtool -q get "$regkey")"; then
1905 | # check in native HKLM for installed VS (R31+)
1906 | [[ -n $winvsprefix && -f "$winvsprefix/core64/vspipe.exe" ]] &&
1907 | vsprefix="$(cygpath -u "$winvsprefix")/core64"
1908 | elif winvsprefix="$(regtool -qW get "$regkey")"; then
1909 | # check in 32-bit registry for installed VS
1910 | [[ -n $winvsprefix && -f "$winvsprefix/core${bits%bit}/vspipe.exe" ]] &&
1911 | vsprefix="$(cygpath -u "$winvsprefix/core${bits%bit}")"
1912 | elif [[ -n $(command -v vspipe.exe 2> /dev/null) ]]; then
1913 | # last resort, check if vspipe is in path
1914 | vsprefix="$(dirname "$(command -v vspipe.exe)")"
1915 | fi
1916 | if [[ -n $vsprefix && -f "$vsprefix/vapoursynth.dll" && -f "$vsprefix/vsscript.dll" ]]; then
1917 | local bitness
1918 | bitness="$(file "$vsprefix/vapoursynth.dll")"
1919 | { [[ $bits == 64bit && $bitness == *x86-64* ]] ||
1920 | [[ $bits == 32bit && $bitness == *80386* ]]; } &&
1921 | return 0
1922 | else
1923 | return 1
1924 | fi
1925 | }
1926 |
1927 | get_cl_path() {
1928 | { type cl.exe && cl --help; } > /dev/null 2>&1 && return 0
1929 |
1930 | local _suite_vswhere=/opt/bin/vswhere.exe _sys_vswhere
1931 | if _sys_vswhere=$(cygpath -u "$(cygpath -F 0x002a)/Microsoft Visual Studio/Installer/vswhere.exe") &&
1932 | "$_sys_vswhere" -help > /dev/null 2>&1; then
1933 | vswhere=$_sys_vswhere
1934 | elif [[ -e $_suite_vswhere ]] &&
1935 | $_suite_vswhere -help > /dev/null 2>&1; then
1936 | vswhere=$_suite_vswhere
1937 | elif (
1938 | cd "$LOCALBUILDDIR" 2> /dev/null || return 1
1939 | do_wget -c -r -q "https://github.com/Microsoft/vswhere/releases/latest/download/vswhere.exe"
1940 | ./vswhere.exe -help > /dev/null 2>&1 || return 1
1941 | do_install vswhere.exe /opt/bin/
1942 | ); then
1943 | vswhere=$_suite_vswhere
1944 | else
1945 | return 1
1946 | fi
1947 |
1948 | local _hostbits=HostX64 _arch=x64
1949 | [[ $(uname -m) != x86_64 ]] && _hostbits=HostX86
1950 | [[ $bits == 32bit ]] && _arch=x86
1951 |
1952 | local basepath
1953 | if basepath=$(cygpath -u "$("$vswhere" -latest -all -find "VC/Tools/MSVC/*/bin/${_hostbits:-HostX64}/${_arch:-x64}" | sort -uV | tail -1)") &&
1954 | "$basepath/cl.exe" /? > /dev/null 2>&1; then
1955 | export PATH="$basepath:$PATH"
1956 | return 0
1957 | else
1958 | return 1
1959 | fi
1960 | }
1961 |
1962 | get_java_home() {
1963 | local javahome version
1964 | local javabasereg="/HKLM/software/javasoft"
1965 | local regkey="$javabasereg/java development kit"
1966 | export JAVA_HOME=
1967 | export JDK_HOME=""
1968 | if ! regtool -q check "$regkey"; then
1969 | echo "no version of JDK found"
1970 | return
1971 | fi
1972 |
1973 | version="$(regtool -q get "$regkey/CurrentVersion")"
1974 | [[ $(vercmp "$version" 1.8) != 0 ]] &&
1975 | echo "JDK 1.8 required, 9 doesn't work" && return
1976 | javahome="$(regtool -q get "$regkey/$version/JavaHome")"
1977 | javahome="$(cygpath -u "$javahome")"
1978 | [[ -f "$javahome/bin/java.exe" ]] &&
1979 | export JAVA_HOME="$javahome"
1980 | }
1981 |
1982 | # can only retrieve the dll version if it's actually in the ProductVersion field
1983 | get_dll_version() (
1984 | dll=$1
1985 | [[ -f $dll ]] || return 1
1986 | version="$(7z l "$dll" | grep 'ProductVersion:' | sed 's/.*ProductVersion: //')"
1987 | [[ -n $version ]] || return 1
1988 | echo "$version"
1989 | )
1990 |
1991 | get_api_version() {
1992 | local header="$1"
1993 | [[ -n $(file_installed "$header") ]] && header="$(file_installed "$header")"
1994 | local line="$2"
1995 | local column="$3"
1996 | [[ ! -f $header ]] && printf '' && return
1997 | grep "${line:-VERSION}" "$header" | awk '{ print $c }' c="${column:-3}" | sed 's|"||g'
1998 | }
1999 |
2000 | hide_files() {
2001 | local reverse=false echo_cmd
2002 | [[ $1 == "-R" ]] && reverse=true && shift
2003 | [[ $dryrun == y ]] && echo_cmd="echo"
2004 | for opt; do
2005 | if ! $reverse; then
2006 | [[ -f $opt ]] && $echo_cmd mv -f "$opt" "$opt.bak"
2007 | else
2008 | [[ -f "$opt.bak" ]] && $echo_cmd mv -f "$opt.bak" "$opt"
2009 | fi
2010 | done
2011 | }
2012 |
2013 | hide_conflicting_libs() {
2014 | # meant for rude build systems
2015 | local reverse=false
2016 | [[ $1 == "-R" ]] && reverse=true && shift
2017 | local priority_prefix
2018 | local -a installed
2019 | mapfile -t installed < <(find "$LOCALDESTDIR/lib" -maxdepth 1 -name "*.a")
2020 | if ! $reverse; then
2021 | hide_files "${installed[@]//$LOCALDESTDIR/$MINGW_PREFIX}"
2022 | else
2023 | hide_files -R "${installed[@]//$LOCALDESTDIR/$MINGW_PREFIX}"
2024 | fi
2025 | if [[ -n $1 ]]; then
2026 | priority_prefix="$1"
2027 | mapfile -t installed < <(find "$priority_prefix/lib" -maxdepth 1 -name "*.a")
2028 | if ! $reverse; then
2029 | hide_files "${installed[@]//$1/$LOCALDESTDIR}"
2030 | else
2031 | hide_files -R "${installed[@]//$1/$LOCALDESTDIR}"
2032 | fi
2033 | fi
2034 | }
2035 |
2036 | hide_libressl() {
2037 | local _hide_files=(include/openssl
2038 | lib/lib{crypto,ssl,tls}.{,l}a
2039 | lib/pkgconfig/openssl.pc
2040 | lib/pkgconfig/lib{crypto,ssl,tls}.pc)
2041 | local reverse=n
2042 | local _f
2043 | [[ $1 == "-R" ]] && reverse=y && shift
2044 | for _f in ${_hide_files[*]}; do
2045 | _f="$LOCALDESTDIR/$_f"
2046 | if [[ $reverse == n ]]; then
2047 | [[ -e $_f ]] && mv -f "$_f" "$_f.bak"
2048 | else
2049 | [[ -e "$_f.bak" ]] && mv -f "$_f.bak" "$_f"
2050 | fi
2051 | done
2052 | }
2053 |
2054 | add_to_remove() {
2055 | echo "${1:-$(get_first_subdir -f)}" >> "$LOCALBUILDDIR/_to_remove"
2056 | }
2057 |
2058 | clean_suite() {
2059 | do_simple_print -p "${orange}Deleting status files...${reset}"
2060 | cd_safe "$LOCALBUILDDIR" > /dev/null
2061 | find . -maxdepth 2 -name recently_updated -delete
2062 | find . -maxdepth 2 -regex ".*build_successful\(32\|64\)bit\(_\\w+\)?\$" -delete
2063 | echo -e "\\n\\t${green}Zipping man files...${reset}"
2064 | do_zipman
2065 |
2066 | if [[ $deleteSource == y ]]; then
2067 | echo -e "\\t${orange}Deleting temporary build dirs...${reset}"
2068 | find . -maxdepth 5 -name "ab-suite.*.log" -delete
2069 | find . -maxdepth 5 -type d -name "build-*bit" -exec rm -rf {} +
2070 | find . -maxdepth 2 -type d -name "build" -exec test -f "{}/CMakeCache.txt" ';' -exec rm -rf {} ';'
2071 | find . -maxdepth 3 -type f -name "Cargo.toml" -execdir cargo clean -q ";"
2072 |
2073 | if [[ -f _to_remove ]]; then
2074 | echo -e "\\n\\t${orange}Deleting source folders...${reset}"
2075 | grep -E "^($LOCALBUILDDIR|/trunk$LOCALBUILDDIR)" < _to_remove |
2076 | grep -Ev "^$LOCALBUILDDIR/(patches|extras|$)" | sort -u | xargs -r rm -rf
2077 | fi
2078 | if [[ $(du -s /var/cache/pacman/pkg/ | cut -f1) -gt 1000000 ]]; then
2079 | echo -e "\\t${orange}Deleting unneeded Pacman packages...${reset}"
2080 | pacman -Sc --noconfirm
2081 | fi
2082 | fi
2083 |
2084 | rm -f {firstrun,firstUpdate,secondUpdate,pacman,mingw32,mingw64}.log diagnostics.txt \
2085 | logs.zip _to_remove ./*.stripped.log
2086 |
2087 | [[ -f last_run ]] && mv last_run last_successful_run && touch last_successful_run
2088 | [[ -f CHANGELOG.txt ]] && cat CHANGELOG.txt >> newchangelog
2089 | unix2dos -n newchangelog CHANGELOG.txt 2> /dev/null && rm -f newchangelog
2090 | }
2091 |
2092 | create_diagnostic() (
2093 | cmds=("uname -a" "pacman -Qe" "pacman -Qd")
2094 | envs=(MINGW_{PACKAGE_PREFIX,CHOST,PREFIX} MSYSTEM CPATH
2095 | LIBRARY_PATH {LD,C,CPP,CXX}FLAGS PATH)
2096 | do_print_progress " Creating diagnostics file"
2097 | git -C /trunk rev-parse --is-inside-work-tree > /dev/null 2>&1 &&
2098 | cmds+=("git -C /trunk log -1 --pretty=%h")
2099 | {
2100 | echo "Env variables:"
2101 | for _env in "${envs[@]}"; do
2102 | declare -p "$_env" 2> /dev/null
2103 | done
2104 | for cmd in "${cmds[@]}"; do
2105 | echo
2106 | (set -x; $cmd)
2107 | done
2108 | } > "$LOCALBUILDDIR/diagnostics.txt" 2>&1
2109 | )
2110 |
2111 | create_winpty_exe() {
2112 | local exename="$1"
2113 | local installdir="$2"
2114 | shift 2
2115 | [[ -f "${installdir}/${exename}".exe ]] && mv "${installdir}/${exename}"{.,_}exe
2116 | # shellcheck disable=SC2016
2117 | printf '%s\n' "#!/usr/bin/env bash" "$@" \
2118 | 'if [[ -t 1 ]]; then' \
2119 | '/usr/bin/winpty "$( dirname ${BASH_SOURCE[0]} )/'"${exename}"'.exe" "$@"' \
2120 | 'else "$( dirname ${BASH_SOURCE[0]} )/'"${exename}"'.exe" "$@"; fi' \
2121 | > "${installdir}/${exename}"
2122 | [[ -f "${installdir}/${exename}"_exe ]] && mv "${installdir}/${exename}"{_,.}exe
2123 | }
2124 |
2125 | create_ab_pkgconfig() {
2126 | # from https://stackoverflow.com/a/8088167
2127 | local script_file
2128 | IFS=$'\n' read -r -d '' script_file << 'EOF' || true
2129 | #!/bin/sh
2130 |
2131 | while true; do
2132 | case $1 in
2133 | --libs|--libs-*) libs_args+=" $1"; shift ;;
2134 | --static) static="--static"; shift ;;
2135 | --* ) base_args+=" $1"; shift ;;
2136 | * ) break ;;
2137 | esac
2138 | done
2139 |
2140 | [[ -n $PKGCONF_STATIC ]] && static="--static"
2141 |
2142 | run_pkgcfg() {
2143 | "$MINGW_PREFIX/bin/pkgconf" --keep-system-libs --keep-system-cflags "$@" || exit 1
2144 | }
2145 |
2146 | deduplicateLibs() {
2147 | otherflags="$(run_pkgcfg $static $base_args "$@")"
2148 | unordered="$(run_pkgcfg $static $libs_args "$@")"
2149 | libdirs="$(printf '%s\n' $unordered | grep '^-L' | tr '\n' ' ')"
2150 | unordered="${unordered//$libdirs}"
2151 | ord_libdirs=""
2152 | for libdir in $libdirs; do
2153 | libdir="$(cygpath -m ${libdir#-L})"
2154 | ord_libdirs+=" -L$libdir"
2155 | done
2156 | ord_libdirs="$(printf '%s\n' $ord_libdirs | awk '!x[$0]++' | tr '\n' ' ')"
2157 | ord_libs="$(printf '%s\n' $unordered | tac | awk '!x[$0]++' | tac | tr '\n' ' ')"
2158 | printf '%s ' $otherflags $ord_libdirs $ord_libs
2159 | echo
2160 | }
2161 |
2162 | if [[ -n $libs_args ]]; then
2163 | deduplicateLibs "$@"
2164 | else
2165 | run_pkgcfg $static $base_args $libs_args "$@"
2166 | fi
2167 | EOF
2168 | mkdir -p "$LOCALDESTDIR"/bin > /dev/null 2>&1
2169 | [[ -f "$LOCALDESTDIR"/bin/ab-pkg-config ]] &&
2170 | diff -q <(printf '%s' "$script_file") "$LOCALDESTDIR"/bin/ab-pkg-config > /dev/null ||
2171 | printf '%s' "$script_file" > "$LOCALDESTDIR"/bin/ab-pkg-config
2172 | [[ -f "$LOCALDESTDIR"/bin/ab-pkg-config.bat ]] ||
2173 | printf '%s\r\n' "@echo off" "" "bash $LOCALDESTDIR/bin/ab-pkg-config %*" > "$LOCALDESTDIR"/bin/ab-pkg-config.bat
2174 | [[ -f "$LOCALDESTDIR"/bin/ab-pkg-config-static.bat ]] ||
2175 | printf '%s\r\n' "@echo off" "" "bash $LOCALDESTDIR/bin/ab-pkg-config --static %*" > "$LOCALDESTDIR"/bin/ab-pkg-config-static.bat
2176 | }
2177 |
2178 | create_ab_ccache() {
2179 | local bin temp_file ccache_path=false ccache_win_path=
2180 | temp_file=$(mktemp)
2181 | if [[ $ccache == y ]] && type ccache > /dev/null 2>&1; then
2182 | ccache_path="$(command -v ccache)"
2183 | ccache_win_path=$(cygpath -m "$ccache_path")
2184 | fi
2185 | mkdir -p "$LOCALDESTDIR"/bin > /dev/null 2>&1
2186 | for bin in {$MINGW_CHOST-,}{gcc,g++} clang{,++} cc cpp c++; do
2187 | type "$bin" > /dev/null 2>&1 || continue
2188 | cat << EOF > "$temp_file"
2189 | @echo off >nul 2>&1
2190 | rem() { "\$@"; }
2191 | rem test -f nul && rm nul
2192 | rem $ccache_path --help > /dev/null 2>&1 && $ccache_path $(command -v $bin) "\$@" || $(command -v $bin) "\$@"
2193 | rem exit \$?
2194 | $ccache_win_path $(cygpath -m "$(command -v $bin)") %*
2195 | EOF
2196 | diff -q "$temp_file" "$LOCALDESTDIR/bin/$bin.bat" > /dev/null 2>&1 || cp -f "$temp_file" "$LOCALDESTDIR/bin/$bin.bat"
2197 | chmod +x "$LOCALDESTDIR/bin/$bin.bat"
2198 | done
2199 | rm "$temp_file"
2200 | }
2201 |
2202 | create_cmake_toolchain() {
2203 | local _win_paths mingw_path
2204 | _win_paths=$(cygpath -pm "$LOCALDESTDIR:$MINGW_PREFIX:$MINGW_PREFIX/$MINGW_CHOST")
2205 | mingw_path=$(cygpath -m "$MINGW_PREFIX/include")
2206 | local toolchain_file=(
2207 | "SET(CMAKE_RC_COMPILER_INIT windres)"
2208 | ""
2209 | "LIST(APPEND CMAKE_PROGRAM_PATH \"$(cygpath -m "$LOCALDESTDIR/bin")\")"
2210 | "SET(CMAKE_PREFIX_PATH \"$_win_paths\")"
2211 | "SET(CMAKE_FIND_ROOT_PATH \"$_win_paths\")"
2212 | "SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)"
2213 | "SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)"
2214 | "SET(CMAKE_BUILD_TYPE Release)"
2215 | )
2216 |
2217 | mkdir -p "$LOCALDESTDIR"/etc > /dev/null 2>&1
2218 | [[ -f "$LOCALDESTDIR"/etc/toolchain.cmake ]] &&
2219 | diff -q <(printf '%s\n' "${toolchain_file[@]}") "$LOCALDESTDIR"/etc/toolchain.cmake > /dev/null ||
2220 | printf '%s\n' "${toolchain_file[@]}" > "$LOCALDESTDIR"/etc/toolchain.cmake
2221 | }
2222 |
2223 | do_fix_pkgconfig_abspaths() {
2224 | # in case the root was moved, this fixes windows abspaths
2225 | mkdir -p "$LOCALDESTDIR/lib/pkgconfig"
2226 | # pkgconfig keys to find the wrong abspaths from
2227 | local _keys="(prefix|exec_prefix|libdir|includedir)"
2228 | # current abspath root
2229 | local _root
2230 | _root=$(cygpath -m "$LOCALDESTDIR")
2231 | # find .pc files with Windows abspaths
2232 | grep -ElZR "${_keys}=[^/$].*" "$LOCALDESTDIR"/lib/pkgconfig | \
2233 | # find those with a different abspath than the current
2234 | xargs -0r grep -LZ "$_root" | \
2235 | # replace with current abspath
2236 | xargs -0r sed -ri "s;${_keys}=.*$LOCALDESTDIR;\1=$_root;g"
2237 | }
2238 |
2239 | do_clean_old_builds() {
2240 | local _old_libs=(j{config,error,morecfg,peglib}.h
2241 | lib{jpeg,nettle,gnurx,regex}.{,l}a
2242 | lib{opencore-amr{nb,wb},twolame,theora{,enc,dec},caca,magic,uchardet}.{,l}a
2243 | libSDL{,main}.{,l}a libopen{jpwl,mj2,jp2}.{a,pc}
2244 | include/{nettle,opencore-amr{nb,wb},theora,cdio,SDL,openjpeg-2.{1,2},luajit-2.0,uchardet,wels}
2245 | regex.h magic.h
2246 | {nettle,vo-aacenc,sdl,uchardet}.pc
2247 | {opencore-amr{nb,wb},twolame,theora{,enc,dec},caca,dcadec,libEGL,openh264}.pc
2248 | libcdio_{cdda,paranoia}.{{,l}a,pc}
2249 | twolame.h bin-audio/{twolame,cd-paranoia}.exe
2250 | bin-global/{{file,uchardet}.exe,sdl-config,luajit-2.0.4.exe}
2251 | libebur128.a ebur128.h
2252 | libopenh264.a
2253 | liburiparser.{{,l}a,pc}
2254 | libchromaprint.{a,pc} chromaprint.h
2255 | bin-global/libgcrypt-config libgcrypt.a gcrypt.h
2256 | lib/libgcrypt.def bin-global/{dumpsexp,hmac256,mpicalc}.exe
2257 | crossc.{h,pc} libcrossc.a
2258 | include/onig{uruma,gnu,posix}.h libonig.a oniguruma.pc
2259 | )
2260 |
2261 | do_uninstall q all "${_old_libs[@]}"
2262 | }
2263 |
2264 | grep_or_sed() {
2265 | local grep_re="$1"
2266 | local grep_file="$2"
2267 | [[ ! -f $grep_file ]] && return
2268 | local sed_re="$3"
2269 | shift 3
2270 | local sed_files=("$grep_file")
2271 | [[ -n $1 ]] && sed_files=("$@")
2272 |
2273 | grep -q -- "$grep_re" "$grep_file" ||
2274 | sed -ri -- "$sed_re" "${sed_files[@]}"
2275 | }
2276 |
2277 | grep_and_sed() {
2278 | local grep_re="$1"
2279 | local grep_file="$2"
2280 | [[ ! -f $grep_file ]] && return
2281 | local sed_re="$3"
2282 | shift 3
2283 | local sed_files=("$grep_file")
2284 | [[ -n $1 ]] && sed_files=("$@")
2285 |
2286 | grep -q -- "$grep_re" "$grep_file" &&
2287 | sed -ri -- "$sed_re" "${sed_files[@]}"
2288 | }
2289 |
2290 | fix_cmake_crap_exports() {
2291 | local _dir="$1"
2292 | # noop if passed directory is not valid
2293 | test -d "$_dir" || return 1
2294 |
2295 | local _mixeddestdir _oldDestDir _cmakefile
2296 | declare -a _cmakefiles
2297 |
2298 | _mixeddestdir="$(cygpath -m "$LOCALDESTDIR")"
2299 | mapfile -t _cmakefiles < <(grep -Plr '\w:/[\w/]*local(?:32|64)' "$_dir"/*.cmake)
2300 |
2301 | # noop if array is empty
2302 | test ${#_cmakefiles[@]} -lt 1 && return
2303 |
2304 | for _cmakefile in "${_cmakefiles[@]}"; do
2305 | # find at least one
2306 | _oldDestDir="$(grep -oP -m1 '\w:/[\w/]*local(?:32|64)' "$_cmakefile")"
2307 |
2308 | # noop if there's no expected install prefix found
2309 | [[ -z $_oldDestDir ]] && continue
2310 | # noop if old and current install prefix are equal
2311 | [[ $_mixeddestdir == "$_oldDestDir" ]] && continue
2312 |
2313 | # use perl for the matching and replacing, a bit simpler than with sed
2314 | perl -i -p -e 's;([A-Z]:/.*?)local(?:32|64);'"$_mixeddestdir"'\2;' "$_cmakefile"
2315 | done
2316 | }
2317 |
2318 | verify_cuda_deps() {
2319 | enabled cuda-sdk && do_removeOption --enable-cuda-sdk && do_addOption --enable-cuda-nvcc
2320 | if enabled_any libnpp cuda-nvcc && [[ $license != "nonfree" ]]; then
2321 | do_removeOption "--enable-(cuda-nvcc|libnpp)"
2322 | fi
2323 | if enabled libnpp && [[ $bits == 32bit ]]; then
2324 | echo -e "${orange}libnpp is only supported in 64-bit.${reset}"
2325 | do_removeOption --enable-libnpp
2326 | fi
2327 | if enabled_any libnpp cuda-nvcc && [[ -z $CUDA_PATH || ! -d $CUDA_PATH ]]; then
2328 | echo -e "${orange}CUDA_PATH environment variable not set or directory does not exist.${reset}"
2329 | do_removeOption "--enable-(cuda-nvcc|libnpp)"
2330 | fi
2331 | if enabled libnpp && [[ ! -f "$CUDA_PATH/lib/x64/nppc.lib" ]]; then
2332 | do_removeOption --enable-libnpp
2333 | fi
2334 | if enabled cuda-llvm && do_pacman_install clang; then
2335 | do_removeOption --enable-cuda-nvcc
2336 | else
2337 | do_removeOption --enable-cuda-llvm
2338 | if ! disabled autodetect; then
2339 | do_addOption --disable-cuda-llvm
2340 | fi
2341 | fi
2342 | if enabled cuda-nvcc; then
2343 | if ! get_cl_path; then
2344 | echo -e "${orange}MSVC cl.exe not found in PATH or through vswhere; needed by nvcc.${reset}"
2345 | do_removeOption --enable-cuda-nvcc
2346 | elif enabled cuda-nvcc && ! nvcc.exe --help &> /dev/null &&
2347 | ! "$(cygpath -sm "$CUDA_PATH")/bin/nvcc.exe" --help &> /dev/null; then
2348 | echo -e "${orange}nvcc.exe not found in PATH or installed in CUDA_PATH.${reset}"
2349 | do_removeOption --enable-cuda-nvcc
2350 | fi
2351 | fi
2352 | enabled_any libnpp cuda-nvcc || ! disabled cuda-llvm
2353 | }
2354 |
2355 | check_custom_patches() {
2356 | local _basedir=$1 vcsFolder=${1%-*}
2357 | if [[ -z $1 ]]; then
2358 | _basedir=$(get_first_subdir)
2359 | vcsFolder=${_basedir%-*}
2360 | fi
2361 | [[ -f $LOCALBUILDDIR/${vcsFolder}_extra.sh ]] || return
2362 | export REPO_DIR=$LOCALBUILDDIR/$_basedir
2363 | export REPO_NAME=$vcsFolder
2364 | do_print_progress " Found ${vcsFolder}_extra.sh. Sourcing script"
2365 | source "$LOCALBUILDDIR/${vcsFolder}_extra.sh"
2366 | echo "$vcsFolder" >> "$LOCALBUILDDIR/patchedFolders"
2367 | sort -uo "$LOCALBUILDDIR/patchedFolders"{,}
2368 | }
2369 |
2370 | extra_script() {
2371 | local stage="$1"
2372 | local commandname="$2"
2373 | local vcsFolder="${REPO_DIR%-*}"
2374 | vcsFolder="${vcsFolder#*build/}"
2375 | if [[ $commandname =~ ^(make|ninja)$ ]] &&
2376 | type "_${stage}_build" > /dev/null 2>&1; then
2377 | pushd "${REPO_DIR}" > /dev/null 2>&1 || true
2378 | do_print_progress "Running ${stage} build from ${vcsFolder}_extra.sh"
2379 | log -q "${stage}_build" "_${stage}_build"
2380 | popd > /dev/null 2>&1 || true
2381 | elif type "_${stage}_${commandname}" > /dev/null 2>&1; then
2382 | pushd "${REPO_DIR}" > /dev/null 2>&1 || true
2383 | do_print_progress "Running ${stage} ${commandname} from ${vcsFolder}_extra.sh"
2384 | log -q "${stage}_${commandname}" "_${stage}_${commandname}"
2385 | popd > /dev/null 2>&1 || true
2386 | fi
2387 | }
2388 |
2389 | unset_extra_script() {
2390 | # The current repository folder (/build/ffmpeg-git)
2391 | unset REPO_DIR
2392 | # The repository name (ffmpeg)
2393 | unset REPO_NAME
2394 | # Should theoretically be the same as REPO_NAME with
2395 | unset vcsFolder
2396 |
2397 | # Each of the _{pre,post}_ means that there is a "_pre_"
2398 | # and "_post_"
2399 |
2400 | # Runs before cloning or fetching a git repo and after
2401 | unset _{pre,post}_vcs
2402 |
2403 | # Runs before and after building rust packages (do_rust)
2404 | unset _{pre,post}_rust
2405 |
2406 | ## Pregenerational hooks
2407 |
2408 | # Runs before and after running autoreconf -fiv (do_autoreconf)
2409 | unset _{pre,post}_autoreconf
2410 |
2411 | # Runs before and after running ./autogen.sh (do_autogen)
2412 | unset _{pre,post}_autogen
2413 |
2414 | # Generational hooks
2415 |
2416 | # Runs before and after running ./configure (do_separate_conf, do_configure)
2417 | unset _{pre,post}_configure
2418 |
2419 | # Runs before and after running cmake (do_cmake)
2420 | unset _{pre,post}_cmake
2421 |
2422 | ## Build hooks
2423 |
2424 | # Runs before and after runing make (do_make)
2425 | unset _{pre,post}_make
2426 |
2427 | # Runs before and after running meson (do_meson)
2428 | unset _{pre,post}_meson
2429 |
2430 | # Runs before and after running ninja (do_ninja)
2431 | unset _{pre,post}_ninja
2432 |
2433 | unset _{pre,post}_qmake
2434 |
2435 | # Runs before and after running make, meson, ninja, and waf (Generic hook for the previous build hooks)
2436 | # If this is present, it will override the other hooks
2437 | # Use for mpv and python waf based stuff.
2438 | unset _{pre,post}_build
2439 |
2440 | ## Post build hooks
2441 |
2442 | # Runs before and after either ninja install
2443 | # or make install or using install
2444 | # (do_makeinstall, do_ninjainstall, do_install)
2445 | unset _{pre,post}_install
2446 | }
2447 |
2448 | create_extra_skeleton() {
2449 | local overwrite
2450 | while true; do
2451 | case $1 in
2452 | -f) overwrite=y && shift ;;
2453 | --)
2454 | shift
2455 | break
2456 | ;;
2457 | *) break ;;
2458 | esac
2459 | done
2460 | local extraName="$1"
2461 | [[ -z $extraName ]] &&
2462 | printf '%s\n' \
2463 | 'Usage: create_extra_skeleton [-f] ' \
2464 | 'For example, to create a ffmpeg_extra.sh skeleton file in '"$LOCALBUILDDIR"':' \
2465 | '> create_extra_skeleton ffmpeg' && return 1
2466 | [[ -f "$LOCALBUILDDIR/$extraName"_extra.sh && -z $overwrite ]] &&
2467 | echo "$LOCALBUILDDIR/$extraName_extra.sh already exists. Use -f if you are sure you want to overwrite it." && return 1
2468 |
2469 | IFS=$'\n' read -r -d '' script_file << 'EOF' || true
2470 | #!/bin/bash
2471 |
2472 | # Force to the suite to think the package has updates to recompile.
2473 | # Alternatively, you can use "touch recompile" for a similar effect.
2474 | #touch custom_updated
2475 |
2476 | # Commands to run before and after cloning a repo
2477 | _pre_vcs() {
2478 | # ref changes the branch/commit/tag that you want to clone
2479 | ref=research
2480 | }
2481 |
2482 | # Commands to run before and after running cmake (do_cmake)
2483 | _pre_cmake(){
2484 | # Installs libwebp
2485 | #do_pacman_install libwebp
2486 | # Downloads the patch and then applies the patch
2487 | #do_patch "https://gist.githubusercontent.com/1480c1/9fa9292afedadcea2b3a3e067e96dca2/raw/50a3ed39543d3cf21160f9ad38df45d9843d8dc5/0001-Example-patch-for-learning-purpose.patch"
2488 | # Change directory to the build folder
2489 | #cd_safe "build-${bits}"
2490 |
2491 | # Add additional options to suite's cmake execution
2492 | #cmake_extras=(-DENABLE_SWEET_BUT_BROKEN_FEATURE=on)
2493 |
2494 | # To bypass the suite's cmake execution completely, create a do_not_reconfigure file in the repository root:
2495 | #touch "$(get_first_subdir -f)/do_not_reconfigure"
2496 |
2497 | true
2498 | }
2499 |
2500 | _post_cmake(){
2501 | # Run cmake directly with custom options. $LOCALDESTDIR refers to local64 or local32
2502 | #cmake .. -G"Ninja" -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" \
2503 | # -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang \
2504 | # -DBUILD_SHARED_LIBS=off -DENABLE_TOOLS=off
2505 | true
2506 | }
2507 |
2508 | # Runs before and after building rust packages (do_rust)
2509 | _pre_rust() {
2510 | # Add additional options to suite's rust (cargo) execution
2511 | #rust_extras=(--no-default-features --features=binaries)
2512 |
2513 | # To bypass the suite's cargo execution completely, create a do_not_reconfigure file in the repository root:
2514 | #touch "$(get_first_subdir -f)/do_not_reconfigure"
2515 |
2516 | true
2517 | }
2518 | _post_rust() {
2519 | true
2520 | }
2521 |
2522 | # Runs before and after running meson (do_meson)
2523 | _pre_meson() {
2524 | # Add additional options to suite's rust (cargo) execution
2525 | #meson_extras=(-Denable_tools=true)
2526 |
2527 | # To bypass the suite's meson execution completely, create a do_not_reconfigure file in the repository root:
2528 | #touch "$(get_first_subdir -f)/do_not_reconfigure"
2529 |
2530 | true
2531 | }
2532 | _post_meson() {
2533 | true
2534 | }
2535 |
2536 | # Runs before and after running autoreconf -fiv (do_autoreconf)
2537 | _pre_autoreconf() {
2538 | true
2539 | }
2540 | _post_autoreconf() {
2541 | true
2542 | }
2543 |
2544 | # Runs before and after running ./autogen.sh (do_autogen)
2545 | _pre_autogen() {
2546 | true
2547 | }
2548 | _post_autogen() {
2549 | true
2550 | }
2551 |
2552 | # Commands to run before and after running configure on a Autoconf/Automake/configure-using package
2553 | _pre_configure(){
2554 | true
2555 | #
2556 | # Apply a patch from ffmpeg's patchwork site.
2557 | #do_patch "https://patchwork.ffmpeg.org/patch/12563/mbox/" am
2558 | #
2559 | # Apply a local patch inside the directory where is "ffmpeg_extra.sh"
2560 | #patch -p1 -i "$LOCALBUILDDIR/ffmpeg-0001-my_patch.patch"
2561 | #
2562 | # Add extra configure options to ffmpeg (ffmpeg specific)
2563 | # If you want to add something to ffmpeg not within the suite already
2564 | # you will need to install it yourself, either through pacman
2565 | # or compiling from source.
2566 | #FFMPEG_OPTS+=(--enable-libsvthevc)
2567 | #
2568 | }
2569 | _post_configure(){
2570 | true
2571 | }
2572 |
2573 | # Runs before and after runing make (do_make)
2574 | _pre_make(){
2575 | # To bypass the suite's make execution completely, create a do_not_build file in the repository root:
2576 | #touch "$(get_first_subdir -f)/do_not_build"
2577 | true
2578 | }
2579 | _post_make(){
2580 | true
2581 | # Don't run configure again.
2582 | #touch "$(get_first_subdir -f)/do_not_reconfigure"
2583 | # Don't clean the build folder on each successive run.
2584 | # This is for if you want to keep the current build folder as is and just recompile only.
2585 | #touch "$(get_first_subdir -f)/do_not_clean"
2586 | }
2587 |
2588 | # Runs before and after running ninja (do_ninja)
2589 | _pre_ninja() {
2590 | # To bypass the suite's ninja execution completely, create a do_not_build file in the repository root:
2591 | #touch "$(get_first_subdir -f)/do_not_build"
2592 | true
2593 | }
2594 | _post_ninja() {
2595 | true
2596 | }
2597 |
2598 | # Runs before and after running make, meson, ninja, and waf (Generic hook for the previous build hooks)
2599 | # If this is present, it will override the other hooks
2600 | # Use for mpv and python waf based stuff.
2601 | _pre_build() {
2602 | # To bypass the suite's build execution completely, create a do_not_build file in the repository root:
2603 | #touch "$(get_first_subdir -f)/do_not_build"
2604 | true
2605 | }
2606 | _post_build() {
2607 | true
2608 | }
2609 |
2610 | # Runs before and after either ninja install
2611 | # or make install or using install
2612 | # (do_makeinstall, do_ninjainstall, do_install)
2613 | _pre_install() {
2614 | # To bypass the suite's install completely, create a do_not_install file in the repository root:
2615 | #touch "$(get_first_subdir -f)/do_not_install"
2616 | true
2617 | }
2618 | _post_install() {
2619 | true
2620 | }
2621 |
2622 | EOF
2623 | printf '%s' "$script_file" > "${LOCALBUILDDIR}/${extraName}_extra.sh"
2624 | echo "Created skeleton file ${LOCALBUILDDIR}/${extraName}_extra.sh"
2625 | }
2626 |
2627 | # if you absolutely need to remove some of these,
2628 | # add a "-e '!'" option
2629 | # ex: "-e '!/recently_updated'"
2630 | safe_git_clean() {
2631 | git clean -xfd \
2632 | -e "/build_successful*" \
2633 | -e "/recently_updated" \
2634 | -e '/custom_updated' \
2635 | -e '**/ab-suite.*.log' \
2636 | "${@}"
2637 | }
2638 |
--------------------------------------------------------------------------------
/build/media-suite_update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # shellcheck disable=SC2086
3 |
4 | while true; do
5 | case $1 in
6 | --build32=*)
7 | build32="${1#*=}"
8 | shift
9 | ;;
10 | --build64=*)
11 | build64="${1#*=}"
12 | shift
13 | ;;
14 | --update=*)
15 | update="${1#*=}"
16 | shift
17 | ;;
18 | --CC=*)
19 | CC="${1#*=}"
20 | shift
21 | ;;
22 | --)
23 | shift
24 | break
25 | ;;
26 | -*)
27 | echo "Error, unknown option: '$1'."
28 | exit 1
29 | ;;
30 | *) break ;;
31 | esac
32 | done
33 |
34 | [[ "$(uname)" == *6.1* ]] && nargs="-n 4"
35 |
36 | # start suite update
37 | if [[ -d "/trunk/build" ]]; then
38 | cd "/trunk/build" || exit 1
39 | else
40 | cd "$(cygpath -w /)../build" || exit 1
41 | fi
42 | [[ -f media-suite_helper.sh ]] && source media-suite_helper.sh
43 | [[ -f media-suite_deps.sh ]] && source media-suite_deps.sh
44 |
45 | # --------------------------------------------------
46 | # update suite
47 | # --------------------------------------------------
48 |
49 | if [[ $update == "yes" ]]; then
50 | echo
51 | echo "-------------------------------------------------------------------------------"
52 | echo "checking if suite has been updated..."
53 | echo "-------------------------------------------------------------------------------"
54 | echo
55 |
56 | if [[ ! -d ../.git ]] && command -v git > /dev/null; then
57 | if ! git clone "${SOURCE_REPO_MABS:-https://github.com/m-ab-s/media-autobuild_suite.git}" ab-git; then
58 | git -C ab-git fetch
59 | fi
60 | cp -fr ab-git/.git ..
61 | fi
62 | cd_safe ..
63 | if [[ -d .git ]]; then
64 | if [[ -n "$(git diff --name-only)" ]]; then
65 | diffname="$(date +%F-%H.%M.%S)"
66 | git diff --diff-filter=M >> "build/user-changes-${diffname}.diff"
67 | echo "Your changes have been exported to build/user-changes-${diffname}.diff."
68 | git reset --hard "@{upstream}"
69 | fi
70 | git fetch -t
71 | oldHead=$(git rev-parse HEAD)
72 | git reset --hard "@{upstream}"
73 | newHead=$(git rev-parse HEAD)
74 | if [[ $oldHead != "$newHead" ]]; then
75 | echo "Suite has been updated!"
76 | echo "If you had an issue try running the suite again before reporting."
77 | else
78 | echo "Suite up-to-date."
79 | echo "If you had an issue, please report it in GitHub."
80 | fi
81 | read -r -t 15 -p ' to close' ret
82 | fi
83 | fi # end suite update
84 |
85 | # --------------------------------------------------
86 | # packet update system
87 | # --------------------------------------------------
88 |
89 | # remove buggy crap
90 | grep -q abrepo /etc/pacman.conf && sed -i '/abrepo/d' /etc/pacman.conf
91 | rm -f /etc/pacman.d/abrepo.conf
92 |
93 | rm -rf /opt/cargo/bin
94 |
95 | echo
96 | echo "-------------------------------------------------------------------------------"
97 | echo "Updating pacman database..."
98 | echo "-------------------------------------------------------------------------------"
99 | echo
100 |
101 | pacman -Sy --ask=20 --noconfirm
102 | { pacman -Qqe | grep -q sed && pacman -Qqg base | pacman -D --asdeps - && pacman -D --asexplicit mintty flex; } > /dev/null
103 | do_unhide_all_sharedlibs
104 |
105 | # make sure that pacutils is always installed for pacsift
106 | { pacman -Qq pacutils || pacman -S --needed --noconfirm pacutils; } > /dev/null 2>&1
107 |
108 | extract_pkg_prefix() (
109 | case $1 in
110 | *32) [[ $build32 != "yes" ]] && return 1 ;;
111 | *64) [[ $build64 != "yes" ]] && return 1 ;;
112 | esac
113 | . shell "$1"
114 | echo "$MINGW_PACKAGE_PREFIX-"
115 | )
116 |
117 | if [[ -f /etc/pac-base.pk && -f /etc/pac-mingw.pk ]] && ! [[ $build32 == "yes" && $CC =~ clang ]]; then
118 | new=$(mktemp)
119 | old=$(mktemp)
120 | echo
121 | echo "-------------------------------------------------------------------------------"
122 | echo "Checking pacman packages..."
123 | echo "-------------------------------------------------------------------------------"
124 | echo
125 | dos2unix -O /etc/pac-base.pk 2> /dev/null | sort -u >> "$new"
126 | mapfile -t newmingw < <(dos2unix -O /etc/pac-mingw.pk /etc/pac-mingw-extra.pk 2>/dev/null | sort -u)
127 | mapfile -t newmsys < <(dos2unix -O /etc/pac-msys-extra.pk 2> /dev/null | sort -u)
128 | prefix_32='' prefix_64=''
129 | case $CC in
130 | *clang) prefix_64=$(extract_pkg_prefix clang64) ;;
131 | *) prefix_32=$(extract_pkg_prefix mingw32) prefix_64=$(extract_pkg_prefix mingw64) ;;
132 | esac
133 | for pkg in "${newmingw[@]}"; do
134 | if [[ $build32 == "yes" ]] && [[ ! $CC =~ clang ]] &&
135 | pacman -Ss "$prefix_32$pkg" > /dev/null 2>&1; then
136 | printf %s\\n "$prefix_32$pkg" >> "$new"
137 | fi
138 | if [[ $build64 == "yes" ]] &&
139 | pacman -Ss "$prefix_64$pkg" > /dev/null 2>&1; then
140 | printf %s\\n "$prefix_64$pkg" >> "$new"
141 | fi
142 | done
143 | for pkg in "${newmsys[@]}"; do
144 | pacman -Ss "^${pkg}$" > /dev/null 2>&1 && printf %s\\n "$pkg" >> "$new"
145 | done
146 | pacman -Qqe | sort -u >> "$old"
147 | sort -uo "$new"{,}
148 | # mapfile -t new < <(printf %s\\n "${new[@]}" | sort -u)
149 | mapfile -t install < <(diff --changed-group-format='%>' --unchanged-group-format='' "$old" "$new")
150 | mapfile -t uninstall < <(diff --changed-group-format='%<' --unchanged-group-format='' "$old" "$new")
151 |
152 | if [[ ${#uninstall[@]} -gt 0 ]]; then
153 | echo
154 | echo "-------------------------------------------------------------------------------"
155 | echo "You have more packages than needed!"
156 | echo "Do you want to remove them?"
157 | echo "-------------------------------------------------------------------------------"
158 | echo
159 | echo "Remove:"
160 | echo "${uninstall[*]}"
161 | while true; do
162 | read -r -p "remove packs [y/n]? " yn
163 | case $yn in
164 | [Yy]*)
165 | pacman -Rs --noconfirm "${uninstall[@]}" >&2 2> /dev/null
166 | for pkg in "${uninstall[@]}"; do
167 | pacman -Qs "^${pkg}$" && pacman -D --noconfirm --asdeps "$pkg" > /dev/null
168 | done
169 | break
170 | ;;
171 | [Nn]*)
172 | pacman --noconfirm -D --asdeps "${uninstall[@]}"
173 | break
174 | ;;
175 | *) echo "Please answer yes or no" ;;
176 | esac
177 | done
178 | fi
179 | if [[ ${#install[@]} -gt 0 ]]; then
180 | echo "You're missing some packages!"
181 | echo "Proceeding with installation..."
182 | pacman -Sw --noconfirm --needed "${install[@]}"
183 | pacman -S --noconfirm --needed "${install[@]}"
184 | pacman -D --asexplicit "${install[@]}"
185 | fi
186 | rm -f /etc/pac-{base,mingw}.pk "$new" "$old"
187 | elif [[ $build32 == "yes" && $CC =~ clang ]]; then
188 | echo "The CLANG32 environment is no longer supported"
189 | exit 1
190 | fi
191 |
192 | if [[ -d "/trunk" ]]; then
193 | cd "/trunk" || exit 1
194 | else
195 | cd_safe "$(cygpath -w /).."
196 | fi
197 |
198 | # --------------------------------------------------
199 | # packet msys2 system
200 | # --------------------------------------------------
201 |
202 | have_updates="$(pacman -Qu | grep -v ignored]$ | cut -d' ' -f1)"
203 | if [[ -n $have_updates ]]; then
204 | echo "-------------------------------------------------------------------------------"
205 | echo "Updating msys2 system and installed packages..."
206 | echo "-------------------------------------------------------------------------------"
207 | grep -Eq '^(pacman|bash|msys2-runtime)$' <<< "$have_updates" &&
208 | touch /build/update_core &&
209 | have_updates="$(grep -Ev '^(pacman|bash|msys2-runtime)$' <<< "$have_updates")"
210 | xargs $nargs pacman -S --noconfirm --overwrite "/mingw64/*" \
211 | --overwrite "/mingw32/*" --overwrite "/clang64/*" --overwrite "/usr/*" <<< "$have_updates"
212 | fi
213 |
214 | [[ ! -s /usr/ssl/certs/ca-bundle.crt ]] &&
215 | pacman -S --noconfirm --asdeps ca-certificates
216 |
217 | # do a final overall installation for potential downgrades
218 | pacman -Syuu --noconfirm --overwrite "/mingw64/*" \
219 | --overwrite "/mingw32/*" --overwrite "/clang64/*" --overwrite "/usr/*"
220 |
221 | do_hide_all_sharedlibs
222 |
223 | echo "-------------------------------------------------------------------------------"
224 | echo "Updates finished."
225 | echo "-------------------------------------------------------------------------------"
226 |
227 | sleep 2
228 |
229 | exit
230 |
--------------------------------------------------------------------------------
/doc/forcing-recompilations.md:
--------------------------------------------------------------------------------
1 | # How to force compilation of libs/apps
2 |
3 | ## Libraries using pkg-config
4 |
5 | Most libs use pkg-config files to check if they exist, so for most libs in this list all you have to do is delete the corresponding `.pc` file in `/local[32|64]/lib/pkgconfig/`:
6 |
7 | aom
8 | aribb24
9 | chromaprint
10 | codec2
11 | dav1d
12 | davs2
13 | dovi
14 | dvdnav
15 | dvdread
16 | fdk-aac (fdk-aac library only)
17 | ffms2
18 | ffnvcodec
19 | flac
20 | fontconfig
21 | freetype
22 | frei0r
23 | gflags
24 | gnutls
25 | harfbuzz
26 | kvazaar
27 | lensfun
28 | lept (leptonica)
29 | libaacs
30 | libass
31 | libavif
32 | libbluray
33 | libbdplus
34 | libbs2b
35 | libcurl
36 | libglut
37 | libgme (game music emu)
38 | libidn2
39 | libilbc
40 | libjxl
41 | libmediainfo
42 | libmfx (intel quick sync hw accelerator)
43 | libmusicbrainz5
44 | libMXF-1.0
45 | libMXF++-1.0
46 | libmysofa
47 | libopenmpt
48 | libopusenc (opusenc library only)
49 | libplacebo
50 | libpng
51 | libpsl
52 | librav1e
53 | librtmp
54 | libtiff-4
55 | liburiparser
56 | libvmaf
57 | libvvdec
58 | libvvenc
59 | libxml-2.0
60 | libwebp
61 | libzen
62 | lsmash
63 | luajit
64 | mujs
65 | neon
66 | ogg
67 | openal
68 | opencl
69 | openssl
70 | opus
71 | opusfile
72 | rubberband
73 | sdl2
74 | shine
75 | sndfile
76 | speex
77 | spirv-cross
78 | srt
79 | SvtAv1Dec
80 | SvtAv1Enc
81 | SvtHevcEnc
82 | SvtVp9Enc
83 | tesseract
84 | uavs3d
85 | uvg266
86 | vapoursynth
87 | vidstab
88 | vo-amrwbenc
89 | vorbis
90 | vpx
91 | vulkan
92 | x264
93 | x265
94 | xavs
95 | xavs2
96 | xvc
97 | zimg
98 | zlib
99 | zvbi-0.2 (libzvbi)
100 |
101 | ## Libraries not using pkg-config
102 |
103 | To recompile these libs, delete `.a` with the same name in `/local[32|64]/lib`:
104 |
105 | libdl
106 | libflite
107 | libglslang
108 | libgpac_static
109 | libmujs
110 | libpython311
111 | libshaderc_combined
112 | libsoxr (sox resampling library only)
113 | libxavs
114 | libxvidcore
115 |
116 | ## Apps
117 |
118 | To recompile these, delete `.exe` in corresponding binary directories:
119 |
120 | /bin-audio
121 | cyanrip
122 | exhale
123 | faac
124 | fdkaac (fdk-aac encoder)
125 | flac
126 | lame (MP3 encoder)
127 | metaflac
128 | oggdec
129 | oggenc
130 | opusdec
131 | opusenc
132 | opusinfo
133 | sox
134 | shineenc
135 | speexdec
136 | speexenc
137 |
138 | /bin-global
139 | cjpegl
140 | cjxl
141 | curl
142 | cwebp
143 | djpegli
144 | djxl
145 | dssim
146 | dwebp
147 | gifski
148 | idn2
149 | img2webp
150 | jxlinfo
151 | jo
152 | jq
153 | luajit
154 | minigzip
155 | miniunzip
156 | minizip
157 | mujs
158 | openssl
159 | psl
160 | rg
161 | rist
162 | 2rist
163 | receiver
164 | sender
165 | srppasswd
166 | tesseract
167 | tiff
168 | cp
169 | dump
170 | info
171 | set
172 | split
173 | uriparse
174 | webpmux
175 |
176 | /bin-video
177 | aomdec
178 | aomenc
179 | av1an
180 | avifdec
181 | avifenc
182 | bmxtranswrap
183 | dav1d
184 | davs2
185 | dovi_tool
186 | ffmbc
187 | ffmpeg (for static and both)
188 | ffmpegSHARED/ffmpeg (for shared only)
189 | ffmsindex
190 | gpac
191 | hdr10plus_tool
192 | h264dump
193 | kvazaar
194 | libaacs.dll
195 | libass-9.dll
196 | libbdplus.dll
197 | libEGL.dll
198 | libfreetype-6.dll
199 | libfribidi-0.dll
200 | libharfbuzz-0.dll
201 | libharfbuzz-subset-0.dll
202 | mediainfo
203 | MP4Box
204 | mencoder
205 | movdump
206 | mplayer
207 | mpv
208 | MXFDump
209 | mxf2raw
210 | rav1e
211 | raw2mxf
212 | rtmpdump (if rtmpdump=y)
213 | srt-live-transmit
214 | SvtAv1DecApp
215 | SvtAv1EncApp
216 | SvtHevcEncApp
217 | SvtVp9EncApp
218 | uavs3dec
219 | uvg266
220 | vc2dump
221 | vvdecapp
222 | vvencapp
223 | vvencFFapp
224 | vvc
225 | EncoderApp
226 | DecoderApp
227 | vpxenc
228 | x264
229 | x265
230 | xavs2
231 | xvcenc
232 | xvcdec
233 | xvid_encraw
--------------------------------------------------------------------------------
/doc/getting-started.md:
--------------------------------------------------------------------------------
1 | # Getting Started
2 |
3 | ## First Time
4 |
5 | ### Preliminaries
6 |
7 | 1. Path is less than 60 characters.
8 | 2. Path has no spaces.
9 | 3. OS level is Windows 8.1 or above.
10 | - Although Windows 7 could work, it is not supported.
11 | 4. Powershell version 4 and above
12 | - Do not run this script from Powershell Core prior to version 7 as it will fail to download the wget-pack.exe. See [Pull #1021](https://github.com/m-ab-s/media-autobuild_suite/pull/1021)
13 | 5. Make sure to get the latest version of the suite before running anything.
14 | - If you have cloned the repository using git, look at the `Using update_suite.sh` section or the `Using git` section of [updating.md](./updating.md#using-git)
15 | - If you have downloaded the suite through the zip, look at the `Using snapshots from Github` section of [updating.md](./updating.md#using-snapshots-from-github#using-snapshots-from-github)
16 |
17 | ### Running the Suite
18 |
19 | Running the suite is simple:
20 |
21 | 1. Run media-autobuild_suite.bat
22 | 2. Answer the questions that appear
23 |
24 | ### After the Suite is Done
25 |
26 | After the suite is done, the binary files will appear in the local[64|32] folder folders under bin-audio, bin-global, and bin-video.
27 |
28 | To use these, you can either:
29 |
30 | - Copy the files in those folders to a folder that is in your enviroment PATH*.
31 | - Add the bin-* folders to your enviroment PATH*.
32 | - Invoke the programs using their path.
33 | - For CMD: `C:\Users\Potatoe>C:\media-autobuild_suite\local64\bin-video\ffmpeg.exe -h`
34 | - For Powershell: `PS C:\Users\Potatoe> C:\media-autobuild_suite\local64\bin-video\ffmpeg.exe -h`
35 | - Adjust the path to match your situation.
36 |
37 | *Note: It is almost always recommeded to copy/move the files in the bin-\* folders to somewhere you can easily remember and use as you cannot use them while the suite is updating or compiling.*
38 |
39 | \* If you do not know what your enviroment PATH is, either ignore those options or google what the enviroment PATH is.
40 |
41 | ## Afterwards
42 |
43 | Look at [updating.md](./updating.md) for when you want to update the suite or just rerun the batch script as it will automatically look for updates itself.
44 |
45 | If you want to rebuild the programs from scratch at any time due to an error or something else, delete the local[32|64] folder folder and remove any \*-git and \*-svn folders from the build folder. Finally rerun the batch script, it should redownload all of those folders and rebuild into a new local[32|64] folder.
46 |
47 | If you want to rebuild the suite from scratch completely, in addition to deleting the folders specified above, also delete the msys64 folder and rerun the script. It should at that point redownload and setup the msys2 system again.
48 |
--------------------------------------------------------------------------------
/doc/updating.md:
--------------------------------------------------------------------------------
1 | # Updating the suite
2 |
3 | There are three methods for keeping the suite updated, neither are fully automated but one is maybe easier to do. Either one you use, it's highly recommended you do them *before* running the suite since issues are probably fixed in newer versions.
4 |
5 | ## Using update_suite.sh
6 |
7 | A semi-automated way of doing the third method. Uses git too and exports user changes to a .diff file containing the user changes (and changes before the last commit). There's no way to know exactly what version of the suite the user has before using git.
8 |
9 | ### How
10 |
11 | 1. Make sure you selected the option to update the suite when running the .bat.
12 | If you didn't, open `build\media-autobuild_suite.ini` in notepad and change `updateSuite=2` to `1`
13 | 2. If there isn't a file called `update_suite.sh` in the root of the suite, run the .bat until the file is there.
14 | 3. Close the .bat using Ctrl+C or just closing the window if it's running.
15 | **Never run update_suite.sh while the suite is running! You shouldn't change or replace files being executed.**
16 | 4. Run `update_suite.sh` by dragging it to the `mintty` shortcut also in the root of the suite
17 | 5. Wait until it closes and the suite has been updated.
18 | 6. Unless something failed or Github is down, you can be sure you're on the latest version of the suite.
19 |
20 | If you had previously changed the suite files you can check the .diff file inside `build` and try to reproduce them.
21 | Changing the suites files isn't supported, obviously. It's troublesome already to keep up with bugs in upstream
22 | packages.
23 |
24 | ## Using snapshots from Github
25 |
26 | The simpler way but harder to keep track of your changes. Just click [Download ZIP](https://github.com/m-ab-s/media-autobuild_suite/archive/master.zip) in the homepage of the repository in Github and replace all files inside the suite directory with the new ones.
27 |
28 | If you have changes you have to keep track of them manually.
29 |
30 | ## Using git
31 |
32 | ### If you didn't already use git clone to get this repository
33 |
34 | 1. Open mintty using the shortcut
35 | 2. Go to `/trunk/build` and run `git clone https://github.com/m-ab-s/media-autobuild_suite.git`
36 | 3. Run `mv media-autobuild_suite/.git /trunk/`
37 |
38 | You should now be able to `cd /trunk` and something should show up when doing `git status`. You have now turned your copy into a copy of the repository!
39 |
40 | If you had modified the files in any way it's probably best to check with `git diff` and maybe export the changes to a file using `git diff > mychanges.diff`
41 |
42 | After exporting the diff you can now use `git reset --hard origin/master` to get the most updated version of the repository files.
43 |
44 | The diff may contain more than your changes so if you want to apply them again, create a new branch by running `git checkout -b mychanges`. This command also changed the current branch to `mychanges` so you can now add your changes again.
45 |
46 | After reapplying the changes, run `git commit` so your changes are kept in that branch.
47 |
48 | Now everytime you want to update the suite, all you'll have to do is:
49 |
50 | 1. `git checkout master`
51 | 2. `git pull origin master`
52 | 3. If you had changes:
53 | 1. `git checkout mychanges`
54 | 2. `git rebase master`
55 | 3. If it worked, your branch is now updated and with your changes
56 | 4. If it didn't, check online for the problem.
57 |
58 | I recommend reading Github's git guides to learn how to use it, it's a very powerful tool.
--------------------------------------------------------------------------------