Skip to content

Commit d882e2d

Browse files
committed
Added some prebuild toolchain and recipe methods
1 parent a2a4873 commit d882e2d

File tree

4 files changed

+46
-20
lines changed

4 files changed

+46
-20
lines changed

recipes/android/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11

2-
from toolchain import PythonRecipe
2+
from toolchain import PythonRecipe, shprint, ensure_dir
3+
import sh
34

45

56
class AndroidRecipe(PythonRecipe):
6-
name = 'android'
7+
# name = 'android'
78
version = None
89
url = None
910
depends = ['pygame']
1011

12+
def prebuild_armeabi(self):
13+
shprint(sh.cp, '-a', self.get_recipe_dir() + '/src', self.get_build_dir('armeabi'))
14+
15+
1116

1217
recipe = AndroidRecipe()

recipes/hostpython2/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
from toolchain import Recipe, shprint
2+
from toolchain import Recipe, shprint, get_directory
3+
from os.path import join
34
import sh
45

56

@@ -8,5 +9,13 @@ class Hostpython2Recipe(Recipe):
89
url = 'http://python.org/ftp/python/{version}/Python-{version}.tar.bz2'
910
name = 'hostpython2'
1011

12+
def prebuild_armeabi(self):
13+
# Override hostpython Setup?
14+
print('Running hostpython2 prebuild')
15+
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'),
16+
join(self.get_build_dir('armeabi'),
17+
get_directory(self.versioned_url),
18+
'Modules', 'Setup'))
19+
1120

1221
recipe = Hostpython2Recipe()

recipes/sdl/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
from toolchain import Recipe, shprint
1+
from toolchain import NDKRecipe, shprint
22
import sh
33

44

55

6-
class LibSDLRecipe(Recipe):
6+
class LibSDLRecipe(NDKRecipe):
77
version = "1.2.14"
88
url = None
99
name = 'sdl'
1010
depends = ['python2']
1111

12+
def prebuild_armeabi(self):
13+
print('Debug: sdl recipe dir is ' + self.get_build_dir())
14+
1215
def build_arch(self, arch):
1316
# shprint(sh.xcodebuild,
1417
# "ONLY_ACTIVE_ARCH=NO",

toolchain.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,11 @@ class Recipe(object):
522522
# frameworks = []
523523
# sources = []
524524

525-
can_compile_standalone = True
525+
@property
526+
def versioned_url(self):
527+
if self.url is None:
528+
return None
529+
return self.url.format(version=self.version)
526530

527531
# API available for recipes
528532
def download_file(self, url, filename, cwd=None):
@@ -671,6 +675,10 @@ def name(self):
671675
def get_build_dir(self, arch):
672676
return join(self.ctx.build_dir, 'other_builds', self.name, arch)
673677

678+
def get_recipe_dir(self):
679+
# AND: Redundant, an equivalent property is already set by get_recipe
680+
return join(self.ctx.root_dir, 'recipes', self.name)
681+
674682
# Public Recipe API to be subclassed if needed
675683

676684
# def init_with_ctx(self, ctx):
@@ -701,13 +709,14 @@ def prepare_build_dir(self, ctx):
701709
shprint(sh.ln, '-s', user_dir, build_dir)
702710
return
703711

712+
ensure_dir(build_dir)
713+
704714
if self.url is None:
705715
print('Nothing to do for {} recipe preparation'.format(self.name))
706716
return
707717

708718
print('Preparing and downloading {}'.format(self.name))
709719

710-
shprint(sh.mkdir, '-p', join(build_dir))
711720
shprint(sh.mkdir, '-p', join(ctx.packages_path, self.name))
712721

713722
print('Moving to', join(ctx.packages_path, self.name))
@@ -836,19 +845,19 @@ def custom_dir(self):
836845
return d
837846

838847
# @cache_execution
839-
def download(self):
840-
key = "{}.archive_root".format(self.name)
841-
if self.custom_dir:
842-
self.ctx.state[key] = basename(self.custom_dir)
843-
else:
844-
src_dir = join(self.recipe_dir, self.url)
845-
if exists(src_dir):
846-
self.ctx.state[key] = basename(src_dir)
847-
return
848-
fn = self.archive_fn
849-
if not exists(fn):
850-
self.download_file(self.url.format(version=self.version), fn)
851-
self.ctx.state[key] = self.get_archive_rootdir(self.archive_fn)
848+
# def download(self):
849+
# key = "{}.archive_root".format(self.name)
850+
# if self.custom_dir:
851+
# self.ctx.state[key] = basename(self.custom_dir)
852+
# else:
853+
# src_dir = join(self.recipe_dir, self.url)
854+
# if exists(src_dir):
855+
# self.ctx.state[key] = basename(src_dir)
856+
# return
857+
# fn = self.archive_fn
858+
# if not exists(fn):
859+
# self.download_file(self.url.format(version=self.version), fn)
860+
# self.ctx.state[key] = self.get_archive_rootdir(self.archive_fn)
852861

853862
# @cache_execution
854863
def extract(self):

0 commit comments

Comments
 (0)