Skip to content

Commit

Permalink
Update build.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jblindsay committed Oct 23, 2022
1 parent 054f759 commit c8d03fc
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
if len(result.stdout) > 0:
print(result.stdout)

if os.path.exists(output_dir):
rmtree(output_dir)
if os.path.exists(output_dir):
rmtree(output_dir)

print("Compiling...")
result = subprocess.run(['cargo', 'build', '--release'], stdout=subprocess.PIPE)
Expand All @@ -34,7 +34,6 @@
if not os.path.exists(output_plugin_dir):
os.makedirs(output_plugin_dir)


ext = ''
if platform.system() == 'Windows':
ext = '.exe'
Expand All @@ -43,6 +42,8 @@
exe_file = os.path.join(target_dir, 'whitebox_tools') + ext
dst = os.path.join(output_dir, 'whitebox_tools') + ext
copyfile(exe_file, dst)
if platform.system() != 'Windows':
result = subprocess.run(['strip', dst], stdout=subprocess.PIPE)
os.system("chmod 755 " + dst) # grant executable permission

# Copy the ancillary files
Expand Down Expand Up @@ -90,6 +91,25 @@
exe_file = os.path.join(target_dir, plugin) + ext
dst = os.path.join(output_plugin_dir, plugin) + ext
copyfile(exe_file, dst)
if platform.system() != 'Windows':
print("Stripping", plugin)
result = subprocess.run(['strip', dst], stdout=subprocess.PIPE)
# print(result)

os.system("chmod 755 " + dst) # grant executable permission

# Copy the register_license binary into the plugins folder if it is available
os.chdir(app_dir)
if os.path.exists('../GeneralToolsetExtension'):
# Copy the executable file into the plugins directory
exe_file = f"../GeneralToolsetExtension/register_license{ext}"
if os.path.exists(exe_file):
dst = os.path.join(output_plugin_dir, 'register_license') + ext
copyfile(exe_file, dst)
os.system("chmod 755 " + dst) # grant executable permission
else:
print("No register_license file found...")
else:
print("No directory containing the register_license file found...")

print("Done!")

0 comments on commit c8d03fc

Please sign in to comment.