Skip to content

Commit 985bead

Browse files
filnetf5soh
authored andcommitted
Merged in filnet/librepilot/LP-535_msys2_automatic_dependencies (pull request #443)
LP-535 msys2 automatic dependencies Approved-by: Jan NIJS <dr.oblivium@gmail.com> Approved-by: Philippe Renon <philippe_renon@yahoo.fr> Approved-by: Alessio Morale <alessiomorale@gmail.com> Approved-by: Lalanne Laurent <f5soh@free.fr>
2 parents 43de409 + d4f7f4a commit 985bead

6 files changed

Lines changed: 154 additions & 91 deletions

File tree

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build:
66
- if [ $$arch = 32 ]; then target=i686; fi
77
- if [ $$arch = 64 ]; then target=x86_64; fi
88
- echo -e "[librepilot-mingw]\nSigLevel = Optional TrustAll\nServer = http://download.librepilot.org/repo/mingw" >> /etc/pacman.conf
9-
- pacman -Syu --noconfirm --noprogressbar --needed git unzip tar mingw-w64-${target}-toolchain mingw-w64-${target}-ccache mingw-w64-${target}-qt5 mingw-w64-${target}-SDL mingw-w64-${target}-mesa mingw-w64-${target}-openssl mingw-w64-${target}-gdal-minimal mingw-w64-${target}-OpenSceneGraph mingw-w64-${target}-osgearth
9+
- pacman -Syu --noconfirm --noprogressbar --needed git unzip tar mingw-w64-${target}-toolchain mingw-w64-${target}-ccache mingw-w64-${target}-ntldd mingw-w64-${target}-qt5 mingw-w64-${target}-SDL mingw-w64-${target}-mesa mingw-w64-${target}-openssl mingw-w64-${target}-gdal-minimal mingw-w64-${target}-OpenSceneGraph mingw-w64-${target}-osgearth
1010
- mingw32-make all_sdk_install
1111
- git config core.filemode false
1212
- mingw32-make build-info && cat build/build-info.txt

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Add the following lines at the end of your /etc/pacman.conf file:
4141
Start a MinGW-w64 Win64 Shell or a MinGW-w64 Win32 Shell.
4242

4343
pacman -Sy
44-
pacman -S --needed git unzip tar mingw-w64-i686-toolchain mingw-w64-i686-ccache mingw-w64-i686-qt5 mingw-w64-i686-SDL mingw-w64-i686-mesa mingw-w64-i686-openssl mingw-w64-i686-gdal-minimal mingw-w64-i686-OpenSceneGraph mingw-w64-i686-osgearth
44+
pacman -S --needed git unzip tar mingw-w64-i686-toolchain mingw-w64-i686-ccache mingw-w64-i686-ntldd mingw-w64-i686-qt5 mingw-w64-i686-SDL mingw-w64-i686-mesa mingw-w64-i686-openssl mingw-w64-i686-gdal-minimal mingw-w64-i686-OpenSceneGraph mingw-w64-i686-osgearth
4545

4646
Optionally install debug packages:
4747

@@ -52,7 +52,7 @@ Optionally install debug packages:
5252
Start a MinGW-w64 Win64 Shell.
5353

5454
pacman -Sy
55-
pacman -S --needed git unzip tar mingw-w64-x86_64-toolchain mingw-w64-x86_64-ccache mingw-w64-x86_64-qt5 mingw-w64-x86_64-SDL mingw-w64-x86_64-mesa mingw-w64-x86_64-openssl mingw-w64-x86_64-gdal-minimal mingw-w64-x86_64-OpenSceneGraph mingw-w64-x86_64-osgearth
55+
pacman -S --needed git unzip tar mingw-w64-x86_64-toolchain mingw-w64-x86_64-ccache mingw-w64-x86_64-ntldd mingw-w64-x86_64-qt5 mingw-w64-x86_64-SDL mingw-w64-x86_64-mesa mingw-w64-x86_64-openssl mingw-w64-x86_64-gdal-minimal mingw-w64-x86_64-OpenSceneGraph mingw-w64-x86_64-osgearth
5656

5757
Optionally install debug packages:
5858

ground/gcs/copydata.pro

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -87,35 +87,11 @@ win32 {
8787
Qt5MultimediaWidgets$${DS}.dll \
8888
Qt5Quick$${DS}.dll \
8989
Qt5QuickWidgets$${DS}.dll \
90-
Qt5Qml$${DS}.dll \
91-
libicuin57.dll \
92-
libicudt57.dll \
93-
libicuuc57.dll \
94-
libstdc++-6.dll \
95-
libwinpthread-1.dll \
96-
libpcre-1.dll \
97-
libpcre16-0.dll \
98-
zlib1.dll \
99-
libharfbuzz-0.dll \
100-
libgraphite2.dll \
101-
libfreetype-6.dll \
102-
libbz2-1.dll \
103-
libpng16-16.dll \
104-
libjpeg-8.dll \
105-
libglib-2.0-0.dll \
106-
libintl-8.dll \
107-
libiconv-2.dll
108-
109-
contains(QT_ARCH, i386) {
110-
QT_DLLS += \
111-
libgcc_s_dw2-1.dll
112-
} else {
113-
QT_DLLS += \
114-
libgcc_s_seh-1.dll
115-
}
90+
Qt5Qml$${DS}.dll
11691

11792
for(dll, QT_DLLS) {
11893
addCopyFileTarget($${dll},$$[QT_INSTALL_BINS],$${GCS_APP_PATH})
94+
win32:addCopyDependenciesTarget($${dll},$$[QT_INSTALL_BINS],$${GCS_APP_PATH})
11995
}
12096

12197
# copy OpenSSL DLLs
@@ -141,6 +117,7 @@ win32 {
141117

142118
for(plugin, QT_PLUGINS) {
143119
addCopyFileTarget($${plugin},$$[QT_INSTALL_PLUGINS],$${GCS_QT_PLUGINS_PATH})
120+
win32:addCopyDependenciesTarget($${plugin},$$[QT_INSTALL_PLUGINS],$${GCS_APP_PATH})
144121
}
145122

146123
# Copy QtQuick2 complete directories

ground/gcs/gcs.pri

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,46 @@ defineTest(addCopyFileTarget) {
3333
src = $$2/$$1
3434
dest = $$3/$$1
3535

36-
$${file}.target = $$dest
37-
$${file}.depends = $$src
36+
target = $${file}
37+
$${target}.target = $$dest
38+
$${target}.depends = $$src
3839

3940
# create directory. Better would be an order only dependency
40-
$${file}.commands = -@$(MKDIR) \"$$dirname(dest)\" $$addNewline()
41-
$${file}.commands += $(COPY_FILE) \"$$src\" \"$$dest\"
41+
$${target}.commands = -@$(MKDIR) \"$$dirname(dest)\" $$addNewline()
42+
$${target}.commands += $(COPY_FILE) \"$$src\" \"$$dest\"
4243

43-
QMAKE_EXTRA_TARGETS += $$file
44-
POST_TARGETDEPS += $$eval($${file}.target)
44+
QMAKE_EXTRA_TARGETS += $$target
45+
POST_TARGETDEPS += $$eval($${target}.target)
4546

46-
export($${file}.target)
47-
export($${file}.depends)
48-
export($${file}.commands)
47+
export($${target}.target)
48+
export($${target}.depends)
49+
export($${target}.commands)
50+
export(QMAKE_EXTRA_TARGETS)
51+
export(POST_TARGETDEPS)
52+
53+
return(true)
54+
}
55+
56+
defineTest(addCopyDependenciesTarget) {
57+
file = $$1
58+
src = $$2/$$1
59+
dest = $$3
60+
61+
target_file = $${OUT_PWD}/deps/$${file}.deps
62+
63+
target = $${file}_deps
64+
$${target}.target = $$target_file
65+
$${target}.depends = $$src
66+
67+
$${target}.commands = -@$(MKDIR) \"$$dirname(target_file)\" $$addNewline()
68+
$${target}.commands += $$(PYTHON) $$(ROOT_DIR)/make/copy_dependencies.py --dest \"$$dest\" --files \"$$src\" --excludes OPENGL32.DLL > \"$$target_file\"
69+
70+
QMAKE_EXTRA_TARGETS += $$target
71+
POST_TARGETDEPS += $$eval($${target}.target)
72+
73+
export($${target}.target)
74+
export($${target}.depends)
75+
export($${target}.commands)
4976
export(QMAKE_EXTRA_TARGETS)
5077
export(POST_TARGETDEPS)
5178

@@ -57,22 +84,23 @@ defineTest(addCopyDirTarget) {
5784
src = $$2/$$1
5885
dest = $$3/$$1
5986

60-
$${dir}.target = $$dest
61-
$${dir}.depends = $$src
87+
target = $${dir}
88+
$${target}.target = $$dest
89+
$${target}.depends = $$src
6290
# Windows does not update directory timestamp if files are modified
63-
win32: $${dir}.depends += FORCE
91+
win32:$${target}depends += FORCE
6492

65-
$${dir}.commands = @rm -rf \"$$dest\" $$addNewline()
93+
$${target}.commands = @rm -rf \"$$dest\" $$addNewline()
6694
# create directory. Better would be an order only dependency
67-
$${dir}.commands += -@$(MKDIR) \"$$dirname(dest)\" $$addNewline()
68-
$${dir}.commands += $(COPY_DIR) \"$$src\" \"$$dest\"
95+
$${target}.commands += -@$(MKDIR) \"$$dirname(dest)\" $$addNewline()
96+
$${target}.commands += $(COPY_DIR) \"$$src\" \"$$dest\"
6997

70-
QMAKE_EXTRA_TARGETS += $$dir
71-
POST_TARGETDEPS += $$eval($${dir}.target)
98+
QMAKE_EXTRA_TARGETS += $$target
99+
POST_TARGETDEPS += $$eval($${target}.target)
72100

73-
export($${dir}.target)
74-
export($${dir}.depends)
75-
export($${dir}.commands)
101+
export($${target}.target)
102+
export($${target}.depends)
103+
export($${target}.commands)
76104
export(QMAKE_EXTRA_TARGETS)
77105
export(POST_TARGETDEPS)
78106

ground/gcs/src/libs/osgearth/copydata.pro

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,39 +44,7 @@ linux|macx {
4444
}
4545

4646
osg:win32 {
47-
# osg & osgearth dependencies
48-
49-
# curl
50-
OSG_LIBS = \
51-
libcurl-4.dll \
52-
libidn-11.dll \
53-
librtmp-1.dll \
54-
libgmp-10.dll \
55-
libgnutls-30.dll \
56-
libunistring-2.dll \
57-
libp11-kit-0.dll \
58-
libffi-6.dll \
59-
libtasn1-6.dll \
60-
libssh2-1.dll \
61-
libnghttp2-14.dll
62-
63-
equals(OSG_VERSION, "3.5.1") {
64-
OSG_LIBS += \
65-
libhogweed-4-2.dll \
66-
libnettle-6-2.dll
67-
} else {
68-
OSG_LIBS += \
69-
libhogweed-4.dll \
70-
libnettle-6.dll
71-
}
72-
73-
# other
74-
OSG_LIBS += \
75-
libjpeg-8.dll \
76-
libfreetype-6.dll \
77-
libpng16-16.dll \
78-
libiconv-2.dll \
79-
zlib1.dll
47+
# osg and osgearth dependencies
8048

8149
# osg libraries
8250
OSG_LIBS += \
@@ -103,6 +71,7 @@ osg:win32 {
10371

10472
for(lib, OSG_LIBS) {
10573
addCopyFileTarget($${lib},$${OSG_SDK_DIR}/bin,$${GCS_APP_PATH})
74+
win32:addCopyDependenciesTarget($${lib},$${OSG_SDK_DIR}/bin,$${GCS_APP_PATH})
10675
}
10776

10877
# osg plugins
@@ -183,6 +152,7 @@ osg:win32 {
183152

184153
for(lib, OSG_PLUGINS) {
185154
addCopyFileTarget($${lib},$${OSG_SDK_DIR}/bin/osgPlugins-$${OSG_VERSION},$${GCS_LIBRARY_PATH}/osg/osgPlugins-$${OSG_VERSION})
155+
win32:addCopyDependenciesTarget($${lib},$${OSG_SDK_DIR}/bin/osgPlugins-$${OSG_VERSION},$${GCS_APP_PATH})
186156
}
187157
}
188158

@@ -193,23 +163,18 @@ osgearth:win32 {
193163
libosgEarthAnnotation$${DS}.dll \
194164
libosgEarthFeatures$${DS}.dll \
195165
libosgEarthSymbology$${DS}.dll \
196-
libosgEarthUtil$${DS}.dll \
197-
libprotobuf.dll
166+
libosgEarthUtil$${DS}.dll
198167

199-
# gdal
168+
# loaded dynamically (probably by an osg plugin, need to find by which)
200169
OSGEARTH_LIBS += \
201-
libgdal-20.dll \
202-
libgeos_c.dll \
203-
libgeos.dll \
204-
libopenjp2-7.dll \
205-
libtiff-5.dll \
206-
liblzma-5.dll
170+
libopenjp2-7.dll
207171

208172
osgearthQt:OSGEARTH_LIBS += \
209173
libosgEarthQt$${DS}.dll
210174

211175
for(lib, OSGEARTH_LIBS) {
212176
addCopyFileTarget($${lib},$${OSGEARTH_SDK_DIR}/bin,$${GCS_APP_PATH})
177+
win32:addCopyDependenciesTarget($${lib},$${OSGEARTH_SDK_DIR}/bin,$${GCS_APP_PATH})
213178
}
214179

215180
# osgearth plugins
@@ -261,5 +226,6 @@ osgearth:win32 {
261226

262227
for(lib, OSGEARTH_PLUGINS) {
263228
addCopyFileTarget($${lib},$${OSGEARTH_SDK_DIR}/bin/osgPlugins-$${OSG_VERSION},$${GCS_LIBRARY_PATH}/osg/osgPlugins-$${OSG_VERSION})
229+
win32:addCopyDependenciesTarget($${lib},$${OSGEARTH_SDK_DIR}/bin/osgPlugins-$${OSG_VERSION},$${GCS_APP_PATH})
264230
}
265231
}

make/copy_dependencies.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/python2
2+
3+
###############################################################################
4+
#
5+
# The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017.
6+
# Script to find and copy dependencies (msys2 only).
7+
# ./copy_dependencies.py -h for usage.
8+
#
9+
###############################################################################
10+
11+
import argparse
12+
import glob
13+
import os
14+
import re
15+
import shutil
16+
import subprocess
17+
import sys
18+
19+
def cygpath(file):
20+
return subprocess.check_output(["cygpath", "-m", file]).strip()
21+
22+
# ldd does not work well on Windows 10 and is not supported on mingw32
23+
# ntldd seems to be more reliable but is not recursive (so recursion needs to be done here)
24+
def ldd(file):
25+
ldd_output = subprocess.check_output(["ntldd", file])
26+
# sanitize output
27+
ldd_output = ldd_output.strip()
28+
ldd_output = ldd_output.replace('\\', '/')
29+
# split output into lines
30+
ldd_lines = ldd_output.split('\n')
31+
# parse lines that match this format : <file name> ==> <file path> (<memory address>)
32+
file_pattern = ".*/mingw../bin/.*"
33+
pattern = "(.*) => (" + file_pattern + ") \((.*)\)";
34+
regex = re.compile(pattern)
35+
dependencies = {m.group(2).strip() for m in [regex.match(line) for line in ldd_lines] if m}
36+
return dependencies
37+
38+
def find_dependencies(file, visited):
39+
print "Analyzing " + file
40+
visited.add(file)
41+
dependencies = ldd(file)
42+
# recurse
43+
for f in dependencies.copy():
44+
if f in visited:
45+
continue
46+
if args.excludes and os.path.basename(f) in args.excludes:
47+
print "Ignoring " + f
48+
dependencies.remove(f)
49+
continue
50+
dependencies = dependencies | find_dependencies(f, visited)
51+
return dependencies
52+
53+
parser = argparse.ArgumentParser(description='Find and copy dependencies to a destination directory.')
54+
parser.add_argument('-n', '--no-copy', action='store_true', help='don\'t copy dependencies to destination dir')
55+
parser.add_argument('-v', '--verbose', action='store_true', help='enable verbose mode')
56+
parser.add_argument('-d', '--dest', type=str, default='.', help='destination directory (defaults to current directory)')
57+
parser.add_argument('-s', '--source', type=str, default='.', help='source directory (defaults to current directory)')
58+
parser.add_argument('-f', '--files', metavar='FILE', nargs='+', required=True, help='a file')
59+
parser.add_argument('-e', '--excludes', metavar='FILE', nargs='+', help='a file')
60+
61+
args = parser.parse_args()
62+
63+
# check that args.dest exists and is a directory
64+
if not os.path.isdir(args.dest):
65+
print "Error: destination " + str(args.dest) + " is not a directory."
66+
exit(1)
67+
68+
# find dependencies
69+
dependencies = set()
70+
visited = set()
71+
for file in args.files:
72+
file = os.path.join(args.source, file)
73+
files = glob.glob(file)
74+
for f in files:
75+
dependencies = dependencies | find_dependencies(f, visited)
76+
print "Found " + str(len(dependencies)) + " dependencies."
77+
78+
# no copy, exit now
79+
if args.no_copy:
80+
exit(0)
81+
82+
# copy dependencies to destination dir
83+
copy_count = 0
84+
for file in dependencies:
85+
dest_file = args.dest + "/" + os.path.basename(file)
86+
if not os.path.isfile(dest_file):
87+
print "Copying " + file + " to " + args.dest
88+
shutil.copy2(file, args.dest)
89+
copy_count += 1
90+
print "Copied " + str(copy_count) + " dependencies to '" + str(args.dest) + "'."
91+
92+
exit(0)

0 commit comments

Comments
 (0)