Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal build #361

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ styles
*.svg
AutoDict_*
spng
version.txt
17 changes: 17 additions & 0 deletions waft/wcb.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,23 @@ def haveit(one):
submodules = find_submodules(cfg)
debug(f'wcb: {submodules=}')

# List any packages that may exist in the source but are not ready for
# release builds. Development builds will include them.
pre_release_packages = ["patrec"]
if cfg.env.IS_DEVELOPMENT:
# add any development-only config
debug("wcb: development build options")
else:

strict_flags = "-Werror -Wall -Werror=return-type -pedantic -Wno-unused-local-typedefs"
info(f'Adding strict compiler flags for release: "{strict_flags}"')
cfg.env.CXXFLAGS += strict_flags.split()

for notyet in pre_release_packages:
if notyet in submodules:
info(f'Removing package "{notyet}" due to not yet being ready for release')
submodules.remove(notyet)

# Remove WCT packages if they an optional dependency wasn't found
for pkg,ext in [
("root","HAVE_ROOTSYS"),
Expand Down
53 changes: 46 additions & 7 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,48 @@
# according to the LICENSE file provided as also part of this project.

import os
import sys
import subprocess

# fixme: move into waft/
from waflib.Build import BuildContext
from waflib.Logs import debug, info, error, warn
from waflib.Logs import debug, info

TOP = '.'
APPNAME = 'WireCell'
VERSION = os.popen("git describe --tags").read().strip()

# to avoid adding tooldir="waft" in all the load()'s
import os
import sys
sys.path.insert(0, os.path.realpath("./waft"))
def determine_version():
proc = subprocess.run(["git", "describe", "--tags"], capture_output=True)
if proc.returncode:
if os.path.exists("version.txt"):
return open("version.txt", "r").readlines()[0].strip()
raise FileNotFoundError("Wire-Cell Toolkit must either be built from a git clone or a version.txt must be provided in the source distribution")
version = proc.stdout.decode().strip()
proc = subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], capture_output=True)
branch = proc.stdout.decode().strip()
if branch == "master" or branch[0].isdecimal():
return version
return f'{branch}-{version}'

VERSION = determine_version()


# Valid log level identifiers
log_levels = "trace debug info warn error critical off "
log_levels = (log_levels + log_levels.upper()).split()

# to avoid adding tooldir="waft" in all the load()'s
sys.path.insert(0, os.path.realpath("./waft"))

def options(opt):
opt.load("wcb")

# this used in cfg/wscript_build
opt.add_option('--install-config', type=str, default="",
help="Install configuration files for given experiment")

opt.add_option('--build-mode', type=str, default="",
help="Force the build mode (default, detect based on git branch)")

# fixme: add to spdlog entry in wcb.py
opt.add_option('--with-spdlog-static', type=str, default="yes",
help="Def is true, set to false if your spdlog is not compiled (not recomended)")
Expand All @@ -43,11 +61,32 @@ def options(opt):
help="Set the value for the compiler's --std= option, default 'c++17'")


def is_development():
'''
Return True if we are sitting on a "development" branch.

A "development" branch is any that is not master or a numerical release
branch.
'''
if VERSION == "master" or VERSION[0].isdecimal():
return False
return True


def configure(cfg):
# Save to BuildConfig.h and env
cfg.define("WIRECELL_VERSION", VERSION)
cfg.env.VERSION = VERSION

# see waft/wcb.py for how this is consumed.
cfg.env.IS_DEVELOPMENT = is_development()
if cfg.env.IS_DEVELOPMENT:
info(f"configuring for DEVELOPMENT ({VERSION})")
cfg.define("WIRECELL_DEVELOPMENT", VERSION)
else:
info(f"configuring for RELEASE ({VERSION})")
cfg.define("WIRECELL_RELEASE", VERSION)

# See https://github.com/WireCell/wire-cell-toolkit/issues/337
if not cfg.options.libdir and cfg.env.LIBDIR.endswith("lib64"):
cfg.env.LIBDIR = cfg.env.LIBDIR[:-2]
Expand Down