Skip to content

Commit

Permalink
build script
Browse files Browse the repository at this point in the history
  • Loading branch information
fohristiwhirl committed Jun 14, 2019
1 parent dc7203f commit 9ba06fc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ nibbler.log
releases/*
concat.py
leelaz_opencl_tuning
electron_zipped/*
56 changes: 56 additions & 0 deletions builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import json, os, shutil, zipfile

with open("package.json") as f:
version = json.load(f)["version"]

# Location of zipped electron distributions...

linux_electron = "electron_zipped/electron-v5.0.3-linux-x64.zip"
windows_electron = "electron_zipped/electron-v5.0.3-win32-x64.zip"

# Setup directories...

linux_dir = "./dist/nibbler-{}-linux".format(version)
windows_dir = "./dist/nibbler-{}-windows".format(version)

linux_app_dir = os.path.join(linux_dir, "resources/app")
windows_app_dir = os.path.join(windows_dir, "resources/app")

os.makedirs(linux_app_dir, exist_ok = True)
os.makedirs(windows_app_dir, exist_ok = True)

# Source and other technical files...

useful_files = [file for file in os.listdir() if file.endswith(".js") or file.endswith(".html") or file.endswith(".css") or file == "package.json"]

for file in useful_files:
shutil.copy(file, linux_app_dir)
shutil.copy(file, windows_app_dir)

# Folders...

folders = ["modules", "pieces"]

for folder in folders:
shutil.copytree(folder, os.path.join(linux_app_dir, folder))
shutil.copytree(folder, os.path.join(windows_app_dir, folder))

# config.example.json - to the high level dir, not the app dir

shutil.copy("config.example.json", linux_dir)
shutil.copy("config.example.json", windows_dir)

# Extract Electron

z = zipfile.ZipFile(linux_electron, "r")
z.extractall(linux_dir)
z.close()

z = zipfile.ZipFile(windows_electron, "r")
z.extractall(windows_dir)
z.close()

# Rename Electron

os.rename(os.path.join(linux_dir, "electron"), os.path.join(linux_dir, "nibbler"))
os.rename(os.path.join(windows_dir, "electron.exe"), os.path.join(windows_dir, "nibbler.exe"))

0 comments on commit 9ba06fc

Please sign in to comment.