-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
68 lines (49 loc) · 2.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
.PHONY: all run clean
include os-detect.mk
# should match what's in the .csproj files
TARGET_FRAMEWORK?=net8.0
RUNTIME_IDENTIFIER?=$(SYSTEM)-$(CPUARCH)
export TARGET_FRAMEWORK
export RUNTIME_IDENTIFIER
ifndef LOCAL_RUNTIME
RUNTIME_PACK_DIR_FILE:= out/GetRuntimePack/bin/Release/$(TARGET_FRAMEWORK)/$(RUNTIME_IDENTIFIER)/runtime-pack-dir.txt
else
RUNTIME_PACK_DIR_FILE:= out/local-build/runtime-pack-dir.txt
endif
all: out/.touch-CsharpSample $(RUNTIME_PACK_DIR_FILE) out/native/main$(EXE)
CSHARP_SAMPLE_CSPROJ:= src/CsharpSample/CsharpSample.csproj
GET_RUNTIME_PACK_CSPROJ:= src/GetRuntimePack/GetRuntimePack.csproj
CSHARP_SAMPLE_SRC:= \
$(CSHARP_SAMPLE_CSPROJ) \
src/CsharpSample/CSharpSample.cs \
src/CsharpSample/Directory.Build.props
GET_RUNTIME_PACK_SRC:= \
$(GET_RUNTIME_PACK_CSPROJ) \
src/GetRuntimePack/Directory.Build.props
NATIVE_SRC:= \
src/native/Makefile \
src/native/gen-managed.sh \
src/native/main.c
DOTNET_PUBLISH_ARGS=-r $(RUNTIME_IDENTIFIER) -f $(TARGET_FRAMEWORK) -p:TargetFramework=$(TARGET_FRAMEWORK) -c Release
out/.touch-CsharpSample: $(CSHARP_SAMPLE_SRC)
dotnet publish $< $(DOTNET_PUBLISH_ARGS) --self-contained
touch $@
ifndef LOCAL_RUNTIME
$(RUNTIME_PACK_DIR_FILE): $(GET_RUNTIME_PACK_SRC)
dotnet publish $< $(DOTNET_PUBLISH_ARGS) --self-contained /bl:out/GetRuntimePack.binlog
else
$(RUNTIME_PACK_DIR_FILE): $(LOCAL_RUNTIME)
if [ "z$(LOCAL_RUNTIME)" = z -o ! -d "$(LOCAL_RUNTIME)/runtimes/$(RUNTIME_IDENTIFIER)/native" ]; then echo expected $(LOCAL_RUNTIME) to contain a runtimes/$(RUNTIME_IDENTIFIER)/native subdirectory; false ; fi
mkdir -p $(dir $(RUNTIME_PACK_DIR_FILE))
echo "$(LOCAL_RUNTIME)" > $(RUNTIME_PACK_DIR_FILE)
endif
out/native/main$(EXE): $(NATIVE_SRC) $(RUNTIME_PACK_DIR_FILE) out/.touch-CsharpSample
if [ "z$(RUNTIME_PACK_DIR_FILE)" = z -o ! -f "$(RUNTIME_PACK_DIR_FILE)" ]; then echo RUNTIME_PACK_DIR_FILE=$(RUNTIME_PACK_DIR_FILE) does not exist ; false ; fi
make -C src/native runtime_pack_dir_file=$(realpath $(RUNTIME_PACK_DIR_FILE))
ifeq ($(SYSTEM),linux)
SET_LDLIBRARY_PATH=LD_LIBRARY_PATH=out/native
endif
run: out/native/main$(EXE)
$(SET_LDLIBRARY_PATH) out/native/main$(EXE)
clean:
-rm -rf out