From 07a877af18778394773d89addfea27e868769f39 Mon Sep 17 00:00:00 2001 From: "keldu.magnus" Date: Thu, 15 Oct 2020 01:35:31 +0200 Subject: [PATCH] initial commit --- .gitignore | 72 +++++++++++++++++++++++++++++++++++++++ SConstruct | 86 +++++++++++++++++++++++++++++++++++++++++++++++ driver/SConscript | 13 +++++++ source/SConscript | 13 +++++++ source/window.h | 19 +++++++++++ test/SConscript | 17 ++++++++++ 6 files changed, 220 insertions(+) create mode 100644 .gitignore create mode 100644 SConstruct create mode 100644 driver/SConscript create mode 100644 source/SConscript create mode 100644 source/window.h create mode 100644 test/SConscript diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de1aca6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,72 @@ +# ---> SCons +# for projects that use SCons for building: http://http://www.scons.org/ +.sconsign.dblite + +# ---> C +# Prerequisites +*.d + +# Object files +*.o +*.os +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +# binary files +bin/ +# test files +assets/ +# custom build tracking +compile_commands.json +# logs and some custom thoughts +log +thoughts + +*.swp +vgcore.* +*.pdf diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000..dce24c5 --- /dev/null +++ b/SConstruct @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 + +import sys +import os +import os.path +import glob +import re + +if sys.version_info < (3,): + def isbasestring(s): + return isinstance(s,basestring) +else: + def isbasestring(s): + return isinstance(s, (str,bytes)) + +def add_kel_source_files(self, sources, filetype, lib_env=None, shared=False, target_post=""): + + if isbasestring(filetype): + dir_path = self.Dir('.').abspath + filetype = sorted(glob.glob(dir_path+"/"+filetype)) + + for path in filetype: + target_name = re.sub( r'(.*?)(\.cpp|\.c\+\+)', r'\1' + target_post, path ) + if shared: + target_name+='.os' + sources.append( self.SharedObject( target=target_name, source=path ) ) + else: + target_name+='.o' + sources.append( self.StaticObject( target=target_name, source=path ) ) + pass + +env=Environment(CPPPATH=['#source','#','#driver'], + CXX='c++', + CPPDEFINES=['GIN_UNIX'], + CXXFLAGS=['-std=c++17','-g','-Wall','-Wextra'], + LIBS=[]) +env.__class__.add_source_files = add_kel_source_files + +env.sources = [] +env.headers = [] +env.objects = [] + +Export('env') +SConscript('source/SConscript') +SConscript('driver/SConscript') + +# Library build + +env_library = env.Clone() + +env.objects_shared = [] +env_library.add_source_files(env.objects_shared, env.sources, shared=True) +env.library_shared = env_library.SharedLibrary('#bin/kelgin-window', [env.objects_shared]) + +env.objects_static = [] +env_library.add_source_files(env.objects_static, env.sources) +env.library_static = env_library.StaticLibrary('#bin/kelgin-window', [env.objects_static]) + +env.Alias('library', [env.library_shared, env.library_static]) +env.Alias('library_shared', env.library_shared) +env.Alias('library_static', env.library_static) + +env.Default('library') + +# Tests +SConscript('test/SConscript') + +env.Alias('test', env.test_program) + +# Clang format part +env.Append(BUILDERS={'ClangFormat' : Builder(action = 'clang-format --style=file -i $SOURCE')}) +env.format_actions = [] +def format_iter(env,files): + for f in files: + env.format_actions.append(env.AlwaysBuild(env.ClangFormat(target=f+"-clang-format",source=f))) + pass + +format_iter(env,env.sources + env.headers) + +env.Alias('format', env.format_actions) + +env.Alias('all', ['format', 'library_shared', 'library_static', 'test']) + +env.Install('/usr/local/lib/', [env.library_shared, env.library_static]) +env.Install('/usr/local/include/kelgin/window/', [env.headers]) +env.Alias('install', '/usr/local/') diff --git a/driver/SConscript b/driver/SConscript new file mode 100644 index 0000000..490e08e --- /dev/null +++ b/driver/SConscript @@ -0,0 +1,13 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +env.sources += sorted(glob.glob(dir_path + "/*.cpp")) +env.headers += sorted(glob.glob(dir_path + "/*.h")) diff --git a/source/SConscript b/source/SConscript new file mode 100644 index 0000000..490e08e --- /dev/null +++ b/source/SConscript @@ -0,0 +1,13 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +env.sources += sorted(glob.glob(dir_path + "/*.cpp")) +env.headers += sorted(glob.glob(dir_path + "/*.h")) diff --git a/source/window.h b/source/window.h new file mode 100644 index 0000000..f438f80 --- /dev/null +++ b/source/window.h @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace gin { +class Window { +public: + virtual ~Window() = default; +}; + +class Device { +public: + virtual ~Device() = default; + + virtual Own createWindow(); +}; + +Own createDevice(); +} \ No newline at end of file diff --git a/test/SConscript b/test/SConscript new file mode 100644 index 0000000..1cfd1b5 --- /dev/null +++ b/test/SConscript @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +import os +import os.path +import glob + +Import('env') + +dir_path = Dir('.').abspath +env.test_sources = sorted(glob.glob(dir_path + "/*.cpp")) + +env_test = env.Clone() +env_test.Append(CPPDEFINES=['GIN_COMPILE_TEST_BINARY']) +env.test_objects = [] +env.test_sources.append(dir_path+'/suite/suite.cpp') + +env.test_program = env_test.Program('#bin/test', [env.test_sources, env.library_static])