diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-07-03 18:33:50 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-07-03 18:33:50 +0200 |
commit | d205153060b58af342cc47c48973f10129417eef (patch) | |
tree | 73aa9d7464bc4153d444c143f75708ad000cd286 | |
parent | 7e4dbdfadcb666c038f2815722e8c58f821c58af (diff) |
c++,window-opengl: Starting to provide the basic gl creation
-rw-r--r-- | default.nix | 7 | ||||
-rw-r--r-- | src/window-opengl/.nix/derivation.nix | 37 | ||||
-rw-r--r-- | src/window-opengl/SConscript | 38 | ||||
-rw-r--r-- | src/window-opengl/SConstruct | 66 |
4 files changed, 148 insertions, 0 deletions
diff --git a/default.nix b/default.nix index e27153a..d38ed9e 100644 --- a/default.nix +++ b/default.nix @@ -61,6 +61,13 @@ in rec { inherit clang; inherit clang-tools; }; + + window-opengl = pkgs.callPackage src/window/.nix/derivation.nix { + inherit version; + inherit forstio; + inherit clang; + inherit clang-tools; + }; }; forstio-test-cases = pkgs.callPackage tests/.nix/derivation.nix { diff --git a/src/window-opengl/.nix/derivation.nix b/src/window-opengl/.nix/derivation.nix new file mode 100644 index 0000000..95cd318 --- /dev/null +++ b/src/window-opengl/.nix/derivation.nix @@ -0,0 +1,37 @@ +{ lib +, stdenvNoCC +, scons +, clang +, clang-tools +, version +, forstio +, xorg +}: + +let + +in stdenvNoCC.mkDerivation { + pname = "forstio-window-opengl"; + inherit version; + src = ./..; + + enableParallelBuilding = true; + + nativeBuildInputs = [ + scons + clang + clang-tools + ]; + + buildInputs = [ + forstio.core + forstio.async + forstio.io + forstio.codec + forstio.window + xorg.libX11 + xorg.libxcb + ]; + + outputs = ["out" "dev"]; +} diff --git a/src/window-opengl/SConscript b/src/window-opengl/SConscript new file mode 100644 index 0000000..bd830b9 --- /dev/null +++ b/src/window-opengl/SConscript @@ -0,0 +1,38 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +window_env = env.Clone(); + +window_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) +window_env.headers = sorted(glob.glob(dir_path + "/*.h")) + +env.sources += window_env.sources; +env.headers += window_env.headers; + +## Shared lib +objects_shared = [] +window_env.add_source_files(objects_shared, window_env.sources, shared=True); +window_env.library_shared = window_env.SharedLibrary('#build/forstio-window', [objects_shared]); + +## Static lib +objects_static = [] +window_env.add_source_files(objects_static, window_env.sources, shared=False); +window_env.library_static = window_env.StaticLibrary('#build/forstio-window', [objects_static]); + +# Set Alias +env.Alias('library_window', [window_env.library_shared, window_env.library_static]); + +env.targets += ['library_window']; + +# Install +env.Install('$prefix/lib/', [window_env.library_shared, window_env.library_static]); +env.Install('$prefix/include/forstio/window/', [window_env.headers]); diff --git a/src/window-opengl/SConstruct b/src/window-opengl/SConstruct new file mode 100644 index 0000000..05fc016 --- /dev/null +++ b/src/window-opengl/SConstruct @@ -0,0 +1,66 @@ +#!/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 + +def isAbsolutePath(key, dirname, env): + assert os.path.isabs(dirname), "%r must have absolute path syntax" % (key,) + +env_vars = Variables( + args=ARGUMENTS +) + +env_vars.Add('prefix', + help='Installation target location of build results and headers', + default='/usr/local/', + validator=isAbsolutePath +) + +env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], + CPPDEFINES=['SAW_UNIX', 'SAW_UNIX_XCB'], + CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], + LIBS=['forstio-core', 'forstio-io', 'forstio-async', 'forstio-codec']) +env.__class__.add_source_files = add_kel_source_files +env.Tool('compilation_db'); +env.cdb = env.CompilationDatabase('compile_commands.json'); + +env.objects = []; +env.sources = []; +env.headers = []; +env.targets = []; + +Export('env') +SConscript('SConscript') + +env.Alias('cdb', env.cdb); +env.Alias('all', [env.targets]); +env.Default('all'); + +env.Alias('install', '$prefix') |