Skip to content

Commit

Permalink
aws-lc/s2n fixes (#100)
Browse files Browse the repository at this point in the history
* Switched s2n from depending on libcrypto to aws-lc

* Updates to s2n/aws-lc to make them play nice
  • Loading branch information
Justin Boswell authored Mar 3, 2021
1 parent c7b150a commit ef76bfa
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion builder/actions/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def _project_dirs(env, project):
if not project.resolved():
print('Project is not resolved: {}'.format(project.name))
raise Exception('Project is not resolved: {}'.format(project.name))

source_dir = str(Path(project.path).relative_to(env.root_dir))
build_dir = str(Path(os.path.join(env.build_dir, project.name)).relative_to(env.root_dir))
Expand Down
13 changes: 10 additions & 3 deletions builder/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ def get_config(self, spec, overrides=None, **additional_vars):

# project cache
_projects = {}
_imports = {}

@staticmethod
def _publish_variable(var, value):
Expand Down Expand Up @@ -632,9 +633,15 @@ def _cache_project(project):
Project._projects[project.name.lower()] = project
if getattr(project, 'path', None):
Scripts.load(project.path)

return project

@staticmethod
def _cache_import(imp):
Project._imports[imp.name.lower()] = imp
if getattr(imp, 'path', None):
Scripts.load(imp.path)
return imp

@staticmethod
def default_project():
project = Project._project_from_path('.')
Expand Down Expand Up @@ -716,13 +723,13 @@ def find_project(name, hints=None):
def find_import(name, hints=None):
if hints is None:
hints = []
imp = Project._projects.get(name.lower(), None)
imp = Project._imports.get(name.lower(), None)
if imp and imp.resolved():
return imp

for h in hints:
Scripts.load(h)
imp_cls = Project._find_import_class(name)
if imp_cls:
return Project._cache_project(imp_cls())
return Project._cache_import(imp_cls())
return Import(name=name, resolved=False)
25 changes: 25 additions & 0 deletions builder/imports/awslc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0.

import os

from builder.core.project import Project, Import
from builder.actions.git import DownloadSource


config = {
Expand All @@ -13,15 +16,37 @@

class AWSLCImport(Import):
def __init__(self, **kwargs):
if kwargs.get('name'):
del kwargs['name']
super().__init__(
library=True,
name='aws-lc',
config=config,
**kwargs)

def pre_build(self, env):
# Search for an aws-lc directory
if not hasattr(self, 'path'):
for root, dirs, files in os.walk(env.deps_dir):
for search_dir in dirs:
if search_dir.endswith('aws-lc'):
self.path = os.path.join(root, search_dir)
break
# No aws-lc directory, download to deps dir now
if not hasattr(self, 'path'):
self.path = os.path.join(env.deps_dir, 'aws-lc')
DownloadSource(project=Project.find_project(self.name), path=env.deps_dir).run(env)

def build(self, env):
return Project.build(Project.find_project(self.name, [self.path]), env)


class AWSLCProject(Project):
def __init__(self, **kwargs):
if kwargs.get('name'):
del kwargs['name']
super().__init__(
account='awslabs',
name='aws-lc',
config=config,
**kwargs)
6 changes: 4 additions & 2 deletions builder/imports/s2n.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ class S2NImport(Import):
def __init__(self, **kwargs):
super().__init__(
library=True,
upstreams=['aws-lc'],
imports=['aws-lc'],
config=config,
url='https://github.com/aws/s2n-tls.git',
**kwargs)


class S2NProject(Project):
def __init__(self, **kwargs):
super().__init__(
account='awslabs',
upstreams=['aws-lc'],
imports=['aws-lc'],
config=config,
url='https://github.com/aws/s2n-tls.git',
**kwargs)

0 comments on commit ef76bfa

Please sign in to comment.