1# Copyright (c) 2013 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5# 6# This script allows you to build, upload, and publish demo binaries that will 7# go on Google Cloud Storage. 8# 9# NOTE: you normally should not upload examples. This will be done 10# automatically by the buildbots. 11# 12# Building 13# -------- 14# 15# * Build all examples. 16# 17# $ make 18# 19# * Build a specific example. 20# 21# $ make bullet 22# 23# Uploading 24# --------- 25# 26# * Build and upload all examples. 27# 28# $ make upload REVISION=1234 29# 30# * Build and upload a single example 31# 32# $ make upload-bullet REVISION=1234 33# 34# Publishing 35# ---------- 36# 37# * Publish binaries for all examples. 38# 39# $ make publish REVISION=1234 40# 41# * Publish binaries for one example. 42# 43# $ make publish-bullet REVISION=1234 44# 45 46ifeq (,$(NACL_SDK_ROOT)) 47 $(error NACL_SDK_ROOT is not defined) 48endif 49 50# Define default build target 51all: 52 53# 54# All projects built by this Makefile 55# 56PROJECTS = earth voronoi life bullet lua smoothlife cube 57 58GS_URL_CONTINUOUS = gs://gonacl/demos/continuous 59GS_URL_PUBLISH = gs://gonacl/demos/publish 60 61# 62# Each project must define the following variables. All paths should be 63# absolute paths. 64# 65# foo_SRCS: src files for this project 66# foo_TGTS: generated files for this project 67# foo_EXTRA_UPLOADS: additional files to upload for this project (optional) 68# 69# And a recipe to build TGTS from SRCS: 70# $(foo_TGTS): $(foo_SRCS) 71# ... 72# 73 74# 75# Earth 76# 77earth_SRC_DIR = earth 78earth_TGT_DIR = earth/pnacl/Release 79earth_JPG_DIR = ../../examples/demo/earth 80earth_SRCS = $(earth_SRC_DIR)/earth.cc \ 81 $(earth_SRC_DIR)/Makefile \ 82 common/fps.h 83earth_TGTS = $(earth_TGT_DIR)/earth.pexe \ 84 $(earth_TGT_DIR)/earth.nmf 85earth_JPGS = $(earth_JPG_DIR)/earth.jpg \ 86 $(earth_JPG_DIR)/earthnight.jpg 87earth_EXTRA_UPLOADS = $(earth_JPGS) 88 89$(earth_TGTS): $(earth_SRCS) 90 $(MAKE) -C earth TOOLCHAIN=pnacl CONFIG=Release 91 92 93# 94# Bullet 95# 96bullet_SRC_DIR = bullet 97bullet_TGT_DIR = bullet/out 98bullet_SRCS = $(bullet_SRC_DIR)/build.sh \ 99 $(bullet_SRC_DIR)/Makefile 100bullet_TGTS = $(bullet_TGT_DIR)/NaClAMBullet.pexe \ 101 $(bullet_TGT_DIR)/NaClAMBullet.nmf 102 103$(bullet_TGTS): $(bullet_SRCS) 104 bullet/build.sh 105 106# 107# Lua 108# 109lua_SRC_DIR = lua 110lua_TGT_DIR = lua/out/naclports/src/out/publish/lua/pnacl 111lua_SRCS = $(lua_SRC_DIR)/build.sh 112lua_TGTS = $(lua_TGT_DIR)/lua.pexe \ 113 $(lua_TGT_DIR)/scimark.lua \ 114 $(lua_TGT_DIR)/binarytrees.lua \ 115 $(lua_TGT_DIR)/luadata.tar \ 116 $(lua_TGT_DIR)/lua.nmf \ 117 $(lua_TGT_DIR)/hterm.concat.js 118 119$(lua_TGTS): $(lua_SRCS) 120 lua/build.sh 121 122# 123# Voronoi 124# 125voronoi_SRC_DIR = voronoi 126voronoi_TGT_DIR = voronoi/pnacl/Release 127voronoi_SRCS = $(voronoi_SRC_DIR)/voronoi.cc \ 128 $(voronoi_SRC_DIR)/Makefile \ 129 common/fps.h 130voronoi_TGTS = $(voronoi_TGT_DIR)/voronoi.pexe \ 131 $(voronoi_TGT_DIR)/voronoi.nmf 132 133$(voronoi_TGTS): $(voronoi_SRCS) 134 $(MAKE) -C voronoi TOOLCHAIN=pnacl CONFIG=Release 135 136# 137# Life 138# 139life_SRC_DIR = life 140life_TGT_DIR = life/pnacl/Release 141life_SRCS = $(life_SRC_DIR)/life.c \ 142 $(life_SRC_DIR)/Makefile \ 143 common/fps.h 144life_TGTS = $(life_TGT_DIR)/life.pexe \ 145 $(life_TGT_DIR)/life.nmf 146 147$(life_TGTS): $(life_SRCS) 148 $(MAKE) -C life TOOLCHAIN=pnacl CONFIG=Release 149 150# 151# SmoothLife 152# 153smoothlife_SRC_DIR = smoothlife 154smoothlife_TGT_DIR = smoothlife/out 155smoothlife_SRCS = $(smoothlife_SRC_DIR)/build.sh 156smoothlife_TGTS = $(smoothlife_TGT_DIR)/smoothnacl.pexe \ 157 $(smoothlife_TGT_DIR)/smoothnacl.nmf 158 159$(smoothlife_TGTS): $(smoothlife_SRCS) 160 smoothlife/build.sh 161 162 163# 164# Rotating Cube 165# 166cube_SRC_DIR = cube 167cube_TGT_DIR = cube/pnacl/Release 168cube_SRCS = $(cube_SRC_DIR)/cube.cc \ 169 $(cube_SRC_DIR)/matrix.cc \ 170 $(cube_SRC_DIR)/matrix.h \ 171 $(cube_SRC_DIR)/texture.cc \ 172 $(cube_SRC_DIR)/Makefile \ 173 common/fps.h 174cube_TGTS = $(cube_TGT_DIR)/cube.pexe \ 175 $(cube_TGT_DIR)/cube.nmf 176 177$(cube_TGTS): $(cube_SRCS) 178 $(MAKE) -C cube TOOLCHAIN=pnacl CONFIG=Release 179 180############################################################################### 181 182SHELL = /bin/bash 183 184OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py 185GETOS := python $(NACL_SDK_ROOT)/tools/getos.py 186WHICH := $(OSHELPERS) which 187 188# Try the location of gsutil on the bots first... 189BOT_GSUTIL = /b/build/scripts/slave/gsutil 190ifneq (,$(wildcard $(BOT_GSUTIL))) 191 GSUTIL = $(BOT_GSUTIL) 192else 193 GSUTIL = $(shell $(WHICH) gsutil) 194 ifeq (,$(wildcard $(GSUTIL))) 195 $(error Unable to find gstuil) 196 endif 197endif 198 199# 200# Define some variables for the given project. 201# 202# FOO_UPLOADS: 203# All files to upload for this project. 204# FOO_CONTINUOUS_DIR: 205# URL of the continuous build directory for this 206# project and revision. 207# FOO_CONTINUOUS_UPLOADS: 208# URLs of all files that will be uploaded for this 209# project and revision. 210# FOO_PUBLISH_DIR: 211# URL of the publish directory for this project and revision. 212# 213# $1 = NAME (e.g. earth) 214# 215define PROJECT 216 $(1)_UPLOADS = $$($(1)_TGTS) $$($(1)_EXTRA_UPLOADS) 217 $(1)_CONTINUOUS_DIR = $(GS_URL_CONTINUOUS)/$(REVISION)/$(1)/ 218 $(1)_CONTINUOUS_UPLOADS = $$(addprefix $$($(1)_CONTINUOUS_DIR),$$(notdir $$($(1)_UPLOADS))) 219 $(1)_PUBLISH_DIR = $(GS_URL_PUBLISH)/$(REVISION)/$(1)/ 220 221 all: $$($(1)_TGTS) 222 223 .PHONY: $(1) 224 $(1): $$($(1)_TGTS) 225endef 226 227 228# 229# Define rules to upload the project files to the continuous builder directory 230# on CDS. 231# 232# $1 = NAME (e.g. earth) 233# 234define UPLOAD_RULE 235.PHONY: upload-$(1) 236upload-$(1): revision-check 237 @echo "Uploading $$(notdir $$($(1)_UPLOADS)) to $$($(1)_CONTINUOUS_DIR)" 238 @$(GSUTIL) cp -q -a public-read $$($(1)_UPLOADS) $$($(1)_CONTINUOUS_DIR) 239 240upload: upload-$(1) 241endef 242 243# 244# Define rules to copy the project files from the continuous builder 245# directory to the publish directory. 246# 247# $1 = NAME (e.g. earth) 248# 249define PUBLISH_RULE 250.PHONY: publish-$(1) 251publish-$(1): revision-check 252 @echo "Testing that files to publish '$(1)' exist on CDS..." 253 @$(GSUTIL) ls $$($(1)_CONTINUOUS_UPLOADS) 254 @echo OK. 255 @echo "About to publish revision $(REVISION) of '$(1)'..." 256 @read -p "Continue? " -n 1 -r && \ 257 echo && \ 258 if [[ ! $$$${REPLY} =~ ^[Yy]$$$$ ]]; then \ 259 exit 1; \ 260 fi; 261 @echo "Publishing..." 262 @$(GSUTIL) cp -q -p $$($(1)_CONTINUOUS_UPLOADS) $$($(1)_PUBLISH_DIR) 263 @echo "Done." 264 265publish: publish-$(1) 266endef 267 268 269############################################################################### 270# RULES 271 272.PHONY: all 273all: 274 275$(foreach project,$(PROJECTS),$(eval $(call PROJECT,$(project)))) 276 277.PHONY: revision-check 278revision-check: 279ifeq (,$(REVISION)) 280 $(error Unknown revision number. Run with REVSION=<...>) 281endif 282 283.PHONY: upload 284upload: all 285 286.PHONY: publish 287publish: 288 289$(foreach project,$(PROJECTS),$(eval $(call UPLOAD_RULE,$(project)))) 290$(foreach project,$(PROJECTS),$(eval $(call PUBLISH_RULE,$(project)))) 291