11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Copyright (c) 2013 The Chromium Authors. All rights reserved.
21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be
31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# found in the LICENSE file.
41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# This script allows you to build, upload, and publish demo binaries that will
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)# go on Google Cloud Storage.
81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
91e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# NOTE: you normally should not upload examples. This will be done
101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# automatically by the buildbots.
111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Building
131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# --------
141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# * Build all examples.
161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     $ make
181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# * Build a specific example.
201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     $ make bullet
221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Uploading
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# ---------
251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# * Build and upload all examples.
271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     $ make upload REVISION=1234
291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# * Build and upload a single example
311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     $ make upload-bullet REVISION=1234
331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Publishing
351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# ----------
361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# * Publish binaries for all examples.
381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     $ make publish REVISION=1234
401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# * Publish binaries for one example.
421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     $ make publish-bullet REVISION=1234
441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)ifeq (,$(NACL_SDK_ROOT))
471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  $(error NACL_SDK_ROOT is not defined)
481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)endif
491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Define default build target
511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)all:
521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# All projects built by this Makefile
551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
560f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)PROJECTS = earth voronoi life bullet lua smoothlife cube
571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)GS_URL_CONTINUOUS = gs://gonacl/demos/continuous
591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)GS_URL_PUBLISH = gs://gonacl/demos/publish
601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Each project must define the following variables. All paths should be
631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# absolute paths.
641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# foo_SRCS: src files for this project
661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# foo_TGTS: generated files for this project
671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# foo_EXTRA_UPLOADS: additional files to upload for this project (optional)
681e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
691e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# And a recipe to build TGTS from SRCS:
701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# $(foo_TGTS): $(foo_SRCS)
711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# 	...
721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Earth
761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)earth_SRC_DIR = earth
781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)earth_TGT_DIR = earth/pnacl/Release
791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)earth_JPG_DIR = ../../examples/demo/earth
801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)earth_SRCS = $(earth_SRC_DIR)/earth.cc \
81f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)             $(earth_SRC_DIR)/Makefile \
82f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)             common/fps.h
831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)earth_TGTS = $(earth_TGT_DIR)/earth.pexe \
841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)             $(earth_TGT_DIR)/earth.nmf
851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)earth_JPGS = $(earth_JPG_DIR)/earth.jpg \
861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)             $(earth_JPG_DIR)/earthnight.jpg
871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)earth_EXTRA_UPLOADS = $(earth_JPGS)
881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)$(earth_TGTS): $(earth_SRCS)
901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	$(MAKE) -C earth TOOLCHAIN=pnacl CONFIG=Release
911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
921e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
931e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
941e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Bullet
951e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
961e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bullet_SRC_DIR = bullet
971e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bullet_TGT_DIR = bullet/out
981e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bullet_SRCS = $(bullet_SRC_DIR)/build.sh \
991e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)              $(bullet_SRC_DIR)/Makefile
1001e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)bullet_TGTS = $(bullet_TGT_DIR)/NaClAMBullet.pexe \
1011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)              $(bullet_TGT_DIR)/NaClAMBullet.nmf
1021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)$(bullet_TGTS): $(bullet_SRCS)
1041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	bullet/build.sh
1051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
1071e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Lua
1081e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
1091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)lua_SRC_DIR = lua
1101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)lua_TGT_DIR = lua/out/naclports/src/out/publish/lua/pnacl
1111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)lua_SRCS = $(lua_SRC_DIR)/build.sh
1121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)lua_TGTS = $(lua_TGT_DIR)/lua.pexe \
113f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)           $(lua_TGT_DIR)/scimark.lua \
114f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)           $(lua_TGT_DIR)/binarytrees.lua \
1151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)           $(lua_TGT_DIR)/luadata.tar \
1161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)           $(lua_TGT_DIR)/lua.nmf \
1171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)           $(lua_TGT_DIR)/hterm.concat.js
1181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)$(lua_TGTS): $(lua_SRCS)
1201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	lua/build.sh
1211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
1231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Voronoi
1241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
1251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)voronoi_SRC_DIR = voronoi
1261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)voronoi_TGT_DIR = voronoi/pnacl/Release
1271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)voronoi_SRCS = $(voronoi_SRC_DIR)/voronoi.cc \
128f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)               $(voronoi_SRC_DIR)/Makefile \
129f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)               common/fps.h
1301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)voronoi_TGTS = $(voronoi_TGT_DIR)/voronoi.pexe \
1311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)               $(voronoi_TGT_DIR)/voronoi.nmf
1321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)$(voronoi_TGTS): $(voronoi_SRCS)
1341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	$(MAKE) -C voronoi TOOLCHAIN=pnacl CONFIG=Release
1351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
1371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Life
1381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
1391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)life_SRC_DIR = life
1401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)life_TGT_DIR = life/pnacl/Release
1411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)life_SRCS = $(life_SRC_DIR)/life.c \
142f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            $(life_SRC_DIR)/Makefile \
143f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            common/fps.h
1441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)life_TGTS = $(life_TGT_DIR)/life.pexe \
1451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)            $(life_TGT_DIR)/life.nmf
1461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)$(life_TGTS): $(life_SRCS)
1481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	$(MAKE) -C life TOOLCHAIN=pnacl CONFIG=Release
1491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1500f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#
1510f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)# SmoothLife
1520f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#
1530f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)smoothlife_SRC_DIR = smoothlife
1540f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)smoothlife_TGT_DIR = smoothlife/out
1550f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)smoothlife_SRCS = $(smoothlife_SRC_DIR)/build.sh
1560f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)smoothlife_TGTS = $(smoothlife_TGT_DIR)/smoothnacl.pexe \
1570f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                  $(smoothlife_TGT_DIR)/smoothnacl.nmf
1580f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
1590f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)$(smoothlife_TGTS): $(smoothlife_SRCS)
1600f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)	smoothlife/build.sh
1610f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
1620f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
1630f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#
1640f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)# Rotating Cube
1650f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#
1660f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)cube_SRC_DIR = cube
1670f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)cube_TGT_DIR = cube/pnacl/Release
1680f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)cube_SRCS = $(cube_SRC_DIR)/cube.cc \
1690f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)            $(cube_SRC_DIR)/matrix.cc \
1700f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)            $(cube_SRC_DIR)/matrix.h \
1710f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)            $(cube_SRC_DIR)/texture.cc \
172f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            $(cube_SRC_DIR)/Makefile \
173f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            common/fps.h
1740f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)cube_TGTS = $(cube_TGT_DIR)/cube.pexe \
1750f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)            $(cube_TGT_DIR)/cube.nmf
1760f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
1770f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)$(cube_TGTS): $(cube_SRCS)
1780f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)	$(MAKE) -C cube TOOLCHAIN=pnacl CONFIG=Release
1790f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
1801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)###############################################################################
1811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)SHELL = /bin/bash
1831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py
1851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)GETOS := python $(NACL_SDK_ROOT)/tools/getos.py
1861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)WHICH := $(OSHELPERS) which
1871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Try the location of gsutil on the bots first...
1891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)BOT_GSUTIL = /b/build/scripts/slave/gsutil
1901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)ifneq (,$(wildcard $(BOT_GSUTIL)))
1911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  GSUTIL = $(BOT_GSUTIL)
1921e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)else
1931e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  GSUTIL = $(shell $(WHICH) gsutil)
1941e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  ifeq (,$(wildcard $(GSUTIL)))
1951e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    $(error Unable to find gstuil)
1961e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  endif
1971e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)endif
1981e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
1991e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
2001e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Define some variables for the given project.
2011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
2021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# FOO_UPLOADS:
2031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     All files to upload for this project.
2041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# FOO_CONTINUOUS_DIR:
2051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     URL of the continuous build directory for this
2061e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     project and revision.
2071e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# FOO_CONTINUOUS_UPLOADS:
2081e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     URLs of all files that will be uploaded for this
2091e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     project and revision.
2101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# FOO_PUBLISH_DIR:
2111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#     URL of the publish directory for this project and revision.
2121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
2131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# $1 = NAME (e.g. earth)
2141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
2151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)define PROJECT
2161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  $(1)_UPLOADS = $$($(1)_TGTS) $$($(1)_EXTRA_UPLOADS)
2170f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  $(1)_CONTINUOUS_DIR = $(GS_URL_CONTINUOUS)/$(REVISION)/$(1)/
2180f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  $(1)_CONTINUOUS_UPLOADS = $$(addprefix $$($(1)_CONTINUOUS_DIR),$$(notdir $$($(1)_UPLOADS)))
2190f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  $(1)_PUBLISH_DIR = $(GS_URL_PUBLISH)/$(REVISION)/$(1)/
2201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  all: $$($(1)_TGTS)
2221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  .PHONY: $(1)
2241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  $(1): $$($(1)_TGTS)
2251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)endef
2261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
2291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Define rules to upload the project files to the continuous builder directory
2301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# on CDS.
2311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
2321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# $1 = NAME (e.g. earth)
2331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
2341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)define UPLOAD_RULE
2351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles).PHONY: upload-$(1)
2361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)upload-$(1): revision-check
2371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	@echo "Uploading $$(notdir $$($(1)_UPLOADS)) to $$($(1)_CONTINUOUS_DIR)"
2381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	@$(GSUTIL) cp -q -a public-read $$($(1)_UPLOADS) $$($(1)_CONTINUOUS_DIR)
2391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)upload: upload-$(1)
2411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)endef
2421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
2441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# Define rules to copy the project files from the continuous builder
2451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# directory to the publish directory.
2461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
2471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# $1 = NAME (e.g. earth)
2481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#
2491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)define PUBLISH_RULE
2501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles).PHONY: publish-$(1)
2511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)publish-$(1): revision-check
2521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	@echo "Testing that files to publish '$(1)' exist on CDS..."
2531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	@$(GSUTIL) ls $$($(1)_CONTINUOUS_UPLOADS)
2541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	@echo OK.
2551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	@echo "About to publish revision $(REVISION) of '$(1)'..."
2561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	@read -p "Continue? " -n 1 -r && \
2571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	  echo && \
2581e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	  if [[ ! $$$${REPLY} =~ ^[Yy]$$$$ ]]; then \
2591e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	    exit 1; \
2601e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	  fi;
2611e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	@echo "Publishing..."
2620f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)	@$(GSUTIL) cp -q -p $$($(1)_CONTINUOUS_UPLOADS) $$($(1)_PUBLISH_DIR)
2631e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	@echo "Done."
2641e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)publish: publish-$(1)
2661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)endef
2671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2681e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2691e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)###############################################################################
2701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)# RULES
2711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles).PHONY: all
2731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)all:
2741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)$(foreach project,$(PROJECTS),$(eval $(call PROJECT,$(project))))
2761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles).PHONY: revision-check
2781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)revision-check:
2791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)ifeq (,$(REVISION))
2801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)	$(error Unknown revision number. Run with REVSION=<...>)
2811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)endif
2821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2831e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles).PHONY: upload
2841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)upload: all
2851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles).PHONY: publish
2871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)publish:
2881e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
2891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)$(foreach project,$(PROJECTS),$(eval $(call UPLOAD_RULE,$(project))))
2901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)$(foreach project,$(PROJECTS),$(eval $(call PUBLISH_RULE,$(project))))
291