Commit Graph

54 Commits (683ac78ca25f1e3f6b3468bb81b1cec2ca64cc94)

Author SHA1 Message Date
whitequark 0ae0343fc7 Add a simple benchmarking harness. 2016-11-18 13:55:24 +00:00
whitequark c8ff17f4a2 Add OpenGL 2 support on Windows using ANGLE.
This commit performs two main changes:
  * Alters the shaders to use only strictly conformant GLSL 2.0.
  * Alters the Windows UI to use ANGLE via GL ES 2.0 and EGL 1.4.

This commit also drops official support for Windows XP, since ANGLE
requires a non-XP toolset to build. It is still possible to build
SolveSpace for Windows XP using:

  cmake -T v120_xp -DOPENGL=1
2016-11-18 11:38:45 +00:00
whitequark d151eb56fc CMake: reject in-tree builds.
We do not support clobbering the source tree with build products,
nor recommend this in any documentation, and this already leads to
weird bugs with the resource system. Show an explicit error in this
case to avoid confusion.
2016-11-03 07:25:57 +00:00
whitequark fbe2705ebe CMake: disable unsigned overflow sanitizer check.
This seems too aggressive for us; it breaks the hash function and
I would prefer to not add tool-specific exclusions in the code.
2016-08-07 19:27:58 +00:00
whitequark 068ed2816a CMake: fix typo. 2016-08-07 17:33:27 +00:00
whitequark a2a50927e9 CMake: make code coverage work with Clang.
Clang uses a slightly different .gcno/.gcda format than GCC, and
it is necessary to point lcov to `llvm-cov gcov` instead of `gcov`.
2016-08-01 05:39:18 +00:00
whitequark 42d3ec9917 CMake: finish Clang sanitizer support.
This makes ENABLE_SANITIZERS a proper cached variable, removes some
spurious failures and configures asan/ubsan to die on an error.
2016-08-01 05:39:18 +00:00
whitequark 2fdbabc13c Add statement/condition coverage measurement for the test suite.
We're using gcov+lcov, since these tools appear to be the only
usable ones that use the SC/CC metric; and measuring just the line
coverage would be practically criminal negligence.

gcov only works with GCC and Clang, and MSVC's own coverage
measurement tools are not up to the task; so MSVC is out of luck.
2016-08-01 02:19:06 +00:00
whitequark 5e63d8301e Add a simple harness for automated, headless testing.
This commit alters the build system substantially; it adds another
platform, `headless`, that provides stubs in place of all GUI
functions, and provides a library `solvespace_headless` alongside
the main executable. To cut down build times, only the few files
that have #if defined(HEADLESS) are built twice for the executable
and the library; the rest is grouped into a new `solvespace_cad`
library. It is not usable on its own and just serves for grouping.

This commit also gates the tests behind a -DENABLE_TESTS=ON CMake
option, ON by default (but suggested as OFF in the README so that
people don't ever have to install cairo to build the executable.)

The tests introduced in this commit are (so far) rudimentary,
although functional, and they serve as a stepping point towards
introducing coverage analysis.
2016-08-01 00:48:37 +00:00
whitequark 6963c7e25b Add Cairo (and, transitively, Pixman) dependencies. 2016-08-01 00:48:37 +00:00
whitequark 7f0083aa1d CMake: correctly use if(STREQUAL).
If an operand is a string, it should be quoted to prevent expansion.
This doesn't matter with "GNU", but does with "MSVC" (which expands
to "YES").
2016-08-01 00:48:37 +00:00
whitequark bcd8c3e790 CMake: do not leak solvespace-specific compiler flags.
Before this commit, our warning flags and definitions were leaking
into the vendored dependencies.
2016-07-25 04:22:03 +00:00
whitequark 6607a48357 CMake: refactor inclusion of external libraries.
This commit makes common external packages always be included through
find_package to eliminate differences in variables set, wraps
find_package for vendored libraries on Windows to factor out common
code, and removes miscellaneous useless code elsewhere in dependency
handling.

This also fixes a problem where pkg-config would pick up `build`
libraries instead of `host` when cross-compiling.
2016-07-25 04:22:02 +00:00
whitequark 7265121b24 Refactor GlOffscreen; remove the GLEW dependency.
It was never really needed, since both Linux and OS X, where
GlOffscreen is used, guarantee that the API we need is present,
on all OS versions we're interested in.

Also, reorganize GlOffscreen consistently with the rest of our
codebase, and don't use RAII for OpenGL resource management because
of its requirement for an active context.
2016-07-25 04:21:55 +00:00
whitequark ad2371cfae Unix: compatibility with platforms where backtrace() is not in libc.
Also, don't depend on backtrace() when built as libslvs; it is not
the responsbility of the library to use it.
2016-07-19 15:40:52 +00:00
whitequark 131acc5e56 CMake: add a note to packagers about GIT_COMMIT_HASH. 2016-06-28 09:49:37 +00:00
whitequark e0283b2d2e OS X: fix typo in build system. 2016-06-19 19:46:51 +00:00
whitequark 3c887d30e3 OS X: find frameworks last.
Before this commit, any available libpng or libfreetype would be
picked, e.g. from Mono.framework. After, homebrew and MacPorts
are prioritized.
2016-06-13 04:15:13 +00:00
whitequark 14cbd0bbee Cocoa, Win32: embed version info into distributable application.
This shows up in crash dumps, etc, and helps track them back to
a git commit.
2016-06-03 00:07:30 +00:00
whitequark 1249f8496e Enable exhaustive switch coverage warnings as an error, and use them.
Specifically, this enables -Wswitch=error on GCC/Clang and its MSVC
equivalent; the exact way it is handled varies slightly, but what
they all have in common is that in a switch statement over an
enumeration, any enumerand that is not explicitly (via case:) or
implicitly (via default:) handled in the switch triggers an error.

Moreover, we also change the switch statements in three ways:

  * Switch statements that ought to be extended every time a new
    enumerand is added (e.g. Entity::DrawOrGetDistance(), are changed
    to explicitly list every single enumerand, and not have a
    default: branch.

    Note that the assertions are kept because it is legal for
    a enumeration to have a value unlike any of its defined
    enumerands, and we can e.g. read garbage from a file, or
    an uninitialized variable. This requires some rearranging if
    a default: branch is undesired.

  * Switch statements that ought to only ever see a few select
    enumerands, are changed to always assert in the default: branch.

  * Switch statements that do something meaningful for a few
    enumerands, and ignore everything else, are changed to do nothing
    in a default: branch, under the assumption that changing them
    every time an enumerand is added or removed would just result
    in noise and catch no bugs.

This commit also removes the {Request,Entity,Constraint}::UNKNOWN and
Entity::DATUM_POINT enumerands, as those were just fancy names for
zeroes. They mess up switch exhaustiveness checks and most of the time
were not the best way to implement what they did anyway.
2016-05-26 12:43:52 +00:00
whitequark 4c318f09c4 Bump version to 3.0. 2016-05-20 14:50:00 +00:00
whitequark 4415f5bb91 Implement ssassert(), a replacement for oops(). 2016-05-20 12:38:29 +00:00
whitequark 1b52c46b81 Remove some dead code. 2016-05-18 23:00:34 +00:00
whitequark d37d77a257 CMake: require GCC 5.0+. 2016-05-18 17:27:37 +00:00
whitequark fbc5bfc27f Enable -Wfloat-conversion on Clang.
This is a high-SNR warning that's enabled by default on MSVC and
it has highlighted some bugs in glhelper.cpp (that are also fixed
in this commit).

Unfortunately GCC does not have an equivalent for that warning,
and -Wconversion is very noisy.
2016-05-18 11:24:24 +00:00
whitequark 56e2d451f4 MSVC: add /D_USE_MATH_DEFINES.
Turns out M_PI and friends aren't from the C standard, but rather
they are a POSIX extension. This definition is necessary to enable
them on MSVC.
2016-05-18 11:24:24 +00:00
whitequark fc79642788 Move vector font to res/fonts/; remove lff2c.
This commit integrates the vector font in the resource system, so
that cross-compilation would be easier and a custom font could be
used without recompilation.

The font handling code was carefully written to lazily load glyphs;
as possible; in practice this means that startup is less than 15ms
slower after this commit, most of it spent in inflate().

This also reduces executable size and makes compilation of
glhelper.cpp much faster.
2016-05-18 11:24:24 +00:00
whitequark f4c01f670c Implement a resource system.
Currently, icons, fonts, etc are converted to C structures at compile
time and are hardcoded to the binary. This presents several problems:

  * Cross-compilation is complicated. Right now, it is necessary
    to be able to run executables for the target platform; this
    happens to work with wine-binfmt installed, but is rather ugly.

  * Icons can only have one resolution. On OS X, modern software is
    expected to take advantage of high-DPI ("Retina") screens and
    use so-called @2x assets when ran in high-DPI mode.

  * Localization is complicated. Win32 and OS X provide built-in
    support for loading the resource appropriate for the user's
    locale.

  * Embedding strings can only be done as raw strings, using C++'s
    R"(...)" literals. This precludes embedding sizable strings,
    e.g. JavaScript libraries as used in Three.js export, and makes
    git history less useful. Not embedding the libraries means we
    have to rely on external CDNs, which requires an Internet
    connection and adds a glaring point of failure.

  * Linux distribution guidelines are violated. All architecture-
    independent data, especially large data such as fonts, is
    expected to be in /usr/share, not in the binary.

  * Customization is impossible without recompilation. Minor
    modifications like adding a few missing vector font characters
    or adjusting localization require a complete development
    environment, which is unreasonable to expect from users of
    a mechanical CAD.

As such, this commit adds a resource system that bundles (and
sometimes builds) resources with the executable. Where they go is
platform-dependent:

  * on Win32: into resources of the executable, which allows us to
    keep distributing one file;
  * on OS X: into the app bundle;
  * on other *nix: into /usr/share/solvespace/ or ../res/ (relative
    to the executable path), the latter allowing us to run freshly
    built executables without installation.

It also subsides the platform-specific resources that are in src/.

The resource system is not yet used for anything; this will be added
in later commits.
2016-05-18 11:24:23 +00:00
whitequark 3bdaa53725 MSVC: expand C99's `inline` to MSVC's `__inline`.
This is not done for C++ as C++ has a proper inline keyword, and
MSVC's C++ standard library will not like it becoming a macro.
2016-05-17 12:54:51 +00:00
whitequark e969bc94ad Enable -Wall -Wextra -Wno-unused-parameter on GCC/Clang.
This is good practice and helps to catch bugs. Several changes
were made to accomodate the newly enabled warnings:
  * -Wunused-function:
    * in exposed/, static functions that were supposed to be inlined
      were explicitly marked as inline;
    * some actually unused functions were removed;
  * -Wsign-compare: explicit conversions were added, and in
    the future we should find a nicer way than aux* fields;
  * -Wmissing-field-initializers: added initializers;
  * -Wreorder: reordered properly;
  * -Wunused-but-set-variable: remove variable.

-Wunused-parameter was turned off as enabling it would result in
massive amount of churn in UI code. Despite that, we should enable
it at some point as it has a fairly high SNR otherwise.
2016-05-08 00:01:35 +00:00
whitequark 7f79461d5d CMake: build with sanitizers if -DSANITIZE=TRUE passed. 2016-05-04 03:21:12 +00:00
whitequark 52af725606 Only #include "config.h" when we need something from it.
config.h now includes the git hash and so, as long as it's included
in solvespace.h, any change of git HEAD will trigger a complete
recompilation, which makes bisecting especially annoying.

While we're at it, remove HAVE_STDINT_H from it, since we require
C++11 and all MSVC versions that include C++11 also include stdint.h.
2016-04-23 23:06:31 +00:00
whitequark 2fed0587ea Embed git commit hash in the "About" dialog.
Also, remove usage of __DATE__ and __TIME__ to make the build fully
deterministic. They are redundant once we have the commit hash,
anyway.
2016-04-23 22:53:21 +00:00
whitequark c6747438e0 CMake: properly invoke buildsystems of vendored libraries.
Before this commit, running "make" would build e.g. zlib's tests
and fail because they are not designed to work when zlib is included
as a subproject.

After this commit, EXCLUDE_FROM_ALL, which I did not know about,
prevents any actions from being done by default in these subprojects.
2016-04-23 19:39:40 +00:00
whitequark 20a041e0ef DXF: initial libdxfrw import.
We had to fork libdxfrw since the upstream doesn't have a git
repository, a CMake buildsystem, and is quite buggy.

libdxfrw is also used in LibreCAD, but they just vendored
their version.
2016-02-19 23:16:36 +00:00
whitequark 7c2ec8f80e Always build in C++11 mode on GCC and Clang.
This will weed out compilers that are too old to build our code
(among others, recent gtkmm and glibmm have a hard dependency on
C++11, not even C++0x) and also properly communicate our wish to GCC
(Clang defaults to C++11 these days).
2016-02-15 20:08:46 +00:00
whitequark 29ad1acdfe Enable and mollify -Wunused-variable.
In my (whitequark's) experience this warning tends to expose
copy-paste errors with a high SNR, so making a few fragments
slightly less symmetric is worth it.

Also mollify -Wlogical-op-parentheses while we're at it.
2016-02-14 14:29:47 +00:00
whitequark e5294eef9d Add freetype dependency.
We are going to use freetype instead of the old custom TTF parser,
since the old parser has many annoying bugs when handling non-Latin
fonts and fixing it is not really worth the time.

On Windows, Freetype is built from a submodule.
On Linux and OS X, Freetype is provided together with the desktop,
though development files have to be installed separately.
2016-02-13 21:08:18 +00:00
whitequark 062344e40d Define _SCL_SECURE_NO_WARNINGS on Windows.
This is required to squash warnings about 'checked iterators'.
Regardless of their utility we can't use them on other platforms,
so we don't care.
2016-02-12 05:00:29 +00:00
EvilSpirit 3af4e1c5b0 Define NOMINMAX for Windows builds.
Without #define NOMINMAX, <windows.h> defines min and max as macros,
which shadows the definitions from <algorithm> and makes them
unusable with multiple arguments.
2016-01-27 09:09:18 +00:00
whitequark 97a9b4743e Make sure only *W functions from Win32 API are called.
After this commit, SolveSpace always uses UTF-8 strings internally
(represented as char* and std::string) on every OS, for everything:
UI labels, paths and user input. OS X always uses UTF-8; on Windows,
strings are converted at boundary; and on Linux/BSD/etc SolveSpace
refuses to start unless the current locale is UTF-8. This will
negatively affect literally no one.

This commit does not bring forth any user-visible improvement yet;
in order to correctly handle Unicode in filenames, it is still
necessary to change the fopen calls to _wfopen on Windows.
2016-01-13 06:45:16 +00:00
whitequark 02c30e6f87 Rewrite ttf2c to use GNU Unifont and merge with pngchar2c.pl.
After this change, SolveSpace does not contain nonfree assets.
Additionally, Perl is not required for the build.

Note that in the US, case law suggests that copyright does
not apply to bitmap fonts:
  http://www.renpy.org/wiki/renpy/misc/Bitmap_Fonts_and_Copyright

Nevertheless, it was prudent to replace the asset with something
that is unambiguously free.
2015-12-29 11:15:50 +08:00
whitequark f76f76ff60 Rewrite png2c.pl in C++.
This allows us to always generate icons during build,
and in the future remove a Perl dependency.
2015-12-29 11:15:50 +08:00
whitequark 7c3c20161b Allow building on FreeBSD. 2015-12-28 21:37:07 +08:00
whitequark 063dfc4f98 Require cmake 3.1.0 and C++11.
We plan to use C++11 features in the future. Moreover, recent gtkmm
has a hard requirement on C++11.
2015-12-28 21:37:06 +08:00
whitequark 1b6cd0d632 Make in-tree zlib more robust. 2015-12-28 21:37:06 +08:00
whitequark 0159a87a8a Add support for cross-compiling from Linux.
As a side effect, zlib and libpng are now git submodules,
based on their respective official git repositories.
This is necessary, because MinGW has a different ABI and
it cannot use the prebuilt binaries built by MSVC.

The submodules are also used for Windows, for several reasons:
  * to allow 64-bit builds;
  * to allow using newer MSVC, which doesn't like the prebuilt
    libraries;
  * to keep the libraries updated.
2015-07-10 15:59:12 +03:00
whitequark 46db5378dc Add Travis CI and Appveyor CI configurations. 2015-07-10 15:59:12 +03:00
whitequark d0c0a7ae5a Remove FLTK port.
It provides no value over the native GTK and Cocoa ports.
2015-07-10 15:59:12 +03:00
whitequark 95ab80d0ee Implement OS X port. 2015-07-10 15:59:12 +03:00