14 Commits
Author SHA1 Message Date
Lukas Dürrenberger f84ff413a1 Update CSFML version to 2.5.1
- Add macOS build script
- Update existing nuget build script
2021-07-11 16:54:41 +02:00
Davipb 76671cf453 Change 'net' TFM to 'netframework' 2021-05-12 00:55:16 +02:00
Davipb ea8048376f Add icon on package 2021-03-01 15:19:41 +01:00
Davipb 063923308f Add build error for AnyCPU on .NET Framework 2021-03-01 15:19:41 +01:00
Lukas Dürrenberger 99cea94aaf Add GitHub actions for Windows, Linux and macOS 2021-02-19 20:48:44 +01:00
Jairard@Windows ffb5763206 Fix compilation and add check in sfTexture_updateFromTexture 2019-11-22 13:26:00 +01:00
asumface 0f8209fade Remove stray semicolon 2019-11-22 12:53:20 +01:00
DemoXin 7627ef1c5d Implement sfTexture_updateFromTexture
Method was declared, but not implemented. Also corrects an EntryPointNotFound exception in SFML.NET
2019-07-17 17:51:29 +02:00
crumblingstatue cdc9bc6a21 Fix incorrect sfRenderTexture_createWithSettings header signature 2019-07-17 16:05:43 +02:00
Laurent Gomila 282621e499 Merge pull request #139 from DJMaster/patch-1
Update RenderTexture.h
2019-03-23 18:35:41 +01:00
DJMaster 1c75ff0546 Update RenderTexture.h
CSFML_GRAPHICS_API is missing
2019-03-23 18:22:42 +01:00
Davipb d6f3ec2f34 Fix $OutDir vestiges 2019-01-23 22:59:18 +01:00
Davipb b189a4e168 Fix Windows script for non-existing runtimes folder 2019-01-23 22:59:18 +01:00
Davipb d8e19e74ed Add NuGet package tools 2019-01-23 22:59:18 +01:00
25 changed files with 961 additions and 5 deletions

No files matched your search

+50
View File
@@ -0,0 +1,50 @@
name: CI
on: [push, pull_request]
jobs:
build:
name: ${{ matrix.platform.name }} ${{ matrix.config.name }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- { name: Windows VS2017, os: windows-2016 }
- { name: Windows VS2019, os: windows-latest }
- { name: Linux GCC, os: ubuntu-latest }
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: MacOS XCode, os: macos-latest, flags: -DSFML_BUILD_FRAMEWORKS=FALSE, prefix: sudo }
steps:
- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev
- name: Checkout SFML
uses: actions/checkout@v2
with:
repository: SFML/SFML
ref: 2.5.1
path: SFML
- name: Configure SFML CMake
shell: bash
run: cmake -S $GITHUB_WORKSPACE/SFML -B $GITHUB_WORKSPACE/SFML/build -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/SFML/install -DBUILD_SHARED_LIBS=TRUE -DSFML_BUILD_EXAMPLES=FALSE -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_VERBOSE_MAKEFILE=ON ${{matrix.platform.flags}}
- name: Build SFML
shell: bash
run: ${{matrix.platform.prefix}} cmake --build $GITHUB_WORKSPACE/SFML/build --config Release --target install
- name: Checkout CSFML
uses: actions/checkout@v2
with:
path: CSFML
- name: Configure CSFML CMake
shell: bash
run: cmake -S $GITHUB_WORKSPACE/CSFML -B $GITHUB_WORKSPACE/CSFML/build -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/CSFML/install -DBUILD_SHARED_LIBS=TRUE -DCSFML_LINK_SFML_STATICALLY=FALSE -DSFML_DIR=$GITHUB_WORKSPACE/SFML/install/lib/cmake/SFML -DCMAKE_VERBOSE_MAKEFILE=ON ${{matrix.platform.flags}}
- name: Build CSFML
shell: bash
run: cmake --build $GITHUB_WORKSPACE/CSFML/build --config Release --target install
+1 -1
View File
@@ -22,7 +22,7 @@ include(${CMAKE_SOURCE_DIR}/cmake/Config.cmake)
# setup version numbers
set(VERSION_MAJOR 2)
set(VERSION_MINOR 5)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)
# add the CSFML header path
include_directories(${CMAKE_SOURCE_DIR}/include)
+6
View File
@@ -64,6 +64,12 @@ elseif(MSVC)
set(SFML_MSVC_VERSION 11)
elseif(MSVC_VERSION EQUAL 1800)
set(SFML_MSVC_VERSION 12)
elseif(MSVC_VERSION EQUAL 1900)
set(SFML_MSVC_VERSION 14)
elseif(MSVC_VERSION LESS_EQUAL 1919)
set(SFML_MSVC_VERSION 15)
elseif(MSVC_VERSION LESS_EQUAL 1929)
set(SFML_MSVC_VERSION 16)
endif()
else()
message(FATAL_ERROR "Unsupported compiler")
+1 -1
View File
@@ -31,7 +31,7 @@
////////////////////////////////////////////////////////////
#define CSFML_VERSION_MAJOR 2
#define CSFML_VERSION_MINOR 5
#define CSFML_VERSION_PATCH 0
#define CSFML_VERSION_PATCH 1
////////////////////////////////////////////////////////////
+2 -2
View File
@@ -65,7 +65,7 @@ CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_create(unsigned int width, u
/// \return A new sfRenderTexture object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_createWithSettings(unsigned int width, unsigned int height, sfContextSettings settings);
CSFML_GRAPHICS_API sfRenderTexture* sfRenderTexture_createWithSettings(unsigned int width, unsigned int height, const sfContextSettings* settings);
////////////////////////////////////////////////////////////
/// \brief Destroy an existing render texture
@@ -302,7 +302,7 @@ CSFML_GRAPHICS_API const sfTexture* sfRenderTexture_getTexture(const sfRenderTex
/// \return The maximum anti-aliasing level supported by the system
///
////////////////////////////////////////////////////////////
unsigned int sfRenderTexture_getMaximumAntialiasingLevel();
CSFML_GRAPHICS_API unsigned int sfRenderTexture_getMaximumAntialiasingLevel();
////////////////////////////////////////////////////////////
/// \brief Enable or disable the smooth filter on a render texture
+1 -1
View File
@@ -1,7 +1,7 @@
CSFML
-----
CSFML - Copyright (C) 2007-2018 Laurent Gomila - laurent@sfml-dev.org
CSFML - Copyright (C) 2007-2021 Laurent Gomila - laurent@sfml-dev.org
This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held
+10
View File
@@ -181,6 +181,16 @@ void sfTexture_updateFromPixels(sfTexture* texture, const sfUint8* pixels, unsig
}
////////////////////////////////////////////////////////////
void sfTexture_updateFromTexture(sfTexture* destination, const sfTexture* texture, unsigned int x, unsigned int y)
{
CSFML_CHECK(texture);
CSFML_CHECK(texture->This);
CSFML_CALL_PTR(destination, update(*texture->This, x, y));
}
////////////////////////////////////////////////////////////
void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, unsigned int x, unsigned int y)
{
+2
View File
@@ -0,0 +1,2 @@
*.sh eol=lf -text
*.ps1 eol=crlf -text
+9
View File
@@ -0,0 +1,9 @@
# Ignore .NET build artifacts
/*/bin/
/*/obj/
# Ignore compiled CSFML assemblies generated by the scripts
/*/runtimes/
# Ignore the intermediate folder used by scripts to compile CSFML
/Build/
+42
View File
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<!-- Workaround to remove the NETStandard.Library NuGet reference without breaking everything -->
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<Version>2.5.1</Version>
<Authors>Laurent Gomila</Authors>
<PackageTags>sfml csfml</PackageTags>
<Copyright>Copyright © Laurent Gomila</Copyright>
<PackageLicenseExpression>Zlib</PackageLicenseExpression>
<PackageProjectUrl>https://www.sfml-dev.org/</PackageProjectUrl>
<PackageIconUrl>https://www.sfml-dev.org/images/sfml-icon.png</PackageIconUrl>
<PackageIcon>sfml-icon.png</PackageIcon>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
<!-- Workaround to remove the NETStandard.Library NuGet reference without breaking everything -->
<PackageReference Include="NETStandard.Library" Version="1.6.1" PrivateAssets="all" />
</ItemGroup>
<PropertyGroup>
<Description>This package contains the native libraries for the C port of SFML, used as a dependency for SFML.Net</Description>
<Title>CSFML</Title>
</PropertyGroup>
<ItemGroup>
<None Pack="True" Include="runtimes/**" PackagePath="runtimes" />
<None Pack="True" Include="build/**" PackagePath="build" />
<None Pack="True" Include="sfml-icon.png" PackagePath="/" />
</ItemGroup>
</Project>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CSFMLIgnoreAnyCPU>false</CSFMLIgnoreAnyCPU>
</PropertyGroup>
</Project>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CSFMLAnyCPUError" Condition="$(CSFMLIgnoreAnyCPU) != true and $(Platform) == 'AnyCPU'" BeforeTargets="Build">
<Error Text="CSFML doesn't support 'Any CPU' on the .NET Framework. Consider switching to .NET Core. If this is not possible, change your platform to x64 or x86, or set the MSBuild property 'CSFMLIgnoreAnyCPU' to true and manually load the appropriate native library at runtime." />
</Target>
</Project>
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

+38
View File
@@ -0,0 +1,38 @@
# CSFML NuGet Packages
This directory contains all the files needed to build and package the native CSFML libraries for [SFML.Net](github.com/SFML/SFML.Net).
**All scripts must be run from the directory they are located in**.
That means that your current working directory (`$PWD`) must be the same where the script is.
All build scripts follow the same routine:
1. Clone the SFML repository at `Build/SFML`, if it isn't already there
1. Configure & compile SFML with cmake inside of `Build/(RID)/SFML`, where `(RID)` is the [Runtime Identifier](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog) for the target of the libraries being built
1. Configure & compile CSFML with cmake inside of `Build/(RID)/CSFML`
1. Copy the resulting libraries to `CSFML/runtimes/(RID)/native/`
* `build.win.ps1`
* 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`)
You must have Visual Studio 2019, cmake, and the Windows SDK 10 installed to run this script.
* `build.linux.sh`
* 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.
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.
* `build.macos.sh`
* 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.
Currently supported RIDs are:
* osx.10.15-x64
* osx.11.0-x64
* osx.11.0-arm64 (requires SFML 2.6)
* `build.docker.sh`, `build.docker.ps1`
* 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:
* `alpine-x64`
* `debian-x64` (compatible with derivatives such as Ubuntu and Linux Mint)
* `fedora-x64`
* `pushnuget.ps1`, `pushnuget.sh`
* A script to automatically build and push the NuGet package to nuget.org. Make sure that all the native libraries are in `CSFML/runtimes/` before running this.
* Other scripts
* Any script not mentioned here is intended for internal use by other scripts only and shouldn't be called directly.
+43
View File
@@ -0,0 +1,43 @@
Param(
[Parameter(Position = 0)]
[string] $RID
)
$ErrorActionPreference = "Stop"
if (-not $RID ) {
Write-Output "No RID specified, building all known RIDs"
./build.docker.ps1 "alpine-x64"
./build.docker.ps1 "debian-x64"
./build.docker.ps1 "fedora-x64"
exit
}
$Image = $null
$Shell = $null
switch ($RID) {
'alpine-x64' {
$Image = 'alpine'
$Shell = '/bin/sh'
}
'debian-x64' {
$Image = 'debian'
$Shell = '/bin/bash'
}
'fedora-x64' {
$Image = 'fedora'
$Shell = '/bin/bash'
}
Default {
Write-Error "Unknown Runtime Identifier $RID"
exit
}
}
Write-Host "Building $RID with image $Image using $Shell"
$RepoRoot = (Get-Item (git rev-parse --show-toplevel)).FullName
docker run --rm --mount "type=bind,source=$RepoRoot,destination=/csfml/" $Image $Shell -c "cd /csfml/tools/nuget/; ./docker.$RID.sh"
exit $LastExitCode
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
# Automatically exit on error
set -e
if [[ -z "$1" ]]; then
echo 'No Runtime Identifier specified, running all known RIDs'
./build.docker.sh "alpine-x64"
./build.docker.sh "debian-x64"
./build.docker.sh "fedora-x64"
exit 0
fi
RID="$1"
case "$RID" in
'alpine-x64')
Image='alpine'
Shell='/bin/sh'
;;
'debian-x64')
Image='debian'
Shell='/bin/bash'
;;
'fedora-x64')
Image='fedora'
Shell='/bin/bash'
;;
*)
echo "Unknown Runtime Identifier $RID"
exit 1
;;
esac
echo "Building $RID using image $Image with $Shell"
RepoRoot="$(realpath "$(git rev-parse --show-toplevel)")"
docker run --rm --mount "type=bind,source=$RepoRoot,destination=/csfml/" "$Image" "$Shell" -c "cd /csfml/tools/nuget/; ./docker.$RID.sh"
+155
View File
@@ -0,0 +1,155 @@
#!/bin/bash
# Automatically exit on error
set -e
# ========================= #
# PRELUDE: A note on rpaths #
# ========================= #
# Unlike Windows, Linux doesn't search the current directory by default when searching for shared libraries (.so)
# It only searches the system default directories (usually /lib and /usr/lib) and the paths in LD_LIBRARY_PATH
# The .NET Runtime will find the CSFML library in its NuGet packages just fine, but that library will then request
# the OS for libsfml-(module).so, and the .NET Runtime will have no say in how that SFML library is found.
# Without SFML installed globally on the system, this will fail, causing the loading of CSFML to fail, causing the
# .NET Runtime to think the CSFML library doesn't exist or is invalid.
# And so, we need to set the rpath of the CSFML library.
# The rpath is a special value embedded straight into a library that specifies to the OS a list of folders where
# other libraries that it references may be found.
# $ORIGIN, a kind-of environment variable, can be used in rpath to point to the folder where the library currently is.
# 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
# gcc linker option
# Since CSFML and SFML will always be deployed on the same folder by NuGet, we just need to add an rpath to CSFML
# that points to $ORIGIN, causing the OS to search the current folder for SFML, without interference from .NET
# We also add the same rpath to SFML itself for future-proofing, in case we ever decide to ship some Linux SFML
# dependencies on the Native package.
# =================================================== #
# STEP 1: Setup all variables needed during the build #
# =================================================== #
if [[ -z "$1" ]]; then
echo "Please specify the platform Runtime Identifier as an argument to this script"
exit 1
fi
echo "Please note that all SFML dependencies must be installed and available to cmake. SFML does not ship with its linux dependencies."
RID="$1"
SFMLBranch="2.5.x" # The branch or tag of the SFML repository to be cloned
CSFMLDir="$(realpath "$(git rev-parse --show-toplevel)")" # The directory of the source code of CSFML
OutDir="./CSFML/runtimes/$RID/native" # The base directory of all CSFML modules, used to copy the final libraries
mkdir -p "$OutDir"
OutDir="$(realpath "$OutDir")"
echo "Building $RID"
mkdir -p "Build"
pushd "Build"
# ================== #
# STEP 2: Clone SFML #
# ================== #
if [[ ! -d "SFML/.git" ]]; then
echo "Cloning SFML"
rm -rf "SFML"
git clone --branch "$SFMLBranch" --depth 1 "git://github.com/SFML/SFML.git" "SFML"
fi
SFMLDir="$(realpath SFML)"
# ================== #
# STEP 3: Build SFML #
# ================== #
rm -rf "$RID"
mkdir -p "$RID"
pushd "$RID"
echo "Building SFML"
mkdir -p SFML
pushd SFML
SFMLBuiltDir="$(realpath .)" # The directory where SFML was built to. Used later to direct cmake when building CSFML
mkdir -p lib
# The directory that contains the final SFML libraries
# Since linux libraries don't support static linking from a shared library, this is used to copy the
# SFML shared libraries together with the CSFML shared libraries into SFML.Net
SFMLLibDir="$(realpath lib)"
cmake -E env LDFLAGS="-z origin" \
cmake \
'-DBUILD_SHARED_LIBS=1' \
'-DCMAKE_BUILD_TYPE=Release' \
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$SFMLLibDir" \
'-DCMAKE_BUILD_WITH_INSTALL_RPATH=1' \
'-DCMAKE_INSTALL_RPATH=$ORIGIN' \
"$SFMLDir"
cmake --build . --config Release
popd # Pop SFML
# =================== #
# STEP 4: Build CSFML #
# =================== #
echo "Building CSFML using SFML at $SFMLBuiltDir"
mkdir -p CSFML
pushd CSFML
mkdir -p lib
CSFMLLibDir="$(realpath lib)" # The directory that contains the final CSFML libraries. Used to copy the result into SFML.Net
cmake -E env LDFLAGS="-z origin" \
cmake \
"-DSFML_DIR=$SFMLBuiltDir" \
'-DBUILD_SHARED_LIBS=1' \
'-DCMAKE_BUILD_TYPE=Release' \
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$CSFMLLibDir" \
'-DCMAKE_BUILD_WITH_INSTALL_RPATH=1' \
'-DCMAKE_INSTALL_RPATH=$ORIGIN' \
"$CSFMLDir"
cmake --build . --config Release
# ======================================== #
# STEP 5: Copy result to the NuGet folders #
# ======================================== #
# Copies one SFML and CSFML module into the NuGet package
# The module name must be passed to this function as an argument, in lowercase
# This function then copies $SFMLLibDir/libsfml-(module).so and
# $CSFMLLibDir/libcsfml-(module).so into $OutDir
copymodule()
{
MODULE="$1"
mkdir -p "$OutDir"
# Note the wildcard at the end of the first argument
# We are copying every versioned file here, not just the .so
# (libsfml-audio.so, libsfml-audio.so.2, libsfml-audio.so.2.5, etc)
# This is needed because of the way linux searches for libraries based
# one their SONAME
cp "$SFMLLibDir/libsfml-$MODULE.so"* "$OutDir"
cp "$CSFMLLibDir/libcsfml-$MODULE.so" "$OutDir"
}
copymodule audio
copymodule graphics
copymodule system
copymodule window
popd # Pop CSFML
popd # Pop $RID
popd # Pop Build
+183
View File
@@ -0,0 +1,183 @@
#!/bin/bash
# Automatically exit on error
set -e
# ========================= #
# PRELUDE: A note on rpaths #
# ========================= #
# Unlike Windows, macOS doesn't search the current directory by default when searching for shared libraries (.dylib)
# It only searches the system default directories (usually /lib and /usr/lib) and the paths in LD_LIBRARY_PATH
# The .NET Runtime will find the CSFML library in its NuGet packages just fine, but that library will then request
# the OS for libsfml-(module).dylib, and the .NET Runtime will have no say in how that SFML library is found.
# Without SFML installed globally on the system, this will fail, causing the loading of CSFML to fail, causing the
# .NET Runtime to think the CSFML library doesn't exist or is invalid.
# And so, we need to set the rpath of the CSFML library.
# The rpath is a special value embedded straight into a library that specifies to the OS a list of folders where
# other libraries that it references may be found.
# $ORIGIN, a kind-of environment variable, can be used in rpath to point to the folder where the library currently is.
# 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
# gcc linker option
# Since CSFML and SFML will always be deployed on the same folder by NuGet, we just need to add an rpath to CSFML
# that points to $ORIGIN, causing the OS to search the current folder for SFML, without interference from .NET
# We also add the same rpath to SFML itself for future-proofing, in case we ever decide to ship some Linux SFML
# dependencies on the Native package.
# You may need to `brew install coreutils` first for grealpath
# See supported RID at https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
# =================================================== #
# STEP 1: Setup all variables needed during the build #
# =================================================== #
if [[ -z "$1" ]]; then
echo "Please specify the platform Runtime Identifier as an argument to this script"
exit 1
fi
echo "Please note that all SFML dependencies must be installed and available to cmake. SFML does not ship with its linux dependencies."
RID="$1"
SFMLBranch="2.5.x" # The branch or tag of the SFML repository to be cloned
CSFMLDir="$(grealpath "$(git rev-parse --show-toplevel)")" # The directory of the source code of CSFML
OutDir="./CSFML/runtimes/$RID/native" # The base directory of all CSFML modules, used to copy the final libraries
mkdir -p "$OutDir"
OutDir="$(grealpath "$OutDir")"
echo "Building $RID"
mkdir -p "Build"
pushd "Build"
# ================== #
# STEP 2: Clone SFML #
# ================== #
if [[ ! -d "SFML/.git" ]]; then
echo "Cloning SFML"
rm -rf "SFML"
git clone --branch "$SFMLBranch" --depth 1 "git://github.com/SFML/SFML.git" "SFML"
fi
SFMLDir="$(grealpath SFML)"
# ================== #
# STEP 3: Build SFML #
# ================== #
rm -rf "$RID"
mkdir -p "$RID"
pushd "$RID"
echo "Building SFML"
mkdir -p SFML
pushd SFML
SFMLBuiltDir="$(grealpath .)" # The directory where SFML was built to. Used later to direct cmake when building CSFML
mkdir -p lib
# The directory that contains the final SFML libraries
# Since linux libraries don't support static linking from a shared library, this is used to copy the
# SFML shared libraries together with the CSFML shared libraries into SFML.Net
SFMLLibDir="$(grealpath lib)"
if [ $RID == "osx.10.15-x64" ]; then
ARCHITECTURE="x86_64"
TARGET="10.15"
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/"
elif [ $RID == "osx.11.0-x64" ]; then
ARCHITECTURE="x86_64"
TARGET="11.0"
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/"
elif [ $RID == "osx.11.0-arm64" ]; then
ARCHITECTURE="arm64"
TARGET="11.0"
SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/"
echo "Note: arm64 is only supported with SFML 2.6"
else
echo "Unsupported RID provided. Use 'osx.10.15-x64', 'osx.11.0-x64' or 'osx.11.0-arm64'"
exit 1
fi
cmake -E env \
cmake -G "Unix Makefiles" \
-D 'BUILD_SHARED_LIBS=ON' \
-D 'CMAKE_BUILD_TYPE=Release' \
-D "CMAKE_OSX_ARCHITECTURES=$ARCHITECTURE" \
-D "CMAKE_OSX_DEPLOYMENT_TARGET=$TARGET" \
-D "CMAKE_OSX_SYSROOT=$SYSROOT" \
-D "CMAKE_LIBRARY_OUTPUT_DIRECTORY=$SFMLLibDir" \
-D 'CMAKE_BUILD_WITH_INSTALL_RPATH=ON' \
-D 'CMAKE_INSTALL_RPATH=@executable_path' \
"$SFMLDir"
cmake --build . --config Release
popd # Pop SFML
# =================== #
# STEP 4: Build CSFML #
# =================== #
echo "Building CSFML using SFML at $SFMLBuiltDir"
mkdir -p CSFML
pushd CSFML
mkdir -p lib
CSFMLLibDir="$(realpath lib)" # The directory that contains the final CSFML libraries. Used to copy the result into SFML.Net
cmake -E env \
cmake -G "Unix Makefiles" \
-D "SFML_DIR=$SFMLBuiltDir" \
-D 'BUILD_SHARED_LIBS=ON' \
-D 'CMAKE_BUILD_TYPE=Release' \
-D "CMAKE_OSX_ARCHITECTURES=$ARCHITECTURE" \
-D "CMAKE_OSX_DEPLOYMENT_TARGET=$TARGET" \
-D "CMAKE_OSX_SYSROOT=$SYSROOT" \
-D "CMAKE_LIBRARY_OUTPUT_DIRECTORY=$CSFMLLibDir" \
-D 'CMAKE_BUILD_WITH_INSTALL_RPATH=ON' \
-D 'CMAKE_INSTALL_RPATH=@executable_path' \
"$CSFMLDir"
cmake --build . --config Release
# ======================================== #
# STEP 5: Copy result to the NuGet folders #
# ======================================== #
# Copies one SFML and CSFML module into the NuGet package
# The module name must be passed to this function as an argument, in lowercase
# This function then copies $SFMLLibDir/libsfml-(module).so and
# $CSFMLLibDir/libcsfml-(module).so into $OutDir
copymodule()
{
MODULE="$1"
mkdir -p "$OutDir"
# Note the wildcard at the end of the first argument
# We are copying every versioned file here, not just the .dylib
# (libsfml-audio.dylib, libsfml-audio.2.dylib, libsfml-audio.2.5.dylib, etc)
# This is needed because of the way macOS searches for libraries based
# one their SONAME
cp "$SFMLLibDir/libsfml-$MODULE."* "$OutDir"
cp "$CSFMLLibDir/libcsfml-$MODULE."* "$OutDir"
}
copymodule audio
copymodule graphics
copymodule system
copymodule window
popd # Pop CSFML
popd # Pop $RID
popd # Pop Build
+207
View File
@@ -0,0 +1,207 @@
Param(
[Parameter(Position = 0)]
[string] $RID
)
$ErrorActionPreference = "Stop"
# =================================================== #
# STEP 1: Setup all variables needed during the build #
# =================================================== #
if (-not $RID) {
Write-Output "No RID specified, building all known RIDs"
./build.win.ps1 "win-x86"
./build.win.ps1 "win-x64"
exit
}
$Generator = 'Visual Studio 16 2019'
switch ($RID) {
'win-x86' {
$Architecture = 'Win32'
}
'win-x64' {
$Architecture = 'x64'
}
Default {
Write-Error "Unknown RID '$RID'"
exit
}
}
Write-Output "Building $RID"
Write-Output "Using $Generator as the cmake generator"
Write-Output "Using architecture $Architecture"
$SFMLBranch = "2.5.x" # The branch or tag of the SFML repository to be cloned
$CSFMLDir = (Get-Item (git rev-parse --show-toplevel)).FullName # The directory of the source code of CSFML
$OutDir = "./CSFML/runtimes/$RID/native" # The directory of all CSFML modules, used to copy the final dlls
New-Item -ItemType Directory -ErrorAction Ignore $OutDir > $null
$OutDir = (Get-Item $OutDir).FullName
<#
.SYNOPSIS
Ensures that the last command run was a success, checking its exit code.
#>
function Ensure-Success() {
if ($LastExitCode -ne 0) {
exit
}
}
<#
.SYNOPSIS
Creates a new subdirectory of the current working directory and pushes it into the directory
stack with Push-Location, so that it can be reverted with Pop-Location.
.PARAMETER path
The path to create and push.
#>
function New-Push($path) {
New-Item -ItemType Directory -ErrorAction Ignore $path > $null
Push-Location $path > $null
}
New-Push "Build"
# ================== #
# STEP 2: Clone SFML #
# ================== #
If (-not (Test-Path "SFML/.git")) {
Write-Output "Cloning SFML"
Remove-Item -Recurse -Force -ErrorAction Ignore "SFML" > $null
git clone --branch "$SFMLBranch" --depth 1 "git://github.com/SFML/SFML.git" "SFML"
Ensure-Success
}
Push-Location "SFML"
$SFMLDir = (Get-Item .).FullName
switch ($RID) {
'win-x86' {
$SFMLExtLibs = (Get-Item ./extlibs/libs-msvc-universal/x86).FullName
$SFMLAudioExtras = (Get-Item ./extlibs/bin/x86).FullName
}
'win-x64' {
$SFMLExtLibs = (Get-Item ./extlibs/libs-msvc-universal/x64).FullName
$SFMLAudioExtras = (Get-Item ./extlibs/bin/x64).FullName
}
Default {
Write-Error "Unknown RID '$RID'"
exit
}
}
Pop-Location # Pop SFML
# ================== #
# STEP 3: Build SFML #
# ================== #
Remove-Item -Recurse -Force -ErrorAction Ignore "$RID"
New-Push "$RID"
Write-Output "Building SFML"
New-Push SFML
$SFMLBuiltDir = Get-Location # The directory where SFML was built to. Used later to direct cmake when building CSFML
cmake `
'-DBUILD_SHARED_LIBS=0' `
'-DCMAKE_BUILD_TYPE=Release' `
'-DCMAKE_SYSTEM_VERSION=8.1' `
'-DSFML_USE_STATIC_STD_LIBS=1' `
"-G$Generator" `
"-A$Architecture" `
$SFMLDir
Ensure-Success
cmake --build . --config Release -- '-verbosity:minimal'
Ensure-Success
Pop-Location # Pop SFML
# =================== #
# STEP 4: Build CSFML #
# =================== #
Write-Output "Building CSFML using SFML at $SFMLBuiltDir"
New-Push CSFML
New-Item -ItemType Directory lib > $null
$CSFMLLibDir = (Get-Item lib).FullName; # The directory where the final CSFML dlls are located
cmake `
"-DSFML_DIR=$SFMLBuiltDir" `
'-DCSFML_LINK_SFML_STATICALLY=1' `
"-DCMAKE_LIBRARY_PATH=$SFMLExtLibs" `
`
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$CSFMLLibDir" `
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=$CSFMLLibDir" `
`
"-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=$CSFMLLibDir" `
"-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=$CSFMLLibDir" `
`
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$CSFMLLibDir" `
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=$CSFMLLibDir" `
`
'-DCMAKE_SYSTEM_VERSION=8.1' `
'-DSTATIC_STD_LIBS=1' `
`
"-DBUILD_SHARED_LIBS=1" `
'-DCMAKE_BUILD_TYPE=Release' `
`
"-G$generator" `
"-A$Architecture" `
`
$CSFMLDir
Ensure-Success
cmake --build . --config Release -- '-verbosity:minimal'
Ensure-Success
# ======================================== #
# STEP 5: Copy result to the NuGet folders #
# ======================================== #
Write-Output "Copying CSFML modules"
<#
.SYNOPSIS
Copies a specific CSFML module into its proper NuGet project
.DESCRIPTION
This function locates a file named csfml-(module)-2.dll inside of the
folder specified by $CSFMLLibDir and copies it to $OutDir/csfml-(module).dll.
Notice how it removes the "-2" at the end, to make the name compatible with other platforms.
.PARAMETER module
The case-insensitive name of the module to copy.
#>
function Copy-Module($module) {
Write-Output "Copying CSFML $module"
New-Item -ItemType Directory $OutDir -ErrorAction Ignore > $null
Copy-Item "$CSFMLLibDir/csfml-$module-2.dll" "$OutDir/csfml-$module.dll" -Force > $null
}
Copy-Module 'audio'
Copy-Module 'graphics'
Copy-Module 'system'
Copy-Module 'window'
Write-Output "Copying Audio module extra files"
Copy-Item "$SFMLAudioExtras/*" "$OutDir"
Pop-Location # Pop CSFML
Pop-Location # Pop $RID
Pop-Location # Pop Build
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
# Alpine Linux doesn't come with bash by default, so we need to bootstrap everything with sh
# Automatically exit on error
set -e
apk add \
bash \
git \
freetype-dev \
libx11-dev \
libxrandr-dev \
eudev-dev \
mesa-dev \
flac-dev \
libogg-dev \
libvorbis-dev \
openal-soft-dev \
libpthread-stubs \
cmake \
make \
g++
./build.linux.sh alpine-x64
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
# Automatically exit on error
set -e
apt-get update
apt-get install -y \
git \
libfreetype6-dev \
xorg-dev \
libxrandr-dev \
libudev-dev \
libgl1-mesa-dev \
libflac-dev \
libogg-dev \
libvorbis-dev \
libvorbisenc2 \
libvorbisfile3 \
libopenal-dev \
libpthread-stubs0-dev \
cmake \
g++
./build.linux.sh debian-x64
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# Automatically exit on error
set -e
dnf install -y \
git \
freetype-devel \
xorg-x11-server-devel \
libXrandr-devel \
systemd-devel \
mesa-libEGL-devel \
flac-devel \
libogg-devel \
libvorbis-devel \
openal-soft-devel \
gcc-c++ \
cmake \
make
./build.linux.sh fedora-x64
+34
View File
@@ -0,0 +1,34 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSFML", "CSFML\CSFML.csproj", "{A0261C3A-E44E-40E3-8030-C14E3272B720}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Debug|x64.ActiveCfg = Debug|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Debug|x64.Build.0 = Debug|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Debug|x86.ActiveCfg = Debug|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Debug|x86.Build.0 = Debug|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Release|Any CPU.Build.0 = Release|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Release|x64.ActiveCfg = Release|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Release|x64.Build.0 = Release|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Release|x86.ActiveCfg = Release|Any CPU
{A0261C3A-E44E-40E3-8030-C14E3272B720}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+28
View File
@@ -0,0 +1,28 @@
Param(
[Parameter(Mandatory, Position = 0)]
[string]$APIKey
)
dotnet build -c Release
if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed"
exit 1
}
$count = 0
$packages = (Get-ChildItem */bin/Release/*.nupkg)
foreach ($package in $packages) {
Write-Progress "Pushing packages" -CurrentOperation "Pushing $($package.Name)" -PercentComplete (($count * 100.0) / $packages.Length)
dotnet nuget push -k $APIKey -s https://api.nuget.org/v3/index.json $package.FullName
if ($LASTEXITCODE -ne 0) {
Write-Error "Unable to push $($package.Name)"
exit 1
}
$count++
}
Write-Progress "Done" -Completed
Write-Output "Successfully pushed $count packages"
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
# Automatically exit on error
set -e
if [ -z "$1" ]; then
echo "Specify the NuGet API Key as a parameter to this script"
exit 1
fi
dotnet build -c Release
# Find every file that matches the glob ./*/bin/Release/*.nupkg
# and push it to nuget.org using the key specified as a parameter
# to this script
find \
-type f \
-regex "\./\w+/bin/Release/[^/]+\.nupkg" \
-exec dotnet nuget push -k "$1" -s "https://api.nuget.org/v3/index.json" "{}" ";"