Skip to content
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

[wasm] Use rsp file for emcc default flags, and a props file instead of txt #52941

Merged
merged 9 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@
Include="
$(LibrariesNativeArtifactsPath)src\*.c;
$(LibrariesNativeArtifactsPath)src\*.js;
$(LibrariesNativeArtifactsPath)src\emcc-flags.txt;
$(LibrariesNativeArtifactsPath)src\emcc-version.txt;"
$(LibrariesNativeArtifactsPath)src\emcc-default.rsp;
$(LibrariesNativeArtifactsPath)src\Emcc.props;"
NativeSubDirectory="src"
IsNative="true" />
<LibrariesRuntimeFiles Condition="'$(TargetOS)' == 'Browser'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@
<PlatformManifestFileEntry Include="driver.c" IsNative="true" />
<PlatformManifestFileEntry Include="pinvoke.c" IsNative="true" />
<PlatformManifestFileEntry Include="pinvoke.h" IsNative="true" />
<PlatformManifestFileEntry Include="emcc-flags.txt" IsNative="true" />
<PlatformManifestFileEntry Include="emcc-version.txt" IsNative="true" />
<PlatformManifestFileEntry Include="emcc-default.rsp" IsNative="true" />
<PlatformManifestFileEntry Include="Emcc.props" IsNative="true" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can runtime packs include a props file that will be automatically loaded?

<!-- ICU-specific files -->
<PlatformManifestFileEntry Include="libicudata.a" IsNative="true" />
<PlatformManifestFileEntry Include="libicui18n.a" IsNative="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<PackageFile Include="Sdk\AutoImport.props" TargetPath="Sdk" />
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\WasmApp.props" TargetPath="Sdk" />
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\WasmApp.targets" TargetPath="Sdk" />
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\WasmApp.Native.*" TargetPath="Sdk" />
<PackageFile Include="$(RepoRoot)\src\mono\wasm\build\EmSdkRepo.Defaults.props" TargetPath="Sdk" />
</ItemGroup>

<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
Expand Down
2 changes: 1 addition & 1 deletion src/mono/sample/wasm/wasm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ run-browser:
echo "The tool dotnet-serve could not be found. Install with: $(DOTNET) tool install --global dotnet-serve"; \
exit 1; \
else \
$(DOTNET) serve -d bin/$(CONFIG)/AppBundle -p 8000; \
$(DOTNET) serve -d:bin/$(CONFIG)/AppBundle -p:8000; \
fi

run-console:
Expand Down
37 changes: 14 additions & 23 deletions src/mono/wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ MONO_BIN_DIR?=$(BINDIR)/mono/Browser.wasm.$(CONFIG)
NATIVE_BIN_DIR?=$(BINDIR)/native/net6.0-Browser-$(CONFIG)-wasm
ICU_LIBDIR?=
SYSTEM_NATIVE_LIBDIR?=$(TOP)/src/libraries/Native/Unix/System.Native
ENABLE_ES6?=false
_MSBUILD_WASM_BUILD_ARGS=/p:TargetOS=Browser /p:TargetArchitecture=wasm /p:Configuration=$(CONFIG)
ENABLE_METADATA_UPDATE?=false
XHARNESS_BROWSER?=chrome
EMCC_DEFAULT_RSP=$(NATIVE_BIN_DIR)/src/emcc-default.rsp

all: build-native icu-files source-files header-files

Expand Down Expand Up @@ -63,14 +62,6 @@ MONO_LIBS = \
$(ICU_LIBDIR)/libicuuc.a \
$(ICU_LIBDIR)/libicui18n.a

EMCC_FLAGS=--profiling-funcs -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 -s FORCE_FILESYSTEM=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString', 'UTF8ArrayToString', 'addFunction']" -s "EXPORTED_FUNCTIONS=['_putchar']" --source-map-base http://example.com -emit-llvm
ifneq ($(ENABLE_ES6),false)
EMCC_FLAGS+=-s MODULARIZE=1 -s EXPORT_ES6=1
endif
ifeq ($(ENABLE_METADATA_UPDATE),true)
EMCC_FLAGS+=-DENABLE_METADATA_UPDATE=1
endif

EMCC_DEBUG_FLAGS =-g -Os -s ASSERTIONS=1 -DDEBUG=1
EMCC_RELEASE_FLAGS=-Oz --llvm-opts 2

Expand Down Expand Up @@ -101,28 +92,28 @@ $(NATIVE_BIN_DIR)/include/wasm:
$(BUILDS_OBJ_DIR):
mkdir -p $$@

$(NATIVE_BIN_DIR)/dotnet.js: $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o runtime/library_mono.js runtime/binding_support.js runtime/dotnet_support.js $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(2) | $(NATIVE_BIN_DIR)
$(EMCC) $(EMCC_FLAGS) $(1) --js-library runtime/library_mono.js --js-library runtime/binding_support.js --js-library runtime/dotnet_support.js --js-library $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o $(2) -o $(NATIVE_BIN_DIR)/dotnet.js $(3)
$(NATIVE_BIN_DIR)/dotnet.js: $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o runtime/library_mono.js runtime/binding_support.js runtime/dotnet_support.js $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(2) $(EMCC_DEFAULT_RSP) | $(NATIVE_BIN_DIR)
$(EMCC) @$(EMCC_DEFAULT_RSP) $(1) --js-library runtime/library_mono.js --js-library runtime/binding_support.js --js-library runtime/dotnet_support.js --js-library $(SYSTEM_NATIVE_LIBDIR)/pal_random.js $(BUILDS_OBJ_DIR)/driver.o $(BUILDS_OBJ_DIR)/pinvoke.o $(BUILDS_OBJ_DIR)/corebindings.o $(2) -o $(NATIVE_BIN_DIR)/dotnet.js $(3)

$(BUILDS_OBJ_DIR)/pinvoke-table.h: $(PINVOKE_TABLE) | $(BUILDS_OBJ_DIR)
if cmp -s $(PINVOKE_TABLE) $$@ ; then : ; else cp $(PINVOKE_TABLE) $$@ ; fi

$(BUILDS_OBJ_DIR)/driver.o: runtime/driver.c | $(BUILDS_OBJ_DIR)
$(EMCC) $(EMCC_FLAGS) $(1) -Oz -DCORE_BINDINGS -I$(BUILDS_OBJ_DIR) -I$(MONO_INCLUDE_DIR) runtime/driver.c -c -o $$@
$(BUILDS_OBJ_DIR)/driver.o: runtime/driver.c $(EMCC_DEFAULT_RSP) | $(BUILDS_OBJ_DIR)
$(EMCC) @$(EMCC_DEFAULT_RSP) $(1) -Oz -DCORE_BINDINGS -I$(BUILDS_OBJ_DIR) -I$(MONO_INCLUDE_DIR) runtime/driver.c -c -o $$@

$(BUILDS_OBJ_DIR)/pinvoke.o: runtime/pinvoke.c runtime/pinvoke.h $(BUILDS_OBJ_DIR)/pinvoke-table.h | $(BUILDS_OBJ_DIR)
$(EMCC) $(EMCC_FLAGS) $(1) -Oz -DGEN_PINVOKE=1 -I$(BUILDS_OBJ_DIR) runtime/pinvoke.c -c -o $$@
$(BUILDS_OBJ_DIR)/pinvoke.o: runtime/pinvoke.c runtime/pinvoke.h $(BUILDS_OBJ_DIR)/pinvoke-table.h $(EMCC_DEFAULT_RSP) | $(BUILDS_OBJ_DIR)
$(EMCC) @$(EMCC_DEFAULT_RSP) $(1) -Oz -DGEN_PINVOKE=1 -I$(BUILDS_OBJ_DIR) runtime/pinvoke.c -c -o $$@

$(BUILDS_OBJ_DIR)/corebindings.o: runtime/corebindings.c | $(BUILDS_OBJ_DIR)
$(EMCC) $(EMCC_FLAGS) $(1) -Oz -I$(MONO_INCLUDE_DIR) runtime/corebindings.c -c -o $$@
$(BUILDS_OBJ_DIR)/corebindings.o: runtime/corebindings.c $(EMCC_DEFAULT_RSP) | $(BUILDS_OBJ_DIR)
$(EMCC) @$(EMCC_DEFAULT_RSP) $(1) -Oz -I$(MONO_INCLUDE_DIR) runtime/corebindings.c -c -o $$@

$(NATIVE_BIN_DIR)/src/emcc-flags.txt: | $(NATIVE_BIN_DIR)/src Makefile
echo "$(call escape_quote,$(EMCC_FLAGS)) $(1)" > $$@
$(EMCC_DEFAULT_RSP): $(CURDIR)/wasm.proj | $(NATIVE_BIN_DIR)/src Makefile
$(DOTNET) build $(CURDIR)/wasm.proj /p:Configuration=$(CONFIG) /t:GenerateEmccPropsAndRspFiles

$(NATIVE_BIN_DIR)/src/emcc-version.txt: $(EMSDK_PATH)/upstream/.emsdk_version | $(NATIVE_BIN_DIR)/src
$(EMCC) --version | head -1 > $$@
$(NATIVE_BIN_DIR)/src/Emcc.props: $(EMSDK_PATH)/upstream/.emsdk_version | $(NATIVE_BIN_DIR)/src
$(DOTNET) build $(CURDIR)/wasm.proj /p:Configuration=$(CONFIG) /t:GenerateEmccPropsAndRspFiles

build-native: $(NATIVE_BIN_DIR)/dotnet.js $(NATIVE_BIN_DIR)/src/emcc-flags.txt $(NATIVE_BIN_DIR)/src/emcc-version.txt
build-native: $(NATIVE_BIN_DIR)/dotnet.js $(NATIVE_BIN_DIR)/src/emcc-default.rsp $(NATIVE_BIN_DIR)/src/Emcc.props

endef

Expand Down
Loading