Skip to content

Commit 6b1588b

Browse files
authored
Merge branch 'facebook:main' into update-release-yml
2 parents c036c53 + 3187346 commit 6b1588b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1356
-397
lines changed

CMakeLists.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@ set(CMAKE_MODULE_PATH
1212
"${CMAKE_CURRENT_SOURCE_DIR}/build/fbcode_builder/CMake"
1313
${CMAKE_MODULE_PATH})
1414

15-
set(CMAKE_CXX_STANDARD 17)
15+
if(NOT CMAKE_CXX_STANDARD)
16+
set(CMAKE_CXX_STANDARD 17)
17+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
18+
message(STATUS "setting C++ standard to C++${CMAKE_CXX_STANDARD}")
19+
endif()
20+
21+
# Explicitly enable coroutine support, since GCC does not enable it
22+
# by default when targeting C++17.
23+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
24+
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fcoroutines>)
25+
endif()
1626

1727
if (WIN32)
1828
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DSTRICT")
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 97518207214e89d6db73da63837f4e1dc2b57acf
1+
Subproject commit 4662bb3dd9ff5cc4324e794e29509b8acb1c8a4b
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit ab576d641d9ae77662e6e54a5db7fbe6d215fa6d
1+
Subproject commit 819b4c4d46a7d6447584e46a7eb0731297622acf
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit dd5f918c13d1f4c89519cc76edec50e39c0fdc2b
1+
Subproject commit 7beae5da9cc5293dd785dd424b5ad5f7d819c64b

build/fbcode_builder/getdeps.py

+33-1
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,12 @@ def run_project_cmd(self, args, loader, manifest):
333333

334334
cache = cache_module.create_cache()
335335
for m in projects:
336+
fetcher = loader.create_fetcher(m)
337+
if isinstance(fetcher, SystemPackageFetcher):
338+
# We are guaranteed that if the fetcher is set to
339+
# SystemPackageFetcher then this item is completely
340+
# satisfied by the appropriate system packages
341+
continue
336342
cached_project = CachedProject(cache, loader, m)
337343
if cached_project.download():
338344
continue
@@ -348,7 +354,6 @@ def run_project_cmd(self, args, loader, manifest):
348354
continue
349355

350356
# We need to fetch the sources
351-
fetcher = loader.create_fetcher(m)
352357
fetcher.update()
353358

354359

@@ -923,6 +928,27 @@ def run_project_cmd(self, args, loader, manifest):
923928
self.create_builder(loader, manifest).debug(reconfigure=False)
924929

925930

931+
@cmd(
932+
"env",
933+
"print the environment in a shell sourceable format",
934+
)
935+
class EnvCmd(ProjectCmdBase):
936+
def setup_project_cmd_parser(self, parser):
937+
parser.add_argument(
938+
"--os-type",
939+
help="Filter to just this OS type to run",
940+
choices=["linux", "darwin", "windows"],
941+
action="store",
942+
dest="ostype",
943+
default=None,
944+
)
945+
946+
def run_project_cmd(self, args, loader, manifest):
947+
if args.ostype:
948+
loader.build_opts.host_type.ostype = args.ostype
949+
self.create_builder(loader, manifest).printenv(reconfigure=False)
950+
951+
926952
@cmd("generate-github-actions", "generate a GitHub actions configuration")
927953
class GenerateGitHubActionsCmd(ProjectCmdBase):
928954
RUN_ON_ALL = """ [push, pull_request]"""
@@ -995,6 +1021,8 @@ def write_job_for_platform(self, platform, args): # noqa: C901
9951021
if build_opts.is_linux():
9961022
artifacts = "linux"
9971023
runs_on = f"ubuntu-{args.ubuntu_version}"
1024+
if args.cpu_cores:
1025+
runs_on = f"{args.cpu_cores}-core-ubuntu-{args.ubuntu_version}"
9981026
elif build_opts.is_windows():
9991027
artifacts = "windows"
10001028
runs_on = "windows-2019"
@@ -1246,6 +1274,10 @@ def setup_project_cmd_parser(self, parser):
12461274
parser.add_argument(
12471275
"--ubuntu-version", default="22.04", help="Version of Ubuntu to use"
12481276
)
1277+
parser.add_argument(
1278+
"--cpu-cores",
1279+
help="Number of CPU cores to use (applicable for Linux OS)",
1280+
)
12491281
parser.add_argument(
12501282
"--cron",
12511283
help="Specify that the job runs on a cron schedule instead of on pushes",

build/fbcode_builder/getdeps/builder.py

+97-7
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
import subprocess
1616
import sys
1717
import typing
18+
from shlex import quote as shellquote
1819
from typing import Optional
1920

21+
from .copytree import simple_copytree
2022
from .dyndeps import create_dyn_dep_munger
2123
from .envfuncs import add_path_entry, Env, path_search
2224
from .fetcher import copy_if_different
@@ -157,6 +159,29 @@ def debug(self, reconfigure: bool) -> None:
157159
shell = ["powershell.exe"] if sys.platform == "win32" else ["/bin/sh", "-i"]
158160
self._run_cmd(shell, cwd=self.build_dir, env=env)
159161

162+
def printenv(self, reconfigure: bool) -> None:
163+
"""print the environment in a shell sourcable format"""
164+
reconfigure = self._reconfigure(reconfigure)
165+
self._apply_patchfile()
166+
self._prepare(reconfigure=reconfigure)
167+
env = self._compute_env(env=Env(src={}))
168+
prefix = "export "
169+
sep = ":"
170+
expand = "$"
171+
expandpost = ""
172+
if self.build_opts.is_windows():
173+
prefix = "SET "
174+
sep = ";"
175+
expand = "%"
176+
expandpost = "%"
177+
for k, v in sorted(env.items()):
178+
existing = os.environ.get(k, None)
179+
if k.endswith("PATH") and existing:
180+
v = shellquote(v) + sep + f"{expand}{k}{expandpost}"
181+
else:
182+
v = shellquote(v)
183+
print("%s%s=%s" % (prefix, k, v))
184+
160185
def build(self, reconfigure: bool) -> None:
161186
print("Building %s..." % self.manifest.name)
162187
reconfigure = self._reconfigure(reconfigure)
@@ -225,14 +250,16 @@ def _build(self, reconfigure) -> None:
225250
system needs to regenerate its rules."""
226251
pass
227252

228-
def _compute_env(self):
253+
def _compute_env(self, env=None) -> Env:
254+
if env is None:
255+
env = self.env
229256
# CMAKE_PREFIX_PATH is only respected when passed through the
230257
# environment, so we construct an appropriate path to pass down
231258
return self.build_opts.compute_env_for_install_dirs(
232259
self.loader,
233260
self.dep_manifests,
234261
self.ctx,
235-
env=self.env,
262+
env=env,
236263
manifest=self.manifest,
237264
)
238265

@@ -461,6 +488,61 @@ def _build(self, reconfigure) -> None:
461488
self._run_cmd(install_cmd, env=env)
462489

463490

491+
class SystemdBuilder(BuilderBase):
492+
# SystemdBuilder assumes that meson build tool has already been installed on
493+
# the machine.
494+
def __init__(
495+
self,
496+
loader,
497+
dep_manifests,
498+
build_opts,
499+
ctx,
500+
manifest,
501+
src_dir,
502+
build_dir,
503+
inst_dir,
504+
) -> None:
505+
super(SystemdBuilder, self).__init__(
506+
loader,
507+
dep_manifests,
508+
build_opts,
509+
ctx,
510+
manifest,
511+
src_dir,
512+
build_dir,
513+
inst_dir,
514+
)
515+
516+
def _build(self, reconfigure) -> None:
517+
env = self._compute_env()
518+
meson = path_search(env, "meson")
519+
if meson is None:
520+
raise Exception("Failed to find Meson")
521+
522+
# Meson builds typically require setup, compile, and install steps.
523+
# During this setup step we ensure that the static library is built and
524+
# the prefix is empty.
525+
self._run_cmd(
526+
[
527+
meson,
528+
"setup",
529+
"-Dstatic-libsystemd=true",
530+
"-Dprefix=/",
531+
self.build_dir,
532+
self.src_dir,
533+
]
534+
)
535+
536+
# Compile step needs to satisfy the build directory that was previously
537+
# prepared during setup.
538+
self._run_cmd([meson, "compile", "-C", self.build_dir])
539+
540+
# Install step
541+
self._run_cmd(
542+
[meson, "install", "-C", self.build_dir, "--destdir", self.inst_dir]
543+
)
544+
545+
464546
class CMakeBuilder(BuilderBase):
465547
MANUAL_BUILD_SCRIPT = """\
466548
#!{sys.executable}
@@ -1084,9 +1166,14 @@ def _build(self, reconfigure) -> None:
10841166
perl = typing.cast(str, path_search(env, "perl", "perl"))
10851167

10861168
make_j_args = []
1169+
extra_args = []
10871170
if self.build_opts.is_windows():
1088-
make = "nmake.exe"
1171+
# jom is compatible with nmake, adds the /j argument for parallel build
1172+
make = "jom.exe"
1173+
make_j_args = ["/j%s" % self.num_jobs]
10891174
args = ["VC-WIN64A-masm", "-utf-8"]
1175+
# fixes "if multiple CL.EXE write to the same .PDB file, please use /FS"
1176+
extra_args = ["/FS"]
10901177
elif self.build_opts.is_darwin():
10911178
make = "make"
10921179
make_j_args = ["-j%s" % self.num_jobs]
@@ -1119,11 +1206,14 @@ def _build(self, reconfigure) -> None:
11191206
"no-unit-test",
11201207
"no-tests",
11211208
]
1209+
+ extra_args
11221210
)
1211+
# show the config produced
1212+
self._run_cmd([perl, "configdata.pm", "--dump"], env=env)
11231213
make_build = [make] + make_j_args
1124-
self._run_cmd(make_build)
1214+
self._run_cmd(make_build, env=env)
11251215
make_install = [make, "install_sw", "install_ssldirs"]
1126-
self._run_cmd(make_install)
1216+
self._run_cmd(make_install, env=env)
11271217

11281218

11291219
class Boost(BuilderBase):
@@ -1240,7 +1330,7 @@ def build(self, reconfigure: bool) -> None:
12401330
os.makedirs(dest_parent)
12411331
if os.path.isdir(full_src):
12421332
if not os.path.exists(full_dest):
1243-
shutil.copytree(full_src, full_dest)
1333+
simple_copytree(full_src, full_dest)
12441334
else:
12451335
shutil.copyfile(full_src, full_dest)
12461336
shutil.copymode(full_src, full_dest)
@@ -1252,7 +1342,7 @@ def build(self, reconfigure: bool) -> None:
12521342
os.chmod(full_dest, st.st_mode | stat.S_IXUSR)
12531343
else:
12541344
if not os.path.exists(self.inst_dir):
1255-
shutil.copytree(self.src_dir, self.inst_dir)
1345+
simple_copytree(self.src_dir, self.inst_dir)
12561346

12571347

12581348
class SqliteBuilder(BuilderBase):

build/fbcode_builder/getdeps/buildopts.py

+15-13
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,14 @@ def compute_env_for_install_dirs(
304304
is_direct_dep = (
305305
manifest is not None and m.name in manifest.get_dependencies(ctx)
306306
)
307-
self.add_prefix_to_env(
308-
loader.get_project_install_dir(m),
309-
env,
310-
append=False,
311-
is_direct_dep=is_direct_dep,
312-
)
307+
d = loader.get_project_install_dir(m)
308+
if os.path.exists(d):
309+
self.add_prefix_to_env(
310+
d,
311+
env,
312+
append=False,
313+
is_direct_dep=is_direct_dep,
314+
)
313315

314316
# Linux is always system openssl
315317
system_openssl = self.is_linux()
@@ -521,7 +523,8 @@ def find_unused_drive_letter():
521523
return available[-1]
522524

523525

524-
def create_subst_path(path: str) -> str:
526+
def map_subst_path(path: str) -> str:
527+
"""find a short drive letter mapping for a path"""
525528
for _attempt in range(0, 24):
526529
drive = find_existing_win32_subst_for_path(
527530
path, subst_mapping=list_win32_subst_letters()
@@ -542,9 +545,11 @@ def create_subst_path(path: str) -> str:
542545
# other processes on the same host, so this may not succeed.
543546
try:
544547
subprocess.check_call(["subst", "%s:" % available, path])
545-
return "%s:\\" % available
548+
subst = "%s:\\" % available
549+
print("Mapped scratch dir %s -> %s" % (path, subst), file=sys.stderr)
550+
return subst
546551
except Exception:
547-
print("Failed to map %s -> %s" % (available, path))
552+
print("Failed to map %s -> %s" % (available, path), file=sys.stderr)
548553

549554
raise Exception("failed to set up a subst path for %s" % path)
550555

@@ -617,10 +622,7 @@ def setup_build_options(args, host_type=None) -> BuildOptions:
617622
os.makedirs(scratch_dir)
618623

619624
if is_windows():
620-
subst = create_subst_path(scratch_dir)
621-
print(
622-
"Mapping scratch dir %s -> %s" % (scratch_dir, subst), file=sys.stderr
623-
)
625+
subst = map_subst_path(scratch_dir)
624626
scratch_dir = subst
625627
else:
626628
if not os.path.exists(scratch_dir):

0 commit comments

Comments
 (0)