I'm using a Makefile for building a lambda extension. It works fine when I run a sam build
command from Azure DevOps using Ubuntu. However, sometimes I want to build from my PC and the Makefile doesn't work because commands are different. I suppose I could setup command aliases for dos but that seems treacherous. I'd prefer to use something like OS detecting makefile but when I tried that it didn't work out.
Here's the pertinent snippet from my template:
TokenCacheLayer:
Type: AWS::Serverless::LayerVersion
Metadata:
BuildMethod: makefile
Properties:
LayerName: !Ref TokenCacheLayerName
Description: AWS Lambda extension to cache tokens aquired from an external API.
ContentUri: ./token-cache
LicenseInfo: MIT-0
CompatibleRuntimes:
- nodejs12.x
RetentionPolicy: Retain
Here's my Makefile:
build-TokenCacheLayer:
cp -R extensions "$(ARTIFACTS_DIR)"
cp -R token-cache-extension "$(ARTIFACTS_DIR)"
Here's the 2 ways I've tried altering to make it OS independent:
build-TokenCacheLayer:
ifeq ($(OS),Windows_NT)
xcopy extensions "$(ARTIFACTS_DIR)\extensions"
xcopy token-cache-extension "$(ARTIFACTS_DIR)"
else
cp -R extensions "$(ARTIFACTS_DIR)"
cp -R token-cache-extension "$(ARTIFACTS_DIR)"
endif
and
ifeq ($(OS),Windows_NT)
build-TokenCacheLayer:
xcopy extensions "$(ARTIFACTS_DIR)\extensions"
xcopy token-cache-extension "$(ARTIFACTS_DIR)"
else
build-TokenCacheLayer:
cp -R extensions "$(ARTIFACTS_DIR)"
cp -R token-cache-extension "$(ARTIFACTS_DIR)"
endif
The first way I got the error:
Error: CustomMakeBuilder:MakeBuild - Make Failed: process_begin: CreateProcess(NULL, cp -R extensions D:\Development\AWS.Integration\buildpro\layers\sam-build\TokenCacheLayer, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [D:\Development\AWS.Integration\buildpro\layers\token-cache\Makefile:6: build-TokenCacheLayer] Error 2
The second gave me this:
Error: CustomMakeBuilder:MakeBuild - Make Failed: D:\Development\AWS.Integration\buildpro\layers\token-cache\Makefile:2: *** recipe commences before first target. Stop.
Update
I went back and tried the first way again and while I'm not getting an error it doesn't copy the files either.