diff --git a/.gitignore b/.gitignore index cf5c7a2a..bea0c6ee 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ venv.bak/ build dist +# compiled firmware +firmware + #logs log.txt alog.txt @@ -22,3 +25,6 @@ alog.txt __pycache__/ *.py[cod] *$py.class + +# macOS junk +.DS_Store diff --git a/.travis.yml b/.travis.yml index be9d8f28..e38b4f6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,75 @@ -os: - - linux - # - windows language: python -install: - - pip install -r requirements.txt - - pip install -U platformio - - pip install pyinstaller +# python: "3.7" -script: - - bash buildFirmware.sh - - pyinstaller main-onedir.spec - - cd dist && mv main webcontrol && cd webcontrol - - touch webcontrol-linux-singledirectory.tar.gz - - tar -zcvf webcontrol-linux-singledirectory.tar.gz --exclude=webcontrol-linux-singledirectory.tar.gz . - - cd ../.. +jobs: + include: + - stage: Build + name: Universal + os: linux + script: + - tools/download_firmware_release.sh + - tools/build_universal_release.sh + deploy: &base_deploy + provider: releases + token: $GITHUB_TOKEN + file_glob: true + file: dist/*.tar.gz + skip_cleanup: true + prerelease: true + draft: true + on: + tags: true - -before_deploy: - # Set up git user name and tag this commit - - git config --local user.name "Emile Cantin" - - git config --local user.email "emile.cantin@gmail.com" - - export TRAVIS_TAG=${TRAVIS_TAG:-$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)} - - git tag $TRAVIS_TAG -deploy: - provider: releases - api_key: $GITHUB_TOKEN - file: dist/webcontrol/webcontrol-linux-singledirectory.tar.gz - skip_cleanup: true - draft: true + - stage: Build + name: Linux + os: linux + install: &base_install + - pip install -r requirements.txt + - pip install pyinstaller + script: + - tools/download_firmware_release.sh + - tools/build_release.sh linux + deploy: + <<: *base_deploy + - stage: Build + name: macOS + os: osx + language: generic + addons: + homebrew: + packages: python3 + before_install: + - pip3 install virtualenv + - virtualenv -p python3 ~/venv + - source ~/venv/bin/activate + install: + - *base_install + script: + - tools/download_firmware_release.sh + - tools/build_release.sh osx + deploy: + <<: *base_deploy + - stage: Build + name: Windows + os: windows + language: shell + env: PATH=/c/Python37:/c/Python37/Scripts:$PATH + before_install: + - choco install python --version=3.7.7 + - python -m pip install -U pip setuptools + install: + - *base_install + script: + - tools/download_firmware_release.sh + - tools/build_release.sh windows + deploy: + <<: *base_deploy + - stage: Publish + install: + - echo install + script: + - echo script + deploy: + <<: *base_deploy + draft: false diff --git a/Actions/actions.py b/Actions/actions.py index b8f74993..70464d5f 100644 --- a/Actions/actions.py +++ b/Actions/actions.py @@ -1406,6 +1406,7 @@ def upgradeFirmware(self, version): # cmd = "\"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\bin\\avrdude\" -Cavr/avrdude.conf -v -patmega2560 -cwiring -P" + port + " -b115200 -D -Uflash:w:" + filename + ":i" #else: cmd = home+"/tools/avrdude -C"+home+"/tools/avrdude.conf -v -patmega2560 -cwiring -P"+port+" -b115200 -D -Uflash:w:"+filename+":i" + # cmd = "avrdude -v -patmega2560 -cwiring -P"+port+" -b115200 -D -Uflash:w:"+filename+":i" #print(cmd) # I think this is blocking.. x = os.system(cmd) diff --git a/README.md b/README.md index ac41a56a..9c7b27b7 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,17 @@ For Windows 10 and Linux (Debian-based, such as Ubuntu) machines, users can down For Linux/RPI users, make a new subdirectory,and then issue the untar: **For RPI:** ->cd ~
->mkdir webcontrol
->cd webcontrol
->wget https://github.com/madgrizzle/WebControl/releases/download/v0.920/webcontrol-0.920-rpi-singledirectory.tar.gz
->tar -zxvf webcontrol-0.920-rpi-singledirectory.tar.gz
+ +``` +cd ~ +wget https://github.com/madgrizzle/WebControl/releases/download/v0.920/webcontrol-0.920-rpi-singledirectory.tar.gz +mkdir webcontrol +tar -zxvf webcontrol-0.920-rpi-singledirectory.tar.gz -C webcontrol +cd webcontrol +sudo tools/install_dependencies.sh +python3 main.py +``` + **For Linux:** >cd ~
diff --git a/main.spec b/main.spec index 98fdadba..8b4ce59b 100644 --- a/main.spec +++ b/main.spec @@ -22,7 +22,7 @@ exe = EXE(pyz, a.zipfiles, a.datas, [], - name='main', + name='webcontrol', debug=False, bootloader_ignore_signals=False, strip=False, diff --git a/requirements.txt b/requirements.txt index 958473e6..2ecfc5aa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,4 +23,4 @@ PyGithub wget distro python-frontmatter -markdown \ No newline at end of file +markdown diff --git a/tools/build_release.sh b/tools/build_release.sh new file mode 100755 index 00000000..240f90b2 --- /dev/null +++ b/tools/build_release.sh @@ -0,0 +1,24 @@ +#!/bin/bash +VARIANT=$1 + +# cleanup +rm -rf dist + +# Build the bundles +pyinstaller --noconfirm main-onedir.spec +pyinstaller --noconfirm main.spec + +# Rename the directory +pushd dist + +# Zip the releases +touch webcontrol-"${VARIANT}"-singledirectory.tar.gz +pushd main +tar -zcvf ../webcontrol-"${VARIANT}"-singledirectory.tar.gz . +popd +touch webcontrol-"${VARIANT}"-singlefile.tar.gz +tar -zcvf webcontrol-"${VARIANT}"-singlefile.tar.gz webcontrol +ls -l + +popd + diff --git a/tools/build_universal_release.sh b/tools/build_universal_release.sh new file mode 100755 index 00000000..88715dde --- /dev/null +++ b/tools/build_universal_release.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# create the webcontrol script +touch webcontrol +chmod +x webcontrol +echo "#!/bin/bash" > webcontrol +echo "" >> webcontrol +echo "python3 main.py" >> webcontrol + +mkdir -p dist/ +touch dist/webcontrol-universal.tar.gz + +tar -zcvf dist/webcontrol-universal.tar.gz --exclude=dist --exclude=.venv --exclude=.git . + diff --git a/tools/download_firmware_release.sh b/tools/download_firmware_release.sh new file mode 100755 index 00000000..6164c251 --- /dev/null +++ b/tools/download_firmware_release.sh @@ -0,0 +1,21 @@ +#!/bin/bash +mkdir -p firmware +pushd firmware + +# Download the latest release +curl -s https://api.github.com/repos/webcontrolcnc/Firmware/releases/latest \ + | grep "browser_download_url.*hex" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + | wget -qi - + +mkdir -p maslowcnc +mv maslowcnc*.hex maslowcnc/ + +mkdir -p holey +mv holey*.hex holey/ + +mkdir -p madgrizzle +mv madgrizzle*.hex madgrizzle/ + +popd diff --git a/tools/install_dependencies.sh b/tools/install_dependencies.sh new file mode 100755 index 00000000..9531e1ce --- /dev/null +++ b/tools/install_dependencies.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +apt-get update + +apt-get install -y --no-install-recommends python3-pip python3-setuptools python3-dev unzip wget sed build-essential cmake pkg-config libv4l-dev libatlas-base-dev gfortran libevent-dev libatlas-base-dev avrdude libffi-dev libxml2-dev libxslt-dev libsm6 libxext6 libxrender-dev git python3-opencv python3-scipy python3-numpy libjasper1 libgstreamer1.0-0 libavcodec58 libqtgui4 libqt4-test + +apt-get -y autoremove + +# Remove opencv, scipy and numpy from requirements (since they're already installed) +sed -i '/opencv-python.*/d' requirements.txt +sed -i '/scipy.*/d' requirements.txt +sed -i '/numpy.*/d' requirements.txt + +pip3 install -r requirements.txt diff --git a/tools/upgrade_webcontrol.sh b/tools/upgrade_webcontrol.sh index 8ec7c7bf..b6a90b69 100755 --- a/tools/upgrade_webcontrol.sh +++ b/tools/upgrade_webcontrol.sh @@ -4,4 +4,14 @@ echo $1 echo $2 cd $2 tar -zxvf $1 + +# Install dependencies if we're running on Raspbian +IS_RASPBIAN=$(cat /etc/os-release | grep "Raspbian") +if [ -n "${IS_RASPBIAN}" ] +then + echo "We are on Raspbian, installing dependencies" + sudo tools/install_dependencies.sh +fi + +echo "Starting WebControl" ./webcontrol