blob: 454a3919aaaf849981cd60a098e9137910fff357 [file] [log] [blame]
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001#!/usr/bin/env python3
2#
3# SPDX-License-Identifier: GPL-2.0-only
4#
5# Copyright (C) 2020 Richard Purdie
6#
7
8import os
9import sys
10import warnings
Andrew Geissler5199d832021-09-24 16:47:35 -050011warnings.simplefilter("default")
Andrew Geisslerc9f78652020-09-18 14:11:35 -050012import logging
13sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
14
Andrew Geissler517393d2023-01-13 08:55:19 -060015import bb
16
17bb.utils.check_system_locale()
Andrew Geisslerc9f78652020-09-18 14:11:35 -050018
19# Users shouldn't be running this code directly
Andrew Geissler517393d2023-01-13 08:55:19 -060020if len(sys.argv) != 11 or not sys.argv[1].startswith("decafbad"):
Andrew Geisslerc9f78652020-09-18 14:11:35 -050021 print("bitbake-server is meant for internal execution by bitbake itself, please don't use it standalone.")
22 sys.exit(1)
23
24import bb.server.process
25
26lockfd = int(sys.argv[2])
27readypipeinfd = int(sys.argv[3])
28logfile = sys.argv[4]
29lockname = sys.argv[5]
30sockname = sys.argv[6]
Andrew Geisslerc926e172021-05-07 16:11:35 -050031timeout = float(sys.argv[7])
Andrew Geissler517393d2023-01-13 08:55:19 -060032profile = bool(int(sys.argv[8]))
33xmlrpcinterface = (sys.argv[9], int(sys.argv[10]))
Andrew Geisslerc9f78652020-09-18 14:11:35 -050034if xmlrpcinterface[0] == "None":
35 xmlrpcinterface = (None, xmlrpcinterface[1])
Andrew Geisslerc9f78652020-09-18 14:11:35 -050036
37# Replace standard fds with our own
38with open('/dev/null', 'r') as si:
39 os.dup2(si.fileno(), sys.stdin.fileno())
40
41so = open(logfile, 'a+')
42os.dup2(so.fileno(), sys.stdout.fileno())
43os.dup2(so.fileno(), sys.stderr.fileno())
44
45# Have stdout and stderr be the same so log output matches chronologically
46# and there aren't two seperate buffers
47sys.stderr = sys.stdout
48
49logger = logging.getLogger("BitBake")
50# Ensure logging messages get sent to the UI as events
51handler = bb.event.LogHandler()
52logger.addHandler(handler)
53
Andrew Geissler517393d2023-01-13 08:55:19 -060054bb.server.process.execServer(lockfd, readypipeinfd, lockname, sockname, timeout, xmlrpcinterface, profile)
Andrew Geisslerc9f78652020-09-18 14:11:35 -050055