Skip to content

Commit

Permalink
Merge branch 'main' into dev/issue/610
Browse files Browse the repository at this point in the history
  • Loading branch information
mstaylor committed Aug 31, 2022
2 parents 94856aa + 121b386 commit 49fbb89
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 315 deletions.
43 changes: 26 additions & 17 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ def check_conda_prefix():
cpp_build.add_argument("-root", help='Cylon Source root directory',
default=Path(os.getcwd()))
cpp_build.add_argument(
"-cmake-flags", help='Additional cmake flags', default='')
"-cmake-flags", "--cmake-flags", help='Additional cmake flags', default='')

# Build mode
build_mode = parser.add_argument_group(
"Build Mode").add_mutually_exclusive_group()
build_mode = parser.add_argument_group("Build Mode").add_mutually_exclusive_group()
build_mode.add_argument("--debug", action='store_true',
help='Build the core in debug mode')
build_mode.add_argument("--release", action='store_true',
Expand All @@ -86,11 +85,12 @@ def check_conda_prefix():
# Paths
parser.add_argument("-bpath", help='Build directory',
default=Path(os.getcwd(), 'build'))
parser.add_argument("-ipath", help='Install directory')
parser.add_argument("-ipath", "--prefix", dest='ipath', help='Install directory')

parser.add_argument("--verbose", help='Set verbosity', default=False, action="store_true")
parser.add_argument("-j", help='Parallel build threads', default=os.cpu_count(),
dest='parallel', type=int)
parser.add_argument("--clean", action='store_true', help="Clean before building")

args = parser.parse_args()

Expand Down Expand Up @@ -127,15 +127,19 @@ def on_off(arg):

PYTHON_EXEC = sys.executable

if args.style_check:
cmd = f'{PYTHON_EXEC} -m pip install cpplint'
res = subprocess.run(cmd, shell=True, cwd=PYTHON_SOURCE_DIR)
check_status(res.returncode, "cpplint install")
CPPLINT_COMMAND = ""


def check_and_install_cpplint():
global CPPLINT_COMMAND
if args.style_check:
cmd = f'{PYTHON_EXEC} -m pip install cpplint'
res = subprocess.run(cmd, shell=True, cwd=PYTHON_SOURCE_DIR)
check_status(res.returncode, "cpplint install")

CPPLINT_COMMAND = "-DCMAKE_CXX_CPPLINT=\"cpplint;--linelength=100;--headers=h," \
"hpp;--filter=-legal/copyright,-build/c++11,-runtime/references\" "

CPPLINT_COMMAND = "-DCMAKE_CXX_CPPLINT=\"cpplint;--linelength=100;--headers=h," \
"hpp;--filter=-legal/copyright,-build/c++11,-runtime/references\" "
else:
CPPLINT_COMMAND = " "

CMAKE_BOOL_FLAGS = {'CYLON_GLOO', 'CYLON_UCX', 'CYLON_UCC'}
CMAKE_FALSE_OPTIONS = {'0', 'FALSE', 'OFF', 'N', 'NO', 'IGNORE', 'NOTFOUND'}
Expand All @@ -153,8 +157,10 @@ def parse_cmake_bool(v):


def parse_cmake_flags(flag):
for f in CMAKE_FLAGS.strip().replace('-D', '').split():
k, v = f.split('=')
for f in CMAKE_FLAGS.strip().split('-D'):
if not f.strip():
continue
k, v = f.strip().split('=')
if k != flag:
continue
else:
Expand Down Expand Up @@ -204,6 +210,7 @@ def build_cpp():

win_cmake_args = "-A x64" if os.name == 'nt' else ""
verb = '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' if args.verbose else ''
clean = '--clean-first' if args.clean else ''

cmake_command = f"cmake -DPYCYLON_BUILD={on_off(BUILD_PYTHON)} {win_cmake_args} " \
f"-DCMAKE_BUILD_TYPE={CPP_BUILD_MODE} " \
Expand All @@ -217,7 +224,7 @@ def build_cpp():
res = subprocess.call(cmake_command, cwd=BUILD_DIR, shell=True)
check_status(res, "C++ cmake generate")

cmake_build_command = f'cmake --build . --parallel {PARALLEL} --config {CPP_BUILD_MODE}'
cmake_build_command = f'cmake --build . --parallel {PARALLEL} --config {CPP_BUILD_MODE} {clean}'
logger.info(f"Build command: {cmake_build_command}")
res = subprocess.call(cmake_build_command, cwd=BUILD_DIR, shell=True)
check_status(res, "C++ cmake build")
Expand Down Expand Up @@ -298,7 +305,6 @@ def build_python():

conda_prefix = check_conda_prefix()

python_build_command = f'{PYTHON_EXEC} -m pip install -v --upgrade .'
env = os.environ
env["CYLON_PREFIX"] = str(BUILD_DIR)
if os.name == 'posix':
Expand All @@ -315,7 +321,9 @@ def build_python():
env['UCC_PREFIX'] = UCC_PREFIX

logger.info("Arrow prefix: " + str(Path(conda_prefix)))
res = subprocess.run(python_build_command, shell=True, env=env, cwd=PYTHON_SOURCE_DIR)
clean = '--upgrade' if args.clean else ''
cmd = f'{PYTHON_EXEC} -m pip install -v {clean} .'
res = subprocess.run(cmd, shell=True, env=env, cwd=PYTHON_SOURCE_DIR)
check_status(res.returncode, "PyCylon build")


Expand All @@ -331,6 +339,7 @@ def build_java():
check_status(res.returncode, "JCylon build")


check_and_install_cpplint()
build_cpp()
build_python()
python_test()
Expand Down
Loading

0 comments on commit 49fbb89

Please sign in to comment.