summaryrefslogtreecommitdiff
path: root/utils/cmake/download.cmake
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2021-12-23 11:12:31 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2021-12-25 17:47:14 +0100
commit774b35cccfb2d3c94374bd47398d19e1b3c6f012 (patch)
tree836529f86d10e42765383aa9f3fa5603fb5216e8 /utils/cmake/download.cmake
parent4eb3f05042608aeaf359bcfd177525ed8052d6eb (diff)
downloadrockbox-774b35cccfb2d3c94374bd47398d19e1b3c6f012.tar.gz
rockbox-774b35cccfb2d3c94374bd47398d19e1b3c6f012.zip
rbutil: Deploy support in cmake.
Add a "deploy" target that will create a distributable file. - Linux: AppImage. - Windows: zip file. - MacOS: dmg. Change-Id: Id8ae9c021bc5bbb1abf066205b57d943c3f3b327
Diffstat (limited to 'utils/cmake/download.cmake')
-rw-r--r--utils/cmake/download.cmake47
1 files changed, 47 insertions, 0 deletions
diff --git a/utils/cmake/download.cmake b/utils/cmake/download.cmake
new file mode 100644
index 0000000000..bd3df4d83d
--- /dev/null
+++ b/utils/cmake/download.cmake
@@ -0,0 +1,47 @@
1#
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8#
9# All files in this archive are subject to the GNU General Public License.
10# See the file COPYING in the source tree root for full license agreement.
11#
12# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
13# KIND, either express or implied.
14#
15
16# This is a separate cmake script, to be invoked as
17# cmake -P -DURL=<url-to-download> -DOUTDIR=<output-folder>
18# Downloads the file and store it in OUTDIR, using the file basename as output
19# filename.
20# The downloaded file gets its executable flag set.
21
22function(gettempdir basedir tmpdir)
23 # Create a random filename in current directory.
24 # Result stored in tmpdir.
25 string(RANDOM LENGTH 24 _tmp)
26 while(EXISTS "${basedir}/${_tmp}.tmp")
27 string(RANDOM LENGTH 24 _tmp)
28 endwhile()
29 set("${tmpdir}" "${basedir}/${_tmp}.tmp" PARENT_SCOPE)
30endfunction()
31
32get_filename_component(fname "${URL}" NAME)
33
34if(EXISTS "${OUTDIR}/${fname}")
35 message("-- Found ${fname}")
36else()
37 message("-- Downloading ${URL} ...")
38 gettempdir(${OUTDIR} tmp)
39
40 # cmake CHOWN is 3.19+, thus download to a temporary folder, then copy.
41 file(DOWNLOAD "${URL}" "${tmp}/${fname}")
42 file(COPY "${tmp}/${fname}" DESTINATION "${OUTDIR}"
43 FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
44 file(REMOVE_RECURSE "${tmp}")
45endif()
46
47