Compare commits
No commits in common. "master" and "1.2" have entirely different histories.
20
.github/workflows/build.yml
vendored
20
.github/workflows/build.yml
vendored
@ -1,20 +0,0 @@
|
|||||||
name: Builds
|
|
||||||
run-name: ${{ github.actor }} runs Gitea Actions
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
XTChain:
|
|
||||||
runs-on: oscw
|
|
||||||
container:
|
|
||||||
image: codingworkshop/oscw-runner:latest
|
|
||||||
steps:
|
|
||||||
- name: Clone repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Build XTChain
|
|
||||||
run: CORES=10 ./build-linux.sh
|
|
||||||
- name: Publish binaries
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
env:
|
|
||||||
OSCW_GITHUB_USERNAME: ${{ secrets.OSCW_GITHUB_USERNAME }}
|
|
||||||
OSCW_GITHUB_PASSWORD: ${{ secrets.OSCW_GITHUB_PASSWORD }}
|
|
||||||
run: github_publish $OSCW_GITHUB_USERNAME $OSCW_GITHUB_PASSWORD $(ls xtchain-*-linux.tar.zst)
|
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +0,0 @@
|
|||||||
binaries/*
|
|
||||||
sources/*
|
|
||||||
xtchain-*.zst
|
|
636
COPYING.md
636
COPYING.md
@ -1,636 +0,0 @@
|
|||||||
# GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 [Free Software Foundation, Inc.](http://fsf.org/)
|
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
|
||||||
document, but changing it is not allowed.
|
|
||||||
|
|
||||||
## Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for software and
|
|
||||||
other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed to take
|
|
||||||
away your freedom to share and change the works. By contrast, the GNU General
|
|
||||||
Public License is intended to guarantee your freedom to share and change all
|
|
||||||
versions of a program--to make sure it remains free software for all its users.
|
|
||||||
We, the Free Software Foundation, use the GNU General Public License for most
|
|
||||||
of our software; it applies also to any other work released this way by its
|
|
||||||
authors. You can apply it to your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not price. Our
|
|
||||||
General Public Licenses are designed to make sure that you have the freedom to
|
|
||||||
distribute copies of free software (and charge for them if you wish), that you
|
|
||||||
receive source code or can get it if you want it, that you can change the
|
|
||||||
software or use pieces of it in new free programs, and that you know you can do
|
|
||||||
these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you these rights
|
|
||||||
or asking you to surrender the rights. Therefore, you have certain
|
|
||||||
responsibilities if you distribute copies of the software, or if you modify it:
|
|
||||||
responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether gratis or for
|
|
||||||
a fee, you must pass on to the recipients the same freedoms that you received.
|
|
||||||
You must make sure that they, too, receive or can get the source code. And you
|
|
||||||
must show them these terms so they know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
|
|
||||||
1. assert copyright on the software, and
|
|
||||||
2. offer you this License giving you legal permission to copy, distribute
|
|
||||||
and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains that
|
|
||||||
there is no warranty for this free software. For both users' and authors' sake,
|
|
||||||
the GPL requires that modified versions be marked as changed, so that their
|
|
||||||
problems will not be attributed erroneously to authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run modified
|
|
||||||
versions of the software inside them, although the manufacturer can do so. This
|
|
||||||
is fundamentally incompatible with the aim of protecting users' freedom to
|
|
||||||
change the software. The systematic pattern of such abuse occurs in the area of
|
|
||||||
products for individuals to use, which is precisely where it is most
|
|
||||||
unacceptable. Therefore, we have designed this version of the GPL to prohibit
|
|
||||||
the practice for those products. If such problems arise substantially in other
|
|
||||||
domains, we stand ready to extend this provision to those domains in future
|
|
||||||
versions of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents. States
|
|
||||||
should not allow patents to restrict development and use of software on
|
|
||||||
general-purpose computers, but in those that do, we wish to avoid the special
|
|
||||||
danger that patents applied to a free program could make it effectively
|
|
||||||
proprietary. To prevent this, the GPL assures that patents cannot be used to
|
|
||||||
render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and modification
|
|
||||||
follow.
|
|
||||||
|
|
||||||
## TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
### 0. Definitions.
|
|
||||||
|
|
||||||
*This License* refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
*Copyright* also means copyright-like laws that apply to other kinds of works,
|
|
||||||
such as semiconductor masks.
|
|
||||||
|
|
||||||
*The Program* refers to any copyrightable work licensed under this License.
|
|
||||||
Each licensee is addressed as *you*. *Licensees* and *recipients* may be
|
|
||||||
individuals or organizations.
|
|
||||||
|
|
||||||
To *modify* a work means to copy from or adapt all or part of the work in a
|
|
||||||
fashion requiring copyright permission, other than the making of an exact copy.
|
|
||||||
The resulting work is called a *modified version* of the earlier work or a work
|
|
||||||
*based on* the earlier work.
|
|
||||||
|
|
||||||
A *covered work* means either the unmodified Program or a work based on the
|
|
||||||
Program.
|
|
||||||
|
|
||||||
To *propagate* a work means to do anything with it that, without permission,
|
|
||||||
would make you directly or secondarily liable for infringement under applicable
|
|
||||||
copyright law, except executing it on a computer or modifying a private copy.
|
|
||||||
Propagation includes copying, distribution (with or without modification),
|
|
||||||
making available to the public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To *convey* a work means any kind of propagation that enables other parties to
|
|
||||||
make or receive copies. Mere interaction with a user through a computer
|
|
||||||
network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays *Appropriate Legal Notices* to the
|
|
||||||
extent that it includes a convenient and prominently visible feature that
|
|
||||||
|
|
||||||
1. displays an appropriate copyright notice, and
|
|
||||||
2. tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the work
|
|
||||||
under this License, and how to view a copy of this License.
|
|
||||||
|
|
||||||
If the interface presents a list of user commands or options, such as a menu, a
|
|
||||||
prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
### 1. Source Code.
|
|
||||||
|
|
||||||
The *source code* for a work means the preferred form of the work for making
|
|
||||||
modifications to it. *Object code* means any non-source form of a work.
|
|
||||||
|
|
||||||
A *Standard Interface* means an interface that either is an official standard
|
|
||||||
defined by a recognized standards body, or, in the case of interfaces specified
|
|
||||||
for a particular programming language, one that is widely used among developers
|
|
||||||
working in that language.
|
|
||||||
|
|
||||||
The *System Libraries* of an executable work include anything, other than the
|
|
||||||
work as a whole, that (a) is included in the normal form of packaging a Major
|
|
||||||
Component, but which is not part of that Major Component, and (b) serves only
|
|
||||||
to enable use of the work with that Major Component, or to implement a Standard
|
|
||||||
Interface for which an implementation is available to the public in source code
|
|
||||||
form. A *Major Component*, in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system (if any) on
|
|
||||||
which the executable work runs, or a compiler used to produce the work, or an
|
|
||||||
object code interpreter used to run it.
|
|
||||||
|
|
||||||
The *Corresponding Source* for a work in object code form means all the source
|
|
||||||
code needed to generate, install, and (for an executable work) run the object
|
|
||||||
code and to modify the work, including scripts to control those activities.
|
|
||||||
However, it does not include the work's System Libraries, or general-purpose
|
|
||||||
tools or generally available free programs which are used unmodified in
|
|
||||||
performing those activities but which are not part of the work. For example,
|
|
||||||
Corresponding Source includes interface definition files associated with source
|
|
||||||
files for the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require, such as
|
|
||||||
by intimate data communication or control flow between those subprograms and
|
|
||||||
other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users can regenerate
|
|
||||||
automatically from other parts of the Corresponding Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that same work.
|
|
||||||
|
|
||||||
### 2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of copyright on
|
|
||||||
the Program, and are irrevocable provided the stated conditions are met. This
|
|
||||||
License explicitly affirms your unlimited permission to run the unmodified
|
|
||||||
Program. The output from running a covered work is covered by this License only
|
|
||||||
if the output, given its content, constitutes a covered work. This License
|
|
||||||
acknowledges your rights of fair use or other equivalent, as provided by
|
|
||||||
copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not convey, without
|
|
||||||
conditions so long as your license otherwise remains in force. You may convey
|
|
||||||
covered works to others for the sole purpose of having them make modifications
|
|
||||||
exclusively for you, or provide you with facilities for running those works,
|
|
||||||
provided that you comply with the terms of this License in conveying all
|
|
||||||
material for which you do not control copyright. Those thus making or running
|
|
||||||
the covered works for you must do so exclusively on your behalf, under your
|
|
||||||
direction and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under the
|
|
||||||
conditions stated below. Sublicensing is not allowed; section 10 makes it
|
|
||||||
unnecessary.
|
|
||||||
|
|
||||||
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological measure
|
|
||||||
under any applicable law fulfilling obligations under article 11 of the WIPO
|
|
||||||
copyright treaty adopted on 20 December 1996, or similar laws prohibiting or
|
|
||||||
restricting circumvention of such measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention is
|
|
||||||
effected by exercising rights under this License with respect to the covered
|
|
||||||
work, and you disclaim any intention to limit operation or modification of the
|
|
||||||
work as a means of enforcing, against the work's users, your or third parties'
|
|
||||||
legal rights to forbid circumvention of technological measures.
|
|
||||||
|
|
||||||
### 4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you receive it,
|
|
||||||
in any medium, provided that you conspicuously and appropriately publish on
|
|
||||||
each copy an appropriate copyright notice; keep intact all notices stating that
|
|
||||||
this License and any non-permissive terms added in accord with section 7 apply
|
|
||||||
to the code; keep intact all notices of the absence of any warranty; and give
|
|
||||||
all recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey, and you may
|
|
||||||
offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
### 5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to produce it
|
|
||||||
from the Program, in the form of source code under the terms of section 4,
|
|
||||||
provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
- a) The work must carry prominent notices stating that you modified it, and
|
|
||||||
giving a relevant date.
|
|
||||||
- b) The work must carry prominent notices stating that it is released under
|
|
||||||
this License and any conditions added under section 7. This requirement
|
|
||||||
modifies the requirement in section 4 to *keep intact all notices*.
|
|
||||||
- c) You must license the entire work, as a whole, under this License to
|
|
||||||
anyone who comes into possession of a copy. This License will therefore
|
|
||||||
apply, along with any applicable section 7 additional terms, to the whole
|
|
||||||
of the work, and all its parts, regardless of how they are packaged. This
|
|
||||||
License gives no permission to license the work in any other way, but it
|
|
||||||
does not invalidate such permission if you have separately received it.
|
|
||||||
- d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your work need
|
|
||||||
not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent works,
|
|
||||||
which are not by their nature extensions of the covered work, and which are not
|
|
||||||
combined with it such as to form a larger program, in or on a volume of a
|
|
||||||
storage or distribution medium, is called an *aggregate* if the compilation and
|
|
||||||
its resulting copyright are not used to limit the access or legal rights of the
|
|
||||||
compilation's users beyond what the individual works permit. Inclusion of a
|
|
||||||
covered work in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
### 6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms of sections 4
|
|
||||||
and 5, provided that you also convey the machine-readable Corresponding Source
|
|
||||||
under the terms of this License, in one of these ways:
|
|
||||||
|
|
||||||
- a) Convey the object code in, or embodied in, a physical product (including
|
|
||||||
a physical distribution medium), accompanied by the Corresponding Source
|
|
||||||
fixed on a durable physical medium customarily used for software
|
|
||||||
interchange.
|
|
||||||
- b) Convey the object code in, or embodied in, a physical product (including
|
|
||||||
a physical distribution medium), accompanied by a written offer, valid for
|
|
||||||
at least three years and valid for as long as you offer spare parts or
|
|
||||||
customer support for that product model, to give anyone who possesses the
|
|
||||||
object code either
|
|
||||||
1. a copy of the Corresponding Source for all the software in the product
|
|
||||||
that is covered by this License, on a durable physical medium
|
|
||||||
customarily used for software interchange, for a price no more than your
|
|
||||||
reasonable cost of physically performing this conveying of source, or
|
|
||||||
2. access to copy the Corresponding Source from a network server at no
|
|
||||||
charge.
|
|
||||||
- c) Convey individual copies of the object code with a copy of the written
|
|
||||||
offer to provide the Corresponding Source. This alternative is allowed only
|
|
||||||
occasionally and noncommercially, and only if you received the object code
|
|
||||||
with such an offer, in accord with subsection 6b.
|
|
||||||
- d) Convey the object code by offering access from a designated place
|
|
||||||
(gratis or for a charge), and offer equivalent access to the Corresponding
|
|
||||||
Source in the same way through the same place at no further charge. You
|
|
||||||
need not require recipients to copy the Corresponding Source along with the
|
|
||||||
object code. If the place to copy the object code is a network server, the
|
|
||||||
Corresponding Source may be on a different server operated by you or a
|
|
||||||
third party) that supports equivalent copying facilities, provided you
|
|
||||||
maintain clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the Corresponding
|
|
||||||
Source, you remain obligated to ensure that it is available for as long as
|
|
||||||
needed to satisfy these requirements.
|
|
||||||
- e) Convey the object code using peer-to-peer transmission, provided you
|
|
||||||
inform other peers where the object code and Corresponding Source of the
|
|
||||||
work are being offered to the general public at no charge under subsection
|
|
||||||
6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded from the
|
|
||||||
Corresponding Source as a System Library, need not be included in conveying the
|
|
||||||
object code work.
|
|
||||||
|
|
||||||
A *User Product* is either
|
|
||||||
|
|
||||||
1. a *consumer product*, which means any tangible personal property which is
|
|
||||||
normally used for personal, family, or household purposes, or
|
|
||||||
2. anything designed or sold for incorporation into a dwelling.
|
|
||||||
|
|
||||||
In determining whether a product is a consumer product, doubtful cases shall be
|
|
||||||
resolved in favor of coverage. For a particular product received by a
|
|
||||||
particular user, *normally used* refers to a typical or common use of that
|
|
||||||
class of product, regardless of the status of the particular user or of the way
|
|
||||||
in which the particular user actually uses, or expects or is expected to use,
|
|
||||||
the product. A product is a consumer product regardless of whether the product
|
|
||||||
has substantial commercial, industrial or non-consumer uses, unless such uses
|
|
||||||
represent the only significant mode of use of the product.
|
|
||||||
|
|
||||||
*Installation Information* for a User Product means any methods, procedures,
|
|
||||||
authorization keys, or other information required to install and execute
|
|
||||||
modified versions of a covered work in that User Product from a modified
|
|
||||||
version of its Corresponding Source. The information must suffice to ensure
|
|
||||||
that the continued functioning of the modified object code is in no case
|
|
||||||
prevented or interfered with solely because modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as part of a
|
|
||||||
transaction in which the right of possession and use of the User Product is
|
|
||||||
transferred to the recipient in perpetuity or for a fixed term (regardless of
|
|
||||||
how the transaction is characterized), the Corresponding Source conveyed under
|
|
||||||
this section must be accompanied by the Installation Information. But this
|
|
||||||
requirement does not apply if neither you nor any third party retains the
|
|
||||||
ability to install modified object code on the User Product (for example, the
|
|
||||||
work has been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates for a
|
|
||||||
work that has been modified or installed by the recipient, or for the User
|
|
||||||
Product in which it has been modified or installed. Access to a network may be
|
|
||||||
denied when the modification itself materially and adversely affects the
|
|
||||||
operation of the network or violates the rules and protocols for communication
|
|
||||||
across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided, in accord
|
|
||||||
with this section must be in a format that is publicly documented (and with an
|
|
||||||
implementation available to the public in source code form), and must require
|
|
||||||
no special password or key for unpacking, reading or copying.
|
|
||||||
|
|
||||||
### 7. Additional Terms.
|
|
||||||
|
|
||||||
*Additional permissions* are terms that supplement the terms of this License by
|
|
||||||
making exceptions from one or more of its conditions. Additional permissions
|
|
||||||
that are applicable to the entire Program shall be treated as though they were
|
|
||||||
included in this License, to the extent that they are valid under applicable
|
|
||||||
law. If additional permissions apply only to part of the Program, that part may
|
|
||||||
be used separately under those permissions, but the entire Program remains
|
|
||||||
governed by this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option remove any
|
|
||||||
additional permissions from that copy, or from any part of it. (Additional
|
|
||||||
permissions may be written to require their own removal in certain cases when
|
|
||||||
you modify the work.) You may place additional permissions on material, added
|
|
||||||
by you to a covered work, for which you have or can give appropriate copyright
|
|
||||||
permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you add to a
|
|
||||||
covered work, you may (if authorized by the copyright holders of that material)
|
|
||||||
supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
- a) Disclaiming warranty or limiting liability differently from the terms of
|
|
||||||
sections 15 and 16 of this License; or
|
|
||||||
- b) Requiring preservation of specified reasonable legal notices or author
|
|
||||||
attributions in that material or in the Appropriate Legal Notices displayed
|
|
||||||
by works containing it; or
|
|
||||||
- c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in reasonable
|
|
||||||
ways as different from the original version; or
|
|
||||||
- d) Limiting the use for publicity purposes of names of licensors or authors
|
|
||||||
of the material; or
|
|
||||||
- e) Declining to grant rights under trademark law for use of some trade
|
|
||||||
names, trademarks, or service marks; or
|
|
||||||
- f) Requiring indemnification of licensors and authors of that material by
|
|
||||||
anyone who conveys the material (or modified versions of it) with
|
|
||||||
contractual assumptions of liability to the recipient, for any liability
|
|
||||||
that these contractual assumptions directly impose on those licensors and
|
|
||||||
authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered *further restrictions*
|
|
||||||
within the meaning of section 10. If the Program as you received it, or any
|
|
||||||
part of it, contains a notice stating that it is governed by this License along
|
|
||||||
with a term that is a further restriction, you may remove that term. If a
|
|
||||||
license document contains a further restriction but permits relicensing or
|
|
||||||
conveying under this License, you may add to a covered work material governed
|
|
||||||
by the terms of that license document, provided that the further restriction
|
|
||||||
does not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you must place,
|
|
||||||
in the relevant source files, a statement of the additional terms that apply to
|
|
||||||
those files, or a notice indicating where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the form of a
|
|
||||||
separately written license, or stated as exceptions; the above requirements
|
|
||||||
apply either way.
|
|
||||||
|
|
||||||
### 8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly provided
|
|
||||||
under this License. Any attempt otherwise to propagate or modify it is void,
|
|
||||||
and will automatically terminate your rights under this License (including any
|
|
||||||
patent licenses granted under the third paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your license from a
|
|
||||||
particular copyright holder is reinstated
|
|
||||||
|
|
||||||
- a) provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and
|
|
||||||
- b) permanently, if the copyright holder fails to notify you of the
|
|
||||||
violation by some reasonable means prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is reinstated
|
|
||||||
permanently if the copyright holder notifies you of the violation by some
|
|
||||||
reasonable means, this is the first time you have received notice of violation
|
|
||||||
of this License (for any work) from that copyright holder, and you cure the
|
|
||||||
violation prior to 30 days after your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the licenses
|
|
||||||
of parties who have received copies or rights from you under this License. If
|
|
||||||
your rights have been terminated and not permanently reinstated, you do not
|
|
||||||
qualify to receive new licenses for the same material under section 10.
|
|
||||||
|
|
||||||
### 9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or run a copy
|
|
||||||
of the Program. Ancillary propagation of a covered work occurring solely as a
|
|
||||||
consequence of using peer-to-peer transmission to receive a copy likewise does
|
|
||||||
not require acceptance. However, nothing other than this License grants you
|
|
||||||
permission to propagate or modify any covered work. These actions infringe
|
|
||||||
copyright if you do not accept this License. Therefore, by modifying or
|
|
||||||
propagating a covered work, you indicate your acceptance of this License to do
|
|
||||||
so.
|
|
||||||
|
|
||||||
### 10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically receives a
|
|
||||||
license from the original licensors, to run, modify and propagate that work,
|
|
||||||
subject to this License. You are not responsible for enforcing compliance by
|
|
||||||
third parties with this License.
|
|
||||||
|
|
||||||
An *entity transaction* is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered work
|
|
||||||
results from an entity transaction, each party to that transaction who receives
|
|
||||||
a copy of the work also receives whatever licenses to the work the party's
|
|
||||||
predecessor in interest had or could give under the previous paragraph, plus a
|
|
||||||
right to possession of the Corresponding Source of the work from the
|
|
||||||
predecessor in interest, if the predecessor has it or can get it with
|
|
||||||
reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the rights
|
|
||||||
granted or affirmed under this License. For example, you may not impose a
|
|
||||||
license fee, royalty, or other charge for exercise of rights granted under this
|
|
||||||
License, and you may not initiate litigation (including a cross-claim or
|
|
||||||
counterclaim in a lawsuit) alleging that any patent claim is infringed by
|
|
||||||
making, using, selling, offering for sale, or importing the Program or any
|
|
||||||
portion of it.
|
|
||||||
|
|
||||||
### 11. Patents.
|
|
||||||
|
|
||||||
A *contributor* is a copyright holder who authorizes use under this License of
|
|
||||||
the Program or a work on which the Program is based. The work thus licensed is
|
|
||||||
called the contributor's *contributor version*.
|
|
||||||
|
|
||||||
A contributor's *essential patent claims* are all patent claims owned or
|
|
||||||
controlled by the contributor, whether already acquired or hereafter acquired,
|
|
||||||
that would be infringed by some manner, permitted by this License, of making,
|
|
||||||
using, or selling its contributor version, but do not include claims that would
|
|
||||||
be infringed only as a consequence of further modification of the contributor
|
|
||||||
version. For purposes of this definition, *control* includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of this
|
|
||||||
License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent
|
|
||||||
license under the contributor's essential patent claims, to make, use, sell,
|
|
||||||
offer for sale, import and otherwise run, modify and propagate the contents of
|
|
||||||
its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a *patent license* is any express agreement
|
|
||||||
or commitment, however denominated, not to enforce a patent (such as an express
|
|
||||||
permission to practice a patent or covenant not to sue for patent
|
|
||||||
infringement). To *grant* such a patent license to a party means to make such
|
|
||||||
an agreement or commitment not to enforce a patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license, and the
|
|
||||||
Corresponding Source of the work is not available for anyone to copy, free of
|
|
||||||
charge and under the terms of this License, through a publicly available
|
|
||||||
network server or other readily accessible means, then you must either
|
|
||||||
|
|
||||||
1. cause the Corresponding Source to be so available, or
|
|
||||||
2. arrange to deprive yourself of the benefit of the patent license for this
|
|
||||||
particular work, or
|
|
||||||
3. arrange, in a manner consistent with the requirements of this License, to
|
|
||||||
extend the patent license to downstream recipients.
|
|
||||||
|
|
||||||
*Knowingly relying* means you have actual knowledge that, but for the patent
|
|
||||||
license, your conveying the covered work in a country, or your recipient's use
|
|
||||||
of the covered work in a country, would infringe one or more identifiable
|
|
||||||
patents in that country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or arrangement, you
|
|
||||||
convey, or propagate by procuring conveyance of, a covered work, and grant a
|
|
||||||
patent license to some of the parties receiving the covered work authorizing
|
|
||||||
them to use, propagate, modify or convey a specific copy of the covered work,
|
|
||||||
then the patent license you grant is automatically extended to all recipients
|
|
||||||
of the covered work and works based on it.
|
|
||||||
|
|
||||||
A patent license is *discriminatory* if it does not include within the scope of
|
|
||||||
its coverage, prohibits the exercise of, or is conditioned on the non-exercise
|
|
||||||
of one or more of the rights that are specifically granted under this License.
|
|
||||||
You may not convey a covered work if you are a party to an arrangement with a
|
|
||||||
third party that is in the business of distributing software, under which you
|
|
||||||
make payment to the third party based on the extent of your activity of
|
|
||||||
conveying the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory patent
|
|
||||||
license
|
|
||||||
|
|
||||||
- a) in connection with copies of the covered work conveyed by you (or copies
|
|
||||||
made from those copies), or
|
|
||||||
- b) primarily for and in connection with specific products or compilations
|
|
||||||
that contain the covered work, unless you entered into that arrangement, or
|
|
||||||
that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting any implied
|
|
||||||
license or other defenses to infringement that may otherwise be available to
|
|
||||||
you under applicable patent law.
|
|
||||||
|
|
||||||
### 12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not excuse
|
|
||||||
you from the conditions of this License. If you cannot convey a covered work so
|
|
||||||
as to satisfy simultaneously your obligations under this License and any other
|
|
||||||
pertinent obligations, then as a consequence you may not convey it at all. For
|
|
||||||
example, if you agree to terms that obligate you to collect a royalty for
|
|
||||||
further conveying from those to whom you convey the Program, the only way you
|
|
||||||
could satisfy both those terms and this License would be to refrain entirely
|
|
||||||
from conveying the Program.
|
|
||||||
|
|
||||||
### 13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have permission to
|
|
||||||
link or combine any covered work with a work licensed under version 3 of the
|
|
||||||
GNU Affero General Public License into a single combined work, and to convey
|
|
||||||
the resulting work. The terms of this License will continue to apply to the
|
|
||||||
part which is the covered work, but the special requirements of the GNU Affero
|
|
||||||
General Public License, section 13, concerning interaction through a network
|
|
||||||
will apply to the combination as such.
|
|
||||||
|
|
||||||
### 14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of the GNU
|
|
||||||
General Public License from time to time. Such new versions will be similar in
|
|
||||||
spirit to the present version, but may differ in detail to address new problems
|
|
||||||
or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program specifies
|
|
||||||
that a certain numbered version of the GNU General Public License *or any later
|
|
||||||
version* applies to it, you have the option of following the terms and
|
|
||||||
conditions either of that numbered version or of any later version published by
|
|
||||||
the Free Software Foundation. If the Program does not specify a version number
|
|
||||||
of the GNU General Public License, you may choose any version ever published by
|
|
||||||
the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future versions of the
|
|
||||||
GNU General Public License can be used, that proxy's public statement of
|
|
||||||
acceptance of a version permanently authorizes you to choose that version for
|
|
||||||
the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different permissions.
|
|
||||||
However, no additional obligations are imposed on any author or copyright
|
|
||||||
holder as a result of your choosing to follow a later version.
|
|
||||||
|
|
||||||
### 15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
|
|
||||||
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
|
|
||||||
PARTIES PROVIDE THE PROGRAM *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER
|
|
||||||
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
|
|
||||||
QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
|
||||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
|
||||||
CORRECTION.
|
|
||||||
|
|
||||||
### 16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
|
|
||||||
COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS
|
|
||||||
PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
|
|
||||||
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
|
|
||||||
THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
|
|
||||||
INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
|
|
||||||
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY
|
|
||||||
HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
||||||
|
|
||||||
### 17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided above cannot
|
|
||||||
be given local legal effect according to their terms, reviewing courts shall
|
|
||||||
apply local law that most closely approximates an absolute waiver of all civil
|
|
||||||
liability in connection with the Program, unless a warranty or assumption of
|
|
||||||
liability accompanies a copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
## END OF TERMS AND CONDITIONS ###
|
|
||||||
|
|
||||||
### How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest possible
|
|
||||||
use to the public, the best way to achieve this is to make it free software
|
|
||||||
which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to attach
|
|
||||||
them to the start of each source file to most effectively state the exclusion
|
|
||||||
of warranty; and each file should have at least the *copyright* line and a
|
|
||||||
pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short notice like
|
|
||||||
this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w` and `show c` should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands might
|
|
||||||
be different; for a GUI interface, you would use an *about box*.
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school, if
|
|
||||||
any, to sign a *copyright disclaimer* for the program, if necessary. For more
|
|
||||||
information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
[http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program into
|
|
||||||
proprietary programs. If your program is a subroutine library, you may consider
|
|
||||||
it more useful to permit linking proprietary applications with the library. If
|
|
||||||
this is what you want to do, use the GNU Lesser General Public License instead
|
|
||||||
of this License. But first, please read
|
|
||||||
[http://www.gnu.org/philosophy/why-not-lgpl.html](http://www.gnu.org/philosophy/why-not-lgpl.html).
|
|
52
README.md
52
README.md
@ -1,52 +0,0 @@
|
|||||||
<p align=center>
|
|
||||||
<a href="https://git.codingworkshop.eu.org/xt-sys/xtchain">
|
|
||||||
<img alt="GIT Repository" src="https://img.shields.io/badge/Source-GIT-purple">
|
|
||||||
</a>
|
|
||||||
<a href="https://git.codingworkshop.eu.org/xt-sys/xtchain/actions">
|
|
||||||
<img alt="Build Status" src="https://codingworkshop.eu.org/actions.php?project=xt-sys/xtchain">
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/xt-sys/xtchain/releases">
|
|
||||||
<img alt="Releases" src="https://img.shields.io/github/v/release/xt-sys/xtchain?label=Release&color=blueviolet">
|
|
||||||
</a>
|
|
||||||
<a href="https://git.codingworkshop.eu.org/xt-sys/xtchain/src/branch/master/COPYING.md">
|
|
||||||
<img alt="License" src="https://img.shields.io/badge/License-GPLv3-blue.svg">
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/sponsors/xt-sys/">
|
|
||||||
<img alt="Sponsors" src="https://img.shields.io/badge/Sponsor-%E2%9D%A4-red?logo=GitHub">
|
|
||||||
</a>
|
|
||||||
<a href="https://discord.com/invite/zBzJ5qMGX7">
|
|
||||||
<img alt="Discord" src="https://img.shields.io/badge/Chat-Join%20Discord-success">
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## XT Toolchain
|
|
||||||
This is a LLVM/Clang/LLD based mingw-w64 toolchain. It currently supports C and C++, and provides
|
|
||||||
a variety of tools including IDL, message and resource compilers. The XT Toolchain is also the
|
|
||||||
official build environment for compiling XT software, including the XT OS. Currently, it is
|
|
||||||
targeted at Linux host only, however it should be possible to build it in MSYS2 as well.
|
|
||||||
|
|
||||||
Benefits of a LLVM based MinGW toolchain are:
|
|
||||||
* Single toolchain targeting all architectures (i686, x86_64, armv7 and aarch64),
|
|
||||||
* Support for generating debug info in PDB format,
|
|
||||||
* Support for targeting ARM/AARCH64 architectures and ability to produce Windows ARM binaries.
|
|
||||||
|
|
||||||
This software includes:
|
|
||||||
* CMake
|
|
||||||
* GNU Assembler
|
|
||||||
* LLVM
|
|
||||||
* Make
|
|
||||||
* Mingw-w64
|
|
||||||
* Ninja
|
|
||||||
* Wine
|
|
||||||
|
|
||||||
This software is based on [LLVM MinGW Toolchain](https://github.com/mstorsjo/llvm-mingw).
|
|
||||||
|
|
||||||
## Licensing
|
|
||||||
The XTchain project includes the scripts for building and assembling a toolchain as well as wrappers
|
|
||||||
for LLVM tools and environmental shell. These are licensed under the GPLv3 license. It covers only
|
|
||||||
mentioned components that are provided by XTchain directly. For more information on that, refer to
|
|
||||||
the COPYING.md file. The final pre-built toolchain is covered by the licenses of the individual,
|
|
||||||
external projects. The full list of software incorporated into this toolchain is available in the
|
|
||||||
README.md file.
|
|
467
build-linux.sh
467
build-linux.sh
@ -1,10 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# PROJECT: XTchain
|
set -e
|
||||||
# LICENSE: See the COPYING.md in the top level directory
|
|
||||||
# FILE: build-linux.sh
|
|
||||||
# DESCRIPTION: Toolchain building and assembly script
|
|
||||||
# DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
|
|
||||||
|
|
||||||
# Working Directories
|
# Working Directories
|
||||||
BINDIR="$(pwd)/binaries"
|
BINDIR="$(pwd)/binaries"
|
||||||
@ -12,44 +7,40 @@ PCHDIR="$(pwd)/patches"
|
|||||||
SRCDIR="$(pwd)/sources"
|
SRCDIR="$(pwd)/sources"
|
||||||
WRKDIR="$(pwd)"
|
WRKDIR="$(pwd)"
|
||||||
|
|
||||||
# Architecture Settings
|
# Compiler Flags
|
||||||
ARCHS="aarch64 armv7 i686 x86_64"
|
CFLAGS="-march=x86-64 -mtune=generic -O2 -s -pipe"
|
||||||
GENERIC="generic-w64-mingw32"
|
CXXFLAGS="${CFLAGS}"
|
||||||
|
|
||||||
|
# Binutils Settings
|
||||||
|
BINUTILSDIR="${SRCDIR}/binutils"
|
||||||
|
BINUTILSTAG="binutils-2_35"
|
||||||
|
BINUTILSVCS="git://sourceware.org/git/binutils-gdb.git"
|
||||||
|
|
||||||
# CMake Settings
|
# CMake Settings
|
||||||
CMAKEDIR="${SRCDIR}/cmake"
|
CMAKEDIR="${SRCDIR}/cmake"
|
||||||
CMAKETAG="v3.31.3"
|
CMAKETAG="v3.18.1"
|
||||||
CMAKEVCS="https://gitlab.kitware.com/cmake/cmake.git"
|
CMAKEVCS="https://gitlab.kitware.com/cmake/cmake.git"
|
||||||
|
|
||||||
# LLVM Settings
|
# GCC Settings
|
||||||
LLVMDIR="${SRCDIR}/llvm"
|
GCCDIR="${SRCDIR}/gcc"
|
||||||
LLVMTAG="llvmorg-19.1.6"
|
GCCTAG="releases/gcc-9.3.0"
|
||||||
LLVMVCS="https://github.com/llvm/llvm-project.git"
|
GCCVCS="git://gcc.gnu.org/git/gcc.git"
|
||||||
|
|
||||||
# Make Settings
|
|
||||||
MAKEDIR="${SRCDIR}/make"
|
|
||||||
MAKETAG="4.4.1"
|
|
||||||
MAKEVCS="git://git.savannah.gnu.org/make"
|
|
||||||
|
|
||||||
# Mingw-w64 Settings
|
# Mingw-w64 Settings
|
||||||
MINGWDIR="${SRCDIR}/mingw-w64"
|
MINGWDIR="${SRCDIR}/mingw-w64"
|
||||||
MINGWLIB="ucrt"
|
MINGWTAG="v6.0.0"
|
||||||
MINGWTAG="master"
|
|
||||||
MINGWNTV="0x601"
|
|
||||||
MINGWVCS="https://github.com/mirror/mingw-w64.git"
|
MINGWVCS="https://github.com/mirror/mingw-w64.git"
|
||||||
|
|
||||||
# Ninja Settings
|
# Ninja Settings
|
||||||
NINJADIR="${SRCDIR}/ninja"
|
NINJADIR="${SRCDIR}/ninja"
|
||||||
NINJATAG="v1.12.1"
|
NINJATAG="v1.10.0"
|
||||||
NINJAVCS="https://github.com/ninja-build/ninja.git"
|
NINJAVCS="https://github.com/ninja-build/ninja.git"
|
||||||
|
|
||||||
# Wine Settings
|
# Architecture Settings
|
||||||
WINEDIR="${SRCDIR}/wine"
|
ARCHS="i686 x86_64"
|
||||||
WINETAG="wine-9.8"
|
GENERIC="generic-w64-mingw32"
|
||||||
WINEVCS="https://github.com/wine-mirror/wine.git"
|
|
||||||
|
|
||||||
|
|
||||||
# This function applies a patches to the 3rd party project
|
|
||||||
apply_patches()
|
apply_patches()
|
||||||
{
|
{
|
||||||
local PACKAGE="${1}"
|
local PACKAGE="${1}"
|
||||||
@ -74,7 +65,42 @@ apply_patches()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function compiles and installs CMAKE
|
binutils_build()
|
||||||
|
{
|
||||||
|
for ARCH in ${ARCHS}; do
|
||||||
|
echo ">>> Building BINUTILS for ${ARCH} ..."
|
||||||
|
[ -z ${CLEAN} ] || rm -rf ${BINUTILSDIR}/build-${ARCH}
|
||||||
|
mkdir -p ${BINUTILSDIR}/build-${ARCH}
|
||||||
|
cd ${BINUTILSDIR}/build-${ARCH}
|
||||||
|
../configure \
|
||||||
|
--target=${ARCH}-w64-mingw32 \
|
||||||
|
--prefix=${BINDIR} \
|
||||||
|
--with-sysroot=${BINDIR} \
|
||||||
|
--with-zlib=yes \
|
||||||
|
--disable-multilib \
|
||||||
|
--disable-nls \
|
||||||
|
--disable-werror \
|
||||||
|
--enable-gold \
|
||||||
|
--enable-lto \
|
||||||
|
--enable-plugins
|
||||||
|
make -j${CORES}
|
||||||
|
make install
|
||||||
|
done
|
||||||
|
cd ${WRKDIR}
|
||||||
|
}
|
||||||
|
|
||||||
|
binutils_fetch()
|
||||||
|
{
|
||||||
|
if [ ! -d ${BINUTILSDIR} ]; then
|
||||||
|
echo ">>> Downloading BINUTILS ..."
|
||||||
|
git clone ${BINUTILSVCS} ${BINUTILSDIR}
|
||||||
|
cd ${BINUTILSDIR}
|
||||||
|
git checkout tags/${BINUTILSTAG}
|
||||||
|
apply_patches ${BINUTILSDIR##*/} ${BINUTILSTAG}
|
||||||
|
cd ${WRKDIR}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
cmake_build()
|
cmake_build()
|
||||||
{
|
{
|
||||||
echo ">>> Building CMAKE ..."
|
echo ">>> Building CMAKE ..."
|
||||||
@ -90,209 +116,85 @@ cmake_build()
|
|||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function downloads CMAKE from VCS
|
|
||||||
cmake_fetch()
|
cmake_fetch()
|
||||||
{
|
{
|
||||||
if [ ! -d ${CMAKEDIR} ]; then
|
if [ ! -d ${CMAKEDIR} ]; then
|
||||||
echo ">>> Downloading CMAKE ..."
|
echo ">>> Downloading CMAKE ..."
|
||||||
git clone --depth 1 --branch ${CMAKETAG} ${CMAKEVCS} ${CMAKEDIR}
|
git clone ${CMAKEVCS} ${CMAKEDIR}
|
||||||
cd ${CMAKEDIR}
|
cd ${CMAKEDIR}
|
||||||
|
git checkout tags/${CMAKETAG}
|
||||||
apply_patches ${CMAKEDIR##*/} ${CMAKETAG}
|
apply_patches ${CMAKEDIR##*/} ${CMAKETAG}
|
||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function compiles and install LLVM
|
gcc_build_phase1()
|
||||||
llvm_build()
|
|
||||||
{
|
{
|
||||||
echo ">>> Building LLVM ..."
|
|
||||||
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/llvm/build
|
|
||||||
LLVM_ARCHS=()
|
|
||||||
for ARCH in ${ARCHS}; do
|
for ARCH in ${ARCHS}; do
|
||||||
case ${ARCH} in
|
echo ">>> Building GCC (phase1) for ${ARCH} ..."
|
||||||
"aarch64")
|
[ -z ${CLEAN} ] || rm -rf ${GCCDIR}/build-${ARCH}
|
||||||
LLVM_ARCHS+=( "AArch64" )
|
mkdir -p ${GCCDIR}/build-${ARCH}
|
||||||
;;
|
cd ${GCCDIR}/build-${ARCH}
|
||||||
"armv7")
|
|
||||||
LLVM_ARCHS+=( "ARM" )
|
|
||||||
;;
|
|
||||||
"i686"|"x86_64")
|
|
||||||
LLVM_ARCHS+=( "X86" )
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
LLVM_ARCHS=( $(for ARCH in ${LLVM_ARCHS[@]}; do echo ${ARCH}; done | sort -u) )
|
|
||||||
cd ${LLVMDIR}/llvm/tools
|
|
||||||
for UTIL in clang lld; do
|
|
||||||
if [ ! -e ${UTIL} ]; then
|
|
||||||
ln -sf ../../${UTIL} .
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
mkdir -p ${LLVMDIR}/llvm/build
|
|
||||||
cd ${LLVMDIR}/llvm/build
|
|
||||||
cmake -G Ninja \
|
|
||||||
-DCMAKE_BUILD_TYPE="Release" \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=${BINDIR} \
|
|
||||||
-DLLDB_INCLUDE_TESTS=FALSE \
|
|
||||||
-DLLVM_ENABLE_ASSERTIONS=FALSE \
|
|
||||||
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb" \
|
|
||||||
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
|
|
||||||
-DLLVM_LINK_LLVM_DYLIB=ON \
|
|
||||||
-DLLVM_TARGETS_TO_BUILD="$(echo ${LLVM_ARCHS[@]} | tr ' ' ';')" \
|
|
||||||
-DLLVM_TOOLCHAIN_TOOLS="llvm-addr2line;llvm-ar;llvm-as;llvm-cov;llvm-cvtres;llvm-dlltool;llvm-lib;llvm-ml;llvm-nm;llvm-objdump;llvm-objcopy;llvm-pdbutil;llvm-profdata;llvm-ranlib;llvm-rc;llvm-readelf;llvm-readobj;llvm-strings;llvm-strip;llvm-symbolizer;llvm-windres" \
|
|
||||||
..
|
|
||||||
ninja install/strip
|
|
||||||
cd ${WRKDIR}
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function compiles and install LIBCXX & LIBUNWIND
|
|
||||||
llvm_build_libs()
|
|
||||||
{
|
|
||||||
echo ">>> Building LLVM libraries (libcxx) ..."
|
|
||||||
for ARCH in ${ARCHS}; do
|
|
||||||
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/runtimes/build-${ARCH}
|
|
||||||
mkdir -p ${LLVMDIR}/runtimes/build-${ARCH}
|
|
||||||
cd ${LLVMDIR}/runtimes/build-${ARCH}
|
|
||||||
cmake -G Ninja \
|
|
||||||
-DCMAKE_BUILD_TYPE="Release" \
|
|
||||||
-DCMAKE_INSTALL_PREFIX="${BINDIR}/${ARCH}-w64-mingw32" \
|
|
||||||
-DCMAKE_AR="${BINDIR}/bin/llvm-ar" \
|
|
||||||
-DCMAKE_C_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang" \
|
|
||||||
-DCMAKE_C_COMPILER_WORKS=1 \
|
|
||||||
-DCMAKE_C_FLAGS_INIT=-mguard=cf \
|
|
||||||
-DCMAKE_CXX_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang++" \
|
|
||||||
-DCMAKE_CXX_COMPILER_TARGET=${ARCH}-w64-windows-gnu \
|
|
||||||
-DCMAKE_CXX_COMPILER_WORKS=1 \
|
|
||||||
-DCMAKE_CXX_FLAGS_INIT=-mguard=cf \
|
|
||||||
-DCMAKE_CROSSCOMPILING=TRUE \
|
|
||||||
-DCMAKE_RANLIB="${BINDIR}/bin/llvm-ranlib" \
|
|
||||||
-DCMAKE_SYSTEM_NAME="Windows" \
|
|
||||||
-DLLVM_PATH="${LLVMDIR}/llvm" \
|
|
||||||
-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx" \
|
|
||||||
-DLIBUNWIND_USE_COMPILER_RT=TRUE \
|
|
||||||
-DLIBUNWIND_ENABLE_SHARED=TRUE \
|
|
||||||
-DLIBUNWIND_ENABLE_STATIC=TRUE \
|
|
||||||
-DLIBCXX_USE_COMPILER_RT=ON \
|
|
||||||
-DLIBCXX_ENABLE_SHARED=TRUE \
|
|
||||||
-DLIBCXX_ENABLE_STATIC=TRUE \
|
|
||||||
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
|
|
||||||
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE \
|
|
||||||
-DLIBCXX_CXX_ABI="libcxxabi" \
|
|
||||||
-DLIBCXX_LIBDIR_SUFFIX="" \
|
|
||||||
-DLIBCXX_INCLUDE_TESTS=FALSE \
|
|
||||||
-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE \
|
|
||||||
-DLIBCXXABI_USE_COMPILER_RT=ON \
|
|
||||||
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
|
||||||
-DLIBCXXABI_LIBDIR_SUFFIX="" \
|
|
||||||
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
|
|
||||||
..
|
|
||||||
ninja
|
|
||||||
ninja install
|
|
||||||
done
|
|
||||||
cd ${WRKDIR}
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function compiles and install LLVM runtime
|
|
||||||
llvm_build_runtime()
|
|
||||||
{
|
|
||||||
echo ">>> Building LLVM compiler runtime ..."
|
|
||||||
for ARCH in ${ARCHS}; do
|
|
||||||
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/compiler-rt/build-${ARCH}
|
|
||||||
mkdir -p ${LLVMDIR}/compiler-rt/build-${ARCH}
|
|
||||||
cd ${LLVMDIR}/compiler-rt/build-${ARCH}
|
|
||||||
cmake -G Ninja \
|
|
||||||
-DCMAKE_BUILD_TYPE="Release" \
|
|
||||||
-DCMAKE_AR="${BINDIR}/bin/llvm-ar" \
|
|
||||||
-DCMAKE_C_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang" \
|
|
||||||
-DCMAKE_C_COMPILER_TARGET="${ARCH}-windows-gnu" \
|
|
||||||
-DCMAKE_C_FLAGS_INIT="-mguard=cf" \
|
|
||||||
-DCMAKE_CXX_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang++" \
|
|
||||||
-DCMAKE_CXX_FLAGS_INIT="-mguard=cf" \
|
|
||||||
-DCMAKE_FIND_ROOT_PATH="${BINDIR}/${ARCH}-w64-mingw32" \
|
|
||||||
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
|
|
||||||
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=$(${BINDIR}/bin/${ARCH}-w64-mingw32-clang --print-resource-dir) \
|
|
||||||
-DCMAKE_RANLIB="${BINDIR}/bin/llvm-ranlib" \
|
|
||||||
-DCMAKE_SYSTEM_NAME="Windows" \
|
|
||||||
-DCOMPILER_RT_BUILD_BUILTINS=TRUE \
|
|
||||||
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE \
|
|
||||||
-DCOMPILER_RT_USE_BUILTINS_LIBRARY=TRUE \
|
|
||||||
-DLLVM_CONFIG_PATH="" \
|
|
||||||
-DSANITIZER_CXX_ABI="libc++" \
|
|
||||||
../lib/builtins
|
|
||||||
ninja
|
|
||||||
ninja install
|
|
||||||
done
|
|
||||||
cd ${WRKDIR}
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function downloads LLVM from VCS
|
|
||||||
llvm_fetch()
|
|
||||||
{
|
|
||||||
if [ ! -d ${LLVMDIR} ]; then
|
|
||||||
echo ">>> Downloading LLVM ..."
|
|
||||||
git clone --depth 1 --branch ${LLVMTAG} ${LLVMVCS} ${LLVMDIR}
|
|
||||||
cd ${LLVMDIR}
|
|
||||||
apply_patches ${LLVMDIR##*/} ${LLVMTAG##*-}
|
|
||||||
cd ${WRKDIR}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function compiles and install MAKE
|
|
||||||
make_build()
|
|
||||||
{
|
|
||||||
echo ">>> Building Make ..."
|
|
||||||
[ -z ${CLEAN} ] || rm -rf ${MAKEDIR}/build
|
|
||||||
cd ${MAKEDIR}
|
|
||||||
./bootstrap
|
|
||||||
sed -i "s/-Werror//" maintMakefile
|
|
||||||
mkdir -p ${MAKEDIR}/build
|
|
||||||
cd ${MAKEDIR}/build
|
|
||||||
../configure \
|
../configure \
|
||||||
|
--target=${ARCH}-w64-mingw32 \
|
||||||
--prefix=${BINDIR} \
|
--prefix=${BINDIR} \
|
||||||
--disable-dependency-tracking \
|
--with-sysroot=${BINDIR} \
|
||||||
--disable-silent-rules \
|
--with-pkgversion="FerretOS Build Environment" \
|
||||||
--program-prefix=g \
|
--without-zstd \
|
||||||
--without-guile
|
--disable-libstdcxx-verbose \
|
||||||
|
--disable-multilib \
|
||||||
|
--disable-nls \
|
||||||
|
--disable-shared \
|
||||||
|
--disable-werror \
|
||||||
|
--disable-win32-registry \
|
||||||
|
--enable-fully-dynamic-string \
|
||||||
|
--enable-languages=c,c++ \
|
||||||
|
--enable-lto \
|
||||||
|
--enable-sjlj-exceptions \
|
||||||
|
--enable-version-specific-runtime-libs
|
||||||
|
make -j${CORES} all-gcc
|
||||||
|
make install-gcc
|
||||||
|
make install-lto-plugin
|
||||||
|
done
|
||||||
|
cd ${WRKDIR}
|
||||||
|
}
|
||||||
|
|
||||||
|
gcc_build_phase2()
|
||||||
|
{
|
||||||
|
for ARCH in ${ARCHS}; do
|
||||||
|
echo ">>> Building GCC (phase2) for ${ARCH} ..."
|
||||||
|
cd ${GCCDIR}/build-${ARCH}
|
||||||
make -j${CORES}
|
make -j${CORES}
|
||||||
make install
|
make install
|
||||||
if [ ! -e ${BINDIR}/bin/make ]; then
|
done
|
||||||
ln -sf gmake ${BINDIR}/bin/make
|
|
||||||
fi
|
|
||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function downloads MAKE from VCS
|
gcc_fetch()
|
||||||
make_fetch()
|
|
||||||
{
|
{
|
||||||
if [ ! -d ${MAKEDIR} ]; then
|
if [ ! -d ${GCCDIR} ]; then
|
||||||
echo ">>> Downloading Make ..."
|
echo ">>> Downloading GCC ..."
|
||||||
git clone --depth 1 --branch ${MAKETAG} ${MAKEVCS} ${MAKEDIR}
|
git clone ${GCCVCS} ${GCCDIR}
|
||||||
cd ${MAKEDIR}
|
cd ${GCCDIR}
|
||||||
apply_patches ${MAKEDIR##*/} ${MAKETAG}
|
git checkout tags/${GCCTAG}
|
||||||
|
apply_patches ${GCCDIR##*/} ${GCCTAG##*/}
|
||||||
|
./contrib/download_prerequisites
|
||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function compiles and installs MINGW CRT
|
|
||||||
mingw_build_crt()
|
mingw_build_crt()
|
||||||
{
|
{
|
||||||
for ARCH in ${ARCHS}; do
|
for ARCH in ${ARCHS}; do
|
||||||
echo ">>> Building Mingw-W64 (CRT) for ${ARCH} ..."
|
echo ">>> Building Mingw-w64 (CRT) for ${ARCH} ..."
|
||||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
||||||
mkdir -p ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
mkdir -p ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
||||||
cd ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
cd ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
||||||
case ${ARCH} in
|
case ${ARCH} in
|
||||||
"aarch64")
|
i686)
|
||||||
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm64"
|
|
||||||
;;
|
|
||||||
"armv7")
|
|
||||||
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm32"
|
|
||||||
;;
|
|
||||||
"i686")
|
|
||||||
FLAGS="--enable-lib32 --disable-lib64"
|
FLAGS="--enable-lib32 --disable-lib64"
|
||||||
;;
|
;;
|
||||||
"x86_64")
|
x86_64)
|
||||||
FLAGS="--disable-lib32 --enable-lib64"
|
FLAGS="--disable-lib32 --enable-lib64"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -302,8 +204,7 @@ mingw_build_crt()
|
|||||||
--host=${ARCH}-w64-mingw32 \
|
--host=${ARCH}-w64-mingw32 \
|
||||||
--prefix=${BINDIR}/${ARCH}-w64-mingw32 \
|
--prefix=${BINDIR}/${ARCH}-w64-mingw32 \
|
||||||
--with-sysroot=${BINDIR} \
|
--with-sysroot=${BINDIR} \
|
||||||
--with-default-msvcrt=${MINGWLIB} \
|
--with-default-msvcrt=msvcrt \
|
||||||
--enable-cfguard \
|
|
||||||
${FLAGS}
|
${FLAGS}
|
||||||
make -j${CORES}
|
make -j${CORES}
|
||||||
make install
|
make install
|
||||||
@ -312,20 +213,23 @@ mingw_build_crt()
|
|||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function compiles and installs MINGW headers
|
|
||||||
mingw_build_headers()
|
mingw_build_headers()
|
||||||
{
|
{
|
||||||
echo ">>> Building Mingw-W64 (headers) ..."
|
echo ">>> Building Mingw-w64 (headers) ..."
|
||||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
||||||
mkdir -p ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
mkdir -p ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
||||||
cd ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
cd ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
||||||
../configure \
|
../configure \
|
||||||
--prefix=${BINDIR}/${GENERIC} \
|
--prefix=${BINDIR}/${GENERIC} \
|
||||||
--enable-idl \
|
--enable-idl \
|
||||||
--with-default-msvcrt=${MINGWLIB} \
|
--with-default-msvcrt=msvcrt \
|
||||||
--with-default-win32-winnt=${MINGWNTV}
|
--with-default-win32-winnt=0x502
|
||||||
make -j${CORES}
|
make -j${CORES}
|
||||||
make install
|
make install
|
||||||
|
mkdir -p ${BINDIR}/mingw
|
||||||
|
if [ ! -e ${BINDIR}/mingw/include ]; then
|
||||||
|
ln -sfn ../${GENERIC}/include ${BINDIR}/mingw/include
|
||||||
|
fi
|
||||||
for ARCH in ${ARCHS}; do
|
for ARCH in ${ARCHS}; do
|
||||||
mkdir -p ${BINDIR}/${ARCH}-w64-mingw32
|
mkdir -p ${BINDIR}/${ARCH}-w64-mingw32
|
||||||
if [ ! -e ${BINDIR}/${ARCH}-w64-mingw32/include ]; then
|
if [ ! -e ${BINDIR}/${ARCH}-w64-mingw32/include ]; then
|
||||||
@ -335,10 +239,9 @@ mingw_build_headers()
|
|||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function compiles and install MINGW libraries
|
|
||||||
mingw_build_libs()
|
mingw_build_libs()
|
||||||
{
|
{
|
||||||
for LIB in libmangle winpthreads winstorecompat; do
|
for LIB in libmangle winstorecompat; do
|
||||||
echo ">>> Building Mingw-w64 (libs) for ${ARCH} ..."
|
echo ">>> Building Mingw-w64 (libs) for ${ARCH} ..."
|
||||||
for ARCH in ${ARCHS}; do
|
for ARCH in ${ARCHS}; do
|
||||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-libraries/${LIB}/build-${ARCH}
|
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-libraries/${LIB}/build-${ARCH}
|
||||||
@ -349,9 +252,7 @@ mingw_build_libs()
|
|||||||
../configure \
|
../configure \
|
||||||
--host=${ARCH}-w64-mingw32 \
|
--host=${ARCH}-w64-mingw32 \
|
||||||
--prefix=${BINDIR}/${ARCH}-w64-mingw32 \
|
--prefix=${BINDIR}/${ARCH}-w64-mingw32 \
|
||||||
--libdir=${BINDIR}/${ARCH}-w64-mingw32/lib \
|
--libdir=${BINDIR}/${ARCH}-w64-mingw32/lib
|
||||||
CFLAGS="-O2 -mguard=cf" \
|
|
||||||
CXXFLAGS="-O2 -mguard=cf"
|
|
||||||
make -j${CORES}
|
make -j${CORES}
|
||||||
make install
|
make install
|
||||||
PATH="${ORIGPATH}"
|
PATH="${ORIGPATH}"
|
||||||
@ -360,10 +261,9 @@ mingw_build_libs()
|
|||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function compiles and installs MINGW tools
|
|
||||||
mingw_build_tools()
|
mingw_build_tools()
|
||||||
{
|
{
|
||||||
for TOOL in gendef genidl genpeimg widl; do
|
for TOOL in gendef genidl genlib genpeimg widl; do
|
||||||
for ARCH in ${ARCHS}; do
|
for ARCH in ${ARCHS}; do
|
||||||
echo ">>> Building Mingw-w64 (tools) for ${ARCH} ..."
|
echo ">>> Building Mingw-w64 (tools) for ${ARCH} ..."
|
||||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-tools/${TOOL}/build-${ARCH}
|
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-tools/${TOOL}/build-${ARCH}
|
||||||
@ -382,19 +282,18 @@ mingw_build_tools()
|
|||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function downloads MINGW from VCS
|
|
||||||
mingw_fetch()
|
mingw_fetch()
|
||||||
{
|
{
|
||||||
if [ ! -d ${MINGWDIR} ]; then
|
if [ ! -d ${MINGWDIR} ]; then
|
||||||
echo ">>> Downloading MinGW-w64 ..."
|
echo ">>> Downloading Mingw-w64 ..."
|
||||||
git clone --depth 1 --branch ${MINGWTAG} ${MINGWVCS} ${MINGWDIR}
|
git clone ${MINGWVCS} ${MINGWDIR}
|
||||||
cd ${MINGWDIR}
|
cd ${MINGWDIR}
|
||||||
|
git checkout tags/${MINGWTAG}
|
||||||
apply_patches ${MINGWDIR##*/} ${MINGWTAG}
|
apply_patches ${MINGWDIR##*/} ${MINGWTAG}
|
||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function compiles and installs NINJA
|
|
||||||
ninja_build()
|
ninja_build()
|
||||||
{
|
{
|
||||||
echo ">>> Building NINJA ..."
|
echo ">>> Building NINJA ..."
|
||||||
@ -406,104 +305,36 @@ ninja_build()
|
|||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function downloads NINJA from VCS
|
|
||||||
ninja_fetch()
|
ninja_fetch()
|
||||||
{
|
{
|
||||||
if [ ! -d ${NINJADIR} ]; then
|
if [ ! -d ${NINJADIR} ]; then
|
||||||
echo ">>> Downloading NINJA ..."
|
echo ">>> Downloading NINJA ..."
|
||||||
git clone --depth 1 --branch ${NINJATAG} ${NINJAVCS} ${NINJADIR}
|
git clone ${NINJAVCS} ${NINJADIR}
|
||||||
cd ${NINJADIR}
|
cd ${NINJADIR}
|
||||||
|
git checkout tags/${NINJATAG}
|
||||||
apply_patches ${NINJADIR##*/} ${NINJATAG}
|
apply_patches ${NINJADIR##*/} ${NINJATAG}
|
||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function compiles and install WINE tools
|
# Check if script launched as root
|
||||||
wine_build()
|
if [ "$(whoami)" = "root" ]; then
|
||||||
{
|
echo "This script cannot be run as root!"
|
||||||
echo ">>> Building Wine ..."
|
exit 1
|
||||||
mkdir -p ${WINEDIR}/build
|
|
||||||
cd ${WINEDIR}/build
|
|
||||||
../configure \
|
|
||||||
-enable-win64 \
|
|
||||||
--without-freetype \
|
|
||||||
--without-x
|
|
||||||
for TOOL in winedump wmc wrc; do
|
|
||||||
make -j${CORES} tools/${TOOL}/all
|
|
||||||
cp tools/${TOOL}/${TOOL} ${BINDIR}/bin/
|
|
||||||
for ARCH in ${ARCHS}; do
|
|
||||||
if [ ! -e ${BINDIR}/bin/${ARCH}-w64-mingw32-${TOOL} ]; then
|
|
||||||
ln -sf ${TOOL} ${BINDIR}/bin/${ARCH}-w64-mingw32-${TOOL}
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
done
|
|
||||||
cd ${WRKDIR}
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function downloads WINE from VCS
|
|
||||||
wine_fetch()
|
|
||||||
{
|
|
||||||
if [ ! -d ${WINEDIR} ]; then
|
|
||||||
echo ">>> Downloading WINE ..."
|
|
||||||
git clone --depth 1 --branch ${WINETAG} ${WINEVCS} ${WINEDIR}
|
|
||||||
cd ${WINEDIR}
|
|
||||||
apply_patches ${WINEDIR##*/} ${WINETAG##*-}
|
|
||||||
cd ${WRKDIR}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function installs XTCHAIN scripts, wrappers and symlinks
|
|
||||||
xtchain_build()
|
|
||||||
{
|
|
||||||
echo ">>> Building XTchain ..."
|
|
||||||
mkdir -p ${BINDIR}/bin
|
|
||||||
mkdir -p ${BINDIR}/lib/xtchain
|
|
||||||
mkdir -p ${BINDIR}/${GENERIC}/bin
|
|
||||||
cp ${WRKDIR}/scripts/*-wrapper ${BINDIR}/${GENERIC}/bin
|
|
||||||
for ARCH in ${ARCHS}; do
|
|
||||||
for EXEC in c++ c11 c99 cc clang clang++ g++ gcc; do
|
|
||||||
ln -sf ../${GENERIC}/bin/clang-target-wrapper ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
|
||||||
done
|
|
||||||
for EXEC in addr2line ar as nm objcopy pdbutil ranlib rc strings strip; do
|
|
||||||
ln -sf llvm-${EXEC} ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
|
||||||
done
|
|
||||||
for EXEC in dlltool ld objdump; do
|
|
||||||
ln -sf ../${GENERIC}/bin/${EXEC}-wrapper ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
|
||||||
done
|
|
||||||
for EXEC in bin2c exetool windres xtcspecc; do
|
|
||||||
if [ ! -e ${BINDIR}/bin/${EXEC} ]; then
|
|
||||||
gcc ${WRKDIR}/tools/${EXEC}.c -o ${BINDIR}/bin/${EXEC}
|
|
||||||
fi
|
|
||||||
ln -sf ${EXEC} ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
|
||||||
done
|
|
||||||
done
|
|
||||||
cp ${WRKDIR}/scripts/xtclib ${BINDIR}/lib/xtchain/
|
|
||||||
cp ${WRKDIR}/scripts/xtchain ${BINDIR}/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Exit immediately on any failure
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Check number of CPU cores available
|
# Check number of CPU cores available
|
||||||
if [[ ! -n ${CORES} ]]; then
|
|
||||||
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
|
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
|
||||||
: ${CORES:=$(nproc 2>/dev/null)}
|
: ${CORES:=$(nproc 2>/dev/null)}
|
||||||
: ${CORES:=1}
|
: ${CORES:=1}
|
||||||
fi
|
|
||||||
|
|
||||||
# Create working directories
|
# Create working directories
|
||||||
mkdir -p ${BINDIR}
|
mkdir -p ${BINDIR}
|
||||||
mkdir -p ${SRCDIR}
|
mkdir -p ${SRCDIR}
|
||||||
|
|
||||||
# XTchain
|
# Export compiler flags
|
||||||
xtchain_build
|
export CFLAGS
|
||||||
|
export CXXFLAGS
|
||||||
# Download LLVM
|
|
||||||
llvm_fetch
|
|
||||||
|
|
||||||
# Build and install LLVM
|
|
||||||
llvm_build
|
|
||||||
|
|
||||||
# Download Mingw-W64
|
# Download Mingw-W64
|
||||||
mingw_fetch
|
mingw_fetch
|
||||||
@ -511,14 +342,23 @@ mingw_fetch
|
|||||||
# Build and install Mingw-W64 headers
|
# Build and install Mingw-W64 headers
|
||||||
mingw_build_headers
|
mingw_build_headers
|
||||||
|
|
||||||
# Build and install Mingw-W64 CRT
|
# Download Binutils
|
||||||
|
binutils_fetch
|
||||||
|
|
||||||
|
# Build and install Binutils
|
||||||
|
binutils_build
|
||||||
|
|
||||||
|
# Download GCC
|
||||||
|
gcc_fetch
|
||||||
|
|
||||||
|
# Build and install minimal GCC
|
||||||
|
gcc_build_phase1
|
||||||
|
|
||||||
|
# Build and install MSVCRT
|
||||||
mingw_build_crt
|
mingw_build_crt
|
||||||
|
|
||||||
# Build and install LLVM compiler runtime
|
# Build and install GCC
|
||||||
llvm_build_runtime
|
gcc_build_phase2
|
||||||
|
|
||||||
# Build and install LLVM compiler libraries
|
|
||||||
llvm_build_libs
|
|
||||||
|
|
||||||
# Build and install Mingw-W64 libraries
|
# Build and install Mingw-W64 libraries
|
||||||
mingw_build_libs
|
mingw_build_libs
|
||||||
@ -526,18 +366,6 @@ mingw_build_libs
|
|||||||
# Build and install Mingw-W64 tools
|
# Build and install Mingw-W64 tools
|
||||||
mingw_build_tools
|
mingw_build_tools
|
||||||
|
|
||||||
# Download Wine
|
|
||||||
wine_fetch
|
|
||||||
|
|
||||||
# Build and install Wine tools
|
|
||||||
wine_build
|
|
||||||
|
|
||||||
# Download Make
|
|
||||||
make_fetch
|
|
||||||
|
|
||||||
# Build and install Make
|
|
||||||
make_build
|
|
||||||
|
|
||||||
# Download CMake
|
# Download CMake
|
||||||
cmake_fetch
|
cmake_fetch
|
||||||
|
|
||||||
@ -552,15 +380,18 @@ ninja_build
|
|||||||
|
|
||||||
# Remove unneeded files to save disk space
|
# Remove unneeded files to save disk space
|
||||||
echo ">>> Removing unneeded files to save disk space ..."
|
echo ">>> Removing unneeded files to save disk space ..."
|
||||||
rm -rf ${BINDIR}/{doc,include,share/{bash-completion,emacs,info,locale,man,vim}}
|
rm -rf ${BINDIR}/{doc,include,mingw,share/{bash-completion,emacs,gcc*,info,man,vim}}
|
||||||
rm -rf ${BINDIR}/bin/amdgpu-arch,{clang-{check,exdef-mapping,import-test,offload-*,rename,scan-deps},diagtool,hmaptool,ld64.lld,modularize,nxptx-arch,wasm-ld}
|
|
||||||
|
|
||||||
# Save XT Toolchain version
|
# Copy all scripts
|
||||||
|
echo ">>> Copying scripts ..."
|
||||||
|
cp -apf ${WRKDIR}/scripts/* ${BINDIR}/
|
||||||
|
|
||||||
|
# Save FBE version
|
||||||
cd ${WRKDIR}
|
cd ${WRKDIR}
|
||||||
: ${XTCVER:=$(git describe --exact-match --tags 2>/dev/null)}
|
: ${FBEVER:=$(git describe --exact-match --tags 2>/dev/null)}
|
||||||
: ${XTCVER:=DEVEL}
|
: ${FBEVER:=DEV}
|
||||||
echo "${XTCVER}" > ${BINDIR}/Version
|
echo "${FBEVER}" > ${BINDIR}/Version
|
||||||
|
|
||||||
# Prepare archive
|
# Prepare archive
|
||||||
echo ">>> Creating toolchain archive ..."
|
echo ">>> Creating toolchain archive ..."
|
||||||
tar -I 'zstd -19' -cpf xtchain-${XTCVER}-linux.tar.zst -C ${BINDIR} .
|
tar -I 'zstd -19' -cpf fbe-${FBEVER}-linux.tar.zst -C ${BINDIR} .
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
Though GOLD is not yet enabled for TDM-GCC, this patch will help
|
||||||
|
|
||||||
|
From: J.M. Eubank <john@thesnappy.net>
|
||||||
|
|
||||||
|
From
|
||||||
|
<https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-binutils/0001-enable-gold-on.mingw32.patch>
|
||||||
|
---
|
||||||
|
0 files changed
|
||||||
|
|
||||||
|
diff --git a/configure b/configure
|
||||||
|
index 6a9719f6..f07a3b7f 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -3001,6 +3001,7 @@ case "${ENABLE_GOLD}" in
|
||||||
|
yes|default)
|
||||||
|
# Check for ELF target.
|
||||||
|
is_elf=no
|
||||||
|
+ is_pe=no
|
||||||
|
case "${target}" in
|
||||||
|
*-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
|
||||||
|
| *-*-linux* | *-*-gnu* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
|
||||||
|
@@ -3012,10 +3013,12 @@ case "${ENABLE_GOLD}" in
|
||||||
|
*)
|
||||||
|
is_elf=yes
|
||||||
|
;;
|
||||||
|
- esac
|
||||||
|
+ esac;;
|
||||||
|
+ *-*-mingw*)
|
||||||
|
+ is_pe=yes;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- if test "$is_elf" = "yes"; then
|
||||||
|
+ if test "$is_elf" = "yes" -o "$is_pe" = "yes"; then
|
||||||
|
# Check for target supported by gold.
|
||||||
|
case "${target}" in
|
||||||
|
i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-* \
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
|
|
||||||
index 818109f0b7..749377d193 100644
|
|
||||||
--- a/Source/CMakeVersion.cmake
|
|
||||||
+++ b/Source/CMakeVersion.cmake
|
|
||||||
@@ -7,7 +7,7 @@ set(CMake_VERSION_IS_DIRTY 0)
|
|
||||||
|
|
||||||
# Start with the full version number used in tags. It has no dev info.
|
|
||||||
set(CMake_VERSION
|
|
||||||
- "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
|
|
||||||
+ "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}-XTC")
|
|
||||||
if(DEFINED CMake_VERSION_RC)
|
|
||||||
set(CMake_VERSION "${CMake_VERSION}-rc${CMake_VERSION_RC}")
|
|
||||||
endif()
|
|
@ -1,13 +0,0 @@
|
|||||||
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
|
|
||||||
index 818109f0b7..749377d193 100644
|
|
||||||
--- a/Source/CMakeVersion.cmake
|
|
||||||
+++ b/Source/CMakeVersion.cmake
|
|
||||||
@@ -7,7 +7,7 @@ set(CMake_VERSION_IS_DIRTY 0)
|
|
||||||
|
|
||||||
# Start with the full version number used in tags. It has no dev info.
|
|
||||||
set(CMake_VERSION
|
|
||||||
- "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
|
|
||||||
+ "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}-XTC")
|
|
||||||
if(DEFINED CMake_VERSION_RC)
|
|
||||||
set(CMake_VERSION "${CMake_VERSION}-rc${CMake_VERSION_RC}")
|
|
||||||
endif()
|
|
57
patches/gcc/gcc-9.3.0/001-make-gcc-relocatable.patch
Normal file
57
patches/gcc/gcc-9.3.0/001-make-gcc-relocatable.patch
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
Make GCC fully relocatable, not searching any fixed paths
|
||||||
|
|
||||||
|
From: J.M. Eubank <john@thesnappy.net>
|
||||||
|
|
||||||
|
that aren't relative to the current installation path
|
||||||
|
|
||||||
|
# HG changeset patch
|
||||||
|
# Parent 2a1167ee4ed20c6ff3558a104218585837e9963f
|
||||||
|
---
|
||||||
|
0 files changed
|
||||||
|
|
||||||
|
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
|
||||||
|
index 086c0e460..f0ceca42b 100644
|
||||||
|
--- a/gcc/config/i386/mingw32.h
|
||||||
|
+++ b/gcc/config/i386/mingw32.h
|
||||||
|
@@ -78,7 +78,7 @@ along with GCC; see the file COPYING3. If not see
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef NATIVE_SYSTEM_HEADER_COMPONENT
|
||||||
|
-#define NATIVE_SYSTEM_HEADER_COMPONENT "MINGW"
|
||||||
|
+#undef NATIVE_SYSTEM_HEADER_DIR
|
||||||
|
|
||||||
|
#undef CPP_SPEC
|
||||||
|
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \
|
||||||
|
@@ -183,17 +183,12 @@ along with GCC; see the file COPYING3. If not see
|
||||||
|
|
||||||
|
/* Override startfile prefix defaults. */
|
||||||
|
#ifndef STANDARD_STARTFILE_PREFIX_1
|
||||||
|
-#define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
|
||||||
|
+#define STANDARD_STARTFILE_PREFIX_1 ""
|
||||||
|
#endif
|
||||||
|
#ifndef STANDARD_STARTFILE_PREFIX_2
|
||||||
|
#define STANDARD_STARTFILE_PREFIX_2 ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-/* For native mingw-version we need to take care that NATIVE_SYSTEM_HEADER_DIR
|
||||||
|
- macro contains POSIX-style path. See bug 52947. */
|
||||||
|
-#undef NATIVE_SYSTEM_HEADER_DIR
|
||||||
|
-#define NATIVE_SYSTEM_HEADER_DIR "/mingw/include"
|
||||||
|
-
|
||||||
|
/* Output STRING, a string representing a filename, to FILE.
|
||||||
|
We canonicalize it to be in Unix format (backslashes are replaced
|
||||||
|
forward slashes. */
|
||||||
|
diff --git a/gcc/incpath.c b/gcc/incpath.c
|
||||||
|
index bcbe20829..c5d4453d8 100644
|
||||||
|
--- a/gcc/incpath.c
|
||||||
|
+++ b/gcc/incpath.c
|
||||||
|
@@ -183,8 +183,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
|
||||||
|
str = concat (sysroot_no_trailing_dir_separator, p->fname, NULL);
|
||||||
|
free (sysroot_no_trailing_dir_separator);
|
||||||
|
}
|
||||||
|
- else if (!p->add_sysroot && relocated
|
||||||
|
- && !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len))
|
||||||
|
+ if (relocated && !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len))
|
||||||
|
{
|
||||||
|
static const char *relocated_prefix;
|
||||||
|
char *ostr;
|
@ -1,7 +1,7 @@
|
|||||||
diff -apurN a/mingw-w64-tools/widl/Makefile.am b/mingw-w64-tools/widl/Makefile.am
|
diff -apurN a/mingw-w64-tools/widl/Makefile.am b/mingw-w64-tools/widl/Makefile.am
|
||||||
--- a/mingw-w64-tools/widl/Makefile.am 2020-10-13 16:23:12.944066396 +0200
|
--- a/mingw-w64-tools/widl/Makefile.am 2020-07-31 23:17:43.793863913 +0200
|
||||||
+++ b/mingw-w64-tools/widl/Makefile.am 2020-10-13 16:19:00.523221067 +0200
|
+++ b/mingw-w64-tools/widl/Makefile.am 2020-07-31 21:16:36.330432306 +0200
|
||||||
@@ -29,6 +29,7 @@ widl_SOURCES = src/widl.h \
|
@@ -30,6 +30,7 @@ widl_SOURCES = src/widl.h \
|
||||||
src/utils.c \
|
src/utils.c \
|
||||||
src/widl.c \
|
src/widl.c \
|
||||||
src/write_msft.c \
|
src/write_msft.c \
|
||||||
@ -10,19 +10,18 @@ diff -apurN a/mingw-w64-tools/widl/Makefile.am b/mingw-w64-tools/widl/Makefile.a
|
|||||||
src/wpp/ppy.tab.h \
|
src/wpp/ppy.tab.h \
|
||||||
src/wpp/ppl.yy.c \
|
src/wpp/ppl.yy.c \
|
||||||
diff -apurN a/mingw-w64-tools/widl/Makefile.in b/mingw-w64-tools/widl/Makefile.in
|
diff -apurN a/mingw-w64-tools/widl/Makefile.in b/mingw-w64-tools/widl/Makefile.in
|
||||||
--- a/mingw-w64-tools/widl/Makefile.in 2020-10-13 16:23:12.944066396 +0200
|
--- a/mingw-w64-tools/widl/Makefile.in 2020-07-31 23:17:43.793863913 +0200
|
||||||
+++ b/mingw-w64-tools/widl/Makefile.in 2020-10-13 16:21:19.069027341 +0200
|
+++ b/mingw-w64-tools/widl/Makefile.in 2020-07-31 21:21:18.957064708 +0200
|
||||||
@@ -117,7 +117,8 @@ am_widl_OBJECTS = src/widl-client.$(OBJE
|
@@ -117,7 +117,7 @@ am_widl_OBJECTS = src/widl-client.$(OBJE
|
||||||
src/widl-utils.$(OBJEXT) src/widl-widl.$(OBJEXT) \
|
src/widl-widl.$(OBJEXT) src/widl-write_msft.$(OBJEXT) \
|
||||||
src/widl-write_msft.$(OBJEXT) src/wpp/widl-ppl.yy.$(OBJEXT) \
|
src/wpp/widl-ppl.yy.$(OBJEXT) src/wpp/widl-ppy.tab.$(OBJEXT) \
|
||||||
src/wpp/widl-ppy.tab.$(OBJEXT) src/wpp/widl-preproc.$(OBJEXT) \
|
src/wpp/widl-preproc.$(OBJEXT) src/wpp/widl-wpp.$(OBJEXT) \
|
||||||
- src/wpp/widl-wpp.$(OBJEXT) src/widl-pathtools.$(OBJEXT)
|
- src/widl-pathtools.$(OBJEXT)
|
||||||
+ src/wpp/widl-wpp.$(OBJEXT) src/widl-pathtools.$(OBJEXT) \
|
+ src/widl-pathtools.$(OBJEXT) src/widl-write_sltg.$(OBJEXT)
|
||||||
+ src/widl-write_sltg.$(OBJEXT)
|
|
||||||
widl_OBJECTS = $(am_widl_OBJECTS)
|
widl_OBJECTS = $(am_widl_OBJECTS)
|
||||||
widl_LDADD = $(LDADD)
|
widl_LDADD = $(LDADD)
|
||||||
widl_LINK = $(CCLD) $(widl_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
widl_LINK = $(CCLD) $(widl_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
||||||
@@ -356,6 +357,7 @@ widl_SOURCES = src/widl.h \
|
@@ -340,6 +340,7 @@ widl_SOURCES = src/widl.h \
|
||||||
src/utils.c \
|
src/utils.c \
|
||||||
src/widl.c \
|
src/widl.c \
|
||||||
src/write_msft.c \
|
src/write_msft.c \
|
||||||
@ -30,7 +29,7 @@ diff -apurN a/mingw-w64-tools/widl/Makefile.in b/mingw-w64-tools/widl/Makefile.i
|
|||||||
src/wpp/wpp_private.h \
|
src/wpp/wpp_private.h \
|
||||||
src/wpp/ppy.tab.h \
|
src/wpp/ppy.tab.h \
|
||||||
src/wpp/ppl.yy.c \
|
src/wpp/ppl.yy.c \
|
||||||
@@ -527,6 +529,8 @@ src/widl-widl.$(OBJEXT): src/$(am__dirst
|
@@ -513,6 +514,8 @@ src/widl-widl.$(OBJEXT): src/$(am__dirst
|
||||||
src/$(DEPDIR)/$(am__dirstamp)
|
src/$(DEPDIR)/$(am__dirstamp)
|
||||||
src/widl-write_msft.$(OBJEXT): src/$(am__dirstamp) \
|
src/widl-write_msft.$(OBJEXT): src/$(am__dirstamp) \
|
||||||
src/$(DEPDIR)/$(am__dirstamp)
|
src/$(DEPDIR)/$(am__dirstamp)
|
||||||
@ -39,7 +38,15 @@ diff -apurN a/mingw-w64-tools/widl/Makefile.in b/mingw-w64-tools/widl/Makefile.i
|
|||||||
src/wpp/$(am__dirstamp):
|
src/wpp/$(am__dirstamp):
|
||||||
@$(MKDIR_P) src/wpp
|
@$(MKDIR_P) src/wpp
|
||||||
@: > src/wpp/$(am__dirstamp)
|
@: > src/wpp/$(am__dirstamp)
|
||||||
@@ -840,6 +845,20 @@ src/widl-write_msft.obj: src/write_msft.
|
@@ -559,6 +562,7 @@ distclean-compile:
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/widl-utils.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/widl-widl.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/widl-write_msft.Po@am__quote@
|
||||||
|
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/widl-write_sltg.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@src/port/$(DEPDIR)/widl-getopt.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@src/port/$(DEPDIR)/widl-getopt1.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@src/port/$(DEPDIR)/widl-port.Po@am__quote@
|
||||||
|
@@ -835,6 +839,20 @@ src/widl-write_msft.obj: src/write_msft.
|
||||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(widl_CPPFLAGS) $(CPPFLAGS) $(widl_CFLAGS) $(CFLAGS) -c -o src/widl-write_msft.obj `if test -f 'src/write_msft.c'; then $(CYGPATH_W) 'src/write_msft.c'; else $(CYGPATH_W) '$(srcdir)/src/write_msft.c'; fi`
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(widl_CPPFLAGS) $(CPPFLAGS) $(widl_CFLAGS) $(CFLAGS) -c -o src/widl-write_msft.obj `if test -f 'src/write_msft.c'; then $(CYGPATH_W) 'src/write_msft.c'; else $(CYGPATH_W) '$(srcdir)/src/write_msft.c'; fi`
|
||||||
|
|
||||||
@ -61,9 +68,9 @@ diff -apurN a/mingw-w64-tools/widl/Makefile.in b/mingw-w64-tools/widl/Makefile.i
|
|||||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(widl_CPPFLAGS) $(CPPFLAGS) $(widl_CFLAGS) $(CFLAGS) -MT src/wpp/widl-ppl.yy.o -MD -MP -MF src/wpp/$(DEPDIR)/widl-ppl.yy.Tpo -c -o src/wpp/widl-ppl.yy.o `test -f 'src/wpp/ppl.yy.c' || echo '$(srcdir)/'`src/wpp/ppl.yy.c
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(widl_CPPFLAGS) $(CPPFLAGS) $(widl_CFLAGS) $(CFLAGS) -MT src/wpp/widl-ppl.yy.o -MD -MP -MF src/wpp/$(DEPDIR)/widl-ppl.yy.Tpo -c -o src/wpp/widl-ppl.yy.o `test -f 'src/wpp/ppl.yy.c' || echo '$(srcdir)/'`src/wpp/ppl.yy.c
|
||||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/wpp/$(DEPDIR)/widl-ppl.yy.Tpo src/wpp/$(DEPDIR)/widl-ppl.yy.Po
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/wpp/$(DEPDIR)/widl-ppl.yy.Tpo src/wpp/$(DEPDIR)/widl-ppl.yy.Po
|
||||||
diff -apurN a/mingw-w64-tools/widl/src/register.c b/mingw-w64-tools/widl/src/register.c
|
diff -apurN a/mingw-w64-tools/widl/src/register.c b/mingw-w64-tools/widl/src/register.c
|
||||||
--- a/mingw-w64-tools/widl/src/register.c 2020-10-13 16:23:12.950066345 +0200
|
--- a/mingw-w64-tools/widl/src/register.c 2020-07-31 23:17:43.798863890 +0200
|
||||||
+++ b/mingw-w64-tools/widl/src/register.c 2020-10-13 16:19:00.523221067 +0200
|
+++ b/mingw-w64-tools/widl/src/register.c 2020-07-31 21:13:59.935209986 +0200
|
||||||
@@ -281,7 +281,12 @@ void write_typelib_regscript( const stat
|
@@ -286,7 +286,12 @@ void write_typelib_regscript( const stat
|
||||||
if (count && !strendswith( typelib_name, ".res" ))
|
if (count && !strendswith( typelib_name, ".res" ))
|
||||||
error( "Cannot store multiple typelibs into %s\n", typelib_name );
|
error( "Cannot store multiple typelibs into %s\n", typelib_name );
|
||||||
else
|
else
|
||||||
@ -78,8 +85,8 @@ diff -apurN a/mingw-w64-tools/widl/src/register.c b/mingw-w64-tools/widl/src/reg
|
|||||||
}
|
}
|
||||||
if (count && strendswith( typelib_name, ".res" )) flush_output_resources( typelib_name );
|
if (count && strendswith( typelib_name, ".res" )) flush_output_resources( typelib_name );
|
||||||
diff -apurN a/mingw-w64-tools/widl/src/typelib.h b/mingw-w64-tools/widl/src/typelib.h
|
diff -apurN a/mingw-w64-tools/widl/src/typelib.h b/mingw-w64-tools/widl/src/typelib.h
|
||||||
--- a/mingw-w64-tools/widl/src/typelib.h 2020-10-13 16:23:12.950066345 +0200
|
--- a/mingw-w64-tools/widl/src/typelib.h 2020-07-31 23:17:43.537865053 +0200
|
||||||
+++ b/mingw-w64-tools/widl/src/typelib.h 2020-10-13 16:19:00.523221067 +0200
|
+++ b/mingw-w64-tools/widl/src/typelib.h 2020-07-31 21:13:59.935209986 +0200
|
||||||
@@ -83,4 +83,5 @@ enum VARENUM {
|
@@ -83,4 +83,5 @@ enum VARENUM {
|
||||||
extern unsigned short get_type_vt(type_t *t);
|
extern unsigned short get_type_vt(type_t *t);
|
||||||
|
|
||||||
@ -87,17 +94,17 @@ diff -apurN a/mingw-w64-tools/widl/src/typelib.h b/mingw-w64-tools/widl/src/type
|
|||||||
+extern int create_sltg_typelib(typelib_t *typelib);
|
+extern int create_sltg_typelib(typelib_t *typelib);
|
||||||
#endif
|
#endif
|
||||||
diff -apurN a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
|
diff -apurN a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
|
||||||
--- a/mingw-w64-tools/widl/src/widl.c 2020-10-13 16:23:12.951066337 +0200
|
--- a/mingw-w64-tools/widl/src/widl.c 2020-07-31 23:17:43.799863886 +0200
|
||||||
+++ b/mingw-w64-tools/widl/src/widl.c 2020-10-13 16:22:05.493635687 +0200
|
+++ b/mingw-w64-tools/widl/src/widl.c 2020-07-31 21:13:59.935209986 +0200
|
||||||
@@ -64,6 +64,7 @@ static const char usage[] =
|
@@ -62,6 +62,7 @@ static const char usage[] =
|
||||||
" --nostdinc Do not search the standard include path\n"
|
" -m32, -m64 Set the target architecture (Win32 or Win64)\n"
|
||||||
" --ns_prefix Prefix namespaces with ABI namespace\n"
|
" -N Do not preprocess input\n"
|
||||||
" --oldnames Use old naming conventions\n"
|
" --oldnames Use old naming conventions\n"
|
||||||
+" --oldtlb Use old typelib (SLTG) format\n"
|
+" --oldtlb Use old typelib (SLTG) format\n"
|
||||||
" -o, --output=NAME Set the output file name\n"
|
" -o, --output=NAME Set the output file name\n"
|
||||||
" -Otype Type of stubs to generate (-Os, -Oi, -Oif)\n"
|
" -Otype Type of stubs to generate (-Os, -Oi, -Oif)\n"
|
||||||
" -p Generate proxy\n"
|
" -p Generate proxy\n"
|
||||||
@@ -116,6 +117,7 @@ int do_everything = 1;
|
@@ -114,6 +115,7 @@ int do_everything = 1;
|
||||||
static int preprocess_only = 0;
|
static int preprocess_only = 0;
|
||||||
int do_header = 0;
|
int do_header = 0;
|
||||||
int do_typelib = 0;
|
int do_typelib = 0;
|
||||||
@ -105,23 +112,23 @@ diff -apurN a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
|
|||||||
int do_proxies = 0;
|
int do_proxies = 0;
|
||||||
int do_client = 0;
|
int do_client = 0;
|
||||||
int do_server = 0;
|
int do_server = 0;
|
||||||
@@ -168,6 +170,7 @@ enum {
|
@@ -164,6 +166,7 @@ enum {
|
||||||
DLLDATA_OPTION,
|
DLLDATA_OPTION,
|
||||||
DLLDATA_ONLY_OPTION,
|
DLLDATA_ONLY_OPTION,
|
||||||
LOCAL_STUBS_OPTION,
|
LOCAL_STUBS_OPTION,
|
||||||
+ OLD_TYPELIB_OPTION,
|
+ OLD_TYPELIB_OPTION,
|
||||||
NOSTDINC_OPTION,
|
|
||||||
PREFIX_ALL_OPTION,
|
PREFIX_ALL_OPTION,
|
||||||
PREFIX_CLIENT_OPTION,
|
PREFIX_CLIENT_OPTION,
|
||||||
@@ -195,6 +198,7 @@ static const struct option long_options[
|
PREFIX_SERVER_OPTION,
|
||||||
{ "nostdinc", 0, NULL, NOSTDINC_OPTION },
|
@@ -188,6 +191,7 @@ static const struct option long_options[
|
||||||
|
{ "local-stubs", 1, NULL, LOCAL_STUBS_OPTION },
|
||||||
{ "ns_prefix", 0, NULL, RT_NS_PREFIX },
|
{ "ns_prefix", 0, NULL, RT_NS_PREFIX },
|
||||||
{ "oldnames", 0, NULL, OLDNAMES_OPTION },
|
{ "oldnames", 0, NULL, OLDNAMES_OPTION },
|
||||||
+ { "oldtlb", 0, NULL, OLD_TYPELIB_OPTION },
|
+ { "oldtlb", 0, NULL, OLD_TYPELIB_OPTION },
|
||||||
{ "output", 0, NULL, 'o' },
|
{ "output", 0, NULL, 'o' },
|
||||||
{ "prefix-all", 1, NULL, PREFIX_ALL_OPTION },
|
{ "prefix-all", 1, NULL, PREFIX_ALL_OPTION },
|
||||||
{ "prefix-client", 1, NULL, PREFIX_CLIENT_OPTION },
|
{ "prefix-client", 1, NULL, PREFIX_CLIENT_OPTION },
|
||||||
@@ -333,6 +337,7 @@ static void set_everything(int x)
|
@@ -325,6 +329,7 @@ static void set_everything(int x)
|
||||||
{
|
{
|
||||||
do_header = x;
|
do_header = x;
|
||||||
do_typelib = x;
|
do_typelib = x;
|
||||||
@ -129,7 +136,7 @@ diff -apurN a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
|
|||||||
do_proxies = x;
|
do_proxies = x;
|
||||||
do_client = x;
|
do_client = x;
|
||||||
do_server = x;
|
do_server = x;
|
||||||
@@ -749,6 +754,9 @@ int main(int argc,char *argv[])
|
@@ -712,6 +717,9 @@ int main(int argc,char *argv[])
|
||||||
do_everything = 0;
|
do_everything = 0;
|
||||||
do_typelib = 1;
|
do_typelib = 1;
|
||||||
break;
|
break;
|
||||||
@ -140,8 +147,8 @@ diff -apurN a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
|
|||||||
typelib_name = xstrdup(optarg);
|
typelib_name = xstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
diff -apurN a/mingw-w64-tools/widl/src/widl.h b/mingw-w64-tools/widl/src/widl.h
|
diff -apurN a/mingw-w64-tools/widl/src/widl.h b/mingw-w64-tools/widl/src/widl.h
|
||||||
--- a/mingw-w64-tools/widl/src/widl.h 2020-10-13 16:23:12.951066337 +0200
|
--- a/mingw-w64-tools/widl/src/widl.h 2020-07-31 23:17:43.537865053 +0200
|
||||||
+++ b/mingw-w64-tools/widl/src/widl.h 2020-10-13 16:19:00.524221058 +0200
|
+++ b/mingw-w64-tools/widl/src/widl.h 2020-07-31 21:13:59.935209986 +0200
|
||||||
@@ -38,6 +38,7 @@ extern int pedantic;
|
@@ -38,6 +38,7 @@ extern int pedantic;
|
||||||
extern int do_everything;
|
extern int do_everything;
|
||||||
extern int do_header;
|
extern int do_header;
|
||||||
@ -152,7 +159,7 @@ diff -apurN a/mingw-w64-tools/widl/src/widl.h b/mingw-w64-tools/widl/src/widl.h
|
|||||||
extern int do_server;
|
extern int do_server;
|
||||||
diff -apurN a/mingw-w64-tools/widl/src/write_sltg.c b/mingw-w64-tools/widl/src/write_sltg.c
|
diff -apurN a/mingw-w64-tools/widl/src/write_sltg.c b/mingw-w64-tools/widl/src/write_sltg.c
|
||||||
--- a/mingw-w64-tools/widl/src/write_sltg.c 1970-01-01 01:00:00.000000000 +0100
|
--- a/mingw-w64-tools/widl/src/write_sltg.c 1970-01-01 01:00:00.000000000 +0100
|
||||||
+++ b/mingw-w64-tools/widl/src/write_sltg.c 2020-10-13 16:19:00.524221058 +0200
|
+++ b/mingw-w64-tools/widl/src/write_sltg.c 2020-07-31 21:13:59.936209981 +0200
|
||||||
@@ -0,0 +1,1857 @@
|
@@ -0,0 +1,1857 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Typelib (SLTG) generation
|
+ * Typelib (SLTG) generation
|
364
patches/mingw-w64/v7.0.0/002-widl-reactos-support.patch
Normal file
364
patches/mingw-w64/v7.0.0/002-widl-reactos-support.patch
Normal file
@ -0,0 +1,364 @@
|
|||||||
|
diff -apurN a/mingw-w64-tools/widl/src/header.c b/mingw-w64-tools/widl/src/header.c
|
||||||
|
--- a/mingw-w64-tools/widl/src/header.c 2020-08-01 22:51:29.248778551 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/header.c 2020-08-01 21:41:41.998028252 +0200
|
||||||
|
@@ -1221,7 +1221,7 @@ static void write_inline_wrappers(FILE *
|
||||||
|
if (!is_callas(func->attrs)) {
|
||||||
|
const var_t *arg;
|
||||||
|
|
||||||
|
- fprintf(header, "static FORCEINLINE ");
|
||||||
|
+ fprintf(header, "FORCEINLINE ");
|
||||||
|
write_type_decl_left(header, type_function_get_ret(func->declspec.type));
|
||||||
|
fprintf(header, " %s_%s(", name, get_name(func));
|
||||||
|
write_args(header, type_function_get_args(func->declspec.type), name, 1, FALSE);
|
||||||
|
@@ -1256,7 +1256,16 @@ static void do_write_c_method_def(FILE *
|
||||||
|
|
||||||
|
if (type_iface_get_inherit(iface))
|
||||||
|
do_write_c_method_def(header, type_iface_get_inherit(iface), name);
|
||||||
|
-
|
||||||
|
+ else if (type_iface_get_stmts(iface) == NULL)
|
||||||
|
+ {
|
||||||
|
+ fprintf(header, "#ifndef __cplusplus\n");
|
||||||
|
+ indent(header, 0);
|
||||||
|
+ fprintf(header, "char dummy;\n");
|
||||||
|
+ fprintf(header, "#endif\n");
|
||||||
|
+ fprintf(header, "\n");
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface))
|
||||||
|
{
|
||||||
|
const var_t *func = stmt->u.var;
|
||||||
|
@@ -1804,6 +1813,11 @@ void write_header(const statement_list_t
|
||||||
|
fprintf(header, "#ifndef __REQUIRED_RPCNDR_H_VERSION__\n");
|
||||||
|
fprintf(header, "#define __REQUIRED_RPCNDR_H_VERSION__ 475\n");
|
||||||
|
fprintf(header, "#endif\n");
|
||||||
|
+
|
||||||
|
+ fprintf(header, "#ifdef __REACTOS__\n");
|
||||||
|
+ fprintf(header, "#define WIN32_LEAN_AND_MEAN\n");
|
||||||
|
+ fprintf(header, "#endif\n\n");
|
||||||
|
+
|
||||||
|
fprintf(header, "#include <rpc.h>\n" );
|
||||||
|
fprintf(header, "#include <rpcndr.h>\n" );
|
||||||
|
if (!for_each_serializable(stmts, NULL, serializable_exists))
|
||||||
|
diff -apurN a/mingw-w64-tools/widl/src/parser.tab.c b/mingw-w64-tools/widl/src/parser.tab.c
|
||||||
|
--- a/mingw-w64-tools/widl/src/parser.tab.c 2020-08-01 22:51:29.249778547 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/parser.tab.c 2020-08-01 22:55:45.839676740 +0200
|
||||||
|
@@ -196,8 +196,6 @@ static struct namespace global_namespace
|
||||||
|
|
||||||
|
static struct namespace *current_namespace = &global_namespace;
|
||||||
|
|
||||||
|
-static typelib_t *current_typelib;
|
||||||
|
-
|
||||||
|
|
||||||
|
#line 203 "parser.tab.c" /* yacc.c:339 */
|
||||||
|
|
||||||
|
@@ -2612,7 +2610,6 @@ yyreduce:
|
||||||
|
write_client((yyvsp[-1].stmt_list));
|
||||||
|
write_server((yyvsp[-1].stmt_list));
|
||||||
|
write_regscript((yyvsp[-1].stmt_list));
|
||||||
|
- write_typelib_regscript((yyvsp[-1].stmt_list));
|
||||||
|
write_dlldata((yyvsp[-1].stmt_list));
|
||||||
|
write_local_stubs((yyvsp[-1].stmt_list));
|
||||||
|
}
|
||||||
|
@@ -2893,7 +2890,7 @@ yyreduce:
|
||||||
|
|
||||||
|
case 52:
|
||||||
|
#line 424 "parser.y" /* yacc.c:1651 */
|
||||||
|
- { (yyval.str) = (yyvsp[-2].str); if(!parse_only) add_importlib((yyvsp[-2].str), current_typelib); }
|
||||||
|
+ { (yyval.str) = (yyvsp[-2].str); if(!parse_only) add_importlib((yyvsp[-2].str)); }
|
||||||
|
#line 2898 "parser.tab.c" /* yacc.c:1651 */
|
||||||
|
break;
|
||||||
|
|
||||||
|
@@ -2912,7 +2909,7 @@ yyreduce:
|
||||||
|
case 55:
|
||||||
|
#line 430 "parser.y" /* yacc.c:1651 */
|
||||||
|
{ (yyval.typelib) = make_library((yyvsp[-1].str), check_library_attrs((yyvsp[-1].str), (yyvsp[-2].attr_list)));
|
||||||
|
- if (!parse_only && do_typelib) current_typelib = (yyval.typelib);
|
||||||
|
+ if (!parse_only) start_typelib(yyval.typelib);
|
||||||
|
}
|
||||||
|
#line 2918 "parser.tab.c" /* yacc.c:1651 */
|
||||||
|
break;
|
||||||
|
@@ -6019,6 +6016,12 @@ static type_t *reg_typedefs(decl_spec_t
|
||||||
|
type->attrs = attrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* Append the SWITCHTYPE attribute to a non-encapsulated union if it does not already have it */
|
||||||
|
+ if (type_get_type_detect_alias(type) == TYPE_UNION &&
|
||||||
|
+ is_attr(attrs, ATTR_SWITCHTYPE) &&
|
||||||
|
+ !is_attr(type->attrs, ATTR_SWITCHTYPE))
|
||||||
|
+ type->attrs = append_attr(type->attrs, make_attrp(ATTR_SWITCHTYPE, get_attrp(attrs, ATTR_SWITCHTYPE)));
|
||||||
|
+
|
||||||
|
LIST_FOR_EACH_ENTRY( decl, decls, declarator_t, entry )
|
||||||
|
{
|
||||||
|
|
||||||
|
diff -apurN a/mingw-w64-tools/widl/src/parser.y b/mingw-w64-tools/widl/src/parser.y
|
||||||
|
--- a/mingw-w64-tools/widl/src/parser.y 2020-08-01 22:51:29.250778543 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/parser.y 2020-08-01 21:48:30.318245917 +0200
|
||||||
|
@@ -123,8 +123,6 @@ static struct namespace global_namespace
|
||||||
|
|
||||||
|
static struct namespace *current_namespace = &global_namespace;
|
||||||
|
|
||||||
|
-static typelib_t *current_typelib;
|
||||||
|
-
|
||||||
|
%}
|
||||||
|
%union {
|
||||||
|
attr_t *attr;
|
||||||
|
@@ -320,7 +318,6 @@ input: gbl_statements m_acf { check_st
|
||||||
|
write_client($1);
|
||||||
|
write_server($1);
|
||||||
|
write_regscript($1);
|
||||||
|
- write_typelib_regscript($1);
|
||||||
|
write_dlldata($1);
|
||||||
|
write_local_stubs($1);
|
||||||
|
}
|
||||||
|
@@ -421,18 +418,18 @@ import: import_start imp_statements aEOF
|
||||||
|
;
|
||||||
|
|
||||||
|
importlib: tIMPORTLIB '(' aSTRING ')'
|
||||||
|
- semicolon_opt { $$ = $3; if(!parse_only) add_importlib($3, current_typelib); }
|
||||||
|
+ semicolon_opt { $$ = $3; if(!parse_only) add_importlib($3); }
|
||||||
|
;
|
||||||
|
|
||||||
|
libraryhdr: tLIBRARY aIDENTIFIER { $$ = $2; }
|
||||||
|
| tLIBRARY aKNOWNTYPE { $$ = $2; }
|
||||||
|
;
|
||||||
|
library_start: attributes libraryhdr '{' { $$ = make_library($2, check_library_attrs($2, $1));
|
||||||
|
- if (!parse_only && do_typelib) current_typelib = $$;
|
||||||
|
+ if (!parse_only) start_typelib($$);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
librarydef: library_start imp_statements '}'
|
||||||
|
- semicolon_opt { $$ = $1; $$->stmts = $2; }
|
||||||
|
+ semicolon_opt { $$ = $1; $$->stmts = $2; if (!parse_only) end_typelib(); }
|
||||||
|
;
|
||||||
|
|
||||||
|
m_args: { $$ = NULL; }
|
||||||
|
@@ -1906,6 +1903,12 @@ static type_t *reg_typedefs(decl_spec_t
|
||||||
|
type->attrs = attrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* Append the SWITCHTYPE attribute to a non-encapsulated union if it does not already have it. */
|
||||||
|
+ if (type_get_type_detect_alias(type) == TYPE_UNION &&
|
||||||
|
+ is_attr(attrs, ATTR_SWITCHTYPE) &&
|
||||||
|
+ !is_attr(type->attrs, ATTR_SWITCHTYPE))
|
||||||
|
+ type->attrs = append_attr(type->attrs, make_attrp(ATTR_SWITCHTYPE, get_attrp(attrs, ATTR_SWITCHTYPE)));
|
||||||
|
+
|
||||||
|
LIST_FOR_EACH_ENTRY( decl, decls, declarator_t, entry )
|
||||||
|
{
|
||||||
|
|
||||||
|
diff -apurN a/mingw-w64-tools/widl/src/proxy.c b/mingw-w64-tools/widl/src/proxy.c
|
||||||
|
--- a/mingw-w64-tools/widl/src/proxy.c 2020-08-01 22:51:29.079779285 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/proxy.c 2020-08-01 22:56:14.230555312 +0200
|
||||||
|
@@ -88,6 +88,12 @@ static void init_proxy(const statement_l
|
||||||
|
print_proxy( "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
|
||||||
|
print_proxy( "\n");
|
||||||
|
print_proxy( "#define __midl_proxy\n");
|
||||||
|
+
|
||||||
|
+ print_proxy( "#ifdef __REACTOS__\n");
|
||||||
|
+ print_proxy( "#define WIN32_NO_STATUS\n");
|
||||||
|
+ print_proxy( "#define WIN32_LEAN_AND_MEAN\n");
|
||||||
|
+ print_proxy( "#endif\n\n");
|
||||||
|
+
|
||||||
|
print_proxy( "#include \"objbase.h\"\n");
|
||||||
|
print_proxy( "\n");
|
||||||
|
print_proxy( "#ifndef DECLSPEC_HIDDEN\n");
|
||||||
|
@@ -482,14 +488,15 @@ static const statement_t * get_callas_so
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void write_proxy_procformatstring_offsets( const type_t *iface, int skip )
|
||||||
|
+static int write_proxy_procformatstring_offsets( const type_t *iface, int skip )
|
||||||
|
{
|
||||||
|
const statement_t *stmt;
|
||||||
|
+ int i;
|
||||||
|
|
||||||
|
if (type_iface_get_inherit(iface))
|
||||||
|
- write_proxy_procformatstring_offsets( type_iface_get_inherit(iface), need_delegation(iface));
|
||||||
|
+ i = write_proxy_procformatstring_offsets( type_iface_get_inherit(iface), need_delegation(iface));
|
||||||
|
else
|
||||||
|
- return;
|
||||||
|
+ return 0;
|
||||||
|
|
||||||
|
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||||
|
{
|
||||||
|
@@ -509,7 +516,9 @@ static void write_proxy_procformatstring
|
||||||
|
print_proxy( "(unsigned short)-1, /* %s::%s */\n", iface->name, get_name(func));
|
||||||
|
else
|
||||||
|
print_proxy( "%u, /* %s::%s */\n", func->procstring_offset, iface->name, get_name(func));
|
||||||
|
+ i++;
|
||||||
|
}
|
||||||
|
+ return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int write_proxy_methods(type_t *iface, int skip)
|
||||||
|
@@ -643,7 +652,10 @@ static void write_proxy(type_t *iface, u
|
||||||
|
print_proxy( "static const unsigned short %s_FormatStringOffsetTable[] =\n", iface->name );
|
||||||
|
print_proxy( "{\n" );
|
||||||
|
indent++;
|
||||||
|
- write_proxy_procformatstring_offsets( iface, 0 );
|
||||||
|
+ if (write_proxy_procformatstring_offsets( iface, 0 ) == 0)
|
||||||
|
+ {
|
||||||
|
+ print_proxy( "0\n" );
|
||||||
|
+ }
|
||||||
|
indent--;
|
||||||
|
print_proxy( "};\n\n" );
|
||||||
|
|
||||||
|
@@ -718,7 +730,10 @@ static void write_proxy(type_t *iface, u
|
||||||
|
print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name);
|
||||||
|
print_proxy( "{\n");
|
||||||
|
indent++;
|
||||||
|
- write_stub_methods(iface, FALSE);
|
||||||
|
+ if (write_stub_methods(iface, FALSE) == 0)
|
||||||
|
+ {
|
||||||
|
+ fprintf(proxy, 0);
|
||||||
|
+ }
|
||||||
|
fprintf(proxy, "\n");
|
||||||
|
indent--;
|
||||||
|
fprintf(proxy, "};\n\n");
|
||||||
|
diff -apurN a/mingw-w64-tools/widl/src/register.c b/mingw-w64-tools/widl/src/register.c
|
||||||
|
--- a/mingw-w64-tools/widl/src/register.c 2020-08-01 22:52:08.525607975 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/register.c 2020-08-01 22:56:25.382507605 +0200
|
||||||
|
@@ -324,6 +324,9 @@ void output_typelib_regscript( const typ
|
||||||
|
put_str( indent++, "{\n" );
|
||||||
|
expr = get_attrp( typelib->attrs, ATTR_ID );
|
||||||
|
if (expr)
|
||||||
|
+ sprintf(id_part, "\\%d", expr->cval);
|
||||||
|
+
|
||||||
|
+ if (expr)
|
||||||
|
{
|
||||||
|
sprintf(id_part, "\\%d", expr->cval);
|
||||||
|
resname = xmalloc( strlen(typelib_name) + 20 );
|
||||||
|
@@ -349,5 +352,5 @@ void output_typelib_regscript( const typ
|
||||||
|
write_progids( typelib->stmts );
|
||||||
|
put_str( --indent, "}\n" );
|
||||||
|
|
||||||
|
- add_output_to_resources( "WINE_REGISTRY", resname );
|
||||||
|
+ add_output_to_resources( "WINE_REGISTRY", typelib_name );
|
||||||
|
}
|
||||||
|
diff -apurN a/mingw-w64-tools/widl/src/typegen.c b/mingw-w64-tools/widl/src/typegen.c
|
||||||
|
--- a/mingw-w64-tools/widl/src/typegen.c 2020-08-01 22:51:29.250778543 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/typegen.c 2020-08-01 22:56:33.110474542 +0200
|
||||||
|
@@ -4816,7 +4816,7 @@ void write_func_param_struct( FILE *file
|
||||||
|
if (align >= pointer_size)
|
||||||
|
fprintf( file, "%s;\n", arg->name );
|
||||||
|
else
|
||||||
|
- fprintf( file, "%s DECLSPEC_ALIGN(%u);\n", arg->name, pointer_size );
|
||||||
|
+ fprintf( file, "DECLSPEC_ALIGN(%u) %s;\n", pointer_size, arg->name );
|
||||||
|
}
|
||||||
|
if (add_retval && !is_void( retval->declspec.type ))
|
||||||
|
{
|
||||||
|
diff -apurN a/mingw-w64-tools/widl/src/typelib.c b/mingw-w64-tools/widl/src/typelib.c
|
||||||
|
--- a/mingw-w64-tools/widl/src/typelib.c 2020-08-01 22:51:29.080779281 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/typelib.c 2020-08-01 22:56:40.014445003 +0200
|
||||||
|
@@ -44,6 +44,7 @@
|
||||||
|
#include "typelib_struct.h"
|
||||||
|
#include "typetree.h"
|
||||||
|
|
||||||
|
+static typelib_t *typelib;
|
||||||
|
|
||||||
|
/* List of oleauto types that should be recognized by name.
|
||||||
|
* (most of) these seem to be intrinsic types in mktyplib.
|
||||||
|
@@ -239,6 +240,18 @@ unsigned short get_type_vt(type_t *t)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void start_typelib(typelib_t *typelib_type)
|
||||||
|
+{
|
||||||
|
+ if (!do_typelib) return;
|
||||||
|
+ typelib = typelib_type;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void end_typelib(void)
|
||||||
|
+{
|
||||||
|
+ if (!typelib) return;
|
||||||
|
+ create_msft_typelib(typelib);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void tlb_read(int fd, void *buf, int count)
|
||||||
|
{
|
||||||
|
if(read(fd, buf, count) < count)
|
||||||
|
@@ -363,7 +376,7 @@ static void read_importlib(importlib_t *
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
-void add_importlib(const char *name, typelib_t *typelib)
|
||||||
|
+void add_importlib(const char *name)
|
||||||
|
{
|
||||||
|
importlib_t *importlib;
|
||||||
|
|
||||||
|
diff -apurN a/mingw-w64-tools/widl/src/typelib.h b/mingw-w64-tools/widl/src/typelib.h
|
||||||
|
--- a/mingw-w64-tools/widl/src/typelib.h 2020-08-01 22:52:08.525607975 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/typelib.h 2020-08-01 22:56:45.782420322 +0200
|
||||||
|
@@ -21,7 +21,9 @@
|
||||||
|
#ifndef __WIDL_TYPELIB_H
|
||||||
|
#define __WIDL_TYPELIB_H
|
||||||
|
|
||||||
|
-extern void add_importlib(const char *name, typelib_t *typelib);
|
||||||
|
+extern void start_typelib(typelib_t *typelib_type);
|
||||||
|
+extern void end_typelib(void);
|
||||||
|
+extern void add_importlib(const char *name);
|
||||||
|
|
||||||
|
/* Copied from wtypes.h. Not included directly because that would create a
|
||||||
|
* circular dependency (after all, wtypes.h is generated by widl...) */
|
||||||
|
diff -apurN a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
|
||||||
|
--- a/mingw-w64-tools/widl/src/widl.c 2020-08-01 22:52:08.526607970 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/widl.c 2020-08-01 21:36:56.893265451 +0200
|
||||||
|
@@ -388,6 +388,12 @@ static void write_dlldata_list(struct li
|
||||||
|
fprintf(dlldata, "- Do not edit ***/\n\n");
|
||||||
|
if (define_proxy_delegation)
|
||||||
|
fprintf(dlldata, "#define PROXY_DELEGATION\n");
|
||||||
|
+
|
||||||
|
+ fprintf(dlldata, "#ifdef __REACTOS__\n");
|
||||||
|
+ fprintf(dlldata, "#define WIN32_NO_STATUS\n");
|
||||||
|
+ fprintf(dlldata, "#define WIN32_LEAN_AND_MEAN\n");
|
||||||
|
+ fprintf(dlldata, "#endif\n\n");
|
||||||
|
+
|
||||||
|
fprintf(dlldata, "#include <objbase.h>\n");
|
||||||
|
fprintf(dlldata, "#include <rpcproxy.h>\n\n");
|
||||||
|
start_cplusplus_guard(dlldata);
|
||||||
|
@@ -533,6 +539,12 @@ void write_id_data(const statement_list_
|
||||||
|
|
||||||
|
fprintf(idfile, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION);
|
||||||
|
fprintf(idfile, "from %s - Do not edit ***/\n\n", input_idl_name);
|
||||||
|
+
|
||||||
|
+ fprintf(idfile, "#ifdef __REACTOS__\n");
|
||||||
|
+ fprintf(idfile, "#define WIN32_NO_STATUS\n");
|
||||||
|
+ fprintf(idfile, "#define WIN32_LEAN_AND_MEAN\n");
|
||||||
|
+ fprintf(idfile, "#endif\n\n");
|
||||||
|
+
|
||||||
|
fprintf(idfile, "#include <rpc.h>\n");
|
||||||
|
fprintf(idfile, "#include <rpcndr.h>\n\n");
|
||||||
|
|
||||||
|
diff -apurN a/mingw-w64-tools/widl/src/widl.h b/mingw-w64-tools/widl/src/widl.h
|
||||||
|
--- a/mingw-w64-tools/widl/src/widl.h 2020-08-01 22:52:08.526607970 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/widl.h 2020-08-01 22:56:54.478383110 +0200
|
||||||
|
@@ -96,7 +96,6 @@ extern void write_proxies(const statemen
|
||||||
|
extern void write_client(const statement_list_t *stmts);
|
||||||
|
extern void write_server(const statement_list_t *stmts);
|
||||||
|
extern void write_regscript(const statement_list_t *stmts);
|
||||||
|
-extern void write_typelib_regscript(const statement_list_t *stmts);
|
||||||
|
extern void output_typelib_regscript( const typelib_t *typelib );
|
||||||
|
extern void write_local_stubs(const statement_list_t *stmts);
|
||||||
|
extern void write_dlldata(const statement_list_t *stmts);
|
||||||
|
diff -apurN a/mingw-w64-tools/widl/src/write_msft.c b/mingw-w64-tools/widl/src/write_msft.c
|
||||||
|
--- a/mingw-w64-tools/widl/src/write_msft.c 2020-08-01 22:51:29.252778534 +0200
|
||||||
|
+++ b/mingw-w64-tools/widl/src/write_msft.c 2020-08-01 21:39:46.785529130 +0200
|
||||||
|
@@ -54,6 +54,10 @@
|
||||||
|
#include "parser.h"
|
||||||
|
#include "typegen.h"
|
||||||
|
|
||||||
|
+#define S_OK 0
|
||||||
|
+#define S_FALSE 1
|
||||||
|
+#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
|
||||||
|
+
|
||||||
|
enum MSFT_segment_index {
|
||||||
|
MSFT_SEG_TYPEINFO = 0, /* type information */
|
||||||
|
MSFT_SEG_IMPORTINFO, /* import information */
|
||||||
|
@@ -2663,6 +2667,7 @@ static void save_all_changes(msft_typeli
|
||||||
|
sprintf( typelib_id, "#%d", expr->cval );
|
||||||
|
add_output_to_resources( "TYPELIB", typelib_id );
|
||||||
|
output_typelib_regscript( typelib->typelib );
|
||||||
|
+ flush_output_resources( typelib_name );
|
||||||
|
}
|
||||||
|
else flush_output_buffer( typelib_name );
|
||||||
|
}
|
11
readme.md
Normal file
11
readme.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
## FerretOS Build Environment (FBE)
|
||||||
|
The FerretOS Build Environment (FBE) is the official build environment for compiling FerretOS.
|
||||||
|
Currently, it is targeted at Linux only, however a Windows and FerretOS versions will be available
|
||||||
|
in the future as well.
|
||||||
|
|
||||||
|
This software includes:
|
||||||
|
* Binutils
|
||||||
|
* GCC
|
||||||
|
* Mingw-w64
|
||||||
|
* CMake
|
||||||
|
* Ninja
|
@ -1,42 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# PROJECT: XTchain
|
|
||||||
# LICENSE: See the COPYING.md in the top level directory
|
|
||||||
# FILE: scripts/clang-target-wrapper
|
|
||||||
# DESCRIPTION: CLANG Wrapper
|
|
||||||
# DEVELOPERS: Martin Storsjo <martin@martin.st>
|
|
||||||
# Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
|
|
||||||
|
|
||||||
# Set basic variables
|
|
||||||
DIR="$(cd $(dirname $0) && pwd)"
|
|
||||||
CLANG="$DIR/clang"
|
|
||||||
BASENAME="$(basename $0)"
|
|
||||||
TARGET="${BASENAME%-*}"
|
|
||||||
EXECUTABLE="${BASENAME##*-}"
|
|
||||||
DEFAULT_TARGET="x86_64-w64-mingw32"
|
|
||||||
ARCH="${TARGET%%-*}"
|
|
||||||
|
|
||||||
# Set proper target
|
|
||||||
if [ "${TARGET}" = "${BASENAME}" ]; then
|
|
||||||
TARGET="${DEFAULT_TARGET}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set lang-specific flags
|
|
||||||
case ${EXECUTABLE} in
|
|
||||||
"clang++"|"g++"|"c++")
|
|
||||||
FLAGS="$FLAGS --driver-mode=g++"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
FLAGS=""
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Set compiler flags
|
|
||||||
FLAGS="${FLAGS} -target ${TARGET}"
|
|
||||||
FLAGS="${FLAGS} -rtlib=compiler-rt"
|
|
||||||
FLAGS="${FLAGS} -stdlib=libc++"
|
|
||||||
FLAGS="${FLAGS} -fuse-ld=lld"
|
|
||||||
FLAGS="${FLAGS} -Qunused-arguments"
|
|
||||||
|
|
||||||
# Launch the compiler
|
|
||||||
$CLANG $FLAGS "$@"
|
|
@ -1,42 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# PROJECT: XTchain
|
|
||||||
# LICENSE: See the COPYING.md in the top level directory
|
|
||||||
# FILE: scripts/dlltool-wrapper
|
|
||||||
# DESCRIPTION: DLLTOOL Wrapper
|
|
||||||
# DEVELOPERS: Martin Storsjo <martin@martin.st>
|
|
||||||
# Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
|
|
||||||
|
|
||||||
# Set basic variables
|
|
||||||
DIR="$(cd $(dirname $0) && pwd)"
|
|
||||||
BASENAME="$(basename $0)"
|
|
||||||
TARGET="${BASENAME%-*}"
|
|
||||||
DEFAULT_TARGET="x86_64-w64-mingw32"
|
|
||||||
|
|
||||||
# Update PATH
|
|
||||||
export PATH="$DIR":"$PATH"
|
|
||||||
|
|
||||||
# Set proper target
|
|
||||||
if [ "${TARGET}" = "${BASENAME}" ]; then
|
|
||||||
TARGET="${DEFAULT_TARGET}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set target machine
|
|
||||||
ARCH="${TARGET%%-*}"
|
|
||||||
case $ARCH in
|
|
||||||
aarch64)
|
|
||||||
M="arm64"
|
|
||||||
;;
|
|
||||||
armv7)
|
|
||||||
M="arm"
|
|
||||||
;;
|
|
||||||
i686)
|
|
||||||
M="i386"
|
|
||||||
;;
|
|
||||||
x86_64)
|
|
||||||
M="i386:x86-64"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Launch the utility
|
|
||||||
llvm-dlltool -m ${M} "$@"
|
|
@ -1,23 +1,23 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# PROJECT: XTchain
|
|
||||||
# LICENSE: See the COPYING.md in the top level directory
|
|
||||||
# FILE: scripts/xtchain
|
|
||||||
# DESCRIPTION: XTchain Entry Script
|
|
||||||
# DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
|
|
||||||
|
# Check if script launched as root
|
||||||
|
if [ "$(whoami)" = "root" ]; then
|
||||||
|
echo "This script cannot be run as root!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Get the absolute path to the XTchain
|
# Get the absolute path to the FBE
|
||||||
export XTCDIR="$(realpath $(dirname ${0}))"
|
export FBEDIR="$(realpath $(dirname ${0}))"
|
||||||
|
|
||||||
# Read the XTchain version
|
# Read the FBE version
|
||||||
export XTCVER="$(cat ${XTCDIR}/Version)"
|
export FBEVER="$(cat ${FBEDIR}/Version)"
|
||||||
|
|
||||||
# Load the library
|
# Load the library
|
||||||
source ${XTCDIR}/lib/xtchain/xtclib
|
source ${FBEDIR}/fbelib.sh
|
||||||
|
|
||||||
# Set the target architecture
|
# Set the target architecture
|
||||||
: ${TARGET:=${1}}
|
: ${TARGET:=${1}}
|
||||||
: ${TARGET:=amd64}
|
: ${TARGET:=i386}
|
||||||
|
|
||||||
# Save the source directory
|
# Save the source directory
|
||||||
export SRCDIR="${2:-${PWD}}"
|
export SRCDIR="${2:-${PWD}}"
|
||||||
@ -29,7 +29,7 @@ export CXXFLAGS=
|
|||||||
export LDFLAGS=
|
export LDFLAGS=
|
||||||
|
|
||||||
# Update PATH
|
# Update PATH
|
||||||
export PATH="${XTCDIR}/bin:${PATH}"
|
export PATH="${FBEDIR}/bin:${PATH}"
|
||||||
|
|
||||||
# Display banner
|
# Display banner
|
||||||
version
|
version
|
||||||
@ -40,5 +40,5 @@ export PFMAT2="\[\033[0;34;104m\]"
|
|||||||
export PFMAT3="\[\033[0;1;97;104m\]"
|
export PFMAT3="\[\033[0;1;97;104m\]"
|
||||||
export PFMAT4="\[\033[0;94;49m\]"
|
export PFMAT4="\[\033[0;94;49m\]"
|
||||||
export PFMAT5="\[\033[1;38;5;74m\]"
|
export PFMAT5="\[\033[1;38;5;74m\]"
|
||||||
export PROMPT="\n${PFMAT1} XT Toolchain ${PFMAT2}${PFMAT3} \w ${PFMAT4}${PFMAT5} "
|
export PROMPT="\n${PFMAT1} FerretOS BE ${PFMAT2}${PFMAT3} \w ${PFMAT4}${PFMAT5} "
|
||||||
bash --rcfile <(echo 'source ~/.bashrc && export PS1="${PROMPT}" && cd ${SRCDIR}')
|
bash --rcfile <(echo 'source ~/.bashrc && export PS1="${PROMPT}" && cd ${SRCDIR}')
|
40
scripts/fbelib.sh
Executable file
40
scripts/fbelib.sh
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Sets the target architecture
|
||||||
|
charch()
|
||||||
|
{
|
||||||
|
if [ "x${1}" == "x" ]; then
|
||||||
|
echo "Syntax: charch [architecture]"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
case ${1} in
|
||||||
|
"i386"|"i486"|"i586"|"i686"|"x86")
|
||||||
|
export TARGET="i386"
|
||||||
|
;;
|
||||||
|
"amd64"|"x64"|"x86_64")
|
||||||
|
export TARGET="amd64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
export TARGET="UNKNOWN"
|
||||||
|
esac
|
||||||
|
echo "Target Architecture: ${TARGET}"
|
||||||
|
}
|
||||||
|
export -f charch
|
||||||
|
|
||||||
|
# Displays version banner
|
||||||
|
version()
|
||||||
|
{
|
||||||
|
echo "###############################################################################"
|
||||||
|
echo "# FerretOS Build Environment v${FBEVER} for Linux #"
|
||||||
|
echo "# by Rafal Kupiec <belliash@codingworkshop.eu.org> #"
|
||||||
|
echo "###############################################################################"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "Binutils Version: $(${FBEDIR}/bin/i686-w64-mingw32-ld -v | cut -d' ' -f5)"
|
||||||
|
echo "GCC Version: $(${FBEDIR}/bin/i686-w64-mingw32-gcc -v 2>&1| grep 'gcc version' | cut -d' ' -f3)"
|
||||||
|
echo "IDL Compiler Version: $(${FBEDIR}/bin/i686-w64-mingw32-widl -V | grep 'version' | cut -d' ' -f5)"
|
||||||
|
charch ${TARGET}
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
export -f version
|
@ -1,42 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# PROJECT: XTchain
|
|
||||||
# LICENSE: See the COPYING.md in the top level directory
|
|
||||||
# FILE: scripts/ld-wrapper
|
|
||||||
# DESCRIPTION: LLD Wrapper
|
|
||||||
# DEVELOPERS: Martin Storsjo <martin@martin.st>
|
|
||||||
# Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
|
|
||||||
|
|
||||||
# Set basic variables
|
|
||||||
DIR="$(cd $(dirname $0) && pwd)"
|
|
||||||
BASENAME="$(basename $0)"
|
|
||||||
TARGET="${BASENAME%-*}"
|
|
||||||
DEFAULT_TARGET="x86_64-w64-mingw32"
|
|
||||||
|
|
||||||
# Update PATH
|
|
||||||
export PATH="${DIR}":"${PATH}"
|
|
||||||
|
|
||||||
# Set proper target
|
|
||||||
if [ "${TARGET}" = "${BASENAME}" ]; then
|
|
||||||
TARGET="${DEFAULT_TARGET}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set target machine
|
|
||||||
ARCH="${TARGET%%-*}"
|
|
||||||
case ${ARCH} in
|
|
||||||
aarch64)
|
|
||||||
M="arm64pe"
|
|
||||||
;;
|
|
||||||
armv7)
|
|
||||||
M="thumb2pe"
|
|
||||||
;;
|
|
||||||
i686)
|
|
||||||
M="i386pe"
|
|
||||||
;;
|
|
||||||
x86_64)
|
|
||||||
M="i386pep"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Launch the linker
|
|
||||||
ld.lld -m ${M} "$@"
|
|
@ -1,46 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# PROJECT: XTchain
|
|
||||||
# LICENSE: See the COPYING.md in the top level directory
|
|
||||||
# FILE: scripts/objdump-wrapper
|
|
||||||
# DESCRIPTION: OBJDUMP Wrapper
|
|
||||||
# DEVELOPERS: Martin Storsjo <martin@martin.st>
|
|
||||||
# Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
|
|
||||||
|
|
||||||
# Set basic variables
|
|
||||||
DIR="$(cd $(dirname $0) && pwd)"
|
|
||||||
|
|
||||||
# Update PATH
|
|
||||||
export PATH="$DIR":"$PATH"
|
|
||||||
|
|
||||||
# Libtool can try to run objdump -f and wants to see certain strings in
|
|
||||||
# the output, to accept it being a valid windows (import) library
|
|
||||||
if [ "$1" = "-f" ]; then
|
|
||||||
llvm-readobj $2 | while read -r line; do
|
|
||||||
case $line in
|
|
||||||
File:*)
|
|
||||||
file=$(echo $line | awk '{print $2}')
|
|
||||||
;;
|
|
||||||
Format:*)
|
|
||||||
format=$(echo $line | awk '{print $2}')
|
|
||||||
case $format in
|
|
||||||
COFF-i386)
|
|
||||||
format=pe-i386
|
|
||||||
;;
|
|
||||||
COFF-x86-64)
|
|
||||||
format=pe-x86-64
|
|
||||||
;;
|
|
||||||
COFF-ARM*)
|
|
||||||
# This is wrong; modern COFF armv7 isn't pe-arm-wince, and
|
|
||||||
# arm64 definitely isn't, but libtool wants to see this
|
|
||||||
# string (or some of the others) in order to accept it.
|
|
||||||
format=pe-arm-wince
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo $file: file format $format
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
else
|
|
||||||
llvm-objdump "$@"
|
|
||||||
fi
|
|
104
scripts/xtclib
104
scripts/xtclib
@ -1,104 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# PROJECT: XTchain
|
|
||||||
# LICENSE: See the COPYING.md in the top level directory
|
|
||||||
# FILE: scripts/xtclib
|
|
||||||
# DESCRIPTION: XTchain library
|
|
||||||
# DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
|
|
||||||
|
|
||||||
# Sets the target architecture
|
|
||||||
charch()
|
|
||||||
{
|
|
||||||
if [ "x${1}" == "x" ]; then
|
|
||||||
echo "Syntax: charch [architecture]"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
case ${1} in
|
|
||||||
"aarch64"|"arm64")
|
|
||||||
export TARGET="aarch64"
|
|
||||||
;;
|
|
||||||
"arm"|"armv7")
|
|
||||||
export TARGET="armv7"
|
|
||||||
;;
|
|
||||||
"i386"|"i486"|"i586"|"i686"|"x86")
|
|
||||||
export TARGET="i686"
|
|
||||||
;;
|
|
||||||
"amd64"|"x64"|"x86_64")
|
|
||||||
export TARGET="amd64"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
export TARGET="UNKNOWN"
|
|
||||||
esac
|
|
||||||
echo "Target Architecture: ${TARGET}"
|
|
||||||
}
|
|
||||||
export -f charch
|
|
||||||
|
|
||||||
# Sets the build type
|
|
||||||
chbuild()
|
|
||||||
{
|
|
||||||
if [ "x${1}" == "x" ]; then
|
|
||||||
echo "Syntax: chbuild [DEBUG|RELEASE]"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
case ${1} in
|
|
||||||
[Rr][Ee][Ll][Ee][Aa][Ss][Ee])
|
|
||||||
export BUILD_TYPE="RELEASE"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
export BUILD_TYPE="DEBUG"
|
|
||||||
esac
|
|
||||||
echo "Target build type: ${BUILD_TYPE}"
|
|
||||||
}
|
|
||||||
export -f chbuild
|
|
||||||
|
|
||||||
# Prints help
|
|
||||||
help()
|
|
||||||
{
|
|
||||||
version
|
|
||||||
echo "XTChain defines an internal list of commands:"
|
|
||||||
echo " * charch [arch] - sets the target CPU architecture [aarch64/armv7/i686/amd64]"
|
|
||||||
echo " * chbuild [type] - sets build type [debug/release]"
|
|
||||||
echo " * help - prints this message"
|
|
||||||
echo " * version - prints XTChain and its components version"
|
|
||||||
echo " * xbuild - builds an application with a Ninja build system"
|
|
||||||
}
|
|
||||||
export -f help
|
|
||||||
|
|
||||||
# Displays version banner
|
|
||||||
version()
|
|
||||||
{
|
|
||||||
echo "###############################################################################"
|
|
||||||
echo "# XT Toolchain v${XTCVER} for Linux #"
|
|
||||||
echo "# by Rafal Kupiec <belliash@codingworkshop.eu.org> #"
|
|
||||||
echo "###############################################################################"
|
|
||||||
echo
|
|
||||||
echo
|
|
||||||
echo "LLVM Compiler Version: $(${XTCDIR}/bin/clang --version | grep 'clang version' | cut -d' ' -f3)"
|
|
||||||
echo "LLVM Windres Utility Version: $(${XTCDIR}/bin/i686-w64-mingw32-windres -V | cut -d' ' -f6)"
|
|
||||||
echo "Mingw IDL Compiler Version: $(${XTCDIR}/bin/i686-w64-mingw32-widl -V | grep 'version' | cut -d' ' -f5)"
|
|
||||||
echo "Wine Message Compiler Version: $(${XTCDIR}/bin/wmc -V | grep 'version' | cut -d' ' -f5)"
|
|
||||||
echo "Wine Resource Compiler Version: $(${XTCDIR}/bin/wrc --version | grep 'version' | cut -d' ' -f5)"
|
|
||||||
echo
|
|
||||||
charch ${TARGET:-amd64}
|
|
||||||
chbuild ${BUILD_TYPE:-DEBUG}
|
|
||||||
echo
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
export -f version
|
|
||||||
|
|
||||||
# Builds application (wrapper to Ninja)
|
|
||||||
xbuild()
|
|
||||||
{
|
|
||||||
if [ ! -f build.arch ]; then
|
|
||||||
ninja "$@"
|
|
||||||
else
|
|
||||||
ARCH=$(cat build.arch)
|
|
||||||
if [ x"${ARCH}" != x"${TARGET}" ]; then
|
|
||||||
echo "Build is configured for '${ARCH}' while current target set to '${TARGET}'!"
|
|
||||||
echo "Cannot continue until conflict is resolved ..."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
ninja "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
export -f xbuild
|
|
@ -1,74 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: XTchain
|
|
||||||
* LICENSE: See COPYING.md in the top level directory
|
|
||||||
* FILE: tools/bin2c.c
|
|
||||||
* DESCRIPTION: Binary to C converter
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "xtchain.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
/* Check for proper number of arguments */
|
|
||||||
if(argc != 4)
|
|
||||||
{
|
|
||||||
printf("Usage: %s <input binary> <output file> <structure name>\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open the input binary file in binary mode */
|
|
||||||
FILE *inputFile = fopen(argv[1], "rb");
|
|
||||||
if(inputFile == NULL)
|
|
||||||
{
|
|
||||||
printf("Error: unable to open file %s\n", argv[1]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open the destination source code file in text mode */
|
|
||||||
FILE *outputFile = fopen(argv[2], "w");
|
|
||||||
if(outputFile == NULL)
|
|
||||||
{
|
|
||||||
printf("Error: unable to open file %s\n", argv[2]);
|
|
||||||
fclose(inputFile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the size of the binary file */
|
|
||||||
fseek(inputFile, 0, SEEK_END);
|
|
||||||
long binSize = ftell(inputFile);
|
|
||||||
rewind(inputFile);
|
|
||||||
|
|
||||||
/* Allocate memory for the binary data */
|
|
||||||
unsigned char *binData = (unsigned char *)malloc(binSize);
|
|
||||||
if(binData == NULL)
|
|
||||||
{
|
|
||||||
printf("Error: unable to allocate memory for binary data\n");
|
|
||||||
fclose(inputFile);
|
|
||||||
fclose(outputFile);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read the binary data into memory */
|
|
||||||
fread(binData, sizeof(unsigned char), binSize, inputFile);
|
|
||||||
|
|
||||||
/* Write the C structure to the header file */
|
|
||||||
fprintf(outputFile, "unsigned char %s[] = {", argv[3]);
|
|
||||||
for(int i = 0; i < binSize; i++)
|
|
||||||
{
|
|
||||||
fprintf(outputFile, "0x%02X", binData[i]);
|
|
||||||
if(i < binSize - 1)
|
|
||||||
{
|
|
||||||
fprintf(outputFile, ",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf(outputFile, "};\nunsigned int %s_size = %ld;\n", argv[3], binSize);
|
|
||||||
free(binData);
|
|
||||||
|
|
||||||
/* Close all open files */
|
|
||||||
fclose(inputFile);
|
|
||||||
fclose(outputFile);
|
|
||||||
|
|
||||||
printf("Binary data converted to C structure successfully.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
182
tools/exetool.c
182
tools/exetool.c
@ -1,182 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: XTchain
|
|
||||||
* LICENSE: See COPYING.md in the top level directory
|
|
||||||
* FILE: tools/exetool.c
|
|
||||||
* DESCRIPTION: Portable Executable (PE) utility for changing its signature and subsystem
|
|
||||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "xtchain.h"
|
|
||||||
|
|
||||||
typedef struct _PE_SUBSYSTEM
|
|
||||||
{
|
|
||||||
int Identifier;
|
|
||||||
char *Name;
|
|
||||||
} PE_SUBSYSTEM, *PPE_SUBSYSTEM;
|
|
||||||
|
|
||||||
static PE_SUBSYSTEM SubSystems[] = {
|
|
||||||
{0x00, "INVALID_SUBSYSTEM"},
|
|
||||||
{0x01, "NT_NATIVE"},
|
|
||||||
{0x02, "WINDOWS_GUI"},
|
|
||||||
{0x03, "WINDOWS_CLI"},
|
|
||||||
{0x04, "WINDOWS_CE_OLD"},
|
|
||||||
{0x05, "OS2_CUI"},
|
|
||||||
{0x07, "POSIX_CUI"},
|
|
||||||
{0x08, "NATIVE_WINDOWS"},
|
|
||||||
{0x09, "WINDOWS_CE_GUI"},
|
|
||||||
{0x0A, "EFI_APPLICATION"},
|
|
||||||
{0x0B, "EFI_BOOT_SERVICE_DRIVER"},
|
|
||||||
{0x0C, "EFI_RUNTIME_DRIVER"},
|
|
||||||
{0x0D, "EFI_ROM"},
|
|
||||||
{0x0E, "XBOX"},
|
|
||||||
{0x10, "WINDOWS_BOOT_APPLICATION"},
|
|
||||||
{0x14, "XT_NATIVE_KERNEL"},
|
|
||||||
{0x15, "XT_NATIVE_APPLICATION"},
|
|
||||||
{0x16, "XT_NATIVE_DRIVER"},
|
|
||||||
{0x17, "XT_DYNAMIC_LIBRARY"},
|
|
||||||
{0x18, "XT_APPLICATION_CLI"},
|
|
||||||
{0x19, "XT_APPLICATION_GDI"}
|
|
||||||
};
|
|
||||||
|
|
||||||
PPE_SUBSYSTEM getSubSystem(char *Name)
|
|
||||||
{
|
|
||||||
int Index;
|
|
||||||
int SubSystemsCount;
|
|
||||||
PPE_SUBSYSTEM SubSystem;
|
|
||||||
|
|
||||||
/* Count number of subsystems avaialble */
|
|
||||||
SubSystemsCount = sizeof(SubSystems) / sizeof(PE_SUBSYSTEM);
|
|
||||||
|
|
||||||
/* Find subsystem */
|
|
||||||
for(Index = 0; Index < SubSystemsCount; Index++)
|
|
||||||
{
|
|
||||||
SubSystem = &SubSystems[Index];
|
|
||||||
if(strcasecmp(SubSystem->Name, Name) == 0)
|
|
||||||
{
|
|
||||||
/* Subsystem found, return its ID */
|
|
||||||
return SubSystem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No valid subsystem found */
|
|
||||||
return &SubSystems[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
char *getSubSystemName(int Identifier)
|
|
||||||
{
|
|
||||||
int Index;
|
|
||||||
int SubSystemsCount;
|
|
||||||
PPE_SUBSYSTEM SubSystem;
|
|
||||||
|
|
||||||
/* Count number of subsystems avaialble */
|
|
||||||
SubSystemsCount = sizeof(SubSystems) / sizeof(PE_SUBSYSTEM);
|
|
||||||
|
|
||||||
/* Find subsystem */
|
|
||||||
for(Index = 0; Index < SubSystemsCount; Index++)
|
|
||||||
{
|
|
||||||
SubSystem = &SubSystems[Index];
|
|
||||||
if(SubSystem->Identifier == Identifier)
|
|
||||||
{
|
|
||||||
/* Subsystem found, return its ID */
|
|
||||||
return SubSystem->Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No valid subsystem found */
|
|
||||||
return SubSystems[0].Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
FILE *ExeFile;
|
|
||||||
unsigned char Signature[4];
|
|
||||||
unsigned int HeaderOffset;
|
|
||||||
unsigned int ImageSignature;
|
|
||||||
unsigned short SubSystem;
|
|
||||||
PPE_SUBSYSTEM NewSubSystem;
|
|
||||||
|
|
||||||
/* Check for proper number of arguments */
|
|
||||||
if(argc != 3)
|
|
||||||
{
|
|
||||||
printf("Usage: %s <filename> <new SubSystem>\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse the new SubSystem value from the command line argument */
|
|
||||||
NewSubSystem = getSubSystem(argv[2]);
|
|
||||||
if(NewSubSystem->Identifier == 0)
|
|
||||||
{
|
|
||||||
/* Invalid SubSystem provided */
|
|
||||||
printf("Error: %s is not a valid PE SubSystem\n", argv[2]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Open the EXE file in binary mode */
|
|
||||||
ExeFile = fopen(argv[1], "r+b");
|
|
||||||
if(ExeFile == NULL)
|
|
||||||
{
|
|
||||||
/* Failed to open PE file */
|
|
||||||
printf("ERROR: Unable to open file %s\n", argv[1]);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Verify that the input file has a valid DOS header */
|
|
||||||
fread(Signature, sizeof(unsigned char), 4, ExeFile);
|
|
||||||
if(Signature[0] != 'M' || Signature[1] != 'Z')
|
|
||||||
{
|
|
||||||
/* Invalid DOS header */
|
|
||||||
printf("ERROR: %s is not a valid EXE file\n", argv[1]);
|
|
||||||
fclose(ExeFile);
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Verify that the input file has a valid PE header */
|
|
||||||
fseek(ExeFile, 0x3C, SEEK_SET);
|
|
||||||
fread(&HeaderOffset, sizeof(unsigned int), 1, ExeFile);
|
|
||||||
fseek(ExeFile, HeaderOffset, SEEK_SET);
|
|
||||||
fread(Signature, sizeof(unsigned char), 4, ExeFile);
|
|
||||||
if((Signature[0] != 'P' || Signature[1] != 'E' || Signature[2] != 0 || Signature[3] != 0) &&
|
|
||||||
(Signature[0] != 'P' || Signature[1] != 'E' || Signature[2] != 'X' || Signature[3] != 'T'))
|
|
||||||
{
|
|
||||||
/* Invalid PE header */
|
|
||||||
printf("Error: %s is not a valid PE file\n", argv[1]);
|
|
||||||
fclose(ExeFile);
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if setting XT subsystem */
|
|
||||||
if(NewSubSystem->Identifier >= 0x14 && NewSubSystem->Identifier <= 0x19)
|
|
||||||
{
|
|
||||||
/* Write PEXT signature */
|
|
||||||
ImageSignature = 0x54584550;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Write PE00 signature */
|
|
||||||
ImageSignature = 0x00004550;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Seek back to header offset and write new signature */
|
|
||||||
fseek(ExeFile, HeaderOffset, SEEK_SET);
|
|
||||||
fwrite(&ImageSignature, sizeof(ImageSignature), 1, ExeFile);
|
|
||||||
|
|
||||||
/* Seek to the offset of the SubSystem field in the optional header */
|
|
||||||
fseek(ExeFile, HeaderOffset + 0x5C, SEEK_SET);
|
|
||||||
|
|
||||||
/* Read the current SubSystem value */
|
|
||||||
fread(&SubSystem, sizeof(unsigned short), 1, ExeFile);
|
|
||||||
|
|
||||||
/* Seek back to the SubSystem field in the optional header */
|
|
||||||
fseek(ExeFile, -sizeof(unsigned short), SEEK_CUR);
|
|
||||||
|
|
||||||
/* Write the new SubSystem value */
|
|
||||||
fwrite(&NewSubSystem->Identifier, sizeof(unsigned short), 1, ExeFile);
|
|
||||||
|
|
||||||
/* Close the file */
|
|
||||||
fclose(ExeFile);
|
|
||||||
|
|
||||||
/* Finished successfully */
|
|
||||||
printf("PE SubSystem modified: 0x%02X <%s> to 0x%02X <%s>\n",
|
|
||||||
SubSystem, getSubSystemName(SubSystem), NewSubSystem->Identifier, NewSubSystem->Name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
558
tools/windres.c
558
tools/windres.c
@ -1,558 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: XTchain
|
|
||||||
* LICENSE: See COPYING.md in the top level directory
|
|
||||||
* FILE: tools/windres.c
|
|
||||||
* DESCRIPTION: WINDRES compatible interface to LLVM
|
|
||||||
* DEVELOPERS: Josh de Kock <josh@itanimul.li>
|
|
||||||
* Martin Storsjo <martin@martin.st>
|
|
||||||
* Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "xtchain.h"
|
|
||||||
|
|
||||||
#define WINDRES_VERSION "1.0"
|
|
||||||
|
|
||||||
#ifndef DEFAULT_TARGET
|
|
||||||
#define DEFAULT_TARGET "x86_64-w64-mingw32"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#define _tspawnvp_escape _spawnvp
|
|
||||||
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#define _P_WAIT 0
|
|
||||||
|
|
||||||
static
|
|
||||||
int
|
|
||||||
_spawnvp(int mode,
|
|
||||||
const char *filename,
|
|
||||||
const char * const *argv)
|
|
||||||
{
|
|
||||||
pid_t pid;
|
|
||||||
|
|
||||||
if(!(pid = fork()))
|
|
||||||
{
|
|
||||||
execvp(filename, (char **) argv);
|
|
||||||
perror(filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int stat = 0;
|
|
||||||
|
|
||||||
if(waitpid(pid, &stat, 0) == -1)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(WIFEXITED(stat))
|
|
||||||
{
|
|
||||||
return WEXITSTATUS(stat);
|
|
||||||
}
|
|
||||||
errno = EIO;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
const
|
|
||||||
char *unescape_cpp(const char *str)
|
|
||||||
{
|
|
||||||
char *out = strdup(str);
|
|
||||||
int len = strlen(str);
|
|
||||||
int i, outpos = 0;
|
|
||||||
|
|
||||||
for(i = 0; i < len - 1; i++)
|
|
||||||
{
|
|
||||||
if(str[i] == '\\' && str[i + 1] == '"')
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
out[outpos++] = str[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
while(i < len)
|
|
||||||
{
|
|
||||||
out[outpos++] = str[i++];
|
|
||||||
}
|
|
||||||
|
|
||||||
out[outpos++] = '\0';
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void print_version(void)
|
|
||||||
{
|
|
||||||
printf("XTchain windres (GNU windres compatible) %s\n", WINDRES_VERSION);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void print_help(void)
|
|
||||||
{
|
|
||||||
printf(
|
|
||||||
"usage: llvm-windres <OPTION> [INPUT-FILE] [OUTPUT-FILE]\n"
|
|
||||||
"\n"
|
|
||||||
"LLVM Tool to manipulate Windows resources with a GNU windres interface.\n"
|
|
||||||
"\n"
|
|
||||||
"Options:\n"
|
|
||||||
" -i, --input <arg> Name of the input file.\n"
|
|
||||||
" -o, --output <arg> Name of the output file.\n"
|
|
||||||
" -J, --input-format <arg> Input format to read.\n"
|
|
||||||
" -O, --output-format <arg> Output format to generate.\n"
|
|
||||||
" --preprocessor <arg> Custom preprocessor command.\n"
|
|
||||||
" --preprocessor-arg <arg> Preprocessor command arguments.\n"
|
|
||||||
" -F, --target <arg> Target for COFF objects to be compiled for.\n"
|
|
||||||
" -I, --include-dir <arg> Include directory to pass to preprocessor and resource compiler.\n"
|
|
||||||
" -D, --define <arg[=val]> Define to pass to preprocessor.\n"
|
|
||||||
" -U, --undefine <arg[=val]> Undefine to pass to preprocessor.\n"
|
|
||||||
" -c, --codepage <arg> Default codepage to use when reading an rc file (0x0-0xffff).\n"
|
|
||||||
" -l, --language <arg> Specify default language (0x0-0xffff).\n"
|
|
||||||
" --use-temp-file Use a temporary file for the preprocessing output.\n"
|
|
||||||
" -v, --verbose Enable verbose output.\n"
|
|
||||||
" -V, --version Display version.\n"
|
|
||||||
" -h, --help Display this message and exit.\n"
|
|
||||||
"Input Formats:\n"
|
|
||||||
" rc Text Windows Resource\n"
|
|
||||||
" res Binary Windows Resource\n"
|
|
||||||
"Output Formats:\n"
|
|
||||||
" res Binary Windows Resource\n"
|
|
||||||
" coff COFF object\n"
|
|
||||||
"Targets:\n"
|
|
||||||
" pe-x86-64\n"
|
|
||||||
" pei-x86-64\n"
|
|
||||||
" pe-i386\n"
|
|
||||||
" pei-i386\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void error(const char *basename,
|
|
||||||
const char *fmt,
|
|
||||||
...)
|
|
||||||
{
|
|
||||||
fprintf(stderr, _T(TS": error: "), basename);
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vfprintf(stderr, fmt, ap);
|
|
||||||
fprintf(stderr, _T("\n"));
|
|
||||||
va_end(ap);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void print_argv(const char **exec_argv)
|
|
||||||
{
|
|
||||||
while(*exec_argv)
|
|
||||||
{
|
|
||||||
fprintf(stderr, _T(TS" "), *exec_argv);
|
|
||||||
exec_argv++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, _T("\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
void check_num_args(int arg,
|
|
||||||
int max_arg)
|
|
||||||
{
|
|
||||||
if(arg > max_arg)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Too many options added\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc,
|
|
||||||
char* argv[])
|
|
||||||
{
|
|
||||||
char *dir;
|
|
||||||
char *basename;
|
|
||||||
char *target;
|
|
||||||
|
|
||||||
split_argv(argv[0], &dir, &basename, &target, NULL);
|
|
||||||
|
|
||||||
if (!target)
|
|
||||||
target = _T(DEFAULT_TARGET);
|
|
||||||
|
|
||||||
const char *bfd_target = NULL;
|
|
||||||
const char *input = _T("-");
|
|
||||||
const char *output = _T("/dev/stdout");
|
|
||||||
const char *input_format = _T("rc");
|
|
||||||
const char *output_format = _T("coff");
|
|
||||||
const char **includes = malloc(argc * sizeof(*includes));
|
|
||||||
int nb_includes = 0;
|
|
||||||
const char *codepage = _T("1252");
|
|
||||||
const char *language = NULL;
|
|
||||||
const char **cpp_options = malloc(argc * sizeof(*cpp_options));
|
|
||||||
int nb_cpp_options = 0;
|
|
||||||
int verbose = 0;
|
|
||||||
|
|
||||||
#define _tcslen_const(a) (sizeof(a)/sizeof(char) - 1)
|
|
||||||
|
|
||||||
#define _tcsstart(a, b) !strncmp(a, b, _tcslen_const(b))
|
|
||||||
|
|
||||||
#define IF_MATCH_EITHER(short, long) \
|
|
||||||
if(!strcmp(argv[i], _T(short)) || !strcmp(argv[i], _T(long)))
|
|
||||||
|
|
||||||
#define IF_MATCH_THREE(first, second, third) \
|
|
||||||
if(!strcmp(argv[i], _T(first)) || !strcmp(argv[i], _T(second)) || !strcmp(argv[i], _T(third)))
|
|
||||||
|
|
||||||
#define OPTION(short, long, var) \
|
|
||||||
if(_tcsstart(argv[i], _T(short)) && argv[i][_tcslen_const(_T(short))]) { \
|
|
||||||
var = argv[i] + _tcslen_const(_T(short)); \
|
|
||||||
} else if(_tcsstart(argv[i], _T(long "="))) { \
|
|
||||||
var = strchr(argv[i], '=') + 1; \
|
|
||||||
} else IF_MATCH_EITHER(short, long) { \
|
|
||||||
if(i + 1 < argc) \
|
|
||||||
var = argv[++i]; \
|
|
||||||
else \
|
|
||||||
error(basename, _T(TS" missing argument"), argv[i]); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SEPARATE_ARG(var) do { \
|
|
||||||
if(i + 1 < argc) \
|
|
||||||
var = argv[++i]; \
|
|
||||||
else \
|
|
||||||
error(basename, _T(TS" missing argument"), argv[i]); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define SEPARATE_ARG_PREFIX(var, prefix) do { \
|
|
||||||
if(i + 1 < argc) \
|
|
||||||
var = concat(_T(prefix), argv[++i]); \
|
|
||||||
else \
|
|
||||||
error(basename, _T(TS" missing argument"), argv[i]); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
for(int i = 1; i < argc; i++)
|
|
||||||
{
|
|
||||||
OPTION("-i", "--input", input)
|
|
||||||
else OPTION("-o", "--output", output)
|
|
||||||
else OPTION("-J", "--input-format", input_format)
|
|
||||||
else OPTION("-O", "--output-format", output_format)
|
|
||||||
else OPTION("-F", "--target", bfd_target)
|
|
||||||
else IF_MATCH_THREE("-I", "--include-dir", "--include") {
|
|
||||||
SEPARATE_ARG(includes[nb_includes++]);
|
|
||||||
}
|
|
||||||
else if(_tcsstart(argv[i], _T("--include-dir=")) ||
|
|
||||||
_tcsstart(argv[i], _T("--include=")))
|
|
||||||
{
|
|
||||||
includes[nb_includes++] = strchr(argv[i], '=') + 1;
|
|
||||||
}
|
|
||||||
else if(_tcsstart(argv[i], _T("-I")))
|
|
||||||
{
|
|
||||||
includes[nb_includes++] = argv[i] + 2;
|
|
||||||
}
|
|
||||||
else OPTION("-c", "--codepage", codepage)
|
|
||||||
else OPTION("-l", "--language", language)
|
|
||||||
else if(!strcmp(argv[i], _T("--preprocessor")))
|
|
||||||
{
|
|
||||||
error(basename, _T("ENOSYS"));
|
|
||||||
}
|
|
||||||
else if(_tcsstart(argv[i], _T("--preprocessor-arg=")))
|
|
||||||
{
|
|
||||||
cpp_options[nb_cpp_options++] = strchr(argv[i], '=') + 1;
|
|
||||||
}
|
|
||||||
else if(!strcmp(argv[i], _T("--preprocessor-arg")))
|
|
||||||
{
|
|
||||||
SEPARATE_ARG(cpp_options[nb_cpp_options++]);
|
|
||||||
}
|
|
||||||
else IF_MATCH_EITHER("-D", "--define")
|
|
||||||
{
|
|
||||||
SEPARATE_ARG_PREFIX(cpp_options[nb_cpp_options++], "-D");
|
|
||||||
}
|
|
||||||
else if(_tcsstart(argv[i], _T("-D")))
|
|
||||||
{
|
|
||||||
cpp_options[nb_cpp_options++] = argv[i];
|
|
||||||
}
|
|
||||||
else IF_MATCH_EITHER("-U", "--undefine")
|
|
||||||
{
|
|
||||||
SEPARATE_ARG_PREFIX(cpp_options[nb_cpp_options++], "-U");
|
|
||||||
}
|
|
||||||
else if(_tcsstart(argv[i], _T("-U")))
|
|
||||||
{
|
|
||||||
cpp_options[nb_cpp_options++] = argv[i];
|
|
||||||
}
|
|
||||||
else IF_MATCH_EITHER("-v", "--verbose")
|
|
||||||
{
|
|
||||||
verbose = 1;
|
|
||||||
}
|
|
||||||
else IF_MATCH_EITHER("-V", "--version")
|
|
||||||
{
|
|
||||||
print_version();
|
|
||||||
}
|
|
||||||
else IF_MATCH_EITHER("-h", "--help")
|
|
||||||
{
|
|
||||||
print_help();
|
|
||||||
}
|
|
||||||
else if(!strcmp(argv[i], _T("--use-temp-file")))
|
|
||||||
{
|
|
||||||
// No-op, we use a temp file by default.
|
|
||||||
}
|
|
||||||
else if(_tcsstart(argv[i], _T("-")))
|
|
||||||
{
|
|
||||||
error(basename, _T("unrecognized option: `"TS"'"), argv[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(!strcmp(input, _T("-")))
|
|
||||||
{
|
|
||||||
input = argv[i];
|
|
||||||
}
|
|
||||||
else if(!strcmp(output, _T("/dev/stdout")))
|
|
||||||
{
|
|
||||||
output = argv[i];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
error(basename, _T("rip: `"TS"'"), argv[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(bfd_target)
|
|
||||||
{
|
|
||||||
if(!strcmp(bfd_target, _T("pe-x86-64")) ||
|
|
||||||
!strcmp(bfd_target, _T("pei-x86-64")))
|
|
||||||
{
|
|
||||||
target = _T("x86_64-w64-mingw32");
|
|
||||||
}
|
|
||||||
else if(!strcmp(bfd_target, _T("pe-i386")) ||
|
|
||||||
!strcmp(bfd_target, _T("pei-i386")))
|
|
||||||
{
|
|
||||||
target = _T("i686-w64-mingw32");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
error(basename, _T("unsupported target: `"TS"'"), bfd_target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char *arch = strdup(target);
|
|
||||||
char *dash = strchr(arch, '-');
|
|
||||||
if(dash)
|
|
||||||
{
|
|
||||||
*dash = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *machine = _T("unknown");
|
|
||||||
|
|
||||||
if(!strcmp(arch, _T("i686")))
|
|
||||||
{
|
|
||||||
machine = _T("X86");
|
|
||||||
}
|
|
||||||
else if(!strcmp(arch, _T("x86_64")))
|
|
||||||
{
|
|
||||||
machine = _T("X64");
|
|
||||||
}
|
|
||||||
else if(!strcmp(arch, _T("armv7")))
|
|
||||||
{
|
|
||||||
machine = _T("ARM");
|
|
||||||
}
|
|
||||||
else if(!strcmp(arch, _T("aarch64")))
|
|
||||||
{
|
|
||||||
machine = _T("ARM64");
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *CC = concat(target, _T("-clang"));
|
|
||||||
const char **rc_options = malloc(2 * argc * sizeof(*cpp_options));
|
|
||||||
int nb_rc_options = 0;
|
|
||||||
|
|
||||||
for(int i = 0; i < nb_includes; i++)
|
|
||||||
{
|
|
||||||
cpp_options[nb_cpp_options++] = concat(_T("-I"), includes[i]);
|
|
||||||
rc_options[nb_rc_options++] = _T("-I");
|
|
||||||
rc_options[nb_rc_options++] = includes[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = 0; i < nb_cpp_options; i++)
|
|
||||||
{
|
|
||||||
cpp_options[i] = unescape_cpp(cpp_options[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *preproc_rc = concat(output, _T(".preproc.rc"));
|
|
||||||
const char *res = concat(output, _T(".out.res"));
|
|
||||||
|
|
||||||
char *inputdir = strdup(input);
|
|
||||||
{
|
|
||||||
char *sep = _tcsrchrs(inputdir, '/', '\\');
|
|
||||||
if(sep)
|
|
||||||
{
|
|
||||||
*sep = '\0';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
inputdir = strdup(_T("."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int max_arg = 2 * argc + 20;
|
|
||||||
const char **exec_argv = malloc((max_arg + 1) * sizeof(*exec_argv));
|
|
||||||
int arg = 0;
|
|
||||||
|
|
||||||
if(!_tcsicmp(input_format, _T("rc")))
|
|
||||||
{
|
|
||||||
exec_argv[arg++] = concat(dir, CC);
|
|
||||||
exec_argv[arg++] = _T("-E");
|
|
||||||
|
|
||||||
for(int i = 0; i < nb_cpp_options; i++)
|
|
||||||
{
|
|
||||||
exec_argv[arg++] = cpp_options[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
exec_argv[arg++] = _T("-xc");
|
|
||||||
exec_argv[arg++] = _T("-DRC_INVOKED=1");
|
|
||||||
exec_argv[arg++] = input;
|
|
||||||
exec_argv[arg++] = _T("-o");
|
|
||||||
exec_argv[arg++] = preproc_rc;
|
|
||||||
exec_argv[arg] = NULL;
|
|
||||||
|
|
||||||
check_num_args(arg, max_arg);
|
|
||||||
|
|
||||||
if(verbose)
|
|
||||||
{
|
|
||||||
print_argv(exec_argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = _tspawnvp_escape(_P_WAIT, exec_argv[0], exec_argv);
|
|
||||||
|
|
||||||
if(ret == -1)
|
|
||||||
{
|
|
||||||
perror(exec_argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ret != 0)
|
|
||||||
{
|
|
||||||
error(basename, _T("preprocessor failed"));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
arg = 0;
|
|
||||||
exec_argv[arg++] = concat(dir, _T("llvm-rc"));
|
|
||||||
|
|
||||||
for(int i = 0; i < nb_rc_options; i++)
|
|
||||||
{
|
|
||||||
exec_argv[arg++] = rc_options[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
exec_argv[arg++] = _T("-I");
|
|
||||||
exec_argv[arg++] = inputdir;
|
|
||||||
exec_argv[arg++] = preproc_rc;
|
|
||||||
exec_argv[arg++] = _T("-c");
|
|
||||||
exec_argv[arg++] = codepage;
|
|
||||||
|
|
||||||
if(language)
|
|
||||||
{
|
|
||||||
exec_argv[arg++] = _T("-l");
|
|
||||||
exec_argv[arg++] = language;
|
|
||||||
}
|
|
||||||
|
|
||||||
exec_argv[arg++] = _T("-fo");
|
|
||||||
|
|
||||||
if(!_tcsicmp(output_format, _T("res")))
|
|
||||||
{
|
|
||||||
exec_argv[arg++] = output;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
exec_argv[arg++] = res;
|
|
||||||
}
|
|
||||||
|
|
||||||
exec_argv[arg] = NULL;
|
|
||||||
check_num_args(arg, max_arg);
|
|
||||||
|
|
||||||
if(verbose)
|
|
||||||
{
|
|
||||||
print_argv(exec_argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = _tspawnvp_escape(_P_WAIT, exec_argv[0], exec_argv);
|
|
||||||
|
|
||||||
if(ret == -1)
|
|
||||||
{
|
|
||||||
perror(exec_argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ret != 0)
|
|
||||||
{
|
|
||||||
error(basename, _T("llvm-rc failed"));
|
|
||||||
if(!verbose)
|
|
||||||
{
|
|
||||||
unlink(preproc_rc);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!_tcsicmp(output_format, _T("res")))
|
|
||||||
{
|
|
||||||
// All done
|
|
||||||
}
|
|
||||||
else if(!_tcsicmp(output_format, _T("coff")))
|
|
||||||
{
|
|
||||||
arg = 0;
|
|
||||||
exec_argv[arg++] = concat(dir, _T("llvm-cvtres"));
|
|
||||||
exec_argv[arg++] = res;
|
|
||||||
exec_argv[arg++] = concat(_T("-machine:"), machine);
|
|
||||||
exec_argv[arg++] = concat(_T("-out:"), output);
|
|
||||||
exec_argv[arg] = NULL;
|
|
||||||
|
|
||||||
check_num_args(arg, max_arg);
|
|
||||||
if(verbose)
|
|
||||||
{
|
|
||||||
print_argv(exec_argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = _tspawnvp_escape(_P_WAIT, exec_argv[0], exec_argv);
|
|
||||||
if(ret == -1)
|
|
||||||
{
|
|
||||||
perror(exec_argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!verbose)
|
|
||||||
{
|
|
||||||
unlink(preproc_rc);
|
|
||||||
unlink(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
} else {
|
|
||||||
error(basename, _T("invalid output format: `"TS"'"), output_format);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(!_tcsicmp(input_format, _T("res")))
|
|
||||||
{
|
|
||||||
exec_argv[arg++] = concat(dir, _T("llvm-cvtres"));
|
|
||||||
exec_argv[arg++] = input;
|
|
||||||
exec_argv[arg++] = concat(_T("-machine:"), machine);
|
|
||||||
exec_argv[arg++] = concat(_T("-out:"), output);
|
|
||||||
exec_argv[arg] = NULL;
|
|
||||||
|
|
||||||
check_num_args(arg, max_arg);
|
|
||||||
|
|
||||||
if(verbose)
|
|
||||||
{
|
|
||||||
print_argv(exec_argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = _tspawnvp_escape(_P_WAIT, exec_argv[0], exec_argv);
|
|
||||||
if(ret == -1)
|
|
||||||
{
|
|
||||||
perror(exec_argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
error(basename, _T("invalid input format: `"TS"'"), input_format);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
162
tools/xtchain.h
162
tools/xtchain.h
@ -1,162 +0,0 @@
|
|||||||
/**
|
|
||||||
* PROJECT: XTchain
|
|
||||||
* LICENSE: See COPYING.md in the top level directory
|
|
||||||
* FILE: tools/xtchain.h
|
|
||||||
* DESCRIPTION: Common header for XTchain tools
|
|
||||||
* DEVELOPERS: Martin Storsjo <martin@martin.st>
|
|
||||||
* Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef UNICODE
|
|
||||||
#define _UNICODE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define _T(x) x
|
|
||||||
|
|
||||||
#ifdef _UNICODE
|
|
||||||
#define TS "%ls"
|
|
||||||
#else
|
|
||||||
#define TS "%s"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static
|
|
||||||
inline
|
|
||||||
int
|
|
||||||
_tcsicmp(const char *a,
|
|
||||||
const char *b)
|
|
||||||
{
|
|
||||||
while(*a && tolower(*a) == tolower(*b))
|
|
||||||
{
|
|
||||||
a++;
|
|
||||||
b++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *a - *b;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
inline
|
|
||||||
char *
|
|
||||||
concat(const char *prefix,
|
|
||||||
const char *suffix)
|
|
||||||
{
|
|
||||||
int prefixlen = strlen(prefix);
|
|
||||||
int suffixlen = strlen(suffix);
|
|
||||||
|
|
||||||
char *buf = malloc((prefixlen + suffixlen + 1) * sizeof(*buf));
|
|
||||||
|
|
||||||
strcpy(buf, prefix);
|
|
||||||
strcpy(buf + prefixlen, suffix);
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
inline
|
|
||||||
char *
|
|
||||||
_tcsrchrs(const char *str,
|
|
||||||
char char1,
|
|
||||||
char char2)
|
|
||||||
{
|
|
||||||
char *ptr1 = strrchr(str, char1);
|
|
||||||
char *ptr2 = strrchr(str, char2);
|
|
||||||
|
|
||||||
if(!ptr1)
|
|
||||||
{
|
|
||||||
return ptr2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ptr2)
|
|
||||||
{
|
|
||||||
return ptr1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ptr1 < ptr2)
|
|
||||||
{
|
|
||||||
return ptr2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ptr1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
inline
|
|
||||||
void
|
|
||||||
split_argv(const char *argv0,
|
|
||||||
char **dir_ptr,
|
|
||||||
char **basename_ptr,
|
|
||||||
char **target_ptr,
|
|
||||||
char **exe_ptr)
|
|
||||||
{
|
|
||||||
const char *sep = _tcsrchrs(argv0, '/', '\\');
|
|
||||||
char *dir = strdup(_T(""));
|
|
||||||
const char *basename = argv0;
|
|
||||||
|
|
||||||
if(sep)
|
|
||||||
{
|
|
||||||
dir = strdup(argv0);
|
|
||||||
dir[sep + 1 - argv0] = '\0';
|
|
||||||
basename = sep + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
basename = strdup(basename);
|
|
||||||
char *period = strchr(basename, '.');
|
|
||||||
|
|
||||||
if(period)
|
|
||||||
{
|
|
||||||
*period = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
char *target = strdup(basename);
|
|
||||||
char *dash = strrchr(target, '-');
|
|
||||||
const char *exe = basename;
|
|
||||||
|
|
||||||
if(dash)
|
|
||||||
{
|
|
||||||
*dash = '\0';
|
|
||||||
exe = dash + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
target = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dir_ptr)
|
|
||||||
{
|
|
||||||
*dir_ptr = dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(basename_ptr)
|
|
||||||
{
|
|
||||||
*basename_ptr = basename;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(target_ptr)
|
|
||||||
{
|
|
||||||
*target_ptr = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(exe_ptr)
|
|
||||||
{
|
|
||||||
*exe_ptr = exe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
inline
|
|
||||||
int
|
|
||||||
run_final(const char *executable,
|
|
||||||
const char *const *argv)
|
|
||||||
{
|
|
||||||
execvp(executable, (char **) argv);
|
|
||||||
perror(executable);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
1429
tools/xtcspecc.c
1429
tools/xtcspecc.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user