Skip to content

Commit d2201e1

Browse files
committed
Now able to build and run under Windows
1 parent 1f709f9 commit d2201e1

File tree

6 files changed

+216
-1
lines changed

6 files changed

+216
-1
lines changed

cuav/image/scanner.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,9 +1201,13 @@ scanner_thermal_convert(PyObject *self, PyObject *args)
12011201

12021202
for (uint32_t i=0; i<width*height; i++) {
12031203
uint16_t value = data[i];
1204+
#ifndef __MINGW32__
12041205
if (__BYTE_ORDER == __LITTLE_ENDIAN) {
12051206
swab(&value, &value, 2);
12061207
}
1208+
#else
1209+
swab(&value, &value, 2);
1210+
#endif
12071211
value >>= 2;
12081212
mask |= value;
12091213
if (value > maxv) maxv = value;
@@ -1214,9 +1218,13 @@ scanner_thermal_convert(PyObject *self, PyObject *args)
12141218

12151219
for (uint32_t i=0; i<width*height; i++) {
12161220
uint16_t value = data[i];
1221+
#ifndef __MINGW32__
12171222
if (__BYTE_ORDER == __LITTLE_ENDIAN) {
12181223
swab(&value, &value, 2);
12191224
}
1225+
#else
1226+
swab(&value, &value, 2);
1227+
#endif
12201228
value >>= 2;
12211229
uint8_t map_value(float v, const float threshold) {
12221230
if (v > threshold) {

cuav/uav/uav.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from numpy import array, linalg, eye, zeros, dot, transpose
22
from numpy import sin, cos, pi
3-
from matplotlib import pyplot
43

54
#def rotationMatrix(phi, theta, psi):
65
# out = zeros((3,3))
@@ -91,6 +90,8 @@ def __init__(self, fu=200, fv=200, cu=512, cv=480):
9190

9291

9392
if __name__ == '__main__':
93+
from matplotlib import pyplot
94+
9495
xfer = uavxfer()
9596
xfer.setCameraParams(200.0, 200.0, 512, 480)
9697
xfer.setCameraOrientation(0.0, 0.0, -pi/2)

windows/createChangelog.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python
2+
'''
3+
Create a user readable changelog
4+
Requires the gitpython package via pip install gitpython
5+
6+
Stephen Dade
7+
November 2016
8+
'''
9+
10+
from git import Repo
11+
import os
12+
import time
13+
14+
#Get the parent (..\) directory. ie the root cuav dir
15+
path = os.path.abspath(os.path.join(os.getcwd(), os.pardir))
16+
repo = Repo(path)
17+
assert not repo.bare
18+
19+
#get list of all commits
20+
all_commits = list(repo.iter_commits('master'))
21+
22+
#open the changelog for writing
23+
f = open("changelog.txt","w")
24+
25+
#go through all the commits
26+
for comm in all_commits:
27+
#if it's a version raise, add a special message
28+
if "raise version" in comm.message:
29+
commit_date = time.strftime("%d-%m-%Y", time.gmtime(comm.committed_date))
30+
tree = comm.tree
31+
#get setup.py and grab the version number from the file
32+
blob = tree['setup.py']
33+
data = blob.data_stream.read()
34+
curversion = ""
35+
for line in data.split('\n'):
36+
if "version = " in line:
37+
curversion = line[11:len(line)-1]
38+
break
39+
40+
f.write("\n")
41+
f.write("CUAV " + curversion + " (" + commit_date + ")\n")
42+
else:
43+
#just print the summary (1st line) of the commit message
44+
comm.message.split('\n', 1)[0]
45+
f.write("-" + comm.summary + "\n")
46+
47+
f.close()
48+
print("Done")

windows/cuav.spec

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# -*- mode: python -*-
2+
# spec file for pyinstaller to build cuav for windows
3+
geotagAny = Analysis(['.\\cuav\\tools\\geotag.py'],
4+
pathex=[os.path.abspath('.')],
5+
# for some unknown reason these hidden imports don't pull in
6+
# all the needed pieces, so we also import them in mavproxy.py
7+
hiddenimports=['UserList', 'UserString',
8+
'pymavlink.mavwp', 'pymavlink.mavutil', 'pymavlink.dialects.v20.ardupilotmega',
9+
'pymavlink.dialects.v10.ardupilotmega',
10+
'pymavlink.dialects.v20.common', 'pymavlink.dialects.v10.common',
11+
'pymavlink.dialects.v20.ASLUAV', 'pymavlink.dialects.v10.ASLUAV',
12+
'pymavlink.dialects.v20.autoquad', 'pymavlink.dialects.v10.autoquad',
13+
'pymavlink.dialects.v20.matrixpilot', 'pymavlink.dialects.v10.matrixpilot',
14+
'pymavlink.dialects.v20.minimal', 'pymavlink.dialects.v10.minimal',
15+
'pymavlink.dialects.v20.paparazzi', 'pymavlink.dialects.v10.paparazzi',
16+
'pymavlink.dialects.v20.slugs', 'pymavlink.dialects.v10.slugs',
17+
'pymavlink.dialects.v20.standard', 'pymavlink.dialects.v10.standard',
18+
'pymavlink.dialects.v20.ualberta', 'pymavlink.dialects.v10.ualberta',
19+
'pymavlink.dialects.v20.uAvionix', 'pymavlink.dialects.v10.uAvionix'],
20+
excludes=['tcl', 'tk', 'Tkinter', 'tkinter', '_tkinter'],
21+
hookspath=None,
22+
runtime_hooks=None)
23+
pgmconvertAny = Analysis(['.\\cuav\\tools\\pgm_convert.py'],
24+
pathex=[os.path.abspath('.')],
25+
# for some unknown reason these hidden imports don't pull in
26+
# all the needed pieces, so we also import them in mavproxy.py
27+
hiddenimports=['UserList', 'UserString'],
28+
excludes=['tcl', 'tk', 'Tkinter', 'tkinter', '_tkinter'],
29+
hookspath=None,
30+
runtime_hooks=None)
31+
geosearchAny = Analysis(['.\\cuav\\tools\\geosearch.py'],
32+
pathex=[os.path.abspath('.')],
33+
# for some unknown reason these hidden imports don't pull in
34+
# all the needed pieces, so we also import them in mavproxy.py
35+
hiddenimports=['UserList', 'UserString',
36+
'pymavlink.mavwp', 'pymavlink.mavutil', 'pymavlink.dialects.v20.ardupilotmega',
37+
'pymavlink.dialects.v10.ardupilotmega',
38+
'pymavlink.dialects.v20.common', 'pymavlink.dialects.v10.common',
39+
'pymavlink.dialects.v20.ASLUAV', 'pymavlink.dialects.v10.ASLUAV',
40+
'pymavlink.dialects.v20.autoquad', 'pymavlink.dialects.v10.autoquad',
41+
'pymavlink.dialects.v20.matrixpilot', 'pymavlink.dialects.v10.matrixpilot',
42+
'pymavlink.dialects.v20.minimal', 'pymavlink.dialects.v10.minimal',
43+
'pymavlink.dialects.v20.paparazzi', 'pymavlink.dialects.v10.paparazzi',
44+
'pymavlink.dialects.v20.slugs', 'pymavlink.dialects.v10.slugs',
45+
'pymavlink.dialects.v20.standard', 'pymavlink.dialects.v10.standard',
46+
'pymavlink.dialects.v20.ualberta', 'pymavlink.dialects.v10.ualberta',
47+
'pymavlink.dialects.v20.uAvionix', 'pymavlink.dialects.v10.uAvionix'],
48+
excludes=[],
49+
hookspath=None,
50+
runtime_hooks=None)
51+
52+
MERGE( (geotagAny, 'geotag', 'geotag'), (pgmconvertAny, 'pgmconvert', 'pgmconvert'), (geosearchAny, 'geosearch', 'geosearch') )
53+
54+
geotag_pyz = PYZ(geotagAny.pure)
55+
geotag_exe = EXE(geotag_pyz,
56+
geotagAny.scripts,
57+
exclude_binaries=True,
58+
name='geotag.exe',
59+
debug=False,
60+
strip=None,
61+
upx=True,
62+
console=True )
63+
geotag_coll = COLLECT(geotag_exe,
64+
geotagAny.binaries,
65+
geotagAny.zipfiles,
66+
geotagAny.datas,
67+
strip=None,
68+
upx=True,
69+
name='geotag')
70+
71+
pgmconvert_pyz = PYZ(pgmconvertAny.pure)
72+
pgmconvert_exe = EXE(pgmconvert_pyz,
73+
pgmconvertAny.scripts,
74+
exclude_binaries=True,
75+
name='pgmconvert.exe',
76+
debug=False,
77+
strip=None,
78+
upx=True,
79+
console=True )
80+
pgmconvert_coll = COLLECT(pgmconvert_exe,
81+
pgmconvertAny.binaries,
82+
pgmconvertAny.zipfiles,
83+
pgmconvertAny.datas,
84+
strip=None,
85+
upx=True,
86+
name='pgmconvert')
87+
88+
geosearch_pyz = PYZ(geosearchAny.pure)
89+
geosearch_exe = EXE(geosearch_pyz,
90+
geosearchAny.scripts,
91+
exclude_binaries=True,
92+
name='geosearch.exe',
93+
debug=False,
94+
strip=None,
95+
upx=True,
96+
console=True )
97+
geosearch_coll = COLLECT(geosearch_exe,
98+
geosearchAny.binaries,
99+
geosearchAny.zipfiles,
100+
geosearchAny.datas,
101+
strip=None,
102+
upx=True,
103+
name='geosearch')

windows/cuavWinBuild.bat

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
rem build the standalone Cuav tools for Windows.
2+
rem This assumes Python is installed in C:\Python27
3+
rem If it is not, change the PYTHON_LOCATION environment variable accordingly
4+
rem This assumes InnoSetup is installed in C:\Program Files (x86)\Inno Setup 5
5+
rem If it is not, change the INNOSETUP environment variable accordingly
6+
rem This requires the MinGW compiler and libjpeg-turbo development files (libjpeg-turbo-1.5.1-gcc.exe)
7+
rem This requires Pyinstaller==2.1, setuptools==19.2 and packaging==14.2
8+
rem also requires pyexiv2 - https://launchpad.net/pyexiv2
9+
SETLOCAL enableextensions
10+
11+
if "%PYTHON_LOCATION%" == "" (set "PYTHON_LOCATION=C:\Python27")
12+
if "%INNOSETUP%" == "" (set "INNOSETUP=C:\Program Files (x86)\Inno Setup 5")
13+
14+
rem get the version
15+
for /f "tokens=*" %%a in (
16+
'"%PYTHON_LOCATION%\python" returnVersion.py'
17+
) do (
18+
set VERSION=%%a
19+
)
20+
21+
rem -----build the changelog-----
22+
"%PYTHON_LOCATION%\python" createChangelog.py
23+
24+
rem -----Build CUAV-----
25+
cd ..\
26+
"%PYTHON_LOCATION%\python" setup.py clean build --compiler=mingw32 install
27+
"%PYTHON_LOCATION%\Scripts\pyinstaller" -y --clean .\windows\cuav.spec
28+
29+
rem ----Copy the files and scanner.pyd----
30+
mkdir .\dist\cuav
31+
xcopy .\dist\pgmconvert\* .\dist\cuav /Y /E
32+
xcopy .\dist\geotag\* .\dist\cuav /Y /E
33+
xcopy .\dist\geosearch\* .\dist\cuav /Y /E
34+
xcopy .\build\lib.win32-2.7\cuav\image\scanner.pyd .\dist\cuav\cuav.image.scanner.pyd /Y
35+
36+
rem -----Create version Info-----
37+
@echo off
38+
@echo %VERSION%> .\windows\version.txt
39+
@echo on
40+
41+
42+
43+
pause

windows/returnVersion.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This script reads the setup.py and returns the current version number
2+
# Used as part of building the WIndows setup file (cuavWinBuild.bat)
3+
# It assumes there is a line like this:
4+
# version = "12344"
5+
6+
# glob supports Unix style pathname extensions
7+
with open("../setup.py") as f:
8+
searchlines = f.readlines()
9+
for i, line in enumerate(searchlines):
10+
if "version = " in line:
11+
print line[11:len(line)-2]
12+
break

0 commit comments

Comments
 (0)