The C# code for the build process is run on the host for the target. You wouldn’t do #if in there.
For the build.cs files you should look at the Target.Platform variable. It will be set to UnrealTargetPlatform.* (Win32, Win64, Mac, Linux, Android, IOS, TVOS, HTML5). Take a look at PhysX.Build.cs for an example.
C++ does have some platform-specific defines you can use, like #if PLATFORM_ANDROID.