Skip to content

Commit

Permalink
unify messages on building things in the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Jul 20, 2015
1 parent 2822a45 commit a2b81c6
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion tests/test_sanity.py
Expand Up @@ -526,7 +526,7 @@ def test_emcc_ports(self):
# using ports

RETRIEVING_MESSAGE = 'retrieving port'
BUILDING_MESSAGE = 'building port'
BUILDING_MESSAGE = 'generating port'

from tools import system_libs
PORTS_DIR = system_libs.Ports.get_dir()
Expand Down
10 changes: 8 additions & 2 deletions tools/cache.py
@@ -1,4 +1,4 @@
import os.path, sys, shutil, time
import os.path, sys, shutil, time, logging

import tempfiles

Expand Down Expand Up @@ -27,15 +27,21 @@ def get_path(self, shortname):

# Request a cached file. If it isn't in the cache, it will be created with
# the given creator function
def get(self, shortname, creator, extension='.bc'):
def get(self, shortname, creator, extension='.bc', what=None):
if not shortname.endswith(extension): shortname += extension
cachename = os.path.join(self.dirname, shortname)
if os.path.exists(cachename):
return cachename
if what is None:
if shortname.endswith(('.bc', '.so', '.a')): what = 'system library'
else: what = 'system asset'
message = 'generating ' + what + ': ' + shortname + '...'
logging.warn(message)
self.ensure()
temp = creator()
if temp != cachename:
shutil.copyfile(temp, cachename)
logging.warn(' '*len(message) + 'ok')
return cachename

# Given a set of functions of form (ident, text), and a preferred chunk size,
Expand Down
6 changes: 2 additions & 4 deletions tools/ports/libpng.py
Expand Up @@ -5,9 +5,7 @@
def get(ports, settings, shared):
if settings.USE_LIBPNG == 1:
ports.fetch_project('libpng', 'https://github.com/emscripten-ports/libpng/archive/' + TAG + '.zip', 'libpng-' + TAG)
def create():
logging.warning('building port: libpng')

def create():
zlib.get(ports, settings, shared);
# TODO: clear dependent projects
#ports.clear_project_build('sdl2-image')
Expand Down Expand Up @@ -36,7 +34,7 @@ def create():
final = os.path.join(ports.get_build_dir(), 'libpng', 'libpng.bc')
shared.Building.link(o_s, final)
return final
return [shared.Cache.get('libpng', create)]
return [shared.Cache.get('libpng', create, what='port')]
else:
return []

Expand Down
3 changes: 1 addition & 2 deletions tools/ports/sdl.py
Expand Up @@ -22,7 +22,6 @@ def get(ports, settings, shared):
if settings.USE_SDL == 2:
ports.fetch_project('sdl2', 'https://github.com/emscripten-ports/SDL2/archive/' + TAG + '.zip', 'SDL2-' + TAG)
def create():
logging.warning('building port: sdl2')
# we are rebuilding SDL, clear dependant projects so they copy in their includes to ours properly
ports.clear_project_build('sdl2-image')
# copy includes to a location so they can be used as 'SDL2/'
Expand All @@ -47,7 +46,7 @@ def create():
final = os.path.join(ports.get_build_dir(), 'sdl2', 'libsdl2.bc')
shared.Building.link(o_s, final)
return final
return [shared.Cache.get('sdl2', create)]
return [shared.Cache.get('sdl2', create, what='port')]
else:
return []

Expand Down
3 changes: 1 addition & 2 deletions tools/ports/sdl_image.py
Expand Up @@ -8,7 +8,6 @@ def get(ports, settings, shared):
assert os.path.exists(sdl_build), 'You must use SDL2 to use SDL2_image'
ports.fetch_project('sdl2-image', 'https://github.com/emscripten-ports/SDL2_image/archive/' + TAG + '.zip', 'SDL2_image-' + TAG)
def create():
logging.warning('building port: sdl2-image')
shutil.copyfile(os.path.join(ports.get_dir(), 'sdl2-image', 'SDL2_image-' + TAG, 'SDL_image.h'), os.path.join(ports.get_build_dir(), 'sdl2', 'include', 'SDL_image.h'))
shutil.copyfile(os.path.join(ports.get_dir(), 'sdl2-image', 'SDL2_image-' + TAG, 'SDL_image.h'), os.path.join(ports.get_build_dir(), 'sdl2', 'include', 'SDL2', 'SDL_image.h'))
srcs = 'IMG.c IMG_bmp.c IMG_gif.c IMG_jpg.c IMG_lbm.c IMG_pcx.c IMG_png.c IMG_pnm.c IMG_tga.c IMG_tif.c IMG_xcf.c IMG_xpm.c IMG_xv.c IMG_webp.c IMG_ImageIO.m'.split(' ')
Expand All @@ -23,7 +22,7 @@ def create():
final = os.path.join(ports.get_build_dir(), 'sdl2-image', 'libsdl2_image.bc')
shared.Building.link(o_s, final)
return final
return [shared.Cache.get('sdl2-image', create)]
return [shared.Cache.get('sdl2-image', create, what='port')]
else:
return []

Expand Down
6 changes: 2 additions & 4 deletions tools/ports/zlib.py
Expand Up @@ -15,9 +15,7 @@ def get_with_configure(ports, settings, shared):
def get(ports, settings, shared):
if settings.USE_ZLIB == 1:
ports.fetch_project('zlib', 'https://github.com/emscripten-ports/zlib/archive/' + TAG + '.zip', 'zlib-' + TAG)
def create():
logging.warning('building port: zlib')

def create():
ports.clear_project_build('zlib')

source_path = os.path.join(ports.get_dir(), 'zlib', 'zlib-' + TAG)
Expand Down Expand Up @@ -45,7 +43,7 @@ def create():
Popen([shared.LLVM_AR, 'rc', final] + o_s).communicate()
assert os.path.exists(final)
return final
return [shared.Cache.get('zlib', create)]
return [shared.Cache.get('zlib', create, what='port')]
else:
return []

Expand Down
2 changes: 0 additions & 2 deletions tools/system_libs.py
Expand Up @@ -310,9 +310,7 @@ def maybe_noexcept(name):
# We need to build and link the library in
logging.debug('including %s' % name)
def do_create():
logging.warning('building system library: ' + name + '...')
ret = create(name)
logging.warning(' ' + (' '*len(name)) + ' ok')
return ret
libfile = shared.Cache.get(name, do_create, extension=suffix)
ret.append(libfile)
Expand Down

0 comments on commit a2b81c6

Please sign in to comment.