diff --git a/aws_lambda_builders/__main__.py b/aws_lambda_builders/__main__.py index 2a0c3d887..bc03e9856 100644 --- a/aws_lambda_builders/__main__.py +++ b/aws_lambda_builders/__main__.py @@ -131,6 +131,7 @@ def main(): # pylint: disable=too-many-statements architecture=params.get("architecture", X86_64), is_building_layer=params.get("is_building_layer", False), experimental_flags=params.get("experimental_flags", []), + build_in_source=params.get("build_in_source", None), ) # Return a success response diff --git a/aws_lambda_builders/builder.py b/aws_lambda_builders/builder.py index 1538cc0d6..7d5430110 100644 --- a/aws_lambda_builders/builder.py +++ b/aws_lambda_builders/builder.py @@ -71,6 +71,7 @@ def build( architecture=X86_64, is_building_layer=False, experimental_flags=None, + build_in_source=None, ): # pylint: disable-msg=too-many-locals """ @@ -138,6 +139,11 @@ def build( :type experimental_flags: list :param experimental_flags: List of strings, which will indicate enabled experimental flags for the current build session + + :type build_in_source: Optional[bool] + :param build_in_source: + Optional, will execute the build operation in the source directory if True. + """ if not os.path.exists(scratch_dir): @@ -159,6 +165,7 @@ def build( architecture=architecture, is_building_layer=is_building_layer, experimental_flags=experimental_flags, + build_in_source=build_in_source, ) return workflow.run() diff --git a/aws_lambda_builders/workflow.py b/aws_lambda_builders/workflow.py index 7aef1bd84..3a881fd3a 100644 --- a/aws_lambda_builders/workflow.py +++ b/aws_lambda_builders/workflow.py @@ -165,6 +165,7 @@ def __init__( architecture=X86_64, is_building_layer=False, experimental_flags=None, + build_in_source=None, ): # pylint: disable-msg=too-many-locals """ @@ -208,6 +209,9 @@ def __init__( experimental_flags: list, optional List of strings, which will indicate enabled experimental flags for the current build session + + build_in_source: Optional[bool] + Optional, will execute the build operation in the source directory if True. """ self.source_dir = source_dir @@ -225,6 +229,7 @@ def __init__( self.architecture = architecture self.is_building_layer = is_building_layer self.experimental_flags = experimental_flags if experimental_flags else [] + self.build_in_source = build_in_source # Actions are registered by the subclasses as they seem fit self.actions = [] diff --git a/tests/functional/test_cli.py b/tests/functional/test_cli.py index 3d3a64e5d..b22dd68d5 100644 --- a/tests/functional/test_cli.py +++ b/tests/functional/test_cli.py @@ -83,6 +83,7 @@ def test_run_hello_workflow_with_backcompat(self, flavor, protocol_version): "architecture": "x86_64", "is_building_layer": False, "experimental_flags": ["experimental"], + "build_in_source": False, }, } @@ -149,6 +150,7 @@ def test_run_hello_workflow_incompatible(self, flavor): "combine_dependencies": False, "is_building_layer": False, "experimental_flags": ["experimental"], + "build_in_source": False, }, } ) diff --git a/tests/unit/test_builder.py b/tests/unit/test_builder.py index 3b6c55047..b71aed5b2 100644 --- a/tests/unit/test_builder.py +++ b/tests/unit/test_builder.py @@ -127,6 +127,7 @@ def setUp(self): [True, False], # combine_dependencies [True, False], # is_building_layer [None, [], ["a", "b"]], # experimental flags + [True, False], # build_in_source ) ) @patch("aws_lambda_builders.builder.os") @@ -139,6 +140,7 @@ def test_with_mocks( combine_dependencies, is_building_layer, experimental_flags, + build_in_source, get_workflow_mock, os_mock, ): @@ -167,6 +169,7 @@ def test_with_mocks( combine_dependencies=combine_dependencies, is_building_layer=is_building_layer, experimental_flags=experimental_flags, + build_in_source=build_in_source, ) workflow_cls.assert_called_with( @@ -185,6 +188,7 @@ def test_with_mocks( combine_dependencies=combine_dependencies, is_building_layer=is_building_layer, experimental_flags=experimental_flags, + build_in_source=build_in_source, ) workflow_instance.run.assert_called_once() os_mock.path.exists.assert_called_once_with("scratch_dir")