Author SHA1 Message Date
Lukas Dürrenberger 3666ab8f3b Add artifact storage for GitHub Actions 2022-03-26 00:06:15 +01:00
crumblingstatue 317f58fa31 Make sure CallbackStream doesn't get destroyed before the Music
Music's destructor call's stop(), which in turn calls onSeek.
For CSFML, this requires the CallbackStream to stay alive until that point.

In C++, destructors for fields are called in reverse declaration order.
We swap the order of the fields, putting the Music after the
CallbackStream, so it gets destroyed before it.
2021-08-02 23:54:39 +02:00
Lukas Dürrenberger 1d05e82f25 Use Markdown for the readme and license files 2021-07-13 09:00:43 +02:00
Lukas Dürrenberger c5a37aed84 Add build scripts for macOS and Windows 2021-07-11 22:37:39 +02:00
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
31 changed files with 1690 additions and 80 deletions

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
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 VS2019,
os: windows-2019,
sfml-flags: -DBUILD_SHARED_LIBS=FALSE -DSFML_USE_STATIC_STD_LIBS=TRUE,
csfml-flags: -DCSFML_LINK_SFML_STATICALLY=TRUE -DSTATIC_STD_LIBS=TRUE,
}
- {
name: Windows VS2022,
os: windows-2022,
sfml-flags: -DBUILD_SHARED_LIBS=FALSE -DSFML_USE_STATIC_STD_LIBS=TRUE,
csfml-flags: -DCSFML_LINK_SFML_STATICALLY=TRUE -DSTATIC_STD_LIBS=TRUE,
}
- {
name: Linux GCC,
os: ubuntu-latest,
sfml-flags: -DBUILD_SHARED_LIBS=TRUE -DSFML_USE_STATIC_STD_LIBS=FALSE,
csfml-flags: -DCSFML_LINK_SFML_STATICALLY=FALSE -DSTATIC_STD_LIBS=FALSE,
}
- {
name: Linux Clang,
os: ubuntu-latest,
flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++,
sfml-flags: -DBUILD_SHARED_LIBS=TRUE -DSFML_USE_STATIC_STD_LIBS=FALSE,
csfml-flags: -DCSFML_LINK_SFML_STATICALLY=FALSE -DSTATIC_STD_LIBS=FALSE,
}
- {
name: MacOS XCode,
os: macos-latest,
prefix: sudo,
flags: -DSFML_BUILD_FRAMEWORKS=FALSE,
sfml-flags: -DBUILD_SHARED_LIBS=TRUE -DSFML_USE_STATIC_STD_LIBS=FALSE,
csfml-flags: -DCSFML_LINK_SFML_STATICALLY=FALSE -DSTATIC_STD_LIBS=FALSE,
}
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@v3
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=FALSE -DSFML_BUILD_EXAMPLES=FALSE -DSFML_BUILD_TEST_SUITE=FALSE -DCMAKE_VERBOSE_MAKEFILE=ON ${{matrix.platform.flags}} ${{matrix.platform.sfml-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@v3
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 -DSFML_DIR=$GITHUB_WORKSPACE/SFML/install/lib/cmake/SFML -DCMAKE_VERBOSE_MAKEFILE=ON ${{matrix.platform.flags}} ${{matrix.platform.csfml-flags}}
- name: Build CSFML
shell: bash
run: cmake --build $GITHUB_WORKSPACE/CSFML/build --config Release --target install
- name: Upload CSFML Artefact
uses: actions/upload-artifact@v3
with:
name: CSFML - ${{ matrix.platform.name }}
path: ${{ github.workspace }}/CSFML/install
+3 -3
View File
@@ -22,7 +22,7 @@ include(${CMAKE_SOURCE_DIR}/cmake/Config.cmake)
# setup version numbers # setup version numbers
set(VERSION_MAJOR 2) set(VERSION_MAJOR 2)
set(VERSION_MINOR 5) set(VERSION_MINOR 5)
set(VERSION_PATCH 0) set(VERSION_PATCH 1)
# add the CSFML header path # add the CSFML header path
include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_SOURCE_DIR}/include)
@@ -72,5 +72,5 @@ install(DIRECTORY include
DESTINATION . DESTINATION .
COMPONENT devel COMPONENT devel
PATTERN ".svn" EXCLUDE) PATTERN ".svn" EXCLUDE)
install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR}) install(FILES license.md DESTINATION ${INSTALL_MISC_DIR})
install(FILES readme.txt DESTINATION ${INSTALL_MISC_DIR}) install(FILES readme.md DESTINATION ${INSTALL_MISC_DIR})
+6
View File
@@ -64,6 +64,12 @@ elseif(MSVC)
set(SFML_MSVC_VERSION 11) set(SFML_MSVC_VERSION 11)
elseif(MSVC_VERSION EQUAL 1800) elseif(MSVC_VERSION EQUAL 1800)
set(SFML_MSVC_VERSION 12) 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() endif()
else() else()
message(FATAL_ERROR "Unsupported compiler") message(FATAL_ERROR "Unsupported compiler")
+1 -1
View File
@@ -31,7 +31,7 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#define CSFML_VERSION_MAJOR 2 #define CSFML_VERSION_MAJOR 2
#define CSFML_VERSION_MINOR 5 #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 /// \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 /// \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 /// \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 /// \brief Enable or disable the smooth filter on a render texture
+15
View File
@@ -0,0 +1,15 @@
# CSFML
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 liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
## External libraries used by CSFML
* _SFML_ is under the zlib/png license
-31
View File
@@ -1,31 +0,0 @@
CSFML
-----
CSFML - Copyright (C) 2007-2018 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
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but
is not required.
2. Altered source versions must be plainly marked as such,
and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any
source distribution.
External libraries used by CSFML
--------------------------------
* SFML is under the zlib/png license
+34
View File
@@ -0,0 +1,34 @@
[![SFML logo](https://www.sfml-dev.org/images/logo.png)](https://www.sfml-dev.org)
# CSFML - Simple and Fast Multimedia Library for C
SFML is a simple, fast, cross-platform and object-oriented multimedia API. It provides access to windowing, graphics, audio and network. It is originally written in C++, and this project is its official binding for the C language.
## Authors
- Laurent Gomila - main developer (laurent@sfml-dev.org)
- Lukas Dürrenberger - active maintainer (eXpl0it3r@sfml-dev.org)
- Zachariah Brown (contact@zbrown.net)
## Download
You can get the latest official release on [SFML website](https://www.sfml-dev.org/download/csfml). You can also get the current development version from the [Git repository](https://github.com/SFML/CSFML).
## Learn
There is no tutorial for CSFML, but since it's a binding you can use the C++ resources:
* The [official tutorials](https://www.sfml-dev.org/tutorials/)
* The [online API documentation](https://www.sfml-dev.org/documentation/)
* The [community wiki](https://github.com/SFML/SFML/wiki/)
* The [community forum](https://en.sfml-dev.org/forums/) (or [French](https://fr.sfml-dev.org/forums/)
Of course, you can also find the CSFML API documentation in the SDK.
## Building
Set `SFML_DIR` to a directory containing the `SFMLConfig.cmake` file, usually located at `lib/cmake/SFML`.
## Contribute
SFML and CSFML are open-source projects, and they need your help to go on growing and improving. Don't hesitate to post suggestions or bug reports on [the forum](https://en.sfml-dev.org/forums/), or post new bugs/features requests on the [issue tracker](https://github.com/SFML/CSFML/issues/). You can even fork the project on GitHub, maintain your own version and send us pull requests periodically to merge your work.
-42
View File
@@ -1,42 +0,0 @@
CSFML - Simple and Fast Multimedia Library for C
================================================
SFML is a simple, fast, cross-platform and object-oriented multimedia API. It provides access to windowing,
graphics, audio and network.
It is originally written in C++, and this project is its official binding for the C language.
Authors
-------
Laurent Gomila - main developer (laurent@sfml-dev.org)
Zachariah Brown - active maintainer (contact@zbrown.net)
Download
--------
You can get the latest official release on SFML website (http://www.sfml-dev.org/download/csfml).
You can also get the current development version from the git repository (https://github.com/SFML/CSFML).
Learn
-----
There is no tutorial for CSFML, but since it's a binding you can use the C++ resources:
* The official tutorials (http://www.sfml-dev.org/tutorials/)
* The online API documentation (http://www.sfml-dev.org/documentation/)
* The community wiki (https://github.com/SFML/SFML/wiki/)
* The community forum (http://en.sfml-dev.org/forums/) (or http://fr.sfml-dev.org/forums/ for French people)
Of course, you can also find the CSFML API documentation in the SDK.
Building
--------
The FindSFML.cmake script required by CMake to build CSFML, is located in SFML's cmake/Modules/ directory.
Contribute
----------
SFML and CSFML are open-source projects, and they need your help to go on growing and improving.
Don't hesitate to post suggestions or bug reports on the forum (http://en.sfml-dev.org/forums/),
or post new bugs/features requests on the task tracker (https://github.com/SFML/CSFML/issues/).
You can even fork the project on GitHub, maintain your own version and send us pull requests periodically to merge your work.
+1 -1
View File
@@ -37,8 +37,8 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct sfMusic struct sfMusic
{ {
sf::Music This;
CallbackStream Stream; CallbackStream Stream;
sf::Music This;
}; };
+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) void sfTexture_updateFromImage(sfTexture* texture, const sfImage* image, unsigned int x, unsigned int y)
{ {
+609
View File
@@ -0,0 +1,609 @@
#!/bin/sh
VERSION="2.5.1"
VERSION_C="2.5.1"
# BUILD_CSFML=FALSE
BUILD_CSFML=TRUE
BUILD_SFML=FALSE
###
### Create packages for SFML $VERSION on OS X
###
### Author: Marco Antognini <antognini.marco@gmail.com>
### Date: 15/11/2014
###
##
## SETTINGS
##
## Edit $VERSION & $VERSION_C above
##
sfml_giturl='https://github.com/SFML/SFML.git'
csfml_giturl='https://github.com/SFML/CSFML.git'
gittag="$VERSION"
gittag_c="$VERSION_C"
topdir=$(pwd)
tmpdir="$topdir/tmp/"
codedir="$tmpdir/code/"
cmakedir="$tmpdir/cmake/"
builddir="$tmpdir/build/"
installdir="$tmpdir/install/"
sfml_package_source_zip="$topdir/SFML-$gittag-sources.zip"
sfml_source_archive_url="https://github.com/SFML/SFML/archive/$gittag.zip"
sfml_package1070name="SFML-$gittag-macos-clang"
sfml_package1070="$topdir/$sfml_package1070name/"
sfml_archive1070="$sfml_package1070name.tar.gz"
csfml_package1070name="CSFML-$gittag_c-macos-clang"
csfml_package1070="$topdir/$csfml_package1070name/"
csfml_archive1070="$csfml_package1070name.tar.gz"
SDK1070="/Developer/SDKs/MacOSX10.7.sdk"
##
## HELPER FUNCTIONS
##
## Echoes to stderr, and die
error () # $* message to display
{
echo "$@" 1>&2
exit 2
}
## Check that the number of parameters is correct, or die
param_check () # $1 should be $# on call site,
# $2 the number of required params,
# $3 an id for the error message
{
if [ $# -ne 3 ]
then
error "Internal error in param_error: the number of parameters is incorrect"
fi
if [ $1 -ne $2 ]
then
error "Internal error in $3: the number of parameters is incorrect"
fi
}
## Check that the number of parameters is enough, or die
param_check_ge () # $1 should be $# on call site,
# $2 the minimal number of params,
# $3 an id for the error message
{
param_check $# 3 "param_check_ge"
if [ $1 -lt $2 ]
then
error "Internal error in $3: the number of parameters is not enough"
fi
}
## Assert $1 is true, or die
assert () # $1: boolean, $2: an error message
{
param_check $# 2 "assert"
if [ $1 -ne 0 ]
then
error "$2"
fi
}
## Create directory, or die
# === mkdir -p $1
create_dir () # $1: path
{
param_check $# 1 "create_dir"
mkdir -p "$1"
assert $? "Couldn't create $1"
}
## Destroy and create directory, or die
re_create_dir () # $1: path
{
param_check $# 1 "re_create_dir"
destroy "$1"
create_dir "$1"
}
## Destroy directory, or die
# === rm -fr $1
destroy () # $1: path
{
param_check $# 1 "destroy"
rm -fr "$1"
assert $? "Couldn't destroy $1"
}
## [with root access] Destroy directory, or die
# === rm -fr $1
sudo_destroy () # $1: path
{
param_check $# 1 "sudo_destroy"
echo "sudo_destroy need root password for deleting $1"
sudo rm -fr "$1"
assert $? "Couldn't destroy $1"
}
## Destroy all paths, or die
destroy_all () # $1...N: paths
{
param_check_ge $# 1 "destroy_all"
for path in "$@"
do
destroy "$path"
done
}
## [with root access] Destroy all paths, or die
sudo_destroy_all () # $1...N: paths
{
param_check_ge $# 1 "sudo_destroy_all"
for path in "$@"
do
sudo_destroy "$path"
done
}
## Copy files/directories, recursively, or die
copy () # $1...N: src, $N+1: dest
{
param_check_ge $# 2 "copy"
cp -R "$@"
assert $? "Couldn't copy $1 to $2"
}
## Go to dir with pushd, or die
push_pwd () # $1: path
{
param_check $# 1 "push_pwd"
pushd "$1"
assert $? "Couldn't go to $1"
}
## Go back, or die
pop_pwd ()
{
param_check $# 0 "pop_pwd"
popd
assert $? "Couldn't go back"
}
## Create a .tar.gz archive, or die
archive () # $1: src dir, $2: archive name
{
param_check $# 2 "archive"
push_pwd "$1/.."
src=$(basename "$1")
tar -zcvf "$2" "$src"
assert $? "Zip failed for $2"
pop_pwd
}
## Build SFML with CMake and Make, or die
build_sfml () # $1: 'clang' => clang & libc++
# $2: 'frameworks'/'dylibs'
# $3: 'doc'/'no doc'
# $4: 'examples'/'no examples'
# $5: 'templates'/'no templates'
# $6: '10.7 SDK'
{
param_check $# 6 "build_sfml"
case "$1" in
'clang')
cxx="clang++"
cc="clang"
cxx_flags="-stdlib=libc++"
cc_flags="-stdlib=libc++"
;;
*)
error "Unknown compiler for $1 in create_makefile"
;;
esac
case "$2" in
'frameworks')
frameworks="TRUE"
installdir_adapted="$installdir/Library/Frameworks"
;;
'dylibs')
frameworks="FALSE"
installdir_adapted="$installdir/usr/local"
;;
*)
error "Unknown option for $2 in create_makefile"
;;
esac
case "$3" in
'doc')
doc="TRUE"
;;
'no doc')
doc="FALSE"
;;
*)
error "Unknown option for $3 in create_makefile"
;;
esac
case "$4" in
'examples')
examples="TRUE"
makeopts=""
# NB: cannot use -j8 here because it bugs with cocoa example...
;;
'no examples')
examples="FALSE"
makeopts="-j8"
;;
*)
error "Unknown option for $4 in create_makefile"
;;
esac
case "$5" in
'templates')
templates="TRUE"
;;
'no templates')
templates="FALSE"
;;
*)
error "Unknown option for $5 in create_makefile"
;;
esac
case "$6" in
'10.7 SDK')
target="10.7"
sdk="$SDK1070"
;;
*)
error "Unknown option for $6 in create_makefile"
;;
esac
re_create_dir "$cmakedir"
push_pwd "$cmakedir"
cmake -G "Unix Makefiles" \
-D "BUILD_SHARED_LIBS:BOOL=TRUE" \
-D "CMAKE_BUILD_TYPE:STRING=Release" \
-D "CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/$cxx" \
-D "CMAKE_CXX_FLAGS:STRING=$cxx_flags" \
-D "CMAKE_C_COMPILER:FILEPATH=/usr/bin/$cc" \
-D "CMAKE_C_FLAGS:STRING=$cc_flags" \
-D "CMAKE_INSTALL_PREFIX:PATH=$installdir_adapted" \
-D "SFML_DEPENDENCIES_INSTALL_PREFIX:STRING=$installdir/Library/Frameworks" \
-D "SFML_MISC_INSTALL_PREFIX:STRING=$installdir/usr/local/share/SFML" \
-D "CMAKE_OSX_ARCHITECTURES:STRING=x86_64" \
-D "CMAKE_OSX_DEPLOYMENT_TARGET:STRING=$target" \
-D "CMAKE_OSX_SYSROOT:STRING=$sdk" \
-D "SFML_BUILD_DOC:BOOL=$doc" \
-D "SFML_BUILD_EXAMPLES:BOOL=$examples" \
-D "SFML_BUILD_FRAMEWORKS:BOOL=$frameworks" \
-D "SFML_INSTALL_XCODE_TEMPLATES:BOOL=$templates" \
"$codedir"
assert $? "CMake failed"
destroy "$installdir"
make clean && make $makeopts && make install
assert $? "Make failed"
pop_pwd
}
## Build SFML with CMake and Make, or die
build_csfml () # $1: 'clang' => clang & libc++
# $2: 'doc'/'no doc'
# $3: '10.7 SDK'
{
param_check $# 3 "build_csfml"
case "$1" in
'clang')
cxx="clang++"
cc="clang"
cxx_flags="-stdlib=libc++"
cc_flags="-stdlib=libc++"
;;
*)
error "Unknown compiler for $1 in create_makefile"
;;
esac
case "$2" in
'doc')
doc="TRUE"
;;
'no doc')
doc="FALSE"
;;
*)
error "Unknown option for $2 in create_makefile"
;;
esac
case "$3" in
'10.7 SDK')
target="10.7"
sdk="$SDK1070"
;;
*)
error "Unknown option for $3 in create_makefile"
;;
esac
makeopts="-j8"
re_create_dir "$cmakedir"
push_pwd "$cmakedir"
cmake -G "Unix Makefiles" \
-D "BUILD_SHARED_LIBS:BOOL=TRUE" \
-D "CMAKE_BUILD_TYPE:STRING=Release" \
-D "CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/$cxx" \
-D "CMAKE_CXX_FLAGS:STRING=$cxx_flags" \
-D "CMAKE_C_COMPILER:FILEPATH=/usr/bin/$cc" \
-D "CMAKE_C_FLAGS:STRING=$cc_flags" \
-D "CMAKE_INSTALL_PREFIX:PATH=$installdir/usr/local" \
-D "CMAKE_OSX_ARCHITECTURES:STRING=x86_64" \
-D "CMAKE_OSX_DEPLOYMENT_TARGET:STRING=$target" \
-D "CMAKE_OSX_SYSROOT:STRING=$sdk" \
-D "BUILD_DOC:BOOL=$doc" \
-D "SFML_DIR:PATH=$sfml_package1070/Frameworks/SFML.framework/Versions/$gittag/Resources/CMake" \
"$codedir"
assert $? "CMake failed"
destroy "$installdir"
make clean && make $makeopts && make install
assert $? "Make failed"
pop_pwd
}
## Install a package (dylibs only) to compile CSFML later on, or die
minimal_install_package () # $1: path to package
{
param_check $# 1 "install_package"
push_pwd "$1"
create_dir "/usr/local/share/SFML/cmake"
# copy "cmake/Modules/FindSFML.cmake" "/usr/local/share/cmake/Modules/"
copy "lib/" "/usr/local/lib/"
copy "include/" "/usr/local/include/"
pop_pwd
}
## Git clone, or die
clone () # $1: url, $2: dest, $3: branch or tag (also works with sha, but less efficiently)
{
param_check $# 3 "clone"
git clone "$1" --branch "$3" "$2" --depth 1 || git clone "$1" "$2" && git -C "$2" checkout "$3"
assert $? "Cannot download the source code from $1"
}
## Remove anything related to SFML
wipe_sfml ()
{
# Remove SFML from /usr/local
destroy_all "/usr/local/include/SFML" \
"/usr/local/lib/"libsfml-* \
"/usr/local/share/SFML"
# Remove SFML from /Library
sudo_destroy_all "/Library/Frameworks/"sfml-* \
"/Library/Frameworks/SFML.framework"
destroy_all "/Library/Developer/Xcode/Templates/SFML"
}
## Remove anything related to CSFML
wipe_csfml ()
{
# Remove CSFML from /usr/local (that's it)
destroy_all "/usr/local/include/CSFML" \
"/usr/local/lib/"libcsfml-* \
"/usr/local/share/CSFML"
}
##
## INITIALIZE
##
## Clean up before doing anything
wipe_sfml
wipe_csfml
destroy "$sfml_package_source_zip"
destroy_all "$sfml_archive1070" "$sfml_package1070"
destroy_all "$csfml_archive1070" "$csfml_package1070"
destroy "$tmpdir"
##
## CREATE SOURCE ARCHIVE
##
# we need to do it on a Unix compatible system to keep symlinks valid in frameworks extlibs
wget -O "$sfml_package_source_zip" "$sfml_source_archive_url"
assert $? "Couldn't download the source archive"
zip -d "$sfml_package_source_zip" "SFML-$gittag/.gitattributes"
assert $? "Couldn't remove extra files from source archive"
##
## DOWNLOAD SFML
##
## First, download the code from github
destroy "$codedir"
clone "$sfml_giturl" "$codedir" "$gittag"
##
## BUILD SFML FOR 1070
##
# Now configure CMake for 10.7, 64bits, clang & libc++, doc, example, templates, FRAMEWORKS
# and build SFML !
build_sfml 'clang' 'frameworks' 'doc' 'examples' 'templates' '10.7 SDK'
## Copy the results to the package dir
re_create_dir "$sfml_package1070"
copy "$installdir/usr/local/share/SFML/" \
"$sfml_package1070/"
create_dir "$sfml_package1070/extlibs/"
copy "$installdir/Library/Frameworks/FLAC.framework" \
"$installdir/Library/Frameworks/freetype.framework" \
"$installdir/Library/Frameworks/ogg.framework" \
"$installdir/Library/Frameworks/OpenAL.framework" \
"$installdir/Library/Frameworks/vorbis.framework" \
"$installdir/Library/Frameworks/vorbisenc.framework" \
"$installdir/Library/Frameworks/vorbisfile.framework" \
"$sfml_package1070/extlibs/"
create_dir "$sfml_package1070/Frameworks/"
copy "$installdir/Library/Frameworks/"sfml-* \
"$installdir/Library/Frameworks/SFML.framework" \
"$sfml_package1070/Frameworks/"
create_dir "$sfml_package1070/templates/"
copy "/Library/Developer/Xcode/Templates/SFML" \
"$sfml_package1070/templates/"
## Now configure CMake for 10.7, 64bits, clang & libc++, DYLIBS
build_sfml 'clang' 'dylibs' 'no doc' 'no examples' 'no templates' '10.7 SDK'
## Copy the results to the package dir
create_dir "$sfml_package1070/include/"
copy "$installdir/usr/local/include/SFML" \
"$sfml_package1070/include/"
create_dir "$sfml_package1070/lib/"
copy "$installdir/usr/local/lib/"libsfml-* \
"$sfml_package1070/lib/"
copy "$codedir/changelog.md" \
"$sfml_package1070/"
## Clean up some files
find "$sfml_package1070" -regex '.*/\.DS_Store' -delete
assert $? "Find failed while removing extra files"
find "$sfml_package1070" -regex '.*/*\.swp' -delete
assert $? "Find failed while removing extra files"
find "$sfml_package1070" -regex '.*/*~' -delete
assert $? "Find failed while removing extra files"
## Apply patch for templates to fix paths
curl -fsSl "template.2.5.0.patch" | patch "$sfml_package1070/templates/SFML/SFML App.xctemplate/TemplateInfo.plist" --no-backup-if-mismatch
assert $? "Couldn't apply patch on templates"
## And create archives
destroy "$tmpdir"
archive "$sfml_package1070" "$sfml_archive1070"
if [ $BUILD_CSFML != "TRUE" ]
then
echo "I'M NOT BUILDING CSFML!"
exit 0
fi
##
## DOWNLOAD CSFML
##
destroy "$codedir"
clone "$csfml_giturl" "$codedir" "$gittag_c"
##
## BUILD CSFML FOR 1070
##
wipe_sfml
minimal_install_package "$sfml_package1070"
build_csfml 'clang' 'doc' '10.7 SDK'
create_dir "$csfml_package1070/include/"
copy "$installdir/usr/local/include/SFML" \
"$csfml_package1070/include/"
create_dir "$csfml_package1070/lib/"
copy "$installdir/usr/local/lib/"libcsfml-* \
"$csfml_package1070/lib/"
copy "$installdir/usr/local/share/CSFML/" \
"$csfml_package1070/"
##
## CLEAN UP & ARCHIVE
##
find "$csfml_package1070" -regex '.*/\.DS_Store' -delete
assert $? "Find failed while removing extra files"
find "$csfml_package1070" -regex '.*/*\.swp' -delete
assert $? "Find failed while removing extra files"
find "$csfml_package1070" -regex '.*/*~' -delete
assert $? "Find failed while removing extra files"
## Clean up temporary directories
## And create archives
destroy "$tmpdir"
archive "$csfml_package1070" "$csfml_archive1070"
### End Of Script
+35
View File
@@ -0,0 +1,35 @@
Param(
[Parameter(Mandatory, Position = 0)]
[string]$architecture
)
Function Convert-DLL([string]$name)
{
& gendef.exe "..\..\bin\$name-2.dll"
& dlltool.exe -d "$name-2.def" -D "..\..\bin\$name-2.dll" -l "lib$name.a"
del "$name-2.def"
}
Function Create-ImportLib([string]$architecture)
{
New-Item -ItemType "directory" -Path "lib\gcc"
New-Item -ItemType "directory" -Path "lib\msvc"
Move-Item -Path "lib\*.lib" -Destination "lib\msvc"
$patharch = If($architecture -eq "x64") { "64" } Else { "32" }
$oldpath = $env:Path
$env:Path += ";C:\tools\mingw$patharch\bin\"
Push-Location "lib\gcc"
Convert-DLL("csfml-graphics")
Convert-DLL("csfml-window")
Convert-DLL("csfml-audio")
Convert-DLL("csfml-network")
Convert-DLL("csfml-system")
Pop-Location
$env:Path = $oldpath
}
Create-ImportLib $architecture
+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.1" # 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.1" # 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" "{}" ";"