Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
# coding: utf-8
|
2007-06-30 04:41:52 +02:00
|
|
|
|
##
|
|
|
|
|
|
## Buildhelper.py - helpers, custom builders, for SConstruct
|
|
|
|
|
|
##
|
|
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
# Copyright (C)
|
2025-11-25 02:14:21 +01:00
|
|
|
|
# 2008-2025 Hermann Vosseler <Ichthyostega@web.de>
|
2007-06-30 04:41:52 +02:00
|
|
|
|
#
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
# **Lumiera** is free software; you can redistribute it and/or modify it
|
|
|
|
|
|
# under the terms of the GNU General Public License as published by the
|
|
|
|
|
|
# Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
|
# option) any later version. See the file COPYING for further details.
|
2007-06-30 04:41:52 +02:00
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
2007-07-02 05:27:20 +02:00
|
|
|
|
import os
|
|
|
|
|
|
import sys
|
2007-08-13 09:55:32 +02:00
|
|
|
|
import glob
|
2007-07-02 05:27:20 +02:00
|
|
|
|
import fnmatch
|
2007-07-02 11:38:46 +02:00
|
|
|
|
|
2011-01-30 15:27:21 +01:00
|
|
|
|
from SCons import Util
|
2008-08-19 05:03:29 +02:00
|
|
|
|
|
2007-06-30 04:41:52 +02:00
|
|
|
|
|
2007-07-03 00:13:12 +02:00
|
|
|
|
|
2007-06-30 04:41:52 +02:00
|
|
|
|
#
|
|
|
|
|
|
# Common Helper Functions
|
|
|
|
|
|
#
|
|
|
|
|
|
def isCleanupOperation(env):
|
|
|
|
|
|
return env.GetOption('clean')
|
2007-07-02 05:27:20 +02:00
|
|
|
|
|
|
|
|
|
|
def isHelpRequest():
|
2007-07-18 01:45:31 +02:00
|
|
|
|
""" this is a hack: SCons does all configure tests even if only
|
2008-12-12 02:04:50 +01:00
|
|
|
|
the help message is requested. SCons doesn't export the
|
2025-06-07 23:59:57 +02:00
|
|
|
|
help option for retrieval by env.GetOption(),
|
|
|
|
|
|
so we scan the commandline directly.
|
2007-07-18 01:45:31 +02:00
|
|
|
|
"""
|
2007-07-02 05:27:20 +02:00
|
|
|
|
return '-h' in sys.argv or '--help' in sys.argv
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-03 05:46:36 +01:00
|
|
|
|
def srcSubtree(tree, **args):
|
|
|
|
|
|
""" convenience wrapper: scan the given subtree, which is relative
|
|
|
|
|
|
to the current SConscript, and find all source files.
|
2007-07-18 01:45:31 +02:00
|
|
|
|
"""
|
2011-12-03 05:46:36 +01:00
|
|
|
|
return list(scanSubtree(tree, **args))
|
2007-07-02 05:27:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-08-08 04:50:02 +02:00
|
|
|
|
SRCPATTERNS = ['*.c','*.cpp','*.cc']
|
2007-07-02 05:27:20 +02:00
|
|
|
|
|
2008-08-19 05:03:29 +02:00
|
|
|
|
def scanSubtree(roots, patterns=SRCPATTERNS):
|
2025-06-07 23:59:57 +02:00
|
|
|
|
""" first expand (possible) wildcards and filter out non-dirs.
|
|
|
|
|
|
Then scan the given subtree for source filenames
|
2007-07-02 05:27:20 +02:00
|
|
|
|
(python generator function)
|
2007-07-18 01:45:31 +02:00
|
|
|
|
"""
|
2007-08-13 09:55:32 +02:00
|
|
|
|
for root in globRootdirs(roots):
|
2012-01-10 05:52:00 +01:00
|
|
|
|
for (d,_,files) in os.walk(root):
|
Global-Layer-Renaming: fix handling of GuiResources in the build
the new structure causes them now to be installed into $TARGET/stage
which is simply not what I want. I still consider $TARGET/gui the better choice,
since an administrator or packager is not aware of our layer namings.
The existing solution was half baked anyway, it did not really replicate the source tree.
On the other hand, I want to retain the location of the CSS files within the GUI tree,
since I consider it a good practice, to keep "code-like" resources with the actual code,
and not far away in some arcane "data" directory.
No I've noticed, that the env.GuiResource() function is only used once, for this very task.
So, for the time being, we can keep it simple and deditaced to that task, i.e
we pick up all CSS files we find and install it into a single target directory.
NOTE: this issue has brought to my attention two further, completely unrelated issues
* Ticket #1192 (Lumiera hangs on failed GUI start)
* The ProcDispatcher does an idle wait, due to an error in timed-wait implementation
2018-11-16 18:18:33 +01:00
|
|
|
|
d = stripPrefix(d, './')
|
2008-08-19 05:03:29 +02:00
|
|
|
|
for p in patterns:
|
2007-08-13 09:55:32 +02:00
|
|
|
|
for f in fnmatch.filter(files, p):
|
2012-01-10 05:52:00 +01:00
|
|
|
|
yield os.path.join(d,f)
|
2007-08-13 09:55:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def globRootdirs(roots):
|
|
|
|
|
|
""" helper: expand shell wildcards and filter the resulting list,
|
|
|
|
|
|
so that it only contains existing directories
|
|
|
|
|
|
"""
|
2012-01-10 05:52:00 +01:00
|
|
|
|
isDirectory = lambda f: os.path.isdir(f) and os.path.exists(f)
|
2007-08-13 09:55:32 +02:00
|
|
|
|
roots = glob.glob(roots)
|
2012-01-10 05:52:00 +01:00
|
|
|
|
return (d for d in roots if isDirectory(d) )
|
2007-07-02 11:38:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-12 11:42:03 +01:00
|
|
|
|
def findSrcTrees(location, patterns=SRCPATTERNS):
|
|
|
|
|
|
""" find possible source tree roots, starting with the given location.
|
|
|
|
|
|
When delving down from the initial location(s), a source tree is defined
|
2013-01-07 02:15:05 +01:00
|
|
|
|
as a directory containing source files and possibly further sub directories.
|
2009-01-12 11:42:03 +01:00
|
|
|
|
After having initially expanded the given location with #globRootdirs, each
|
|
|
|
|
|
directory is examined depth first, until encountering a directory containing
|
|
|
|
|
|
source files, which then yields a result. Especially, this can be used to traverse
|
2011-01-30 22:12:55 +01:00
|
|
|
|
an organisational directory structure and find out all possible source trees
|
2009-01-12 11:42:03 +01:00
|
|
|
|
to be built into packages, plugins, individual tool executables etc.
|
|
|
|
|
|
@return: the relative path names of all source root dirs found (generator function).
|
|
|
|
|
|
"""
|
2012-01-10 05:52:00 +01:00
|
|
|
|
for directory in globRootdirs(location):
|
|
|
|
|
|
if isSrcDir (directory,patterns):
|
|
|
|
|
|
yield directory
|
2009-01-12 11:42:03 +01:00
|
|
|
|
else:
|
2012-01-10 05:52:00 +01:00
|
|
|
|
for result in findSrcTrees (str(directory)+'/*'):
|
2009-01-12 11:42:03 +01:00
|
|
|
|
yield result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def isSrcDir(path, patterns=SRCPATTERNS):
|
|
|
|
|
|
""" helper: investigate the given (relative) path
|
2025-06-07 23:59:57 +02:00
|
|
|
|
@param patterns: list of wildcards to define what counts as "source file"
|
2009-01-12 11:42:03 +01:00
|
|
|
|
@return: True if it's a directory containing any source file
|
|
|
|
|
|
"""
|
|
|
|
|
|
if not os.path.isdir(path):
|
2012-01-10 05:52:00 +01:00
|
|
|
|
return False
|
2009-01-12 11:42:03 +01:00
|
|
|
|
else:
|
|
|
|
|
|
for p in patterns:
|
|
|
|
|
|
if glob.glob(path+'/'+p):
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-07-02 11:38:46 +02:00
|
|
|
|
|
2012-01-10 05:52:00 +01:00
|
|
|
|
def getDirname (d, basePrefix=None):
|
2011-01-30 22:12:55 +01:00
|
|
|
|
""" extract directory name without leading path,
|
|
|
|
|
|
or without the explicitly given basePrefix
|
|
|
|
|
|
"""
|
2012-01-10 05:52:00 +01:00
|
|
|
|
d = os.path.realpath(d)
|
|
|
|
|
|
if not os.path.isdir(d):
|
|
|
|
|
|
d,_ = os.path.split(d)
|
2011-01-30 22:12:55 +01:00
|
|
|
|
if basePrefix:
|
|
|
|
|
|
basePrefix = os.path.realpath(basePrefix)
|
Global-Layer-Renaming: fix handling of GuiResources in the build
the new structure causes them now to be installed into $TARGET/stage
which is simply not what I want. I still consider $TARGET/gui the better choice,
since an administrator or packager is not aware of our layer namings.
The existing solution was half baked anyway, it did not really replicate the source tree.
On the other hand, I want to retain the location of the CSS files within the GUI tree,
since I consider it a good practice, to keep "code-like" resources with the actual code,
and not far away in some arcane "data" directory.
No I've noticed, that the env.GuiResource() function is only used once, for this very task.
So, for the time being, we can keep it simple and deditaced to that task, i.e
we pick up all CSS files we find and install it into a single target directory.
NOTE: this issue has brought to my attention two further, completely unrelated issues
* Ticket #1192 (Lumiera hangs on failed GUI start)
* The ProcDispatcher does an idle wait, due to an error in timed-wait implementation
2018-11-16 18:18:33 +01:00
|
|
|
|
name = stripPrefix(str(d), basePrefix)
|
2011-01-30 22:12:55 +01:00
|
|
|
|
else:
|
2012-01-10 05:52:00 +01:00
|
|
|
|
_, name = os.path.split(d)
|
2008-08-19 05:03:29 +02:00
|
|
|
|
return name
|
2008-12-19 20:17:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Global-Layer-Renaming: fix handling of GuiResources in the build
the new structure causes them now to be installed into $TARGET/stage
which is simply not what I want. I still consider $TARGET/gui the better choice,
since an administrator or packager is not aware of our layer namings.
The existing solution was half baked anyway, it did not really replicate the source tree.
On the other hand, I want to retain the location of the CSS files within the GUI tree,
since I consider it a good practice, to keep "code-like" resources with the actual code,
and not far away in some arcane "data" directory.
No I've noticed, that the env.GuiResource() function is only used once, for this very task.
So, for the time being, we can keep it simple and deditaced to that task, i.e
we pick up all CSS files we find and install it into a single target directory.
NOTE: this issue has brought to my attention two further, completely unrelated issues
* Ticket #1192 (Lumiera hangs on failed GUI start)
* The ProcDispatcher does an idle wait, due to an error in timed-wait implementation
2018-11-16 18:18:33 +01:00
|
|
|
|
def stripPrefix(path, prefix):
|
|
|
|
|
|
if path.startswith(prefix):
|
|
|
|
|
|
path = path[len(prefix):]
|
|
|
|
|
|
return path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-01-10 05:52:00 +01:00
|
|
|
|
def createPlugins(env, directory, **kw):
|
2009-01-12 11:42:03 +01:00
|
|
|
|
""" investigate the given source directory to identify all contained source trees.
|
|
|
|
|
|
@return: a list of build nodes defining a plugin for each of these source trees.
|
|
|
|
|
|
"""
|
2025-06-07 23:59:57 +02:00
|
|
|
|
return [env.LumieraPlugin( getDirname(tree)
|
2011-12-03 05:46:36 +01:00
|
|
|
|
, srcSubtree(tree)
|
2011-01-30 18:56:51 +01:00
|
|
|
|
, **kw
|
2011-01-29 16:45:22 +01:00
|
|
|
|
)
|
2012-01-10 05:52:00 +01:00
|
|
|
|
for tree in findSrcTrees(directory)
|
2009-01-12 11:42:03 +01:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-19 20:17:23 +01:00
|
|
|
|
def checkCommandOption(env, optID, val=None, cmdName=None):
|
|
|
|
|
|
""" evaluate and verify an option, which may point at a command.
|
|
|
|
|
|
besides specifying a path, the option may read True, yes or 1,
|
|
|
|
|
|
denoting that the system default for this command should be used.
|
|
|
|
|
|
@return: True, if the key has been expanded and validated,
|
|
|
|
|
|
False, if this failed and the key was removed
|
|
|
|
|
|
"""
|
|
|
|
|
|
if not val:
|
|
|
|
|
|
if not env.get(optID): return False
|
|
|
|
|
|
else:
|
|
|
|
|
|
val = env.get(optID)
|
2008-08-19 05:03:29 +02:00
|
|
|
|
|
2008-12-19 20:17:23 +01:00
|
|
|
|
if val=='True' or val=='true' or val=='yes' or val=='1' or val == 1 :
|
|
|
|
|
|
if not cmdName:
|
2022-09-05 23:02:29 +02:00
|
|
|
|
print("WARNING: no default for %s, please specify a full path." % optID)
|
2008-12-19 20:17:23 +01:00
|
|
|
|
del env[optID]
|
|
|
|
|
|
return False
|
|
|
|
|
|
else:
|
|
|
|
|
|
val = env.WhereIs(cmdName)
|
|
|
|
|
|
if not val:
|
2022-09-05 23:02:29 +02:00
|
|
|
|
print("WARNING: %s not found, please specify a full path" % cmdName)
|
2008-12-19 20:17:23 +01:00
|
|
|
|
del env[optID]
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
if not os.path.isfile(val):
|
|
|
|
|
|
val = env.WhereIs(val)
|
|
|
|
|
|
|
|
|
|
|
|
if val and os.path.isfile(val):
|
|
|
|
|
|
env[optID] = val
|
|
|
|
|
|
return True
|
|
|
|
|
|
else:
|
|
|
|
|
|
del env[optID]
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
2008-08-19 05:03:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
2011-01-30 15:27:21 +01:00
|
|
|
|
|
|
|
|
|
|
class Record(dict):
|
2011-02-13 23:11:16 +01:00
|
|
|
|
""" a set of properties with record style access.
|
2011-01-30 15:27:21 +01:00
|
|
|
|
Record is a dictionary, but the elements can be accessed
|
|
|
|
|
|
conveniently as if they where object fields
|
2008-08-19 05:03:29 +02:00
|
|
|
|
"""
|
2011-01-30 15:27:21 +01:00
|
|
|
|
def __init__(self, defaults=None, **props):
|
|
|
|
|
|
if defaults:
|
|
|
|
|
|
defaults.update(props)
|
|
|
|
|
|
props = defaults
|
|
|
|
|
|
dict.__init__(self,props)
|
2008-08-19 05:03:29 +02:00
|
|
|
|
|
2011-01-30 15:27:21 +01:00
|
|
|
|
def __getattr__(self,key):
|
|
|
|
|
|
if key=='__get__' or key=='__set__':
|
|
|
|
|
|
raise AttributeError
|
|
|
|
|
|
return self.setdefault(key)
|
2008-08-19 05:03:29 +02:00
|
|
|
|
|
2011-01-30 15:27:21 +01:00
|
|
|
|
def __setattr__(self,key,val):
|
|
|
|
|
|
self[key] = val
|
|
|
|
|
|
|
2008-08-19 05:03:29 +02:00
|
|
|
|
|
2011-01-30 15:27:21 +01:00
|
|
|
|
def extract_localPathDefs (localDefs):
|
|
|
|
|
|
""" extracts the directory configuration values.
|
|
|
|
|
|
For sake of simplicity, paths and directories are defined
|
|
|
|
|
|
immediately as global variables in the SConstruct. This helper
|
|
|
|
|
|
extracts from the given dict the variables matching some magical
|
|
|
|
|
|
pattern and returns them wrapped into a Record for convenient access
|
|
|
|
|
|
"""
|
|
|
|
|
|
def relevantPathDefs (mapping):
|
2025-11-25 02:14:21 +01:00
|
|
|
|
for (k,v) in mapping.items():
|
2011-01-30 19:20:02 +01:00
|
|
|
|
if (k.startswith('src') or k.startswith('build') or k.startswith('install')) and Util.is_String(v):
|
2011-01-30 15:27:21 +01:00
|
|
|
|
v = v.strip()
|
|
|
|
|
|
if not v.endswith('/'): v += '/'
|
|
|
|
|
|
yield (k,v)
|
|
|
|
|
|
|
|
|
|
|
|
return dict(relevantPathDefs(localDefs))
|