summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStevenWdV <stevenwdv@gmail.com>2021-11-24 17:47:17 +0100
committerStevenWdV <stevenwdv@gmail.com>2021-11-24 17:47:17 +0100
commitbc940a145ca8150bc1e8fbb18d0a4685e9b09ce0 (patch)
tree20c661ab9fa8f79943e2e019f274abe7c6ad902a
parent8878d8705f0b0fcddb3979194340ca39df897580 (diff)
Support more platforms, add make clean targets, support embedding lib in nupkg
-rw-r--r--Makefile6
-rw-r--r--exports/.gitignore4
-rw-r--r--exports/Makefile24
-rw-r--r--wrappers/csharp/EduVpnCommon.csproj47
-rw-r--r--wrappers/csharp/Makefile12
5 files changed, 75 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index b11b774..3cb93fa 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: build test test-go test-wrappers
+.PHONY: build test test-go test-wrappers clean
build:
$(MAKE) -C exports build
@@ -10,3 +10,7 @@ test-go:
test-wrappers: build
$(MAKE) -C wrappers/csharp test
+
+clean:
+ $(MAKE) -C exports clean
+ $(MAKE) -C wrappers/csharp clean
diff --git a/exports/.gitignore b/exports/.gitignore
index a95b306..63ea916 100644
--- a/exports/.gitignore
+++ b/exports/.gitignore
@@ -1,3 +1 @@
-*.dll
-*.so
-*.h
+/*/
diff --git a/exports/Makefile b/exports/Makefile
index 94781be..912e930 100644
--- a/exports/Makefile
+++ b/exports/Makefile
@@ -1,12 +1,18 @@
-.PHONY: build
+.PHONY: build clean
-ifeq ($(OS),Windows_NT)
- lib_suffix := .dll
-else
- lib_suffix := .so
-endif
+lib_suffix_linux = .so
+lib_suffix_windows = .dll
+lib_suffix_darwin = .dylib
-build: eduvpn_verify$(lib_suffix)
+OS = $(shell go env GOHOSTOS)
+ARCH = $(shell go env GOHOSTARCH)
+LIB_SUFFIX = $(lib_suffix_$(OS))
-eduvpn_verify.dll eduvpn_verify.so: exports.go ../verify.go
- go build -o $@ -buildmode=c-shared $<
+# Creates targets like 'linux/amd64/eduvpn_verify.so'
+build: $(OS)/$(ARCH)/eduvpn_verify$(LIB_SUFFIX)
+
+$(OS)/$(ARCH)/eduvpn_verify$(LIB_SUFFIX): exports.go ../verify.go
+ CGO_ENABLED=1 GOOS=$(OS) GOARCH=$(ARCH) go build -o $@ -buildmode=c-shared $<
+
+clean:
+ rm -rf ../exports/*/
diff --git a/wrappers/csharp/EduVpnCommon.csproj b/wrappers/csharp/EduVpnCommon.csproj
index 1bbbc23..04df7f0 100644
--- a/wrappers/csharp/EduVpnCommon.csproj
+++ b/wrappers/csharp/EduVpnCommon.csproj
@@ -4,6 +4,11 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>8</LangVersion>
<Nullable>enable</Nullable>
+ <PackageId>EduVpn.Common</PackageId>
+ <PackageVersion>0.1.0</PackageVersion>
+ <Authors />
+ <Description>Common EduVpn logic</Description>
+ <Product>EduVpn</Product>
</PropertyGroup>
<ItemGroup>
@@ -14,13 +19,47 @@
<EmbeddedResource Remove="EduVpnCommonTests/**" />
</ItemGroup>
+ <Target Name="Build library for current OS" BeforeTargets="PrepareForBuild"
+ Condition="!(Exists('../../exports/windows/amd64/eduvpn_verify.dll')
+ Or Exists('../../exports/windows/386/eduvpn_verify.dll')
+ Or Exists('../../exports/windows/arm/eduvpn_verify.dll')
+ Or Exists('../../exports/windows/arm64/eduvpn_verify.dll')
+ Or Exists('../../exports/linux/amd64/eduvpn_verify.so')
+ Or Exists('../../exports/linux/arm/eduvpn_verify.so')
+ Or Exists('../../exports/linux/arm64/eduvpn_verify.so'))">
+ <Message Text="Shared eduvpn_verify library not found, you should build that one first" Importance="high" />
+ </Target>
+
<ItemGroup>
<None Remove="EduVpnCommonTests/**" />
- <None Condition="Exists('../../exports/eduvpn_verify.dll')" Include="../../exports/eduvpn_verify.dll">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+
+ <None Condition="Exists('../../exports/windows/amd64/eduvpn_verify.dll')"
+ Include="../../exports/windows/amd64/eduvpn_verify.dll" Pack="true" PackagePath="runtimes/win-x64/native/">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ <None Condition="Exists('../../exports/windows/386/eduvpn_verify.dll')"
+ Include="../../exports/windows/386/eduvpn_verify.dll" Pack="true" PackagePath="runtimes/win-x86/native/">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ <None Condition="Exists('../../exports/windows/arm/eduvpn_verify.dll')"
+ Include="../../exports/windows/arm/eduvpn_verify.dll" Pack="true" PackagePath="runtimes/win-arm/native/">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ <None Condition="Exists('../../exports/windows/arm64/eduvpn_verify.dll')"
+ Include="../../exports/windows/arm64/eduvpn_verify.dll" Pack="true" PackagePath="runtimes/win-arm64/native/">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ <None Condition="Exists('../../exports/linux/amd64/eduvpn_verify.so')"
+ Include="../../exports/linux/amd64/eduvpn_verify.so" Pack="true" PackagePath="runtimes/linux-x64/native/">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ <None Condition="Exists('../../exports/linux/arm/eduvpn_verify.so')"
+ Include="../../exports/linux/arm/eduvpn_verify.so" Pack="true" PackagePath="runtimes/linux-arm/native/">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
- <None Condition="Exists('../../exports/eduvpn_verify.so')" Include="../../exports/eduvpn_verify.so">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ <None Condition="Exists('../../exports/linux/arm64/eduvpn_verify.so')"
+ Include="../../exports/linux/arm64/eduvpn_verify.so" Pack="true" PackagePath="runtimes/linux-arm64/native/">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
diff --git a/wrappers/csharp/Makefile b/wrappers/csharp/Makefile
index 293a7a2..1761edc 100644
--- a/wrappers/csharp/Makefile
+++ b/wrappers/csharp/Makefile
@@ -1,4 +1,14 @@
-.PHONY: test
+.PHONY: build pack test clean
+
+build:
+ dotnet publish EduVpnCommon.csproj --configuration Release
+
+pack:
+ dotnet pack EduVpnCommon.csproj --configuration Release
test:
+ $(MAKE) -C ../../exports
dotnet test
+
+clean:
+ rm -rf bin/ obj/ EduVpnCommonTests/bin/ EduVpnCommonTests/obj/