def get_developer_dir():
    if 'DEVELOPER_DIR' in os.environ:
        return os.environ['DEVELOPER_DIR']
    else:
        # Before building, Xcode runs clang in a special mode that dumps a bunch
        # of the internal macros that are set. e.g. --
        #
        # /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
        #   -v -E -dM -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk \
        #   -x objective-c -c /dev/null 2>&1
        #
        # At this point, it's not yet setting DEVELOPER_DIR in the environment, but
        # it is prepending '/Applications/Xcode.app/Contents/Developer/usr/bin' to
        # the path.  We can deduce DEVELOPER_DIR from that.

        # This should give us a path that's inside the developer dir, given how
        # Xcode has set our path. e.g. --
        # /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
        xcodebuild_path = subprocess.check_output(['/usr/bin/which', 'xcodebuild']).strip()
        usr_bin_path = os.path.dirname(xcodebuild_path)
        return os.path.normpath(os.path.join(usr_bin_path, '..', '..'))
dataset/ETHPy150Open facebook/clang-as-ios-dylib/clang-as-ios-dylib.py/get_developer_dir/original