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

Dev WIP #7

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
acf0a2f
prefer interpolating strings
biojppm Apr 23, 2020
b327a78
[wip] add command to build individual file
biojppm Apr 23, 2020
b534b64
[wip] improving detection of proj dir and build dir
biojppm Apr 23, 2020
340ea34
chg: usr: require cmake and ninja
biojppm Nov 17, 2020
6925537
chg: dev: move comment from place
biojppm Nov 17, 2020
97b8460
fix: usr: apparently cmake --build --parallel is broken in VS
biojppm Nov 17, 2020
f10fee7
fix: make sure the proj paths are not null
biojppm Nov 17, 2020
534acdc
new: usr: add command build_files
biojppm Nov 17, 2020
ce0cc46
chg: usr: disambiguate: use --glob instead of positional arguments
biojppm Nov 17, 2020
147da5b
new: usr: add -vb/--verbose flag
biojppm Nov 18, 2020
0a5bc01
fix: usr: build_files now works in Visual Studio!!!!
biojppm Nov 18, 2020
46c71f8
fix: usr: mark experimental flags
biojppm Nov 18, 2020
4ff618d
fix: usr: dangling references to --build-dir and --install-dir
biojppm Nov 18, 2020
172bf50
fix: usr: build_files: dev_env is different for vs2015
biojppm Nov 19, 2020
548c51e
fix: usr: build_files must accept empty targets
biojppm Nov 19, 2020
3102c98
new: show_targets descends into all directories
biojppm Nov 21, 2020
cdc70e6
new: usr: added run_target
biojppm Nov 21, 2020
aa49fd8
new: usr: added run_test
biojppm Nov 22, 2020
cd4ee57
fix: usr: verbose flag was ignored because of caching
biojppm Nov 23, 2020
481567a
fix: usr: run_cmd, run_target and run_test: do not build all targets …
biojppm Nov 25, 2020
ac9723a
fix: import of InvalidGenerator
biojppm Nov 26, 2020
cb8f246
fix: shlex.join is only available in python 3.8+
biojppm Jan 7, 2021
dd1c93d
[fix] fix missing arguments to exception
jppm Jan 26, 2021
3d59319
[impl] run target: add options for calling the target from another co…
jppm Jan 26, 2021
da13e9b
[fix] add intel 2021.1
biojppm Jul 10, 2021
84ea77d
[impl] add vs2022
biojppm Aug 19, 2021
b6d7a55
[fix] some targets have the executable created in a non-standard place
biojppm Oct 12, 2021
7d70d1f
subprocess: PIPE
biojppm Dec 7, 2021
db387ef
[fix] target executables may be place in several places
biojppm Jan 22, 2022
c7c6542
[fix] improve loading of toolchains
biojppm Mar 4, 2022
85fdceb
[fix] fix runcmd_nocheck(): stdout was suppressed
biojppm Mar 17, 2022
9155833
[fix] runcmd: ensure stdout is printed
biojppm Mar 4, 2022
5254f14
[fix] add missing argument when raising exception
biojppm May 17, 2022
3c306db
[wip] improve behavior with toolchains
biojppm Jun 11, 2022
a7f2ef8
[wip] improve behavior with toolchains
biojppm Sep 27, 2022
384a055
[fix] improve caching of cmake sysinfo with toolchains
biojppm Oct 29, 2022
8a41178
[fix] allow args to BuildType ctor
biojppm Nov 30, 2022
600887f
[fix] fix VS generation
biojppm Dec 14, 2022
91c9fc7
[fix] fix compiler heuristics for clang++ and g++
biojppm Mar 10, 2023
b78e3e8
[fix] detect when VS is not found
biojppm Mar 10, 2023
64c28dd
[chore] default to vs2022
biojppm Mar 10, 2023
44c8532
build type: be more specific with creating the type
biojppm Mar 14, 2023
0bf8bec
add warning about flag arguments
biojppm Mar 14, 2023
18b60c0
fix tests
biojppm Mar 14, 2023
2b21402
update test scripts
biojppm Mar 14, 2023
314d1ef
[fix] fix dirty-state cache on every call, was triggering reconfigures
biojppm Mar 19, 2023
9f67103
[fix] loaded cache vars must not be from input
biojppm Mar 19, 2023
28e8836
[fix] icc
biojppm Mar 20, 2023
742b2ba
run_target: wrap arguments for gdb, ddd, kdbg
biojppm May 4, 2024
f24acfb
add kflags for C and C++
biojppm May 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/quick_tour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ the install trees are nested under the ``install`` directory. However, you
don't have to use these defaults. The following command will use ``foo`` for
building and ``bar`` for installing::

$ cmany i -c clang++,g++ --build-dir foo --install-dir bar
$ cmany i -c clang++,g++ --build-root foo --install-root bar

$ ls -1 foo/ bar/
bar/linux-x86_64-clang++3.9-Release/
Expand Down
174 changes: 172 additions & 2 deletions doc/vs.rst

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ colorama
argcomplete
dill
python-dateutil
ninja
lxml
4 changes: 3 additions & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
wheel
nose
pytest
pytest-cov
parameterized
twine
coverage
codecov
Expand Down
35 changes: 20 additions & 15 deletions src/c4/cmany/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,29 @@

from .build_item import BuildItem
from . import util
from .cmake import CMakeSysInfo


# -----------------------------------------------------------------------------
class Architecture(BuildItem):
"""Specifies a processor architecture"""

@staticmethod
def default():
def default(toolchain_file: str=None):
"""return the architecture of the current machine"""
return Architecture(__class__.default_str())
return Architecture(__class__.default_str(toolchain_file))

@staticmethod
def default_str():
# s = CMakeSysInfo.architecture()
# if s == "amd64":
# s = "x86_64"
# return s
if util.in_64bit():
return "x86_64"
elif util.in_32bit():
return "x86"
def default_str(toolchain_file: str=None):
s = CMakeSysInfo.architecture(toolchain=toolchain_file)
if s == "amd64":
s = "x86_64"
return s

@property
def is64(self):
def fn():
s = re.search('64', self.name)
return s is not None
return util.cacheattr(self, "_is64", fn)
return util.cacheattr(self, "_is64",
lambda: re.search('64', self.name) is not None)

@property
def is32(self):
Expand All @@ -38,3 +33,13 @@ def is32(self):
@property
def is_arm(self):
return "arm" in self.name.lower()

@property
def vs_dev_env_name(self):
# [arch]: x86 | amd64 | x86_amd64 | x86_arm | x86_arm64 | amd64_x86 | amd64_arm | amd64_arm64
if self.is_arm:
raise Exception("not implemented")
if self.is64:
return "x64"
else:
return "x86"
91 changes: 49 additions & 42 deletions src/c4/cmany/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def setup(subcommands, module):
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=help.epilog,
)
add_verbose(p)
# gather the list of visible subcommands
# https://stackoverflow.com/questions/21692395/hiding-selected-subcommands-using-argparse
visible_metavar = ",".join(["{},{}".format(cmd, ",".join(aliases))
Expand Down Expand Up @@ -153,30 +154,42 @@ def _handle_hidden_args__skip_rest(args):
return False


# -----------------------------------------------------------------------------
def add_verbose(parser):
parser.add_argument("-vb", "--verbose", default=False, action="store_true",
help="""use verbose commands in the build tools. does not apply to configure step;
build_file is always verbose""")


# -----------------------------------------------------------------------------
def add_basic(parser):
parser.add_argument("proj_dir", nargs="?", default=".",
help="""the directory where the project's CMakeLists.txt
is located. An empty argument will default to the
current directory ie, \".\". Passing a directory which
does not contain a CMakeLists.txt will cause an error.""")
parser.add_argument("--build-dir", default="./build",
help="set the build root (defaults to ./build)")
parser.add_argument("--install-dir", default="./install",
parser.add_argument("-P", "--proj-dir", default=None,
help="""the directory where the project's
CMakeLists.txt is located. An empty argument will
default to the current directory ie, "." or, if
the current directory is a build directory containing
CMakeCache.txt, the source directory for that
build directory. Passing a directory which
does not contain a CMakeLists.txt or CMakeCache.txt
will cause an error.""")
parser.add_argument("-B", "--build-root", default="./build",
help="set the build root (defaults to ./build). ")
parser.add_argument("-I", "--install-root", default="./install",
help="set the install root (defaults to ./install)")
parser.add_argument("-j", "--jobs", default=cpu_count(),
help="""use the given number of parallel jobs
(defaults to %(default)s on this machine).""")
parser.add_argument("--continue", default=False, action="store_true",
help="attempt to continue when a build fails")
add_verbose(parser)


# -----------------------------------------------------------------------------
def add_glob(parser):
#
add_basic(parser)
#
parser.add_argument("glob", nargs="*", default="*",
parser.add_argument("--glob", nargs="*", default="*",
help="""glob pattern(s) matching build names (NOTE:
not paths to the build dirs)""")

Expand All @@ -194,31 +207,31 @@ def add_proj(parser):
#
g = parser.add_argument_group('Configuration files')
g.add_argument("--config-file", default=[], action="append",
help="""Specify a file containing configurations. Relative
help="""[EXPERIMENTAL] Specify a file containing configurations. Relative
paths are taken from the project's CMakeLists.txt directory.
Run `cmany help flags` to get help about flag aliases.
Multiple invokations are possible, in which case flags
given in latter files will prevail over those of earlier
files.""")
g.add_argument("--no-default-config", default=False, action="store_true",
help="""Do not read the default config file. Run
help="""[EXPERIMENTAL] Do not read the default config file. Run
`cmany help flags` to get help about this.""")
#
d = parser.add_argument_group('Dependencies')
d.add_argument('--deps', default='', type=str,
metavar='path/to/extern/CMakeLists.txt',
help="""Before configuring, process (ie, configure, build
help="""[EXPERIMENTAL] Before configuring, process (ie, configure, build
and install) the given CMakeLists.txt project containing
needed external project dependencies. This will be done
separately for each build, using the same parameters. The
main project will be configured such that the built
dependencies are found by cmake.""")
d.add_argument('--deps-prefix', default="", type=str,
metavar='path/to/install/directory',
metavar='[EXPERIMENTAL] path/to/install/directory',
help="""When using --deps set the install directory for
external dependencies to the given dir.""")
d.add_argument('--with-conan', action='store_true', default=False,
help="""(WIP)""")
help=argparse.SUPPRESS)


# -----------------------------------------------------------------------------
Expand All @@ -241,47 +254,31 @@ def add_select(parser):
given either as a comma-separated list or with repeated invokations
of their arguments. Commas can be escaped by using a backslash,
\\.""")
#
dft = [system.System.default_str()]
g.add_argument("-s", "--systems", metavar="os1,os2,...",
default=dft, action=BuildItemArgument,
action=BuildItemArgument,
help="""Specify a comma-separated list of operating systems
to combine. Defaults to the current system, """ +
_item_printer(dft) + """.""")
#
dft = [architecture.Architecture.default_str()]
to combine. Defaults to the current system.""")
g.add_argument("-a", "--architectures", metavar="arch1,arch2,...",
default=dft, action=BuildItemArgument,
action=BuildItemArgument,
help="""Specify a comma-separated list of processor
architectures to combine. Defaults to CMake's default
architecture on this system, """ +
_item_printer(dft) + """.""")
#
dft = [compiler.Compiler.default_str()]
architecture on this system.""")
g.add_argument("-c", "--compilers", metavar="compiler1,compiler2,...",
default=dft, action=BuildItemArgument,
action=BuildItemArgument,
help="""Specify a comma-separated list of compilers to
combine. Compilers can be given as an absolute path, or as
a name, in which case that name will be searched for in
the current shell's PATH. Defaults to CMake's default
compiler on this system, """ +
_item_printer(dft) + """.""")
#
# dft = [build_type.BuildType.default_str()] # avoid a circular dependency
dft = ["Release"]
compiler on this system.""")
g.add_argument("-t", "--build-types", metavar="type1,type2,...",
default=dft, action=BuildItemArgument,
action=BuildItemArgument,
help="""Specify a comma-separated list of build types
to combine. Defaults to """ + _item_printer(dft) + """.""")
#
# dft = [variant.Variant.default_str()] # avoid a circular dependency
dft = ["none"]
to combine.""")
g.add_argument("-v", "--variants", metavar="variant1,variant2,...",
default=["none"], action=BuildItemArgument,
action=BuildItemArgument,
help="""Specify a comma-separated list of variants
to combine. The variant name 'none' is special and will be
omitted from the name of the resulting build. Defaults to
""" + _item_printer(dft) + """.""")
omitted from the name of the resulting build. Defaults to none.""")
#add_combination_flags(parser)


Expand Down Expand Up @@ -375,6 +372,14 @@ def add_item_combination_flags(parser):
following variants.""")


def dash_warning(flag):
return """To prevent flags/arguments starting with dash (-) or
double-dash (--) from being expanded by the shell and then
understood as a cmany flag, enclose them in quotes with leading
whitespace. Eg, instead of {} '--flag' use {} ' --flag', or
instead of {} '-f' use {} ' -f'.""".format(flag, flag, flag, flag)


def add_cflags(parser):
g = parser.add_argument_group(
'Flags: CMake cache variables, compiler flags and defines',
Expand All @@ -398,6 +403,8 @@ def add_cflags(parser):
Multiple invokations of -D are possible, in which case
arguments will be appended and not overwritten.
To escape commas, use a backslash \\.""")
g.add_argument("-K", "--kflags", default=[], action=FlagArgument,
help="""Add C and C++ compiler flags. See -C and -X.""")
g.add_argument("-X", "--cxxflags", default=[], action=FlagArgument,
help="""Add C++ compiler flags.
Accepts a comma-separated list of C++ compiler flags.
Expand All @@ -408,7 +415,7 @@ def add_cflags(parser):
to get help about this.
Multiple invokations of -X are possible, in which case
arguments will be appended and not overwritten.
To escape commas, use a backslash \\.""")
To escape commas, use a backslash \\. """ + dash_warning("-X"))
g.add_argument("-C", "--cflags", default=[], action=FlagArgument,
help="""Add C compiler flags.
Accepts a comma-separated list of C compiler flags.
Expand All @@ -419,7 +426,7 @@ def add_cflags(parser):
to get help about this.
Multiple invokations of -X are possible, in which case
arguments will be appended and not overwritten.
To escape commas, use a backslash \\.""")
To escape commas, use a backslash \\. """ + dash_warning("-C"))
# g.add_argument("-I", "--include-dirs", default=[], action=FlagArgument,
# help="""add dirs to the include path of all builds
# Multiple invokations of -I are possible, in which case arguments will be appended and not overwritten.
Expand Down