Skip to content

Commit f25283f

Browse files
committed
[[ Build ]] Only fetch prebuilts for target arch
Previously all arguments to the fetch-libraries.sh script were interpreted as platforms. This patch actually checks the arguments are valid platforms, and if not, assumes only the first argument is a platform and subsequent args are target architectures. The prebuilt fetch gyp action has been modified to call the script with the appropriate platform and architecture arguments.
1 parent 138724e commit f25283f

File tree

3 files changed

+58
-10
lines changed

3 files changed

+58
-10
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ before_install:
6464
6565
# Set up the source tree by fetching Linux-specific prebuilt objects
6666
install:
67-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]] ; then (cd prebuilt && ./fetch-libraries.sh linux) ; fi
67+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]] ; then (cd prebuilt && ./fetch-libraries.sh linux x86_64) ; fi
6868
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] ; then (cd prebuilt && ./fetch-libraries.sh mac) ; fi
6969

7070
# Bootstrap the LCB compiler, build the default target set and run a

prebuilt/fetch-libraries.sh

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,29 @@ function fetchLibrary {
118118
if [ 0 -eq "$#" ]; then
119119
SELECTED_PLATFORMS="${PLATFORMS[@]}"
120120
else
121-
SELECTED_PLATFORMS="$@"
121+
ARGS_ARE_PLATFORMS=1
122+
for SELECTED_PLATFORM in "$@" ; do
123+
ARG_IS_PLATFORM=0
124+
for AVAILABLE_PLATFORM in "${PLATFORMS[@]}"; do
125+
if [ "$AVAILABLE_PLATFORM" == "$SELECTED_PLATFORM" ]; then
126+
ARG_IS_PLATFORM=1
127+
break
128+
fi
129+
done
130+
if [ "$ARG_IS_PLATFORM" != "1" ]; then
131+
ARGS_ARE_PLATFORMS=0
132+
break
133+
fi
134+
done
135+
136+
if [ "$ARGS_ARE_PLATFORMS" == "1" ]; then
137+
SELECTED_PLATFORMS="$@"
138+
else
139+
# If not all args are platforms, assume first arg is platform and the
140+
# rest are architectures
141+
SELECTED_PLATFORMS="$1"
142+
shift 1
143+
fi
122144
fi
123145

124146
FETCH_HEADERS=0
@@ -132,11 +154,17 @@ for PLATFORM in ${SELECTED_PLATFORMS} ; do
132154
FETCH_HEADERS=1
133155
fi
134156

135-
eval "ARCHS=( \${ARCHS_${PLATFORM}[@]} )"
157+
if [ "$ARGS_ARE_PLATFORMS" == "1" ]; then
158+
eval "ARCHS=( \${ARCHS_${PLATFORM}[@]} )"
159+
SELECTED_ARCHS="${ARCHS[@]}"
160+
else
161+
SELECTED_ARCHS="$@"
162+
fi
163+
136164
eval "LIBS=( \${LIBS_${PLATFORM}[@]} )"
137165
eval "SUBPLATFORMS=( \${SUBPLATFORMS_${PLATFORM}[@]} )"
138166

139-
for ARCH in "${ARCHS[@]}" ; do
167+
for ARCH in ${SELECTED_ARCHS} ; do
140168
for LIB in "${LIBS[@]}" ; do
141169
if [ ! -z "${SUBPLATFORMS}" ] ; then
142170
for SUBPLATFORM in "${SUBPLATFORMS[@]}" ; do
@@ -168,7 +196,7 @@ for PLATFORM in ${SELECTED_PLATFORMS} ; do
168196
# the "Release" configuration, in terms of linkability. So if
169197
# there's a "Release" build of any given library, duplicate
170198
# it for "Fast"
171-
for ARCH in "${ARCHS[@]}" ; do
199+
for ARCH in ${SELECTED_ARCHS} ; do
172200
for LIB in "${LIBS[@]}" ; do
173201
echo "Providing 'Fast' configuration for ${LIB} library"
174202
for SUBPLATFORM in "${SUBPLATFORMS[@]}"; do
@@ -186,7 +214,7 @@ for PLATFORM in ${SELECTED_PLATFORMS} ; do
186214
done
187215
done
188216

189-
for ARCH in "${ARCHS[@]}" ; do
217+
for ARCH in ${SELECTED_ARCHS} ; do
190218
for LIB in "${LIBS[@]}" ; do
191219
echo "Monkey patching toolset/arch for ${LIB} library"
192220
for SUBPLATFORM in "v140_static_debug" "v140_static_release" "v140_static_fast"; do

prebuilt/fetch.gyp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,14 @@
311311

312312
'outputs':
313313
[
314-
'lib/android/<(target_arch)',
314+
'lib/android/>(target_arch)',
315315
],
316316

317317
'action':
318318
[
319319
'./fetch-libraries.sh',
320320
'android',
321+
'>(target_arch)',
321322
],
322323
},
323324
],
@@ -347,6 +348,7 @@
347348
[
348349
'./fetch-libraries.sh',
349350
'linux',
351+
'<(host_arch)',
350352
],
351353
},
352354
],
@@ -384,6 +386,22 @@
384386
'target_name': 'fetch-win',
385387
'type': 'none',
386388

389+
'variables':
390+
{
391+
'conditions':
392+
[
393+
[
394+
'target_arch == "x64"',
395+
{
396+
'fetch_arch': 'x86_64',
397+
},
398+
{
399+
'fetch_arch': 'x86',
400+
},
401+
],
402+
],
403+
},
404+
387405
'actions':
388406
[
389407
{
@@ -397,8 +415,8 @@
397415

398416
'outputs':
399417
[
400-
'bin/win32/<(target_arch)',
401-
'lib/win32/<(target_arch)',
418+
'bin/win32/>(fetch_arch)',
419+
'lib/win32/>(fetch_arch)',
402420
'unpacked',
403421
],
404422

@@ -407,7 +425,9 @@
407425
'call',
408426
'../util/invoke-unix.bat',
409427
'./fetch-libraries.sh',
410-
'win32',
428+
# Ensure gyp does not treat these parameters as paths
429+
'$(not_a_real_variable)win32',
430+
'$(not_a_real_variable)>(fetch_arch)',
411431
],
412432
},
413433
],

0 commit comments

Comments
 (0)