How to exclude "Selection & Handles" and other editor-specific code in builds?

I am working on a custom editor script one of the options is to select the parent of the object

Selection.activeGameObject = transform.root.gameObject;

I am also using Handles.Label to display a number to identify waypoint gizmos when
I go to build the game i get unknown identifier selection and the same for handles
with some research i found that these can not be built into the game

my question is can i make it ignore them when i build rather than remark them out
thank you in advance.

well after digging around a bit i found that i dont have to ignore it and still build the game.
i had to place it in an editor script rather than the gameobject script
hope this helps someone else.

_

Unity’s Platform Dependent Compilation feature consists of some preprocessor directives that let you partition your scripts to compile and execute a section of code exclusively for one of the supported platforms.
_

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

public class TestScript : MonoBehaviour
{

    void Start ()
    {
        #if UNITY_EDITOR
        /// this code will be present in Editor only
        Selection.activeGameObject = transform.root.gameObject;
        Debug.Log(transform.root.gameObject.name+" selected",gameObject);
        #endif

        #if DEBUG
        /// this code will be present in Editor AND Debug builds
        Debug.Log("Script started",gameObject);
        #endif
    }

    void Update ()
    {
        transform.localScale = Vector3.one + Vector3.one*0.1f*Mathf.Sin(Time.time);
    }

    #if UNITY_EDITOR
    void OnDrawGizmos ()
    {
        Gizmos.color = Color.yellow;
        Gizmos.DrawWireCube( transform.position , transform.localScale );

        Handles.Label( transform.position , gameObject.name );
    }
    #endif

}