Browse Source

Got it building on win32

master
dirkson 3 years ago
parent
commit
50ea11cfa4
  1. 69
      build
  2. 1
      include/simsecl.h
  3. 5
      meson.build
  4. 3
      src/simsecl.c

69
build

@ -14,10 +14,10 @@
#Directories
BUILDDIR=meson
DOCDIR=doc
BINDIR=bin
LIBDIR=lib
DEPDIR=subprojects
SCRIPTDIR=scripts
#***********
#***OSMIA***
@ -66,10 +66,10 @@ osmia_help () {
echo "-r OR --release : Builds using Meson's release mode"
echo "-d OR --debug : Builds using Meson's debug mode, with --werror added"
echo "-c OR --clean : Cleans up current project meson/ninja/osmia files"
echo "-fc OR --full-clean : Fully clean - Removes dependencies too"
echo "-fc OR --full-clean : Fully clean - Removes osmia dependencies too"
echo "-a OR --add-san : Clang's address sanitizer"
echo "-w OR --win : Cross-compile for win32 using scripts/win32cross.txt"
echo "-w64 OR --win64 : cross-compile for win64"
echo "-w32 OR --win32 : Cross-compile for win32 using subprojects/win32cross.txt"
echo "-w OR --win : cross-compile for win64 using subprojects/win64cross.txt"
echo "-o OR --osx : cross-compile for OSX"
}
osmia_clean () {
@ -91,11 +91,11 @@ osmia_get () {
if [ ! -d "$1" ]; then
$2
if [ ! $? -eq 0 ]; then
echo "Git command failed: $1"
echo "osmia: git command failed: $1"
exit 1
fi
if [ ! -d "$1" ]; then
echo "Could not find directory: $1"
echo "osmia: could not find directory: $1"
exit 1
fi
fi
@ -109,7 +109,7 @@ err=0;
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
err=1
echo "Er... Yeah, don't source this file."
echo "osmia: er... Yeah, don't source this file."
return 1
fi
@ -121,38 +121,39 @@ case "$1" in
MESONOPTS="--werror"
;;
-a)
COMPILER="clang"
DIR=debug
BLD=debug
MESONOPTS=-Db_sanitize=address
MESONOPTS="--werror"
;;
-w|-win|--win|-window|--windows)
-w32|-win32|--win32|-window32|--windows32)
DIR=release
BLD=release
MESONOPTS="--cross-file scripts/win32cross.txt"
MESONOPTS="--cross-file $DEPDIR/win32cross.txt"
;;
-w64|-win64|--win64|-windows64|--windows64)
-w|-win|--win|--window|--windows|-w64|-win64|--win64|--windows64|--windows64)
DIR=release
BLD=release
MESONOPTS="--cross-file scripts/win64cross.txt"
MESONOPTS="--cross-file $DEPDIR/win64cross.txt"
;;
-c|-clean|--clean)
if [ "$#" -ne 1 ]; then
echo "You passed additional arguments to clean. I have no idea what you want. Did not clean."
echo "osmia: you passed additional arguments to clean. I have no idea what you want. Did not clean."
exit 1
fi
osmia_clean
echo "Cleaned."
echo "osmia: cleaned."
exit 0
;;
-fc|-fullclean|--fullclean|-full-clean|--full-clean)
if [ "$#" -ne 1 ]; then
echo "You passed additional arguments to clean. I have no idea what you want. Did not clean."
echo "osmia: you passed additional arguments to clean. I have no idea what you want. Did not clean."
exit 1
fi
osmia_clean
rm -rf $DEPDIR
echo "Fully cleaned."
#rm -rf $DEPDIR
echo "osmia: fully cleaned."
exit 0
;;
-?|-h|-help|--help)
@ -171,19 +172,19 @@ if [ -z "$NINJACOMMAND" ]; then
if [ ! -x "$(command -v $NINJACOMMAND)" ]; then
NINJACOMMAND=samu
if [ ! -x "$(command -v $NINJACOMMAND)" ]; then
echo "Neither ninja nor samu are installed. One of the two is required to build."
echo "Please install either samurai's samu of ninja-build's ninja."
echo "osmia: neither ninja nor samu are installed. One of the two is required to build."
echo "osmia: Please install either samurai's samu or ninja-build's ninja."
err=1;
fi
fi
else
if [ ! -x "$(command -v $NINJACOMMAND)" ]; then
echo "Manually specified ninja command not found"
echo "osmia: manually specified ninja command not found"
err=1;
fi
fi
if [ ! -x "$(command -v meson)" ]; then
echo "Meson not installed. The meson build system is required to build, please install.";
echo "osmia: meson not installed. The meson build system is required to build, please install.";
err=1;
fi
if [ -z "$COMPILER" ]; then
@ -198,23 +199,25 @@ if [ -z "$COMPILER" ]; then
elif [ -x "$(command -v icc)" ]; then
COMPILER="icc"
else
echo "Unable to find any compiler at all. Please install one: clang, musl-gcc, gcc, tcc, icc"
echo "osmia: unable to find any compiler at all. Please install one: clang, musl-gcc, gcc, tcc, icc"
err=1
fi
else
if [ ! -x "$(command -v $COMPILER)" ]; then
echo "Manually specified compiler does not exist. Failing."
echo "osmia: manually specified compiler does not exist. Failing."
err=1
fi
fi
if [ ! -x "$(command -v ccache)" ]; then
echo "ccache not installed. Installing it could speed the build up. Hint Hint.";
CACHE=""
echo "osmia: ccache not installed. Installing it could speed the build up. Hint Hint."
else
CACHE="ccache"
fi
if [ "$#" -gt 2 ]; then
echo "Too many parameters. Failing."
osmia_help
echo "Too many parameters. Failing."
echo "osmia: failed, too many parameters."
err=1;
fi
@ -224,10 +227,9 @@ if [ $err -ne 0 ]; then
fi
#Grab dependencies
if [ -d "$SCRIPTDIR" ] && [ -e scripts/dependencies ]; then
mkdir -p $DEPDIR 2> /dev/null
if [ -d "$DEPDIR" ] && [ -e $DEPDIR/dependencies ]; then
cd "$DEPDIR"
source ../scripts/dependencies
source ../$DEPDIR/dependencies
cd ../
fi
@ -238,15 +240,15 @@ mkdir -p $BUILDDIR 2> /dev/null
#MESONOPTS=MESONOPTS:"-Dc_args=$3"
if [ ! -d "$BUILDDIR/$DIR" ]; then
export CC="$COMPILER"
export CC="$CACHE $COMPILER"
#Run meson if required
mkdir $BUILDDIR/$DIR
meson $BUILDDIR/$DIR $MESONOPTS --buildtype $BLD
if [ ! $? -eq 0 ]; then
#Generally an error here means we need to clean before the next run
tail $BUILDDIR/$DIR/meson/logs/meson-log.txt
cp $BUILDDIR/$DIR/meson/logs/meson-log.txt meson-log.txt
echo "Meson error! Log output to meson-log.txt"
tail $BUILDDIR/$DIR/meson-logs/meson-log.txt
cp $BUILDDIR/$DIR/meson-logs/meson-log.txt meson-log.txt
echo "osmia: meson returned an error. Please check meson-log.txt for more info."
osmia_clean
exit 1
fi
@ -267,5 +269,8 @@ cd ../../
#set up symlinks
osmia_symlink "$BUILDDIR/$DIR/*" "-name *.a -o -name *.so -o -name *.dll" $LIBDIR
osmia_symlink "$BUILDDIR/$DIR/*" "-not -name *.so -not -name *.dll -executable -not -name sanitycheckc.exe" $BINDIR
osmia_symlink "$BUILDDIR/$DIR/*" "-name *.html -o -name *.htm" $DOCDIR
echo "osmia: successful build."
exit 0

1
include/simsecl.h

@ -9,7 +9,6 @@
#include <string.h>
#include <sodium.h>
#include <mpack.h>
typedef enum simsecl_return
{

5
meson.build

@ -8,13 +8,16 @@ endif
simsecl_src = ['src/simsecl.c']
depmpack = dependency('mpack', required:true)
#depmpack = dependency('mpack', required:true)
depsodium = dependency('libsodium', required:true)
subproject('parasol', default_options : ['default_library=static', 'c_std=gnu89'])
depparasol = dependency('parasol', fallback : ['parasol', 'parasol_dep'], required:true)
subproject('mpack', default_options : ['default_library=static', 'c_std=c99'])
depmpack = dependency('mpack', fallback : ['mpack', 'mpack_dep'], required:true)
libsimsecl = library('simsecl', simsecl_src, include_directories : incdir, dependencies: [depsodium, depparasol, depmpack])
simsecl_dep = declare_dependency(link_with : libsimsecl, include_directories : incdir)

3
src/simsecl.c

@ -1,6 +1,9 @@
#include "simsecl.h"
#include <string.h>
#include <mpack.h>
#include <parasol.h>
// TODO: Check through allocations for libsodium allocation
// TODO: Switch Authchit creation to use a binary blob
// TODO: Figure out how to serialize the few things needing serialization

Loading…
Cancel
Save