Commit 6a04d952 authored by carlosperate's avatar carlosperate

Update OS X build steps:

Update the travis configuration to update brew
Update the build script to copy the Resources folder correctly
Update the build script to create a OS X shell script
Update the build script to set the shell scripts to executable
Update the Spec file for better compatibility with pyinstaller on OS X
parent 6424fdb9
...@@ -9,6 +9,7 @@ before_install: ...@@ -9,6 +9,7 @@ before_install:
- python -c "import struct; print(struct.calcsize('P') * 8)" - python -c "import struct; print(struct.calcsize('P') * 8)"
# Install python # Install python
- brew update
- brew install python - brew install python
- brew link --overwrite python - brew link --overwrite python
- pip install --upgrade pip - pip install --upgrade pip
...@@ -33,6 +34,9 @@ before_install: ...@@ -33,6 +34,9 @@ before_install:
# Build and Pack ardublockly # Build and Pack ardublockly
install: install:
#- cd package/pyinstaller/bootloader
#- python ./waf configure build install
#- cd ../../../
- python package/build_pyinstaller.py mac - python package/build_pyinstaller.py mac
- python package/pack_ardublockly.py - python package/pack_ardublockly.py
......
...@@ -115,8 +115,7 @@ def pyinstaller_build(): ...@@ -115,8 +115,7 @@ def pyinstaller_build():
"%s" % os.path.join("package", "pyinstaller.spec")] "%s" % os.path.join("package", "pyinstaller.spec")]
print(script_tab + "Command: %s" % process_args) print(script_tab + "Command: %s" % process_args)
pyinstaller_process = subprocess.Popen( pyinstaller_process = subprocess.Popen(process_args)
process_args)
std_op, std_err_op = pyinstaller_process.communicate() std_op, std_err_op = pyinstaller_process.communicate()
if pyinstaller_process.returncode != 0: if pyinstaller_process.returncode != 0:
...@@ -198,38 +197,58 @@ def copy_cefpython_data_files(os_type): ...@@ -198,38 +197,58 @@ def copy_cefpython_data_files(os_type):
# The Resources is only present in mac, linux uses a locales folder # The Resources is only present in mac, linux uses a locales folder
if os_type == "mac": if os_type == "mac":
cef_exec_resources = os.path.join(cef_exec_folder, "Resources") cef_exec_resources = os.path.join(
project_root_dir, exec_folder_name, "Resources")
print(script_tab + "Copying CEF Resources files from %s/Resources\n" % print(script_tab + "Copying CEF Resources files from %s/Resources\n" %
cef_path + script_tab + "into %s" % cef_exec_resources) cef_path + script_tab + "into %s" % cef_exec_resources)
resources = glob(r"%s/Resources/*.*" % cef_exec_folder) # Copy the entire Resources folder into the execution directory
# Ensure the cefpython3/Resources folder is created and copy the files shutil.copytree(os.path.join(cef_path, "Resources"),
if not os.path.exists(cef_exec_resources): cef_exec_resources)
os.makedirs(cef_exec_resources)
for f in resources:
shutil.copy(f, cef_exec_resources)
def create_bash_file(): def create_bash_file(os_type):
""" """
Creates a bash file into the project root to be able to easily launch the Creates a shell script fil into the project root to be able to easily launch
Ardublockly application. the Ardublockly application.
""" """
bash_text = '#!/bin/bash\n' \ shell_text = ""
'DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )\n' \ shell_location = ""
'echo "[Bash File] Running Ardublockly from: " $DIR\n' \
'./' + exec_folder_name + '/start_cef $DIR' # The script depends on platform
bash_location = os.path.join(project_root_dir, "ardublockly_run.sh") if os_type == "linux":
shell_text = '#!/bin/bash\n' \
'DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )\n' \
'echo "[Shell Launch Script] Executing from: $DIR\n"' \
'./%s/start_cef $DIR' % exec_folder_name
shell_location = os.path.join(project_root_dir, "ardublockly_run.sh")
elif os_type == "mac":
shell_text = '#!/bin/bash\n' \
'DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )\n' \
'echo "[Shell Launch Script] Executing from: $DIR"\n' \
'$DIR/%s/start_cef $DIR' % exec_folder_name
shell_location = os.path.join(
project_root_dir, "ardublockly_run.command")
try: try:
print(script_tab + "Creating bash file into %s" % bash_location) print(script_tab + "Creating shell file into %s" % shell_location)
bash_file = open(bash_location, 'w') bash_file = open(shell_location, 'w')
bash_file.write(bash_text) bash_file.write(shell_text)
bash_file.close() bash_file.close()
except Exception as e: except Exception as e:
print(script_tab + "%s" % e) print(script_tab + "%s" % e)
print(script_tab + "ERROR: Bash file to launch the Ardublockly " print(script_tab + "ERROR: Shell file to launch the Ardublockly "
"application could not be created.") "application could not be created.")
# Make shell script executable by launching a subprocess
process_args = ["chmod", "+x", "%s" % shell_location]
print(script_tab + "Command to make executable: %s" % process_args)
try:
pyinstaller_process = subprocess.Popen(process_args)
std_op, std_err_op = pyinstaller_process.communicate()
except Exception as e:
print(script_tab + "%s" % e)
print(script_tab + "ERROR: Could not make Shell file executable.")
def build_ardublockly(): def build_ardublockly():
print(script_tag + "Build procedure started.") print(script_tag + "Build procedure started.")
...@@ -268,8 +287,8 @@ def build_ardublockly(): ...@@ -268,8 +287,8 @@ def build_ardublockly():
print(script_tag + "Removing PyInstaller recent temp directories.") print(script_tag + "Removing PyInstaller recent temp directories.")
remove_pyinstaller_temps() remove_pyinstaller_temps()
print(script_tag + "Creating bash file to easily execute Ardublockly.") print(script_tag + "Creating shell file to easily execute Ardublockly.")
create_bash_file() create_bash_file(os_type)
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -11,11 +11,11 @@ a = Analysis(['start_cef.py'], ...@@ -11,11 +11,11 @@ a = Analysis(['start_cef.py'],
hiddenimports=["ArdublocklyServer", "cefpython3", "wx"], hiddenimports=["ArdublocklyServer", "cefpython3", "wx"],
hookspath=None, hookspath=None,
runtime_hooks=None, runtime_hooks=None,
excludes=None, excludes=None)
cipher=block_cipher) #cipher=block_cipher)
pyz = PYZ(a.pure, pyz = PYZ(a.pure)
cipher=block_cipher) #cipher=block_cipher)
exe = EXE(pyz, exe = EXE(pyz,
a.scripts, a.scripts,
...@@ -24,7 +24,7 @@ exe = EXE(pyz, ...@@ -24,7 +24,7 @@ exe = EXE(pyz,
debug=False, debug=False,
strip=None, strip=None,
upx=True, upx=True,
console=True) console=False)
coll = COLLECT(exe, coll = COLLECT(exe,
a.binaries, a.binaries,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment