Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
95b1977f
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
95b1977f
编写于
12月 19, 2019
作者:
K
Kevin Ransom (msft)
提交者:
Phillip Carter
12月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up some compiler location redundencies (#8026)
上级
0f912e6a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
44 deletion
+50
-44
src/fsharp/CompileOps.fs
src/fsharp/CompileOps.fs
+3
-7
src/fsharp/DotNetFrameworkDependencies.fs
src/fsharp/DotNetFrameworkDependencies.fs
+26
-15
src/utils/CompilerLocationUtils.fs
src/utils/CompilerLocationUtils.fs
+21
-22
未找到文件。
src/fsharp/CompileOps.fs
浏览文件 @
95b1977f
...
...
@@ -2586,7 +2586,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) =
let
dllReference
,
fileNameOpt
=
computeKnownDllReference
getFSharpCoreLibraryName
match
fileNameOpt
with
|
Some
_
->
dllReference
|
None
->
AssemblyReference
(
range0
,
getDefaultFSharpCore
Reference
,
None
)
|
None
->
AssemblyReference
(
range0
,
getDefaultFSharpCore
Location
,
None
)
// clrRoot: the location of the primary assembly (mscorlib.dll or netstandard.dll or System.Runtime.dll)
//
...
...
@@ -3513,13 +3513,9 @@ type TcAssemblyResolutions(tcConfig: TcConfig, results: AssemblyResolution list,
let
assumeDotNetFramework
=
primaryReference
.
SimpleAssemblyNameIs
(
"mscorlib"
)
if
tcConfig
.
framework
then
for
s
in
defaultReferencesForScriptsAndOutOfProjectSources
assumeDotNetFramework
tcConfig
.
useSdkRefs
do
for
s
in
defaultReferencesForScriptsAndOutOfProjectSources
tcConfig
.
useFsiAuxLib
assumeDotNetFramework
tcConfig
.
useSdkRefs
do
yield
AssemblyReference
(
rangeStartup
,
(
if
s
.
EndsWith
(
".dll"
,
StringComparison
.
OrdinalIgnoreCase
)
then
s
else
s
+
".dll"
),
None
)
if
tcConfig
.
useFsiAuxLib
then
let
name
=
Path
.
Combine
(
tcConfig
.
fsharpBinariesDir
,
getFsiLibraryName
+
".dll"
)
yield
AssemblyReference
(
rangeStartup
,
name
,
None
)
yield
!
tcConfig
.
referencedDLLs
]
...
...
@@ -5555,4 +5551,4 @@ let TypeCheckClosedInputSet (ctok, checkForErrors, tcConfig, tcImports, tcGlobal
// Existing public APIs delegate to newer implementations
let
GetFSharpCoreLibraryName
()
=
getFSharpCoreLibraryName
let
DefaultReferencesForScriptsAndOutOfProjectSources
assumeDotNetFramework
=
defaultReferencesForScriptsAndOutOfProjectSources
assumeDotNetFramework
false
let
DefaultReferencesForScriptsAndOutOfProjectSources
assumeDotNetFramework
=
defaultReferencesForScriptsAndOutOfProjectSources
(*useFsiAuxLib*)
false
assumeDotNetFramework
(*useSdkRefs*)
false
src/fsharp/DotNetFrameworkDependencies.fs
浏览文件 @
95b1977f
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
// Functions to retrieve framework dependencies
module
internal
FSharp
.
Compiler
.
DotNetFrameworkDependencies
open
System
open
System
.
Collections
.
Generic
open
System
.
Diagnostics
open
System
.
Globalization
open
System
.
IO
open
System
.
Reflection
open
Internal
.
Utilities
type
private
TypeInThisAssembly
=
class
end
let
implementationAssemblyDir
=
Path
.
GetDirectoryName
(
typeof
<
obj
>.
Assembly
.
Location
)
let
fSharpCompilerLocation
=
let
location
=
Path
.
GetDirectoryName
(
typeof
<
TypeInThisAssembly
>.
Assembly
.
Location
)
match
FSharpEnvironment
.
BinFolderOfDefaultFSharpCompiler
(
Some
location
)
with
|
Some
path
->
path
|
None
->
#
if
DEBUG
Debug
.
Print
(
sprintf
"FSharpEnvironment.BinFolderOfDefaultFSharpCompiler (Some '%s') returned None Location customized incorrectly: algorithm here: https://github.com/dotnet/fsharp/blob/03f3f1c35f82af26593d025dabca57a6ef3ea9a1/src/utils/CompilerLocationUtils.fs#L171"
location
)
#
endif
// Use the location of this dll
location
let
getFSharpCoreLibraryName
=
"FSharp.Core"
let
getFsiLibraryName
=
"FSharp.Compiler.Interactive.Settings"
let
implementationAssemblyDir
=
Path
.
GetDirectoryName
(
typeof
<
obj
>.
Assembly
.
Location
)
let
getDefaultFSharpCoreReference
=
typeof
<
Microsoft
.
FSharp
.
Core
.
Unit
>.
Assembly
.
Location
let
getFSharpCompilerLocation
=
Path
.
GetDirectoryName
(
typeof
<
TypeInThisAssembly
>.
Assembly
.
Location
)
let
getDefaultFSharpCoreLocation
=
Path
.
Combine
(
fSharpCompilerLocation
,
getFSharpCoreLibraryName
+
".dll"
)
let
getDefaultFsiLibraryLocation
=
Path
.
Combine
(
fSharpCompilerLocation
,
getFsiLibraryName
+
".dll"
)
// Use the ValueTuple that is executing with the compiler if it is from System.ValueTuple
// or the System.ValueTuple.dll that sits alongside the compiler. (Note we always ship one with the compiler)
...
...
@@ -26,15 +38,13 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
if
asm
.
FullName
.
StartsWith
(
"System.ValueTuple"
,
StringComparison
.
OrdinalIgnoreCase
)
then
Some
asm
.
Location
else
let
location
=
Path
.
GetDirectoryName
(
typeof
<
TypeInThisAssembly
>.
Assembly
.
Location
)
let
valueTuplePath
=
Path
.
Combine
(
location
,
"System.ValueTuple.dll"
)
let
valueTuplePath
=
Path
.
Combine
(
fSharpCompilerLocation
,
"System.ValueTuple.dll"
)
if
File
.
Exists
(
valueTuplePath
)
then
Some
valueTuplePath
else
None
with
_
->
None
// Algorithm:
// use implementation location of obj type, on shared frameworks it will always be in:
//
...
...
@@ -161,11 +171,12 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
yield
"System.Data"
yield
"System.Drawing"
yield
"System.Core"
yield
getDefaultFSharpCoreReference
yield
getFSharpCoreLibraryName
if
useFsiAuxLib
then
yield
getFsiLibraryName
// always include a default reference to System.ValueTuple.dll in scripts and out-of-project sources
match
getDefaultSystemValueTupleReference
()
with
match
getDefaultSystemValueTupleReference
()
with
|
None
->
()
|
Some
v
->
yield
v
...
...
@@ -199,8 +210,8 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
// Coreclr supports netstandard assemblies only for now
(
getDependenciesOf
[
yield
!
Directory
.
GetFiles
(
implementationAssemblyDir
,
"*.dll"
)
yield
getDefaultFSharpCore
Reference
if
useFsiAuxLib
then
yield
get
FsiLibraryName
yield
getDefaultFSharpCore
Location
if
useFsiAuxLib
then
yield
get
DefaultFsiLibraryLocation
]).
Values
|>
Seq
.
toList
if
useSdkRefs
then
...
...
@@ -208,8 +219,8 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
match
frameworkRefsPackDirectory
with
|
Some
path
->
try
[
yield
!
Directory
.
GetFiles
(
path
,
"*.dll"
)
yield
getDefaultFSharpCore
Reference
if
useFsiAuxLib
then
yield
get
FsiLibraryName
yield
getDefaultFSharpCore
Location
if
useFsiAuxLib
then
yield
get
DefaultFsiLibraryLocation
]
with
|
_
->
List
.
empty
<
string
>
|
None
->
...
...
@@ -219,8 +230,8 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
dependencies
results
let
defaultReferencesForScriptsAndOutOfProjectSources
assumeDotNetFramework
useSdkRefs
=
fetchPathsForDefaultReferencesForScriptsAndOutOfProjectSources
false
useSdkRefs
assumeDotNetFramework
let
defaultReferencesForScriptsAndOutOfProjectSources
useFsiAuxLib
assumeDotNetFramework
useSdkRefs
=
fetchPathsForDefaultReferencesForScriptsAndOutOfProjectSources
useFsiAuxLib
useSdkRefs
assumeDotNetFramework
// A set of assemblies to always consider to be system assemblies. A common set of these can be used a shared
// resources between projects in the compiler services. Also all assemblies where well-known system types exist
...
...
src/utils/CompilerLocationUtils.fs
浏览文件 @
95b1977f
...
...
@@ -2,6 +2,7 @@
namespace
Internal
.
Utilities
open
System
open
System
.
Diagnostics
open
System
.
IO
open
Microsoft
.
Win32
open
System
.
Runtime
.
InteropServices
...
...
@@ -71,10 +72,11 @@ module internal FSharpEnvironment =
(
try
downcast
Microsoft
.
Win32
.
Registry
.
GetValue
(
"HKEY_LOCAL_MACHINE
\\
"
+
subKey
,
null
,
null
)
with
e
->
System
.
Diagnostics
.
Debug
.
Assert
(
false
,
sprintf
"Failed in GetDefaultRegistryStringValueViaDotNet: %s"
(
e
.
ToString
()
))
#
if
DEBUG
Debug
.
Assert
(
false
,
sprintf
"Failed in GetDefaultRegistryStringValueViaDotNet: %s"
(
e
.
ToString
()
))
#
endif
null
)
let
Get32BitRegistryStringValueViaPInvoke
(
subKey
:
string
)
=
Option
.
ofString
(
try
...
...
@@ -114,11 +116,13 @@ module internal FSharpEnvironment =
if
pathResult
<>
IntPtr
.
Zero
then
Marshal
.
FreeCoTaskMem
(
pathResult
)
with
e
->
System
.
Diagnostics
.
Debug
.
Assert
(
false
,
sprintf
"Failed in Get32BitRegistryStringValueViaPInvoke: %s"
(
e
.
ToString
()
))
#
if
DEBUG
Debug
.
Assert
(
false
,
sprintf
"Failed in Get32BitRegistryStringValueViaPInvoke: %s"
(
e
.
ToString
()
))
#
endif
null
)
let
is32Bit
=
IntPtr
.
Size
=
4
let
runningOnMono
=
try
System
.
Type
.
GetType
(
"Mono.Runtime"
)
<>
null
with
e
->
false
let
tryRegKey
(
subKey
:
string
)
=
...
...
@@ -133,7 +137,7 @@ module internal FSharpEnvironment =
// by comparing against the result from GetDefaultRegistryStringValueViaDotNet(...)
#
if
DEBUG
let
viaPinvoke
=
Get32BitRegistryStringValueViaPInvoke
(
subKey
)
System
.
Diagnostics
.
Debug
.
Assert
((
s
=
viaPinvoke
),
sprintf
"32bit path: pi=%A def=%A"
viaPinvoke
s
)
Debug
.
Assert
((
s
=
viaPinvoke
),
sprintf
"32bit path: pi=%A def=%A"
viaPinvoke
s
)
#
endif
s
else
...
...
@@ -141,13 +145,9 @@ module internal FSharpEnvironment =
#
endif
let
internal
tryCurrentDomain
()
=
let
pathFromCurrentDomain
=
#
if
FX_NO_APP_DOMAINS
System
.
AppContext
.
BaseDirectory
#
else
System
.
AppDomain
.
CurrentDomain
.
BaseDirectory
#
endif
if
not
(
String
.
IsNullOrEmpty
(
pathFromCurrentDomain
))
then
let
pathFromCurrentDomain
=
AppDomain
.
CurrentDomain
.
BaseDirectory
if
not
(
String
.
IsNullOrEmpty
(
pathFromCurrentDomain
))
then
Some
pathFromCurrentDomain
else
None
...
...
@@ -157,14 +157,17 @@ module internal FSharpEnvironment =
#
else
let
internal
tryAppConfig
(_
appConfigKey
:
string
)
=
let
locationFromAppConfig
=
System
.
Configuration
.
ConfigurationSettings
.
AppSettings
.[_
appConfigKey
]
System
.
Diagnostics
.
Debug
.
Print
(
sprintf
"Considering _appConfigKey %s which has value '%s'"
_
appConfigKey
locationFromAppConfig
)
#
if
DEBUG
Debug
.
Print
(
sprintf
"Considering _appConfigKey %s which has value '%s'"
_
appConfigKey
locationFromAppConfig
)
#
endif
if
String
.
IsNullOrEmpty
(
locationFromAppConfig
)
then
None
else
let
exeAssemblyFolder
=
Path
.
GetDirectoryName
(
System
.
Reflection
.
Assembly
.
GetExecutingAssembly
()
.
Location
)
let
locationFromAppConfig
=
locationFromAppConfig
.
Replace
(
"{exepath}"
,
exeAssemblyFolder
)
System
.
Diagnostics
.
Debug
.
Print
(
sprintf
"Using path %s"
locationFromAppConfig
)
#
if
DEBUG
Debug
.
Print
(
sprintf
"Using path %s"
locationFromAppConfig
)
#
endif
Some
locationFromAppConfig
#
endif
...
...
@@ -175,14 +178,10 @@ module internal FSharpEnvironment =
// - default F# binaries directory in service.fs (REVIEW: check this)
// - default location of fsi.exe in FSharp.VS.FSI.dll (REVIEW: check this)
// - default F# binaries directory in (project system) Project.fs
let
BinFolderOfDefaultFSharpCompiler
(
probePoint
:
string
option
)
=
let
BinFolderOfDefaultFSharpCompiler
(
probePoint
:
string
option
)
=
#
if
FX_NO_WIN_REGISTRY
ignore
probePoint
#
if
FX_NO_APP_DOMAINS
Some
System
.
AppContext
.
BaseDirectory
#
else
Some
System
.
AppDomain
.
CurrentDomain
.
BaseDirectory
#
endif
Some
AppDomain
.
CurrentDomain
.
BaseDirectory
#
else
// Check for an app.config setting to redirect the default compiler location
// Like fsharp-compiler-location
...
...
@@ -199,7 +198,7 @@ module internal FSharpEnvironment =
|
Some
p
when
safeExists
(
Path
.
Combine
(
p
,
"FSharp.Core.dll"
))
->
Some
p
|
_
->
// We let you set FSHARP_COMPILER_BIN. I've rarely seen this used and its not documented in the install instructions.
let
result
=
System
.
Environment
.
GetEnvironmentVariable
(
"FSHARP_COMPILER_BIN"
)
let
result
=
Environment
.
GetEnvironmentVariable
(
"FSHARP_COMPILER_BIN"
)
if
not
(
String
.
IsNullOrEmpty
(
result
))
then
Some
result
else
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录