Skip to content

Commit f84ff41

Browse files
committed
Update CSFML version to 2.5.1
- Add macOS build script - Update existing nuget build script
1 parent 76671cf commit f84ff41

File tree

8 files changed

+208
-12
lines changed

8 files changed

+208
-12
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ include(${CMAKE_SOURCE_DIR}/cmake/Config.cmake)
2222
# setup version numbers
2323
set(VERSION_MAJOR 2)
2424
set(VERSION_MINOR 5)
25-
set(VERSION_PATCH 0)
25+
set(VERSION_PATCH 1)
2626

2727
# add the CSFML header path
2828
include_directories(${CMAKE_SOURCE_DIR}/include)

cmake/Config.cmake

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ elseif(MSVC)
6464
set(SFML_MSVC_VERSION 11)
6565
elseif(MSVC_VERSION EQUAL 1800)
6666
set(SFML_MSVC_VERSION 12)
67+
elseif(MSVC_VERSION EQUAL 1900)
68+
set(SFML_MSVC_VERSION 14)
69+
elseif(MSVC_VERSION LESS_EQUAL 1919)
70+
set(SFML_MSVC_VERSION 15)
71+
elseif(MSVC_VERSION LESS_EQUAL 1929)
72+
set(SFML_MSVC_VERSION 16)
6773
endif()
6874
else()
6975
message(FATAL_ERROR "Unsupported compiler")

include/SFML/Config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
////////////////////////////////////////////////////////////
3232
#define CSFML_VERSION_MAJOR 2
3333
#define CSFML_VERSION_MINOR 5
34-
#define CSFML_VERSION_PATCH 0
34+
#define CSFML_VERSION_PATCH 1
3535

3636

3737
////////////////////////////////////////////////////////////

license.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CSFML
22
-----
33

4-
CSFML - Copyright (C) 2007-2018 Laurent Gomila - [email protected]
4+
CSFML - Copyright (C) 2007-2021 Laurent Gomila - [email protected]
55

66
This software is provided 'as-is', without any express or
77
implied warranty. In no event will the authors be held

tools/nuget/CSFML/CSFML.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<!-- Workaround to remove the NETStandard.Library NuGet reference without breaking everything -->
88
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
99

10-
<Version>2.5.0</Version>
10+
<Version>2.5.1</Version>
1111
<Authors>Laurent Gomila</Authors>
1212
<PackageTags>sfml csfml</PackageTags>
1313
<Copyright>Copyright © Laurent Gomila</Copyright>
@@ -22,10 +22,10 @@
2222
</PropertyGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="all" />
25+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
2626

2727
<!-- Workaround to remove the NETStandard.Library NuGet reference without breaking everything -->
28-
<PackageReference Include="NETStandard.Library" Version="[1.6.0,)" PrivateAssets="all" />
28+
<PackageReference Include="NETStandard.Library" Version="1.6.1" PrivateAssets="all" />
2929
</ItemGroup>
3030

3131
<PropertyGroup>

tools/nuget/README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ All build scripts follow the same routine:
1212

1313
* `build.win.ps1`
1414
* A [PowerShell](https://github.com/PowerShell/PowerShell) script to build Windows native libraries. By default, both `win-x86` and `win-x64` are built. To build only one specific Runtime Identifier, pass it to the script as a parameter (`./build.win.ps1 win-x64`)
15-
You must have Visual Studio 2017, cmake, and the Windows SDK 8.1 installed to run this script.
15+
You must have Visual Studio 2019, cmake, and the Windows SDK 10 installed to run this script.
1616

1717
* `build.linux.sh`
1818
* A [Bash](https://www.gnu.org/software/bash/) script to build libraries for a generic Linux distribution. The [Runtime Identifier](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog) of the linux distribution must be specified as a parameter to the script.
1919
This generic script doesn't install any of its dependencies. As such, you must have cmake and make installed, as well as all [SFML Dependencies](https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php#installing-dependencies) available to cmake.
2020

21+
* `build.macos.sh`
22+
* A [Bash](https://www.gnu.org/software/bash/) script to build libraries for macOS. The [Runtime Identifier](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#macos-rids) of the macOS distribution must be specified as parameter to the script.
23+
Currently supported RIDs are:
24+
* osx.10.15-x64
25+
* osx.11.0-x64
26+
* osx.11.0-arm64 (requires SFML 2.6)
27+
2128
* `build.docker.sh`, `build.docker.ps1`
2229
* A script to build the native libraries for a Linux distribution in a Docker container. If no RID is specified as a parameter, all supported RIDs will be built. Currently, the supported RIDs are:
2330
* `alpine-x64`

tools/nuget/build.macos.sh

+183
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
#!/bin/bash
2+
3+
# Automatically exit on error
4+
set -e
5+
6+
# ========================= #
7+
# PRELUDE: A note on rpaths #
8+
# ========================= #
9+
10+
# Unlike Windows, macOS doesn't search the current directory by default when searching for shared libraries (.dylib)
11+
# It only searches the system default directories (usually /lib and /usr/lib) and the paths in LD_LIBRARY_PATH
12+
13+
# The .NET Runtime will find the CSFML library in its NuGet packages just fine, but that library will then request
14+
# the OS for libsfml-(module).dylib, and the .NET Runtime will have no say in how that SFML library is found.
15+
16+
# Without SFML installed globally on the system, this will fail, causing the loading of CSFML to fail, causing the
17+
# .NET Runtime to think the CSFML library doesn't exist or is invalid.
18+
19+
# And so, we need to set the rpath of the CSFML library.
20+
# The rpath is a special value embedded straight into a library that specifies to the OS a list of folders where
21+
# other libraries that it references may be found.
22+
# $ORIGIN, a kind-of environment variable, can be used in rpath to point to the folder where the library currently is.
23+
# To let the OS know that we intend to use $ORIGIN, we need to add the ORIGIN flag to our ELF with the -z origin
24+
# gcc linker option
25+
26+
# Since CSFML and SFML will always be deployed on the same folder by NuGet, we just need to add an rpath to CSFML
27+
# that points to $ORIGIN, causing the OS to search the current folder for SFML, without interference from .NET
28+
29+
# We also add the same rpath to SFML itself for future-proofing, in case we ever decide to ship some Linux SFML
30+
# dependencies on the Native package.
31+
32+
# You may need to `brew install coreutils` first for grealpath
33+
# See supported RID at https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
34+
35+
# =================================================== #
36+
# STEP 1: Setup all variables needed during the build #
37+
# =================================================== #
38+
39+
if [[ -z "$1" ]]; then
40+
echo "Please specify the platform Runtime Identifier as an argument to this script"
41+
exit 1
42+
fi
43+
44+
echo "Please note that all SFML dependencies must be installed and available to cmake. SFML does not ship with its linux dependencies."
45+
46+
RID="$1"
47+
48+
SFMLBranch="2.5.x" # The branch or tag of the SFML repository to be cloned
49+
CSFMLDir="$(grealpath "$(git rev-parse --show-toplevel)")" # The directory of the source code of CSFML
50+
51+
OutDir="./CSFML/runtimes/$RID/native" # The base directory of all CSFML modules, used to copy the final libraries
52+
mkdir -p "$OutDir"
53+
OutDir="$(grealpath "$OutDir")"
54+
55+
echo "Building $RID"
56+
57+
mkdir -p "Build"
58+
pushd "Build"
59+
60+
# ================== #
61+
# STEP 2: Clone SFML #
62+
# ================== #
63+
64+
if [[ ! -d "SFML/.git" ]]; then
65+
echo "Cloning SFML"
66+
rm -rf "SFML"
67+
git clone --branch "$SFMLBranch" --depth 1 "git://github.com/SFML/SFML.git" "SFML"
68+
fi
69+
70+
SFMLDir="$(grealpath SFML)"
71+
72+
# ================== #
73+
# STEP 3: Build SFML #
74+
# ================== #
75+
76+
rm -rf "$RID"
77+
mkdir -p "$RID"
78+
pushd "$RID"
79+
80+
echo "Building SFML"
81+
mkdir -p SFML
82+
pushd SFML
83+
84+
SFMLBuiltDir="$(grealpath .)" # The directory where SFML was built to. Used later to direct cmake when building CSFML
85+
86+
mkdir -p lib
87+
# The directory that contains the final SFML libraries
88+
# Since linux libraries don't support static linking from a shared library, this is used to copy the
89+
# SFML shared libraries together with the CSFML shared libraries into SFML.Net
90+
SFMLLibDir="$(grealpath lib)"
91+
92+
if [ $RID == "osx.10.15-x64" ]; then
93+
ARCHITECTURE="x86_64"
94+
TARGET="10.15"
95+
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/"
96+
elif [ $RID == "osx.11.0-x64" ]; then
97+
ARCHITECTURE="x86_64"
98+
TARGET="11.0"
99+
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/"
100+
elif [ $RID == "osx.11.0-arm64" ]; then
101+
ARCHITECTURE="arm64"
102+
TARGET="11.0"
103+
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/"
104+
105+
echo "Note: arm64 is only supported with SFML 2.6"
106+
else
107+
echo "Unsupported RID provided. Use 'osx.10.15-x64', 'osx.11.0-x64' or 'osx.11.0-arm64'"
108+
exit 1
109+
fi
110+
111+
cmake -E env \
112+
cmake -G "Unix Makefiles" \
113+
-D 'BUILD_SHARED_LIBS=ON' \
114+
-D 'CMAKE_BUILD_TYPE=Release' \
115+
-D "CMAKE_OSX_ARCHITECTURES=$ARCHITECTURE" \
116+
-D "CMAKE_OSX_DEPLOYMENT_TARGET=$TARGET" \
117+
-D "CMAKE_OSX_SYSROOT=$SYSROOT" \
118+
-D "CMAKE_LIBRARY_OUTPUT_DIRECTORY=$SFMLLibDir" \
119+
-D 'CMAKE_BUILD_WITH_INSTALL_RPATH=ON' \
120+
-D 'CMAKE_INSTALL_RPATH=@executable_path' \
121+
"$SFMLDir"
122+
123+
cmake --build . --config Release
124+
125+
popd # Pop SFML
126+
127+
# =================== #
128+
# STEP 4: Build CSFML #
129+
# =================== #
130+
131+
echo "Building CSFML using SFML at $SFMLBuiltDir"
132+
mkdir -p CSFML
133+
pushd CSFML
134+
135+
mkdir -p lib
136+
CSFMLLibDir="$(realpath lib)" # The directory that contains the final CSFML libraries. Used to copy the result into SFML.Net
137+
138+
cmake -E env \
139+
cmake -G "Unix Makefiles" \
140+
-D "SFML_DIR=$SFMLBuiltDir" \
141+
-D 'BUILD_SHARED_LIBS=ON' \
142+
-D 'CMAKE_BUILD_TYPE=Release' \
143+
-D "CMAKE_OSX_ARCHITECTURES=$ARCHITECTURE" \
144+
-D "CMAKE_OSX_DEPLOYMENT_TARGET=$TARGET" \
145+
-D "CMAKE_OSX_SYSROOT=$SYSROOT" \
146+
-D "CMAKE_LIBRARY_OUTPUT_DIRECTORY=$CSFMLLibDir" \
147+
-D 'CMAKE_BUILD_WITH_INSTALL_RPATH=ON' \
148+
-D 'CMAKE_INSTALL_RPATH=@executable_path' \
149+
"$CSFMLDir"
150+
cmake --build . --config Release
151+
152+
# ======================================== #
153+
# STEP 5: Copy result to the NuGet folders #
154+
# ======================================== #
155+
156+
# Copies one SFML and CSFML module into the NuGet package
157+
# The module name must be passed to this function as an argument, in lowercase
158+
# This function then copies $SFMLLibDir/libsfml-(module).so and
159+
# $CSFMLLibDir/libcsfml-(module).so into $OutDir
160+
copymodule()
161+
{
162+
MODULE="$1"
163+
164+
mkdir -p "$OutDir"
165+
166+
# Note the wildcard at the end of the first argument
167+
# We are copying every versioned file here, not just the .dylib
168+
# (libsfml-audio.dylib, libsfml-audio.2.dylib, libsfml-audio.2.5.dylib, etc)
169+
# This is needed because of the way macOS searches for libraries based
170+
# one their SONAME
171+
cp "$SFMLLibDir/libsfml-$MODULE."* "$OutDir"
172+
173+
cp "$CSFMLLibDir/libcsfml-$MODULE."* "$OutDir"
174+
}
175+
176+
copymodule audio
177+
copymodule graphics
178+
copymodule system
179+
copymodule window
180+
181+
popd # Pop CSFML
182+
popd # Pop $RID
183+
popd # Pop Build

tools/nuget/build.win.ps1

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (-not $RID) {
1616
exit
1717
}
1818

19-
$Generator = 'Visual Studio 15 2017'
19+
$Generator = 'Visual Studio 16 2019'
2020

2121
switch ($RID) {
2222
'win-x86' {
@@ -194,10 +194,10 @@ function Copy-Module($module) {
194194
Copy-Item "$CSFMLLibDir/csfml-$module-2.dll" "$OutDir/csfml-$module.dll" -Force > $null
195195
}
196196

197-
Copy-Module 'Audio'
198-
Copy-Module 'Graphics'
199-
Copy-Module 'System'
200-
Copy-Module 'Window'
197+
Copy-Module 'audio'
198+
Copy-Module 'graphics'
199+
Copy-Module 'system'
200+
Copy-Module 'window'
201201

202202
Write-Output "Copying Audio module extra files"
203203
Copy-Item "$SFMLAudioExtras/*" "$OutDir"

0 commit comments

Comments
 (0)