Skip to content

Commit d431e03

Browse files
authored
Merge pull request #68218 from bnbarham/set-python-encoding
[stdlib] Set PYTHONIOENCODING when building the stdlib
2 parents c08464a + 53c4e8f commit d431e03

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ function(_compile_swift_files
801801
set(swift_compiler_tool "${SWIFT_SOURCE_DIR}/utils/check-incremental" "${swift_compiler_tool}")
802802
endif()
803803

804+
set(custom_env "PYTHONIOENCODING=UTF8")
804805
if(SWIFTFILE_IS_STDLIB OR
805806
# Linux "hosttools" build require builder's runtime before building the runtime.
806807
(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" AND SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD")
@@ -811,13 +812,13 @@ function(_compile_swift_files
811812
# to pick up the stdlib from the previous bootstrapping stage, because the
812813
# stdlib in the current stage is not built yet.
813814
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
814-
set(set_environment_args "${CMAKE_COMMAND}" "-E" "env" "DYLD_LIBRARY_PATH=${bs_lib_dir}")
815+
list(APPEND custom_env "DYLD_LIBRARY_PATH=${bs_lib_dir}")
815816
elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD")
816-
set(set_environment_args "${CMAKE_COMMAND}" "-E" "env" "LD_LIBRARY_PATH=${bs_lib_dir}")
817+
list(APPEND custom_env "LD_LIBRARY_PATH=${bs_lib_dir}")
817818
endif()
818819
endif()
819-
820820
endif()
821+
set(set_environment_args "${CMAKE_COMMAND}" "-E" "env" "${custom_env}")
821822

822823
if (SWIFT_REPORT_STATISTICS)
823824
list(GET dirs_to_create 0 first_obj_dir)

test/ScanDependencies/unicode_filename.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %target-swift-frontend -scan-dependencies %/s %/S/Inputs/unicode_filёnamё.swift -o %t/deps.json
33

44
// Check the contents of the JSON output
5-
// RUN: env PYTHONIOENCODING=UTF-8 %validate-json < %t/deps.json
5+
// RUN: %validate-json < %t/deps.json
66
// RUN: %FileCheck %s < %t/deps.json
77

88
public func bar() {
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// REQUIRES: rdar92613094
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
23

34
// RUN: %{python} %utils/line-directive
4-
// RUN: %{python} %utils/line-directive -- %{python} -c "print('你好')"
5+
// RUN: %{python} %utils/line-directive -- %{python} %t/unicode.py
6+
7+
//--- unicode.py
8+
print('你好')

0 commit comments

Comments
 (0)