Commit Graph

6 Commits

Author SHA1 Message Date
Alastair Houghton
ca771c4d1d Change to returning nullptr rather than triggering a fatal error.
Instead of triggering a fatal error on failure, return `nullptr` and
let the caller decide what to do about it.  The CommandLine code should
trigger a fatal error, of course.

rdar://103397975
2022-12-21 11:44:37 +00:00
Alastair Houghton
a31b1c54fa Centralise code to map between UTF-8 and UTF-16 on Windows.
In various places we need to call the Windows API, and because Swift uses UTF-8
for its string representation, we can’t call the ANSI API functions (because the
code page used for the ANSI functions varies depending on the system locale
setting). Instead, we need to use the wide character APIs.

This means that we need to convert UTF-8 to wide character and vice-versa in
various places in the runtime.

rdar://103397975
2022-12-21 11:44:35 +00:00
Egor Zhdan
84a1ffcb33 [Shims] Include SwiftShims headers without ../
This replaces a number of `#include`-s like this:
```
#include "../../../stdlib/public/SwiftShims/Visibility.h"
```
with this:
```
#include "swift/shims/Visibility.h"
```

This is needed to allow SwiftCompilerSources to use C++ headers which include SwiftShims headers. Currently trying to do that results in errors:
```
swift/swift/include/swift/Demangling/../../../stdlib/public/SwiftShims/module.modulemap:1:8: error: redefinition of module 'SwiftShims'
module SwiftShims {
       ^
Builds.noindex/swift/swift/bootstrapping0/lib/swift/shims/module.modulemap:1:8: note: previously defined here
module SwiftShims {
       ^
```
This happens because the headers in both the source dir and the build dir refer to SwiftShims headers by relative path, and both the source root and the build root contain SwiftShims headers (which are equivalent, but since they are located in different dirs, Clang treats them as different modules).
2022-09-14 11:14:50 +01:00
Jonathan Grynspan
7836f25fbb Refactor _swift_stdlib_getUnsafeArgvArgc() to make it easier to add new platform support 2022-04-27 11:53:53 -04:00
Jonathan Grynspan
7b630b3b17 Fix some build issues on Windows 2022-04-25 18:50:42 -04:00
Kuba (Brecka) Mracek
7538949859 Split out CommandLine enum into a separate static library, allow removing it from stdlib (#39591)
This is for the 'freestanding' build to stop assuming the platform has argc/argv.

- Introduce a new sub-library, libswiftCommandLineSupport.a
- Move stubs/CommandLine.cpp into this library
- Conditionally embed it into libswiftCore
- Conditionally embed it into libswiftPrivateLibcExtras if not in libswiftCore to support testing
- Add SWIFT_STDLIB_HAS_COMMANDLINE CMake (and build-script) flag
2021-10-13 07:02:43 -07:00