Skip to content

[src] Create a rsp file for all the arguments to the C# compiler when compiling the product assembly. #21924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 58 additions & 19 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ IOS_DOTNET_BUILD_DIR=$(DOTNET_BUILD_DIR)/ios
TVOS_DOTNET_BUILD_DIR=$(DOTNET_BUILD_DIR)/tvos
MACCATALYST_DOTNET_BUILD_DIR=$(DOTNET_BUILD_DIR)/maccatalyst

GENERATOR_FLAGS=-process-enums -core -nologo -nostdlib -noconfig -native-exception-marshalling --ns:ObjCRuntime
GENERATOR_FLAGS=-process-enums -core -nologo -nostdlib -native-exception-marshalling --ns:ObjCRuntime

GENERATOR_TF_VERSION=$(subst net,,$(DOTNET_TFM))

Expand Down Expand Up @@ -56,7 +56,7 @@ DOTNET_REFERENCES = \
/r:$(DOTNET_BCL_DIR)/System.Xml.ReaderWriter.dll \

DOTNET_OR_GREATER_DEFINES:=$(foreach version,$(shell seq 6 $(firstword $(subst ., ,$(subst net,,$(DOTNET_TFM))))),/define:NET$(version)_0_OR_GREATER)
DOTNET_FLAGS=/warnaserror+ /noconfig /nostdlib+ /deterministic /features:strict /nologo /target:library /debug /unsafe /define:NET /define:NET_TODO $(DOTNET_OR_GREATER_DEFINES) $(DOTNET_REFERENCES)
DOTNET_FLAGS=/warnaserror+ /nostdlib+ /deterministic /features:strict /nologo /target:library /debug /unsafe /define:NET /define:NET_TODO $(DOTNET_OR_GREATER_DEFINES) $(DOTNET_REFERENCES)

ifeq ($(XCODE_IS_STABLE),true)
DOTNET_FLAGS+=/define:XCODE_IS_STABLE
Expand Down Expand Up @@ -135,7 +135,8 @@ IOS_DOTNET_CORE_SOURCES += $(IOS_DOTNET_EXTRA_SOURCES)

IOS_DOTNET_SOURCES += $(IOS_DOTNET_EXTRA_SOURCES) $(IOS_DOTNET_HTTP_SOURCES)

IOS_GENERATOR_FLAGS = -inline-selectors -d:IOS -process-enums $(IOS_GENERATOR_WARNASERROR)
IOS_GENERATOR_DEFINES = -d:IOS
IOS_GENERATOR_FLAGS = -inline-selectors -process-enums $(IOS_GENERATOR_WARNASERROR) $(IOS_GENERATOR_DEFINES)
IOS_DEFINES = -define:IPHONE -define:IOS -define:MONOTOUCH -d:__IOS__ -d:SYSTEM_NET_HTTP

IOS_CORE_DEFINES=-define:COREBUILD $(IOS_DEFINES)
Expand Down Expand Up @@ -169,7 +170,8 @@ $(IOS_DOTNET_BUILD_DIR)/AssemblyInfo.cs: $(TOP)/src/AssemblyInfo.cs.in | $(IOS_D
#

MAC_COMMON_DEFINES = -define:MONOMAC -d:__MACOS__
MACOS_GENERATOR_FLAGS = -d:MONOMAC -d:__MACOS__
MACOS_GENERATOR_DEFINES = -d:MONOMAC -d:__MACOS__
MACOS_GENERATOR_FLAGS = $(MACOS_GENERATOR_DEFINES)
MACOS_CORE_DEFINES = $(MAC_COMMON_DEFINES),COREBUILD
MACOS_DEFINES = $(MAC_COMMON_DEFINES) -D:XAMARIN_MODERN

Expand Down Expand Up @@ -236,7 +238,8 @@ $(MACOS_DOTNET_BUILD_DIR)/AssemblyInfo.cs: $(TOP)/src/AssemblyInfo.cs.in | $(MAC
TVOS_DEFINES = -define:IPHONE -define:MONOTOUCH -d:TVOS -d:__TVOS__ -d:SYSTEM_NET_HTTP

TVOS_CORE_DEFINES=$(TVOS_DEFINES) -d:COREBUILD
TVOS_GENERATOR_FLAGS = -d:TVOS -inline-selectors
TVOS_GENERATOR_DEFINES = -d:TVOS
TVOS_GENERATOR_FLAGS = $(TVOS_GENERATOR_DEFINES) -inline-selectors

TVOS_DOTNET_EXTRA_CORE_SOURCES = \
$(TVOS_DOTNET_BUILD_DIR)/Constants.cs \
Expand Down Expand Up @@ -294,7 +297,8 @@ $(TVOS_DOTNET_BUILD_DIR)/AssemblyInfo.cs: $(TOP)/src/AssemblyInfo.cs.in $(TOP)/M
MACCATALYST_DEFINES = -define:IPHONE -define:IOS -define:MONOTOUCH -d:__IOS__ -d:__MACCATALYST__ -d:SYSTEM_NET_HTTP

MACCATALYST_CORE_DEFINES=$(MACCATALYST_DEFINES) -d:COREBUILD
MACCATALYST_GENERATOR_FLAGS = -d:__MACCATALYST__ -d:IOS -inline-selectors
MACCATALYST_GENERATOR_DEFINES = -d:__MACCATALYST__ -d:IOS
MACCATALYST_GENERATOR_FLAGS = $(MACCATALYST_GENERATOR_DEFINES) -inline-selectors

MACCATALYST_DOTNET_EXTRA_CORE_SOURCES = \
$(MACCATALYST_DOTNET_BUILD_DIR)/Constants.cs \
Expand Down Expand Up @@ -343,19 +347,47 @@ $(MACCATALYST_DOTNET_BUILD_DIR)/AssemblyInfo.cs: $(TOP)/src/AssemblyInfo.cs.in $
include $(TOP)/scripts/generate-sourcelink-json/fragment.mk

define BuildDotNetIntermediateAssembly
$($(2)_DOTNET_BUILD_DIR)/core-$(3).dll: $($(2)_DOTNET_CORE_SOURCES) frameworks.sources $(RSP_DIR)/dotnet/$(3)-defines-dotnet.rsp | $($(2)_DOTNET_BUILD_DIR)
$$(Q_DOTNET_GEN) \
$(DOTNET_CSC) \
rsp:: $($(2)_DOTNET_BUILD_DIR)/core-$(3).rsp
$($(2)_DOTNET_BUILD_DIR)/core-$(3).rsp: Makefile frameworks.sources | $($(2)_DOTNET_BUILD_DIR)
$$(Q_DOTNET_GEN) echo \
$(DOTNET_FLAGS) \
$(DOTNET_CORE_WARNINGS_TO_FIX) \
@$(RSP_DIR)/dotnet/$(3)-defines-dotnet.rsp \
$($(2)_CORE_DEFINES) \
$($(2)_DOTNET_CORE_SOURCES) \
-nullable+ \
-warnaserror+ \
-out:$$@
-out:$($(2)_DOTNET_BUILD_DIR)/core-$(3).dll \
> [email protected]
$$(Q) mv [email protected] $$@

$($(2)_DOTNET_BUILD_DIR)/core-$(3).dll: $($(2)_DOTNET_CORE_SOURCES) $($(2)_DOTNET_BUILD_DIR)/core-$(3).rsp | $($(2)_DOTNET_BUILD_DIR)
$$(Q_DOTNET_GEN) $(DOTNET_CSC) @$($(2)_DOTNET_BUILD_DIR)/core-$(3).rsp

$($(2)_DOTNET_BUILD_DIR)/apidefinition-$(3).rsp: Makefile frameworks.sources
$$(Q_DOTNET_GEN) echo \
-debug \
-unsafe \
-target:library \
-nowarn:436 \
-out:$($(2)_DOTNET_BUILD_DIR)/apidefinition-$(3).dll \
-r:$($(2)_DOTNET_BUILD_DIR)/core-$(3).dll \
-nostdlib \
-nologo \
-r:$(DOTNET_BINDING_ATTRIBUTES) \
$($(2)_APIS) \
$($(2)_GENERATOR_DEFINES) \
@$(RSP_DIR)/dotnet/$(3)-defines-dotnet.rsp \
> [email protected]
$$(Q) mv [email protected] $$@

$($(2)_DOTNET_BUILD_DIR)/apidefinition-$(3).dll: $($(2)_DOTNET_BUILD_DIR)/apidefinition-$(3).rsp $($(2)_DOTNET_BUILD_DIR)/core-$(3).dll $(DOTNET_BINDING_ATTRIBUTES)
$$(Q_GEN) $(DOTNET_CSC) $(DOTNET_FLAGS) @$$<

apidefinition:: $(3)-apidefinition
$(3)-apidefinition: $($(2)_DOTNET_BUILD_DIR)/apidefinition-$(3).dll

$($(2)_DOTNET_BUILD_DIR)/$(3)-generated-sources: $(DOTNET_GENERATOR) $($(2)_DOTNET_APIS) $($(2)_DOTNET_BUILD_DIR)/core-$(3).dll $(DOTNET_BINDING_ATTRIBUTES) $($(2)_DOTNET_BUILD_DIR)/$(3).rsp | $($(2)_DOTNET_BUILD_DIR)/generated-sources
$($(2)_DOTNET_BUILD_DIR)/$(3)-generated-sources: $(DOTNET_GENERATOR) $($(2)_DOTNET_APIS) $($(2)_DOTNET_BUILD_DIR)/core-$(3).dll $($(2)_DOTNET_BUILD_DIR)/apidefinition-$(3).dll $(DOTNET_BINDING_ATTRIBUTES) $($(2)_DOTNET_BUILD_DIR)/$(3).rsp | $($(2)_DOTNET_BUILD_DIR)/generated-sources
$$(Q_DOTNET_GEN) $$< @$($(2)_DOTNET_BUILD_DIR)/$(3).rsp

$($(2)_DOTNET_BUILD_DIR)/$(3).rsp: Makefile Makefile.generator Makefile.rgenerator frameworks.sources $(ROSLYN_GENERATOR) $(ROSLYN_ANALYZER) $(DOTNET_COMPILER) | $($(2)_DOTNET_BUILD_DIR)
Expand All @@ -367,8 +399,7 @@ $($(2)_DOTNET_BUILD_DIR)/$(3).rsp: Makefile Makefile.generator Makefile.rgenerat
-tmpdir=$($(2)_DOTNET_BUILD_DIR)/generated-sources \
-baselib=$($(2)_DOTNET_BUILD_DIR)/core-$(3).dll \
--target-framework=.NETCoreApp,Version=$(GENERATOR_TF_VERSION),Profile=$(3) \
$($(2)_APIS) \
@$(RSP_DIR)/dotnet/$(3)-defines-dotnet.rsp \
--compiled-api-definition-assembly=$($(2)_DOTNET_BUILD_DIR)/apidefinition-$(3).dll \
> $$@

DOTNET_TARGETS_$(3) += \
Expand Down Expand Up @@ -442,6 +473,7 @@ endif

$(2)_DOTNET_PLATFORM_ASSEMBLY_DEPENDENCIES = \
$($(2)_DOTNET_SOURCES) \
$($(2)_DOTNET_BUILD_DIR)/Microsoft.$(1).rsp \
$($(2)_DOTNET_BUILD_DIR)/$(3)-generated-sources \
$($(2)_DOTNET_BUILD_DIR)/SourceLink.json \
$($(2)_DOTNET_BUILD_DIR)/embed-files.rsp \
Expand All @@ -453,9 +485,11 @@ $(2)_DOTNET_PLATFORM_ASSEMBLY_DIR_DEPENDENCIES = \
$($(2)_DOTNET_BUILD_DIR)/$(4) \
$($(2)_DOTNET_BUILD_DIR)/ref \

$($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1)%dll $($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1)%pdb $$($(2)_$(4)_REF_TARGET) $$($(2)_$(4)_DOC_TARGET): $$($(2)_DOTNET_PLATFORM_ASSEMBLY_DEPENDENCIES) $$(ROSLYN_GENERATOR) $$(ROSLYN_ANALYZER) | $$($(2)_DOTNET_PLATFORM_ASSEMBLY_DIR_DEPENDENCIES)
$$(call Q_PROF_CSC,dotnet/$(4)-bit) \
$(DOTNET_CSC) \
rsp:: $($(2)_DOTNET_BUILD_DIR)/Microsoft.$(1).rsp

$($(2)_DOTNET_BUILD_DIR)/Microsoft.$(1).rsp: Makefile | $($(2)_DOTNET_BUILD_DIR)
$$(Q) rm -f $$@
$$(Q) echo \
$(DOTNET_FLAGS) \
/analyzer:$(ROSLYN_GENERATOR_COMMON) \
/analyzer:$(ROSLYN_GENERATOR) \
Expand All @@ -470,18 +504,23 @@ $($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1)%dll $($(2)_DOTNET_BUILD_DIR)/$(4)/M
$$($(2)_$(4)_REFOUT_ARG) \
$$($(2)_$(4)_DOC_ARG) \
-sourcelink:$($(2)_DOTNET_BUILD_DIR)/SourceLink.json \
@$($(2)_DOTNET_BUILD_DIR)/embed-files.rsp \
@$$(abspath $($(2)_DOTNET_BUILD_DIR)/embed-files.rsp) \
$$($(2)_DEFINES) \
$(ARGS_$(4)) \
$$(DOTNET_WARNINGS_TO_FIX) \
@$(RSP_DIR)/dotnet/$(3)-defines-dotnet.rsp \
@$$(abspath $(RSP_DIR)/dotnet/$(3)-defines-dotnet.rsp) \
-res:$($(2)_DOTNET_BUILD_DIR)/ILLink.LinkAttributes.xml \
-res:$($(2)_DOTNET_BUILD_DIR)/ILLink.Substitutions.xml \
-warnaserror+ \
-nullable+ \
$$($(2)_DOTNET_SOURCES) \
@$($(2)_DOTNET_BUILD_DIR)/$(3)-generated-sources \
@$$(abspath $($(2)_DOTNET_BUILD_DIR)/$(3)-generated-sources) \
-out:$($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1).dll \
> [email protected]
$$(Q) mv [email protected] $$@

$($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1)%dll $($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1)%pdb $$($(2)_$(4)_REF_TARGET) $$($(2)_$(4)_DOC_TARGET): $$($(2)_DOTNET_PLATFORM_ASSEMBLY_DEPENDENCIES) $$(ROSLYN_GENERATOR) $$(ROSLYN_ANALYZER) | $$($(2)_DOTNET_PLATFORM_ASSEMBLY_DIR_DEPENDENCIES)
$$(call Q_PROF_CSC,dotnet/$(4)-bit) $(DOTNET_CSC) @$($(2)_DOTNET_BUILD_DIR)/Microsoft.$(1).rsp

dotnet-$(3):: $($(2)_DOTNET_BUILD_DIR)/$(4)/Microsoft.$(1).dll

Expand Down
11 changes: 7 additions & 4 deletions src/bgen/BindingTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,20 @@ public bool TryInitializeApi (BindingTouchConfig config, [NotNullWhen (true)] ou
config.CoreSources.Insert (i - 1, config.Sources [i]);
}

if (config.ApiSources.Count == 0) {
Console.WriteLine ("Error: no api file provided");
if (config.ApiSources.Count == 0 && string.IsNullOrEmpty (compiled_api_definition_assembly)) {
Console.WriteLine ("Error: no api file provided, nor a compiled api definition assembly");
ShowHelp (config.OptionSet);
return false;
}

if (config.TemporaryFileDirectory is null)
config.TemporaryFileDirectory = GetWorkDir ();

string firstApiDefinitionName = Path.GetFileNameWithoutExtension (config.ApiSources [0]);
firstApiDefinitionName = firstApiDefinitionName.Replace ('-', '_'); // This is not exhaustive, but common.
var firstApiDefinitionName = string.Empty;
if (config.ApiSources.Count > 0) {
firstApiDefinitionName = Path.GetFileNameWithoutExtension (config.ApiSources [0]);
firstApiDefinitionName = firstApiDefinitionName.Replace ('-', '_'); // This is not exhaustive, but common.
}
if (outfile is null)
outfile = firstApiDefinitionName + ".dll";

Expand Down
4 changes: 4 additions & 0 deletions src/foundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//

#define DOUBLE_BLOCKS

global using nfloat = global::System.Runtime.InteropServices.NFloat;

using ObjCRuntime;
using CloudKit;
using CoreData;
Expand Down
Loading