move all ports specific code into separate files under tools/ports/ #2404

This commit is contained in:
Alon Zakai 2014-10-18 12:01:13 -07:00
Родитель 5469d27a37
Коммит 0c13a44534
4 изменённых файлов: 27 добавлений и 13 удалений

2
emcc
Просмотреть файл

@ -1163,7 +1163,7 @@ try:
if not LEAVE_INPUTS_RAW and \
not shared.Settings.BUILD_AS_SHARED_LIB and \
not shared.Settings.SIDE_MODULE: # shared libraries/side modules link no C libraries, need them in parent
#extra_files_to_link = system_libs.get_ports(shared.Settings)
extra_files_to_link = system_libs.get_ports(shared.Settings)
extra_files_to_link += system_libs.calculate([f for _, f in sorted(temp_files)] + extra_files_to_link, in_temp, stdout, stderr, forced=forced_stdlibs)
log_time('calculate system libraries')

4
tools/ports/__init__.py Normal file
Просмотреть файл

@ -0,0 +1,4 @@
import sdl
ports = [sdl]

16
tools/ports/sdl.py Normal file
Просмотреть файл

@ -0,0 +1,16 @@
import os
def get(ports, settings, shared):
if settings.USE_SDL == 2:
ports.fetch_project('sdl2', 'https://github.com/emscripten-ports/SDL2/archive/master.zip')
return [ports.build_project('sdl2', 'SDL2-master',
['sh', './configure', '--host=asmjs-unknown-emscripten', '--disable-assembly', '--disable-threads', '--enable-cpuinfo=false', 'CFLAGS=-O2'],
[os.path.join('build', '.libs', 'libSDL2.a')])]
else:
return []
def process_args(args, settings, shared):
if settings.USE_SDL == 1: args += ['-Xclang', '-isystem' + shared.path_from_root('system', 'include', 'SDL')]
elif settings.USE_SDL == 2: args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'sdl2', 'include')]
return args

Просмотреть файл

@ -580,6 +580,8 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]):
# emscripten-ports library management (https://github.com/emscripten-ports)
#---------------------------------------------------------------------------
import ports
class Ports:
@staticmethod
def get_dir():
@ -623,22 +625,14 @@ class Ports:
return libs[0]
return shared.Cache.get(name, create)
# Libraries
class sdl2:
@staticmethod
def get():
Ports.fetch_project('sdl2', 'https://github.com/emscripten-ports/SDL2/archive/master.zip')
return Ports.build_project('sdl2', 'SDL2-master',
['sh', './configure', '--host=asmjs-unknown-emscripten', '--disable-assembly', '--disable-threads', '--enable-cpuinfo=false', 'CFLAGS=-O2'],
[os.path.join('build', '.libs', 'libSDL2.a')])
def get_ports(settings):
ret = []
ok = False
try:
if settings.USE_SDL == 2: ret.append(Ports.sdl2.get())
for port in ports.ports:
ret += port.get(Ports, settings, shared)
ok = True
finally:
if not ok:
@ -647,7 +641,7 @@ def get_ports(settings):
return ret
def process_args(args, settings):
if settings.USE_SDL == 1: args += ['-Xclang', '-isystem' + shared.path_from_root('system', 'include', 'SDL')]
elif settings.USE_SDL == 2: args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'sdl2', 'include')]
for port in ports.ports:
args = port.process_args(args, settings, shared)
return args