Skip to content

Commit

Permalink
Build script for building the standard library shared object for Zhivo.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Oct 17, 2024
1 parent 5b5d38e commit bdccffd
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@
)

cpp_files = []
cc_files = []

for root, dirs, files in os.walk('src'):
for file in files:
if file.endswith('.cpp'):
cpp_files.append(os.path.join(root, file))

for root, dirs, files in os.walk('lib'):
for file in files:
if file.endswith('.cc'):
cc_files.append(os.path.join(root, file))

if not cpp_files:
print("No .cpp files found in the src directory.")
exit(1)
Expand Down Expand Up @@ -85,13 +92,28 @@
exe_build_args.remove('-mfpmath=sse')
exe_build_args.remove('-s')

rt_bin = os.path.join('dist', 'zhivocore.a')
rt_build_args = exe_build_args + cpp_files + [
'-shared',
'-o',
os.path.join('dist', 'zhivocore.a'),
rt_bin,
]

lib_bin = os.path.join('dist', 'stdzhv1.0')
if PLATFORM == 'Windows':
lib_bin = lib_bin + ".dll"
else:
lib_bin = lib_bin + ".so"

lib_build_args = [
COMPILER, '-Iinclude',
'-shared', '-o',
lib_bin,
rt_bin
]

exe_build_args += cpp_files + ['-o', OUTPUT_EXECUTABLE]
lib_build_args += cc_files
cuda_build_args = ['nvcc']

if PLATFORM == 'Windows':
Expand Down Expand Up @@ -129,6 +151,10 @@
print(' '.join(rt_build_args))
subprocess.run(rt_build_args, check=True)

print("Executing:")
print(' '.join(lib_build_args))
subprocess.run(lib_build_args, check=True)

if PLATFORM != 'Darwin':
print("Executing:")
print(' '.join(cuda_build_args))
Expand Down

0 comments on commit bdccffd

Please sign in to comment.