expanded builder env
parent
4dfcfaf821
commit
3a244d789e
|
@ -0,0 +1,6 @@
|
|||
.sconsign.dblite
|
||||
build
|
||||
*.o
|
||||
*.so
|
||||
*.os
|
||||
*.a
|
|
@ -0,0 +1,14 @@
|
|||
{ pkgs
|
||||
, stdenvNoCC
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
||||
name = "kelunit";
|
||||
src = ./..;
|
||||
|
||||
nativeBuildInputs = [
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
];
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{...}:
|
||||
let
|
||||
pkgs = (import <nixpkgs> {});
|
||||
in
|
||||
{
|
||||
kelunit = pkgs.callPackage ./derivation.nix {};
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
#!/usr/bin/env false
|
||||
|
||||
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=['#source/forstio','#source','#','#driver'],
|
||||
CXX='clang++',
|
||||
CPPDEFINES=[],
|
||||
CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'],
|
||||
LIBS=[])
|
||||
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 = [];
|
||||
|
||||
Export('env');
|
||||
SConscript('source/kelunit/SConscript');
|
||||
SConscript('test/SConscript');
|
||||
|
||||
# Format
|
||||
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('cdb', env.cdb);
|
||||
env.Alias('all', ['test']);
|
||||
env.Default('all');
|
||||
|
||||
|
||||
|
||||
env.Install('$prefix/include/kelunit/', [env.headers]);
|
|
@ -0,0 +1,3 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
pkgs.callPackage ./.nix/derivation.nix {}
|
|
@ -0,0 +1,9 @@
|
|||
{ pkgs ? import <nixpkgs> {} }:
|
||||
pkgs.mkShellNoCC {
|
||||
name = "kelunit";
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.scons
|
||||
pkgs.clang
|
||||
];
|
||||
}
|
|
@ -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"))
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/false
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import glob
|
||||
|
||||
|
||||
Import('env')
|
||||
|
||||
test_env = env.Clone();
|
||||
|
||||
dir_path = Dir('.').abspath
|
||||
|
||||
env.test_sources = sorted(glob.glob(dir_path + "/*.cpp"))
|
||||
env.test_headers = sorted(glob.glob(dir_path + "/*.h"))
|
||||
|
||||
env.basic_test = test_env.Program('#/build/bin/basic_test', env.sources + env.test_sources);
|
||||
env.Alias('test', [ env.basic_test ]);
|
Loading…
Reference in New Issue