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

[BUGFIX] a-b-c: actually set compiler, improved default #2051

Merged
merged 8 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions doc/contrib/coding-style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ run the following commands to apply it:

# Install the formatter if not present
pip install black
# Automatically apply style. If unsure what this does read on.
black . scripts/build-catalogue.in
# Automatically apply style to a certain file. If unsure what this does read on.
black . scripts/arbor/build-catalogue.in

The formatter can also be run with ``--check`` to list offending files and
``--diff`` to preview changes. Most editors can `integrate with black
Expand Down
52 changes: 41 additions & 11 deletions scripts/arbor-build-catalogue
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,52 @@ from pathlib import Path
import shutil
import argparse
import re
import sysconfig
brenthuisman marked this conversation as resolved.
Show resolved Hide resolved


config = A.config()
prefix = Path(config['prefix'])
prefix = Path(config["prefix"])
CXX = Path(config["CXX"])
if not prefix.exists():
try:
# Example <>/lib/python3.10/site-packages/arbor
altern = Path(A.__path__[0]).parent.parent.parent.parent
print(f"Warning: prefix '{prefix}' does not exist, falling back to '{altern}'.", file=sys.stderr)
# altern = Path(sysconfig.get_paths()["platlib"]).parent.parent.parent
brenthuisman marked this conversation as resolved.
Show resolved Hide resolved
print(
f"Warning: prefix '{prefix}' does not exist, falling back to '{altern}'.",
file=sys.stderr,
)
prefix = altern
except:
print(f"Error: Neither prefix '{prefix}' nor fallback '{altern}' exist; giving up.", file=sys.stderr)
print(
f"Error: Neither prefix '{prefix}' nor fallback '{altern}' exist. Please specify the prefix where you keep your Python libraries with --prefix.",
file=sys.stderr,
)
exit(-1)
if not CXX.exists():
try:
# Example <>/lib/python3.10/site-packages/arbor
altern = "c++"
print(
f"Warning: prefix '{CXX}' does not exist, falling back to '{altern}'.",
file=sys.stderr,
)
CXX = altern
except:
print(
f"Error: Neither prefix '{CXX}' nor fallback '{altern}' exist. Please provide a path to a C++ compiler with --cxx",
file=sys.stderr,
)
exit(-1)


def parse_arguments():
parser = argparse.ArgumentParser(
description="Generate dynamic catalogue and build it into a shared object.",
usage="%(prog)s catalogue_name mod_source_dir",
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)

parser.add_argument("name", metavar="name", type=str, help="Catalogue name.")

Expand All @@ -54,9 +80,7 @@ enabled) must be present in the target directory.""",

parser.add_argument("-q", "--quiet", action="store_true", help="Less output.")

parser.add_argument("--cpu",
default=True,
help="Enable CPU support.")
parser.add_argument("--cpu", default=True, help="Enable CPU support.")

parser.add_argument(
"--debug",
Expand All @@ -65,7 +89,7 @@ enabled) must be present in the target directory.""",
const=True,
default=None,
help="Don't clean up the generated temp cpp code."
+" Can be a target path for the generated code.",
+ " Can be a target path for the generated code.",
)

parser.add_argument(
Expand All @@ -79,8 +103,8 @@ enabled) must be present in the target directory.""",
parser.add_argument(
"--cxx",
metavar="cxx",
default=config["CXX"],
help='Use this C++ compiler.',
default=CXX,
help="Use this C++ compiler.",
)

parser.add_argument(
Expand Down Expand Up @@ -126,6 +150,12 @@ mod_dir = pwd / Path(args["modpfx"])
mods = [f[:-4] for f in os.listdir(mod_dir) if f.endswith(".mod")]
quiet = args["quiet"]
verbose = args["verbose"] and not quiet
if verbose:
print("=" * 80)
print(f"{os.path.basename(__file__)} called with the following arguments:")
for k, v in args.items():
print(k, v)
print("=" * 80)
debug = args["debug"]
raw = args["raw"]
gpu = args["gpu"]
Expand Down Expand Up @@ -191,7 +221,7 @@ set(arbor_DIR {pakdir})
find_package(arbor REQUIRED)
{gpu_support}
set(CMAKE_BUILD_TYPE release)
set(CMAKE_CXX_COMPILER ${{ARB_CXX}})
set(CMAKE_CXX_COMPILER {args["cxx"]})
set(CMAKE_CXX_FLAGS ${{ARB_CXX_FLAGS}})

include(BuildModules.cmake)
Expand Down