Skip to content

Commit

Permalink
Fix flake8 warnings in tools/ports (#8164)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Feb 22, 2019
1 parent c585010 commit 6a42002
Show file tree
Hide file tree
Showing 18 changed files with 746 additions and 650 deletions.
1 change: 0 additions & 1 deletion .flake8
Expand Up @@ -7,7 +7,6 @@ exclude =
./tests/freetype/src/, # third-party code
./site/source/conf.py,
./tools/debug/,
./tools/ports/,
./tools/emdump.py,
./tools/emterpretify.py,
./tools/js_optimizer.py,
Expand Down
11 changes: 9 additions & 2 deletions tools/ports/binaryen.py
Expand Up @@ -3,10 +3,12 @@
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.

import os, shutil, logging
import os
import logging

TAG = 'version_68'


def needed(settings, shared, ports):
if not settings.WASM:
return False
Expand All @@ -18,22 +20,27 @@ def needed(settings, shared, ports):
logging.debug('setting binaryen root to ' + settings.BINARYEN_ROOT)
return True


def get(ports, settings, shared):
if not needed(settings, shared, ports):
return []

ports.fetch_project('binaryen', 'https://github.com/WebAssembly/binaryen/archive/' + TAG + '.zip', 'binaryen-' + TAG)

def create():
logging.info('building port: binaryen')
ports.build_native(os.path.join(ports.get_dir(), 'binaryen', 'binaryen-' + TAG))
# the "output" of this port build is a tag file, saying which port we have
tag_file = os.path.join(ports.get_dir(), 'binaryen', 'tag.txt')
open(tag_file, 'w').write(TAG)
return tag_file

return [shared.Cache.get('binaryen_tag_' + TAG, create, what='port', extension='.txt')]


def process_args(ports, args, settings, shared):
return args


def show():
return 'Binaryen (Apache 2.0 license)'

52 changes: 29 additions & 23 deletions tools/ports/bullet.py
Expand Up @@ -3,41 +3,47 @@
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.

import os, shutil, logging, subprocess, sys, stat
import logging
import os
import shutil

TAG = 'version_1'


def get(ports, settings, shared):
if settings.USE_BULLET == 1:
ports.fetch_project('bullet', 'https://github.com/emscripten-ports/bullet/archive/' + TAG + '.zip', 'Bullet-' + TAG)
def create():
logging.info('building port: bullet')

source_path = os.path.join(ports.get_dir(), 'bullet', 'Bullet-' + TAG)
dest_path = os.path.join(shared.Cache.get_path('ports-builds'), 'bullet')

shutil.rmtree(dest_path, ignore_errors=True)
shutil.copytree(source_path, dest_path)

src_path = os.path.join(dest_path, 'bullet', 'src')
includes = []
for root, dirs, files in os.walk(src_path, topdown=False):
for dir in dirs:
includes.append(os.path.join(root, dir))

final = os.path.join(ports.get_build_dir(), 'bullet', 'libbullet.bc')
ports.build_port(src_path, final, includes=includes, exclude_dirs=['MiniCL'])
return final
return [shared.Cache.get('bullet', create)]
else:
if settings.USE_BULLET != 1:
return []

ports.fetch_project('bullet', 'https://github.com/emscripten-ports/bullet/archive/' + TAG + '.zip', 'Bullet-' + TAG)

def create():
logging.info('building port: bullet')

source_path = os.path.join(ports.get_dir(), 'bullet', 'Bullet-' + TAG)
dest_path = os.path.join(shared.Cache.get_path('ports-builds'), 'bullet')

shutil.rmtree(dest_path, ignore_errors=True)
shutil.copytree(source_path, dest_path)

src_path = os.path.join(dest_path, 'bullet', 'src')
includes = []
for root, dirs, files in os.walk(src_path, topdown=False):
for dir in dirs:
includes.append(os.path.join(root, dir))

final = os.path.join(ports.get_build_dir(), 'bullet', 'libbullet.bc')
ports.build_port(src_path, final, includes=includes, exclude_dirs=['MiniCL'])
return final

return [shared.Cache.get('bullet', create)]


def process_args(ports, args, settings, shared):
if settings.USE_BULLET == 1:
get(ports, settings, shared)
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'bullet', 'bullet', 'src')]
return args


def show():
return 'bullet (USE_BULLET=1; zlib license)'
158 changes: 79 additions & 79 deletions tools/ports/cocos2d.py
Expand Up @@ -12,62 +12,62 @@


def get(ports, settings, shared):
if settings.USE_COCOS2D == 3:
ports.fetch_project(
'Cocos2d', 'https://github.com/emscripten-ports/Cocos2d/archive/' + TAG + '.zip', 'Cocos2d-' + TAG)

def create():
logging.info('building port: Cocos2d v3')
logging.warn('Cocos2d: library is experimental, do not expect that it will work out of the box')

cocos2d_build = os.path.join(ports.get_dir(), 'Cocos2d')
cocos2d_root = os.path.join(cocos2d_build, 'Cocos2d-' + TAG)
cocos2dx_root = os.path.join(cocos2d_root, 'cocos2dx')
cocos2dx_src = make_source_list(cocos2d_root, cocos2dx_root)
cocos2dx_includes = make_includes(cocos2d_root, cocos2dx_root)

shutil.copytree(os.path.join(cocos2d_root, 'samples', 'Cpp'),
os.path.join(ports.get_build_dir(), 'Cocos2d', 'samples'))

commands = []
o_s = []
for src in cocos2dx_src:
o = os.path.join(cocos2d_build, 'Cocos2d-' +
TAG, 'build', src + '.o')
shared.safe_ensure_dirs(os.path.dirname(o))
command = [shared.PYTHON,
shared.EMCC,
os.path.join(cocos2dx_root, 'proj.emscripten', src),
'-Wno-overloaded-virtual',
'-Wno-deprecated-declarations',
'-D__CC_PLATFORM_FILEUTILS_CPP__',
'-DCC_ENABLE_CHIPMUNK_INTEGRATION',
'-DCC_KEYBOARD_SUPPORT',
'-DGL_ES=1',
'-DNDEBUG', # '-DCOCOS2D_DEBUG=1' 1 - error/warn, 2 - verbose
'-DCP_USE_DOUBLES=0',
'-O2',
'-s', 'USE_ZLIB=1',
'-s', 'USE_LIBPNG=1',
'-o', o, '-w']

for include in cocos2dx_includes:
command.append('-I' + include)

if src.endswith('.cpp'):
command.append('-std=c++11')

commands.append(command)
o_s.append(o)
shared.safe_ensure_dirs(os.path.dirname(o_s[0]))
ports.run_commands(commands)
final = os.path.join(ports.get_build_dir(), 'Cocos2d', 'libcocos2d.bc')
shared.Building.link_to_object(o_s, final)
return final
return [shared.Cache.get('cocos2d', create, what='port')]
else:
if settings.USE_COCOS2D != 3:
return []

ports.fetch_project(
'Cocos2d', 'https://github.com/emscripten-ports/Cocos2d/archive/' + TAG + '.zip', 'Cocos2d-' + TAG)

def create():
logging.info('building port: Cocos2d v3')
logging.warn('Cocos2d: library is experimental, do not expect that it will work out of the box')

cocos2d_build = os.path.join(ports.get_dir(), 'Cocos2d')
cocos2d_root = os.path.join(cocos2d_build, 'Cocos2d-' + TAG)
cocos2dx_root = os.path.join(cocos2d_root, 'cocos2dx')
cocos2dx_src = make_source_list(cocos2d_root, cocos2dx_root)
cocos2dx_includes = make_includes(cocos2d_root, cocos2dx_root)

shutil.copytree(os.path.join(cocos2d_root, 'samples', 'Cpp'),
os.path.join(ports.get_build_dir(), 'Cocos2d', 'samples'))

commands = []
o_s = []
for src in cocos2dx_src:
o = os.path.join(cocos2d_build, 'Cocos2d-' + TAG, 'build', src + '.o')
shared.safe_ensure_dirs(os.path.dirname(o))
command = [shared.PYTHON,
shared.EMCC,
os.path.join(cocos2dx_root, 'proj.emscripten', src),
'-Wno-overloaded-virtual',
'-Wno-deprecated-declarations',
'-D__CC_PLATFORM_FILEUTILS_CPP__',
'-DCC_ENABLE_CHIPMUNK_INTEGRATION',
'-DCC_KEYBOARD_SUPPORT',
'-DGL_ES=1',
'-DNDEBUG', # '-DCOCOS2D_DEBUG=1' 1 - error/warn, 2 - verbose
'-DCP_USE_DOUBLES=0',
'-O2',
'-s', 'USE_ZLIB=1',
'-s', 'USE_LIBPNG=1',
'-o', o, '-w']

for include in cocos2dx_includes:
command.append('-I' + include)

if src.endswith('.cpp'):
command.append('-std=c++11')

commands.append(command)
o_s.append(o)
shared.safe_ensure_dirs(os.path.dirname(o_s[0]))
ports.run_commands(commands)
final = os.path.join(ports.get_build_dir(), 'Cocos2d', 'libcocos2d.bc')
shared.Building.link_to_object(o_s, final)
return final

return [shared.Cache.get('cocos2d', create, what='port')]


def process_dependencies(settings):
if settings.USE_COCOS2D == 3:
Expand Down Expand Up @@ -127,28 +127,28 @@ def add_makefile(makefile):

def make_includes(cocos2d_root, cocos2dx_root):
return [os.path.join(cocos2d_root, 'CocosDenshion', 'include'),
os.path.join(cocos2d_root, 'extensions'),
os.path.join(cocos2d_root, 'extensions', 'AssetsManager'),
os.path.join(cocos2d_root, 'extensions', 'CCArmature'),
os.path.join(cocos2d_root, 'extensions', 'CCBReader'),
os.path.join(cocos2d_root, 'extensions', 'GUI', 'CCControlExtension'),
os.path.join(cocos2d_root, 'extensions', 'GUI', 'CCEditBox'),
os.path.join(cocos2d_root, 'extensions', 'GUI', 'CCScrollView'),
os.path.join(cocos2d_root, 'extensions', 'network'),
os.path.join(cocos2d_root, 'extensions', 'Components'),
os.path.join(cocos2d_root, 'extensions', 'LocalStorage'),
os.path.join(cocos2d_root, 'extensions', 'physics_nodes'),
os.path.join(cocos2d_root, 'extensions', 'spine'),
os.path.join(cocos2d_root, 'external'),
os.path.join(cocos2d_root, 'external', 'chipmunk', 'include', 'chipmunk'),
cocos2dx_root,
os.path.join(cocos2dx_root, 'cocoa'),
os.path.join(cocos2dx_root, 'include'),
os.path.join(cocos2dx_root, 'kazmath', 'include'),
os.path.join(cocos2dx_root, 'platform'),
os.path.join(cocos2dx_root, 'platform', 'emscripten'),
os.path.join(cocos2dx_root, 'platform', 'third_party', 'linux', 'libfreetype2'),
os.path.join(cocos2dx_root, 'platform', 'third_party', 'common', 'etc'),
os.path.join(cocos2dx_root, 'platform', 'third_party', 'emscripten', 'libtiff', 'include'),
os.path.join(cocos2dx_root, 'platform', 'third_party', 'emscripten', 'libjpeg'),
os.path.join(cocos2dx_root, 'platform', 'third_party', 'emscripten', 'libwebp')]
os.path.join(cocos2d_root, 'extensions'),
os.path.join(cocos2d_root, 'extensions', 'AssetsManager'),
os.path.join(cocos2d_root, 'extensions', 'CCArmature'),
os.path.join(cocos2d_root, 'extensions', 'CCBReader'),
os.path.join(cocos2d_root, 'extensions', 'GUI', 'CCControlExtension'),
os.path.join(cocos2d_root, 'extensions', 'GUI', 'CCEditBox'),
os.path.join(cocos2d_root, 'extensions', 'GUI', 'CCScrollView'),
os.path.join(cocos2d_root, 'extensions', 'network'),
os.path.join(cocos2d_root, 'extensions', 'Components'),
os.path.join(cocos2d_root, 'extensions', 'LocalStorage'),
os.path.join(cocos2d_root, 'extensions', 'physics_nodes'),
os.path.join(cocos2d_root, 'extensions', 'spine'),
os.path.join(cocos2d_root, 'external'),
os.path.join(cocos2d_root, 'external', 'chipmunk', 'include', 'chipmunk'),
cocos2dx_root,
os.path.join(cocos2dx_root, 'cocoa'),
os.path.join(cocos2dx_root, 'include'),
os.path.join(cocos2dx_root, 'kazmath', 'include'),
os.path.join(cocos2dx_root, 'platform'),
os.path.join(cocos2dx_root, 'platform', 'emscripten'),
os.path.join(cocos2dx_root, 'platform', 'third_party', 'linux', 'libfreetype2'),
os.path.join(cocos2dx_root, 'platform', 'third_party', 'common', 'etc'),
os.path.join(cocos2dx_root, 'platform', 'third_party', 'emscripten', 'libtiff', 'include'),
os.path.join(cocos2dx_root, 'platform', 'third_party', 'emscripten', 'libjpeg'),
os.path.join(cocos2dx_root, 'platform', 'third_party', 'emscripten', 'libwebp')]

0 comments on commit 6a42002

Please sign in to comment.