diff options
author | Nao Pross <naopross@thearcway.org> | 2019-01-22 15:25:28 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2019-01-22 15:25:28 +0100 |
commit | 6d4630cbdc7feb3ac3cece46aa3556fd5b592eac (patch) | |
tree | 1f6820dc3b23dc11b6e3eff7436263b698a2f6c6 | |
parent | Fix file name in header of mmvec.hpp (diff) | |
download | libmm-6d4630cbdc7feb3ac3cece46aa3556fd5b592eac.tar.gz libmm-6d4630cbdc7feb3ac3cece46aa3556fd5b592eac.zip |
Add ninja build files to create a shared and static library
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | build.ninja | 6 | ||||
-rw-r--r-- | mmvec.cpp | 1 | ||||
-rw-r--r-- | mmvec.hpp | 6 | ||||
-rw-r--r-- | ninja/rules.ninja | 27 |
5 files changed, 38 insertions, 3 deletions
@@ -1 +1,2 @@ build +.ninja* diff --git a/build.ninja b/build.ninja new file mode 100644 index 0000000..3c134bf --- /dev/null +++ b/build.ninja @@ -0,0 +1,6 @@ +include ninja/rules.ninja + +build build/mmvec.o: cpp mmvec.cpp + +build build/libmm.a: link-static build/mmvec.o +build build/libmm.so: link-shared build/mmvec.o diff --git a/mmvec.cpp b/mmvec.cpp new file mode 100644 index 0000000..f555a6e --- /dev/null +++ b/mmvec.cpp @@ -0,0 +1 @@ +#include "mmvec.hpp" @@ -13,11 +13,12 @@ * Naoki Pross <naopross@thearcway.org> * 2018 ~ 2019 */ -#include <iostream> +#pragma once #include <cassert> #include <cmath> +#include <iostream> #include <array> #include <algorithm> #include <numeric> @@ -111,8 +112,7 @@ template<typename T, std::size_t d> template<std::size_t n> mm::basic_vec<T, d>& mm::basic_vec<T, d>::operator=(const mm::basic_vec<T, n>& other) { static_assert( - d >= n, - "cannot copy higher dimensional vector into a smaller one" + d >= n, "cannot copy higher dimensional vector into a smaller one" ); std::copy(other.begin(), other.end(), this->begin()); diff --git a/ninja/rules.ninja b/ninja/rules.ninja new file mode 100644 index 0000000..04b625c --- /dev/null +++ b/ninja/rules.ninja @@ -0,0 +1,27 @@ +includes = -I engine/include +cflags = -Wall -Werror -pedantic -fPIC -std=c++17 $includes + +libs = +lflags = $libs + +flags = -fdiagnostics-color + +rule mkdir + command = mkdir -p $out + description = creating directory $out + +rule cpp + command = g++ $flags $cflags -c $in -o $out $lflags + description = compiling $in + +rule link + command = g++ $flags $cflags -o $out $in $lflags + description = linking $out + +rule link-shared + command = g++ $flags $cflags -shared -o $out $in $lflags + description = linking shared object $out + +rule link-static + command = ar rvs $out $in + description = creating archive $out |