Skip to content

Commit

Permalink
[mono][NativeAOT] System.Globalization.Native build improvements (#82393
Browse files Browse the repository at this point in the history
)

Fixes #82389

- Fixes build of System.Globalization.Native for iOS-like, browser, and wasi platforms
- Removes ICU shim from static builds of Mono runtime and builds it as part of libs.native subset
- Switches browser/wasi to use the static libraries

Co-authored-by: Alexander Köplinger <[email protected]>
  • Loading branch information
filipnavara and akoeplinger authored Apr 25, 2023
1 parent 21001dc commit 0fc8978
Show file tree
Hide file tree
Showing 21 changed files with 116 additions and 35 deletions.
1 change: 1 addition & 0 deletions eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
<ExcludeNativeLibrariesRuntimeFiles Condition="'$(IncludeOOBLibraries)' != 'true'"
Include="$(LibrariesNativeArtifactsPath)libSystem.IO.Ports.Native.*" />
<LibrariesRuntimeFiles Include="
$(LibrariesNativeArtifactsPath)*.dat;
$(LibrariesNativeArtifactsPath)*.dll;
$(LibrariesNativeArtifactsPath)*.dylib;
$(LibrariesNativeArtifactsPath)*.a;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ The .NET Foundation licenses this file to you under the MIT license.

<ItemGroup>
<NetCoreAppNativeLibrary Include="System.Native" />
<!-- FIXME: The library is currently not available for iOS-like platforms -->
<NetCoreAppNativeLibrary Include="System.Globalization.Native" Condition="'$(StaticICULinking)' != 'true' and '$(_IsiOSLikePlatform)' != 'true'" />
<NetCoreAppNativeLibrary Include="System.Globalization.Native" Condition="'$(StaticICULinking)' != 'true'" />
<NetCoreAppNativeLibrary Include="System.IO.Compression.Native" />
<NetCoreAppNativeLibrary Include="System.Net.Security.Native" />
<NetCoreAppNativeLibrary Include="System.Security.Cryptography.Native.Apple" Condition="'$(_IsApplePlatform)' == 'true'" />
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

<PropertyGroup>
<NativeBuildPartitionPropertiesToRemove>ClrFullNativeBuild;ClrRuntimeSubset;ClrJitSubset;ClrPalTestsSubset;ClrAllJitsSubset;ClrILToolsSubset;ClrNativeAotSubset;ClrSpmiSubset;ClrCrossComponentsSubset;HostArchitecture;PgoInstrument;NativeOptimizationDataSupported;CMakeArgs</NativeBuildPartitionPropertiesToRemove>
<_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native</_IcuDir>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="runtime-prereqs.proj" GlobalPropertiesToRemove="$(NativeBuildPartitionPropertiesToRemove)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetsAppleMobile)' == 'true'">
<PackageReference Include="Microsoft.NETCore.Runtime.ICU.Transport" PrivateAssets="all" Version="$(MicrosoftNETCoreRuntimeICUTransportVersion)" GeneratePathProperty="true" />
</ItemGroup>

<Import Project="$(RepositoryEngineeringDir)nativepgo.targets" />

<Target Name="BuildRuntime"
Expand Down Expand Up @@ -52,6 +57,10 @@
<_CoreClrBuildArg Condition="'$(ClrCrossComponentsSubset)' == 'true'" Include="-component crosscomponents" />
</ItemGroup>

<ItemGroup Condition="'$(TargetsAppleMobile)' == 'true'">
<_CoreClrBuildArg Include="-cmakeargs -DCMAKE_ICU_DIR=&quot;$(_IcuDir)&quot;" />
</ItemGroup>

<PropertyGroup>
<_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">build-runtime.cmd</_CoreClrBuildScript>
<_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">build-runtime.sh</_CoreClrBuildScript>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<PlatformManifestFileEntry Include="System.Private.Xml.dll" />
<PlatformManifestFileEntry Include="System.Private.Xml.Linq.dll" />
<!-- Native libraries -->
<PlatformManifestFileEntry Include="libSystem.Globalization.Native.a" IsNative="true" />
<PlatformManifestFileEntry Include="libSystem.Globalization.Native.dylib" IsNative="true" />
<PlatformManifestFileEntry Include="libSystem.Globalization.Native.so" IsNative="true" />
<PlatformManifestFileEntry Include="libSystem.IO.Compression.Native.a" IsNative="true" />
Expand Down
1 change: 1 addition & 0 deletions src/libraries/native-binplace.proj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<BinPlaceItem Include="$(NativeBinDir)*.dwarf" />
<BinPlaceItem Include="$(NativeBinDir)*.dex" />
<BinPlaceItem Include="$(NativeBinDir)*.jar" />
<BinPlaceItem Include="$(NativeBinDir)*.dat" />
<FileWrites Include="@(BinPlaceItem)" />
</ItemGroup>
</Target>
Expand Down
12 changes: 0 additions & 12 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,6 @@
<_MonoRuntimeFilePath>$(MonoObjDir)out\lib\$(MonoFileName)</_MonoRuntimeFilePath>
<_MonoRuntimeStaticFilePath Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(MonoObjDir)out\lib\$(MonoStaticLibFileName)</_MonoRuntimeStaticFilePath>
<_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">true</_MonoIncludeInterpStaticFiles>
<_MonoIncludeIcuFiles Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">true</_MonoIncludeIcuFiles>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildMonoAOTCrossCompiler)' == 'true'">
<_MonoAotCrossFilePath>$(MonoObjCrossDir)out\bin\$(MonoAotCrossFileName)</_MonoAotCrossFilePath>
Expand Down Expand Up @@ -1039,19 +1038,8 @@
<_MonoICorDebugArtifacts Condition="'$(MonoMsCorDbi)' == 'true'" Include="$(MonoObjDir)out\lib\$(LibPrefix)mscordbi$(LibSuffix)">
<Destination>$(RuntimeBinDir)$(LibPrefix)mscordbi$(LibSuffix)</Destination>
</_MonoICorDebugArtifacts>

<_IcuArtifacts Condition="'$(_MonoIncludeIcuFiles)' == 'true'"
Include="$(_IcuLibdir)\libicuuc.a;
$(_IcuLibdir)\libicui18n.a;
$(_IcuLibdir)\libicudata.a;
$(_IcuLibdir)\*.dat" />
</ItemGroup>

<Copy Condition="'$(_MonoIncludeIcuFiles)' == 'true'"
SourceFiles="@(_IcuArtifacts)"
DestinationFolder="$(RuntimeBinDir)"
SkipUnchangedFiles="true" />

<Copy SourceFiles="@(_MonoRuntimeArtifacts)"
DestinationFiles="%(_MonoRuntimeArtifacts.Destination)"
Condition="'$(MonoGenerateOffsetsOSGroups)' == ''"
Expand Down
17 changes: 15 additions & 2 deletions src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ if(HAVE_SYS_ICU)
if(ICU_LIBDIR)
set(ICU_LDFLAGS "-L${ICU_LIBDIR}")
endif()

add_library(icu_shim_objects OBJECT "${icu_shim_sources}")
set(HAVE_ICU_SHIM 1)
endif()

#
Expand Down Expand Up @@ -350,7 +353,7 @@ if(HOST_WIN32)
set_source_files_properties(${ZLIB_SOURCES} PROPERTIES COMPILE_OPTIONS "/wd4005;/wd4127;/wd4131;/wd4244")
endif()

set(monosgen-sources "${icu_shim_sources};${mini_sources};${ZLIB_SOURCES}")
set(monosgen-sources "${mini_sources};${ZLIB_SOURCES}")

add_library(monosgen-objects OBJECT "${monosgen-sources}")
target_link_libraries (monosgen-objects PRIVATE monoapi eglib_api utils_objects sgen_objects metadata_objects)
Expand Down Expand Up @@ -379,6 +382,9 @@ if(NOT DISABLE_SHARED_LIBS)
endif(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X)
set_target_properties(monosgen-shared PROPERTIES OUTPUT_NAME ${MONO_SHARED_LIB_NAME})
target_link_libraries(monosgen-shared PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects)
if(HAVE_ICU_SHIM)
target_link_libraries(monosgen-shared PRIVATE icu_shim_objects)
endif()
target_include_directories (monosgen-shared PRIVATE monoapi)
if(TARGET_WIN32)
# on Windows the import library for the shared mono library will have the same name as the static library,
Expand Down Expand Up @@ -436,6 +442,9 @@ if(NOT DISABLE_SHARED_LIBS)
add_library(${frameworkconfig} SHARED $<TARGET_OBJECTS:monosgen-objects>)
target_compile_definitions(${frameworkconfig} PRIVATE -DMONO_DLL_EXPORT)
target_link_libraries(${frameworkconfig} PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects)
if(HAVE_ICU_SHIM)
target_link_libraries(${frameworkconfig} PRIVATE icu_shim_objects)
endif()
target_link_libraries(${frameworkconfig} PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS})

if(ICU_LDFLAGS)
Expand Down Expand Up @@ -538,7 +547,11 @@ if(NOT DISABLE_EXECUTABLES)
if(MONO_CROSS_COMPILE_EXECUTABLE_NAME)
set_target_properties(mono-sgen PROPERTIES OUTPUT_NAME mono-aot-cross)
endif()
target_link_libraries(mono-sgen PRIVATE monoapi eglib_api monosgen-static ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS})
target_link_libraries(mono-sgen PRIVATE monoapi eglib_api monosgen-static)
if(HAVE_ICU_SHIM)
target_link_libraries(mono-sgen PRIVATE icu_shim_objects)
endif()
target_link_libraries(mono-sgen PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS})
# Alpine Linux implements ucontext in a different library
if(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X)
target_link_libraries(mono-sgen PRIVATE ucontext)
Expand Down
1 change: 1 addition & 0 deletions src/mono/wasi/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ target_link_libraries(dotnet
${MONO_ARTIFACTS_DIR}/libmono-icall-table.a
${NATIVE_BIN_DIR}/wasm-bundled-timezones.a
${NATIVE_BIN_DIR}/libSystem.Native.a
${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a
${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a
)

Expand Down
1 change: 1 addition & 0 deletions src/mono/wasm/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ target_link_libraries(dotnet
${MONO_ARTIFACTS_DIR}/libmono-profiler-browser.a
${NATIVE_BIN_DIR}/wasm-bundled-timezones.a
${NATIVE_BIN_DIR}/libSystem.Native.a
${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a
${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a)

set_target_properties(dotnet PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion src/native/libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
endif ()

add_subdirectory(System.Native)
add_subdirectory(System.Globalization.Native)

if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
# skip for now
Expand All @@ -183,7 +184,6 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
elseif (FORCE_ANDROID_OPENSSL)
add_subdirectory(System.Security.Cryptography.Native)
else ()
add_subdirectory(System.Globalization.Native)
add_subdirectory(System.Net.Security.Native)
add_subdirectory(System.Security.Cryptography.Native)
endif ()
Expand Down
4 changes: 2 additions & 2 deletions src/native/libs/Common/pal_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#if defined(TARGET_UNIX)
#if defined(TARGET_UNIX) || defined(TARGET_WASI)
#include <stdatomic.h>
#elif defined(TARGET_WINDOWS)
#include "windows.h"
Expand All @@ -13,7 +13,7 @@
// The args passed in should match InterlockedCompareExchangePointer Windows API
static int pal_atomic_cas_ptr(void* volatile* dest, void* exchange, void* comparand)
{
#if defined(TARGET_UNIX)
#if defined(TARGET_UNIX) || defined(TARGET_WASI)
return __atomic_compare_exchange_n(dest, &comparand, exchange, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
#elif defined(TARGET_WINDOWS)
return InterlockedCompareExchangePointer(dest, exchange, comparand) == comparand;
Expand Down
30 changes: 21 additions & 9 deletions src/native/libs/System.Globalization.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
project(System.Globalization.Native C)

if(CLR_CMAKE_TARGET_UNIX)
if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI)
add_compile_options(-Wno-switch-enum)
add_compile_options(-Wno-covered-switch-default)

# Workaround for warnings produced by ICU headers
add_compile_options(-Wno-reserved-id-macro)
add_compile_options(-Wno-documentation)
add_compile_options(-Wno-documentation-unknown-command)
add_compile_options(-Wno-reserved-identifier)

# Workaround for https://unicode-org.atlassian.net/browse/ICU-20601
add_compile_options(-Wno-extra-semi-stmt)
add_compile_options(-Wno-unknown-warning-option)

if (NOT CLR_CMAKE_TARGET_ANDROID)
if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST)
if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT DEFINED CMAKE_ICU_DIR)
if (CLR_CMAKE_TARGET_OSX)
execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ICU_HOMEBREW_INC_PATH "${brew_prefix}/opt/icu4c/include")
endif()
Expand All @@ -25,7 +26,7 @@ if(CLR_CMAKE_TARGET_UNIX)
return()
endif()

if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST)
if(CLR_CMAKE_TARGET_OSX)
add_definitions(-DOSX_ICU_LIBRARY_PATH="/usr/lib/libicucore.dylib")
add_definitions(-DU_DISABLE_RENAMING)
else()
Expand Down Expand Up @@ -59,6 +60,17 @@ set(NATIVEGLOBALIZATION_SOURCES
pal_normalization.c
)

if (DEFINED CMAKE_ICU_DIR)
include_directories(${CMAKE_ICU_DIR}/include)
link_libraries(${CMAKE_ICU_DIR}/lib/libicuuc.a ${CMAKE_ICU_DIR}/lib/libicui18n.a ${CMAKE_ICU_DIR}/lib/libicudata.a)
link_libraries(stdc++)
endif()

if (CMAKE_USE_PTHREADS)
add_compile_options(-pthread)
add_linker_flag(-pthread)
endif()

if (LOCAL_BUILD)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim_static.c)
Expand All @@ -69,6 +81,9 @@ if (LOCAL_BUILD)
# For minipal files
include_directories(../../)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
elseif (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
add_definitions(-DSTATIC_ICU)
set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim_static.c)
else()
set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim.c)
endif()
Expand All @@ -82,10 +97,6 @@ if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI)
set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c)
endif()

if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI)
set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} entrypoints.c)
endif()

if (MSVC)
set_source_files_properties(${NATIVEGLOBALIZATION_SOURCES} PROPERTIES LANGUAGE CXX)
endif()
Expand Down Expand Up @@ -116,9 +127,10 @@ endif()
add_library(System.Globalization.Native-Static
STATIC
${NATIVEGLOBALIZATION_SOURCES}
entrypoints.c
)

if(CLR_CMAKE_TARGET_UNIX)
if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI)
set_target_properties(System.Globalization.Native-Static PROPERTIES OUTPUT_NAME System.Globalization.Native CLEAN_DIRECT_OUTPUT 1)
endif()

Expand Down
3 changes: 2 additions & 1 deletion src/native/libs/System.Globalization.Native/config.h.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

#cmakedefine01 HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS
#cmakedefine01 HAVE_SET_MAX_VARIABLE
#cmakedefine01 HAVE_SET_MAX_VARIABLE
#cmakedefine01 HAVE_UCOL_CLONE
3 changes: 2 additions & 1 deletion src/native/libs/System.Globalization.Native/configure.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
if(CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST)
if(CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
set(HAVE_SET_MAX_VARIABLE 1)
set(HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS 1)
set(HAVE_UCOL_CLONE 0)
else()
include(CheckCSourceCompiles)
include(CheckSymbolExists)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "pal_errors_internal.h"
#include "pal_calendarData.h"

#if defined(TARGET_UNIX)
#if defined(TARGET_UNIX) || defined(TARGET_WASI)
#include <strings.h>

#define STRING_COPY(destination, numberOfElements, source) \
Expand Down
1 change: 1 addition & 0 deletions src/native/libs/System.Globalization.Native/pal_icushim.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ static void InitializeVariableMaxAndTopPointers(char* symbolVersion)
#if defined(TARGET_OSX) || defined(TARGET_ANDROID)
// OSX and Android always run against ICU version which has ucol_setMaxVariable.
// We shouldn't come here.
(void)symbolVersion;
assert(false);
#elif defined(TARGET_WINDOWS)
char symbolName[SYMBOL_NAME_SIZE];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

#if defined(TARGET_UNIX)
#if defined(TARGET_UNIX) || defined(TARGET_WASI)

#include "config.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ static void log_icu_error(const char* name, UErrorCode status)
log_shim_error("ICU call %s failed with error #%d '%s'.", name, status, statusText);
}

#if defined(ICU_TRACING)
static void U_CALLCONV icu_trace_data(const void* context, int32_t fnNumber, int32_t level, const char* fmt, va_list args)
{
char buf[1000];
utrace_vformat(buf, sizeof(buf), 0, fmt, args);
printf("[ICUDT] %s: %s\n", utrace_functionName(fnNumber), buf);
}
#endif

static int32_t load_icu_data(const void* pData);

Expand Down Expand Up @@ -127,7 +129,7 @@ cstdlib_load_icu_data(const char *path)
goto error;
}

file_buf = malloc(sizeof(char) * (file_buf_size + 1));
file_buf = malloc(sizeof(char) * (unsigned long)(file_buf_size + 1));

if (file_buf == NULL)
{
Expand All @@ -141,7 +143,7 @@ cstdlib_load_icu_data(const char *path)
goto error;
}

fread(file_buf, sizeof(char), file_buf_size, fp);
fread(file_buf, sizeof(char), (unsigned long)file_buf_size, fp);
if (ferror( fp ) != 0)
{
log_shim_error("Unable to read ICU dat file");
Expand Down
11 changes: 11 additions & 0 deletions src/native/libs/build-native.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set __BuildTarget="build"
set __TargetOS=windows
set CMAKE_BUILD_TYPE=Debug
set __Ninja=1
set __icuDir=""
set __usePThreads=0

:Arg_Loop
:: Since the native build requires some configuration information before msbuild is called, we have to do some manual args parsing
Expand All @@ -42,6 +44,9 @@ if /i [%1] == [rebuild] ( set __BuildTarget=rebuild&&shift&goto Arg_Loop)

if /i [%1] == [msbuild] ( set __Ninja=0&&shift&goto Arg_Loop)

if /i [%1] == [icudir] ( set __icuDir=%2&&shift&&shift&goto Arg_Loop)
if /i [%1] == [usepthreads] ( set __usePThreads=1&&shift&goto Arg_Loop)

shift
goto :Arg_Loop

Expand All @@ -60,6 +65,12 @@ set __cmakeRepoRoot=%__repoRoot:\=/%
set __ExtraCmakeParams="-DCMAKE_REPO_ROOT=%__cmakeRepoRoot%"
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%"

if NOT %__icuDir% == "" (
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_ICU_DIR=%__icuDir%"
)
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_USE_PTHREADS=%__usePThreads%"


if [%__outConfig%] == [] set __outConfig=%__TargetOS%-%__BuildArch%-%CMAKE_BUILD_TYPE%

if %__CMakeBinDir% == "" (
Expand Down
Loading

0 comments on commit 0fc8978

Please sign in to comment.