Skip to content
Open
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
10 changes: 8 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
parser.add_option('-g', '--generate-docs', dest='generate_docs', action="store_true", help='generate documentation for the current target', default=False)
parser.add_option('-j', '--parallelism', dest='parallelism', action="store", help='Set the number of parallel threads to build with, if supported', default=10)
parser.add_option('-n', '--lines', dest='detail_lines', action="store", help="Sets the number of detail lines to output (only relevant to --status)", default=3 )
parser.add_option('--cmake-build-type', dest='cmake_build_type', metavar="-DCMAKE_BUILD_TYPE", help="Pass the -DCMAKE_BUILD_TYPE argument to cmake. Default is 'RelWithDebInfo', which targets size optimizations and includes some basic debug info. Other options include 'Debug', 'Release', and 'MinSizeRel'. See cmake documentation for more details.", default='RelWithDebInfo')

(options, args) = parser.parse_args()

Expand Down Expand Up @@ -131,6 +132,11 @@
print("Too many arguments supplied, only one target can be specified.")
exit(1)

if options.cmake_build_type not in ['Debug', 'Release', 'MinSizeRel', 'RelWithDebInfo']:
print("Invalid CMake build type specified: {}".format(options.cmake_build_type))
print("Valid options are: Debug, Release, MinSizeRel, RelWithDebInfo. See CMake documentation for more details.")
exit(1)

if not options.test_platform:

if not os.path.exists("../codal.json"):
Expand All @@ -141,7 +147,7 @@
generate_docs()
exit(0)

build(options.clean, verbose=options.verbose, parallelism=options.parallelism)
build(options.clean, verbose=options.verbose, parallelism=options.parallelism, cmake_build_type=options.cmake_build_type)
exit(0)

for json_obj in test_json:
Expand All @@ -168,4 +174,4 @@
with open("../codal.json", 'w') as codal_json:
json.dump(config, codal_json, indent=4)

build(True, True, options.parallelism)
build(True, True, options.parallelism, cmake_build_type=options.cmake_build_type)
6 changes: 3 additions & 3 deletions utils/python/codal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ def system(cmd):
if os.system(cmd) != 0:
sys.exit(1)

def build(clean, verbose = False, parallelism = 10):
def build(clean, verbose = False, parallelism = 10, cmake_build_type='RelWithDebInfo'):
# Use Ninja on Windows, or if available in any other OS
use_ninja = shutil.which("ninja") is not None or platform.system() == "Windows"

if use_ninja:
# configure
system("cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G \"Ninja\"")
system(f"cmake .. -DCMAKE_BUILD_TYPE={cmake_build_type} -G \"Ninja\"")

if clean:
system("ninja clean")
Expand All @@ -29,7 +29,7 @@ def build(clean, verbose = False, parallelism = 10):
system("ninja -j {}".format(parallelism))
else:
# configure
system("cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -G \"Unix Makefiles\"")
system(f"cmake .. -DCMAKE_BUILD_TYPE={cmake_build_type} -G \"Unix Makefiles\"")

if clean:
system("make clean")
Expand Down