forked from Azure/azure-functions-nodejs-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Microsoft.Azure.Functions.NodeJsWorker.targets
39 lines (34 loc) · 2.09 KB
/
Microsoft.Azure.Functions.NodeJsWorker.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="InstallGrpc">
<!-- Run from .sln / .csproj context -->
<PropertyGroup Condition="$(ProjectDir)!=''">
<BaseDir>$(ProjectDir)../../</BaseDir>
<GrpcPath>$(ProjectDir)$(OutputPath)workers/node/grpc/</GrpcPath>
</PropertyGroup>
<!-- Run from worker/node folder -->
<PropertyGroup Condition="$(ProjectDir)==''">
<BaseDir>$(MSBuildThisFileDirectory)grpc/</BaseDir>
<GrpcPath>$(MSBuildThisFileDirectory)grpc/</GrpcPath>
</PropertyGroup>
<PropertyGroup Condition="$(OS)!='Windows_NT'">
<ModulesPrefix>lib/</ModulesPrefix>
</PropertyGroup>
<Target Name="CreateModulesDir" Condition="!Exists('$(BaseDir)node_modules')">
<MakeDir Directories="$(BaseDir)node_modules" />
</Target>
<Target Name="InstallNodeAbi" Condition="!Exists('$(BaseDir)node_modules/node-abi')">
<Exec Command="npm install --prefix $(BaseDir) node-abi --production" WorkingDirectory="$(BaseDir)" />
</Target>
<Target Name="GetGrpcBinPath" Condition="$(GrpcBinary)==''">
<Exec Command="node ./getNativeFile.js" ConsoleToMSBuild="true" WorkingDirectory="$(GrpcPath)">
<Output TaskParameter="ConsoleOutput" PropertyName="GrpcBinary" />
</Exec>
</Target>
<Target Name="InstallGrpcNative" Condition="!Exists('$(GrpcPath)src/node/extension_binary/$(GrpcBinary)')" >
<Message Text="Installing node-pre-gyp and native grpc module" Importance="high" />
<Exec Command="npm install --prefix $(BaseDir) node-pre-gyp --production" WorkingDirectory="$(BaseDir)" Condition="!Exists('$(BaseDir)node_modules/node-pre-gyp')" />
<Message Text="$(BaseDir)$(ModulesPrefix)node_modules/node-pre-gyp/bin/node-pre-gyp install --directory $(GrpcPath)" Importance="high" />
<Exec Command="$(BaseDir)$(ModulesPrefix)node_modules/node-pre-gyp/bin/node-pre-gyp install --directory $(GrpcPath)" />
</Target>
<Target Name="InstallGrpc" AfterTargets="Build" DependsOnTargets="CreateModulesDir;InstallNodeAbi;GetGrpcBinPath;InstallGrpcNative" />
</Project>