Skip to content

Commit

Permalink
Start refactoring everything to use the header-only version of Lol En…
Browse files Browse the repository at this point in the history
…gine.
  • Loading branch information
samhocevar committed Feb 24, 2020
1 parent 78bc5c5 commit e472abe
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ binaries/*Release
_ReSharper.*
# Our binaries
lolremez
src/lolremez2d
11 changes: 4 additions & 7 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@

include $(top_srcdir)/lol/build/autotools/common.am
EXTRA_DIST = bootstrap README.md \
.travis.yml lolremez.sln build.config \
.gitignore .gitattributes .gitmodules

ACLOCAL_AMFLAGS = -I lol/build/autotools/m4
EXTRA_DIST += bootstrap README.md \
.travis.yml lolremez.sln build.config \
.gitignore .gitattributes .gitmodules

SUBDIRS = lol src
SUBDIRS = src

test: check

139 changes: 127 additions & 12 deletions bootstrap
Original file line number Diff line number Diff line change
@@ -1,21 +1,136 @@
#!/bin/sh
#! /bin/sh

# Check that the repository is properly set up
if [ ! -x "./lol/bootstrap" ]; then
cat << EOF
Error: cannot execute lol/bootstrap
# bootstrap: generic bootstrap/autogen.sh script for autotools projects
#
# Copyright (c) 2002-2010 Sam Hocevar <[email protected]>
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://www.wtfpl.net/ for more details.
#
# The latest version of this script can be found at the following place:
# http://caca.zoy.org/wiki/build

Did you configure the Lol Engine submodule? The following may help:
# Die if an error occurs
set -e

git submodule update --init --recursive
# Guess whether we are using configure.ac or configure.in
if test -f configure.ac; then
conffile="configure.ac"
elif test -f configure.in; then
conffile="configure.in"
else
echo "$0: could not find configure.ac or configure.in"
exit 1
fi

# Check for needed features
auxdir="`sed -ne 's/^[ \t]*A._CONFIG_AUX_DIR *([[ ]*\([^] )]*\).*/\1/p' $conffile`"
pkgconfig="`grep '^[ \t]*PKG_PROG_PKG_CONFIG' $conffile >/dev/null 2>&1 && echo yes || echo no`"
libtool="`grep '^[ \t]*A._PROG_LIBTOOL' $conffile >/dev/null 2>&1 && echo yes || echo no`"
makefile="`[ -f Makefile.am ] && echo yes || echo no`"
aclocalflags="`sed -ne 's/^[ \t]*ACLOCAL_AMFLAGS[ \t]*=//p' Makefile.am 2>/dev/null || :`"

# Check for automake
amvers="no"
for v in "" "-1.15" "-1.14" "-1.13" "-1.12" "-1.11"; do
if automake${v} --version > /dev/null 2>&1; then
amvers=${v}
break
fi
done

if test "$amvers" = "no"; then
echo "$0: automake not found"
exit 1
fi

EOF
# Check for autoconf
acvers="no"
for v in "" "259" "253"; do
if autoconf${v} --version >/dev/null 2>&1; then
acvers="${v}"
break
fi
done

if test "$acvers" = "no"; then
echo "$0: autoconf not found"
exit 1
fi

# Check for libtool
if test "$libtool" = "yes"; then
libtoolize="no"
if glibtoolize --version >/dev/null 2>&1; then
libtoolize="glibtoolize"
else
for v in "16" "15" "" "14"; do
if libtoolize${v} --version >/dev/null 2>&1; then
libtoolize="libtoolize${v}"
break
fi
done
fi

if test "$libtoolize" = "no"; then
echo "$0: libtool not found"
exit 1
fi
fi

# Bootstrap this project first, using the Lol Engine script
./lol/bootstrap || exit $?
# Check for pkg-config
if test "$pkgconfig" = "yes"; then
if ! pkg-config --version >/dev/null 2>&1; then
echo "$0: pkg-config not found"
exit 1
fi
fi

# Remove old cruft
for x in aclocal.m4 configure config.guess config.log config.sub config.cache config.h.in config.h compile libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh; do rm -f $x autotools/$x; if test -n "$auxdir"; then rm -f "$auxdir/$x"; fi; done
rm -Rf autom4te.cache
if test -n "$auxdir"; then
if test ! -d "$auxdir"; then
mkdir "$auxdir"
fi
aclocalflags="-I $auxdir -I . ${aclocalflags}"
fi

# Honour M4PATH because sometimes M4 doesn't
save_IFS=$IFS
IFS=:
tmp="$M4PATH"
for x in $tmp; do
if test -n "$x"; then
aclocalflags="-I $x ${aclocalflags}"
fi
done
IFS=$save_IFS

# Explain what we are doing from now
set -x

# Bootstrap package
if test "$libtool" = "yes"; then
${libtoolize} --copy --force
if test -n "$auxdir" -a ! "$auxdir" = "." -a -f "ltmain.sh"; then
echo "$0: working around a minor libtool issue"
mv ltmain.sh "$auxdir/"
fi
fi

aclocal${amvers} ${aclocalflags}
autoconf${acvers}
autoheader${acvers}
if test "$makefile" = "yes"; then
#add --include-deps if you want to bootstrap with any other compiler than gcc
#automake${amvers} --add-missing --copy --include-deps
automake${amvers} --foreign --add-missing --copy
fi

# Then bootstrap Lol Engine itself
cd lol && exec ./bootstrap
# Remove cruft that we no longer want
rm -Rf autom4te.cache

4 changes: 3 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([subdir-objects no-define tar-ustar silent-rules dist-xz dist-zip])
AM_DEFAULT_VERBOSITY=0

CXXFLAGS="${CXXFLAGS} -std=c++17"

AC_PROG_CXX
AM_PROG_LIBTOOL
AC_LIBTOOL_CXX
Expand All @@ -29,7 +31,7 @@ dnl
dnl Inherit all Lol Engine checks
dnl

LOL_AC_SUBPROJECT()
#LOL_AC_SUBPROJECT()

dnl
dnl Perform the actual commands
Expand Down
2 changes: 1 addition & 1 deletion lol
Submodule lol updated 468 files
2 changes: 0 additions & 2 deletions src/.gitignore

This file was deleted.

17 changes: 5 additions & 12 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@

include $(top_srcdir)/lol/build/autotools/common.am
EXTRA_DIST = \
.gitignore lolremez.vcxproj lolremez.vcxproj.filters

EXTRA_DIST += .gitignore \
lolremez.vcxproj lolremez.vcxproj.filters
AM_CPPFLAGS = -I../lol/include

bin_PROGRAMS = ../lolremez
noinst_PROGRAMS = lolremez2d

CLEANFILES += lolremez # legacy

___lolremez_SOURCES = \
lolremez.cpp solver.cpp solver.h matrix.h expression.h
___lolremez_CPPFLAGS = $(AM_CPPFLAGS)
___lolremez_DEPENDENCIES = @LOL_DEPS@
___lolremez_LDFLAGS = $(AM_LDFLAGS)

lolremez2d_SOURCES = lolremez2d.cpp
lolremez2d_CPPFLAGS = $(AM_CPPFLAGS)
lolremez2d_DEPENDENCIES = @LOL_DEPS@
lolremez2d_LDFLAGS = $(AM_LDFLAGS)
lolremez2d_SOURCES = \
lolremez2d.cpp

8 changes: 5 additions & 3 deletions src/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
// auto y = e.eval("1.5");
//

#include "tao/pegtl.hpp"
#include <lol/base/pegtl.h>

#include <vector>
#include <tuple>
#include <cassert>

namespace grammar
{

using namespace tao::pegtl;
using long_double = long double;

enum class id : uint8_t
{
Expand Down Expand Up @@ -134,7 +136,7 @@ struct expression

case id::tofloat: push_val(lol::real(float(head))); break;
case id::todouble: push_val(lol::real(double(head))); break;
case id::toldouble: push_val(lol::real(lol::ldouble(head))); break;
case id::toldouble: push_val(lol::real(long_double(head))); break;

case id::x:
case id::y:
Expand All @@ -144,7 +146,7 @@ struct expression
}
}

ASSERT(stack.size() == 1);
assert(stack.size() == 1);
return pop_val();
}

Expand Down
9 changes: 4 additions & 5 deletions src/lolremez.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
#include <iostream>
#include <iomanip>

#include <lol/engine.h>

#include <lol/base/string.h>
#include <lol/base/getopt.h>
#include <lol/math/real.h>

#include "solver.h"
#include "expression.h"

using lol::array;
using lol::real;

static void version(void)
Expand Down Expand Up @@ -130,8 +129,8 @@ int main(int argc, char **argv)
solver.set_order(degree);
} break;
case 'r': { /* --range */
auto arg = lol::split(opt.arg, ':');
if (arg.count() != 2)
auto arg = lol::split(std::string(opt.arg), ':');
if (arg.size() != 2)
FAIL("invalid range");
str_xmin = arg[0];
str_xmax = arg[1];
Expand Down
2 changes: 0 additions & 2 deletions src/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include <iostream>
#include <iomanip>

#include <lol/engine.h>

#include <lol/math/real.h>
#include <lol/math/polynomial.h>

Expand Down
3 changes: 3 additions & 0 deletions src/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
// ----------------------
//

#include <lol/base/thread.h>
#include <lol/math/polynomial.h>

#include <cstdio>

#include "expression.h"
Expand Down

0 comments on commit e472abe

Please sign in to comment.