Skip to content

Commit

Permalink
Create function for producing project artifact
Browse files Browse the repository at this point in the history
Summary:
This creates a function for producing the <Project> artifact output. There is no observable behavior change.

This is an intermediate step to prepare for gathering the cxxflags from the cxx_toolchain, which will be loaded asynchronously and added in a later diff.

Reviewed By: JakobDegen

Differential Revision: D69615223

fbshipit-source-id: 9f749642676d63aff0583e618ba80e18b873e276
  • Loading branch information
skrueger authored and facebook-github-bot committed Feb 14, 2025
1 parent 203357c commit e2b9186
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions prelude/ide_integrations/visual_studio/gen_mode_configs.bxl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ def _get_path(target: str, bxl_ctx):
return absolute_path

def _main(bxl_ctx):
actions = bxl_ctx.bxl_actions().actions
fbsource = bxl_ctx.cli_args.fbsource
root = bxl_ctx.root()

output_artifact = actions.declare_output(get_mode_config_path(bxl_ctx.cli_args.mode_name))

platform = _get_platform(bxl_ctx.cli_args.vs_version_year)

flags_location = LANGUAGE_STANDARD_AND_TOOLSET_MAP[platform][FLAGS_LOCATION]
Expand All @@ -123,13 +129,18 @@ def _main(bxl_ctx):
cxxppflags = cxxppflags,
ldflags = ldflags,
)
_produce_proj_artifact(bxl_ctx, actions, fbsource, cxx_toolchain_flags, output_artifact, root = root, platform = platform)
elif flags_location == _FlagsLocation("CxxToolchain"):
fail("Not Implemented Yet flags_location '%s' in platform '%s'" % (flags_location, platform))
else:
fail("Unknown flags_location '%s' in platform '%s'" % (flags_location, platform))

bxl_ctx.output.print(bxl_ctx.output.ensure(output_artifact).abs_path())

def _produce_proj_artifact(bxl_ctx, actions, fbsource: bool, cxx_toolchain_flags: _CxxToolchainFlags, output_artifact: Artifact, root: str, platform: str):
"""Produce the <Project> file output artifact"""
compiler_settings = _get_compiler_settings(cxx_toolchain_flags)
linker_settings = _get_linker_settings(cxx_toolchain_flags, bxl_ctx.root())
linker_settings = _get_linker_settings(cxx_toolchain_flags, root)
platform_toolset = LANGUAGE_STANDARD_AND_TOOLSET_MAP[platform][TOOLSET]

# Set default language standard if not specified
Expand All @@ -144,7 +155,7 @@ def _main(bxl_ctx):
linker_settings_content = gen_linker_settings(linker_settings)

toolchains_props = ""
if bxl_ctx.cli_args.fbsource and platform != ANDROID:
if fbsource and platform != ANDROID:
toolchains_props = " <Import Project=\"$(RepoRoot)\\third-party\\toolchains\\visual_studio\\toolchain.props\"/>"

absolutize_path_exe = _get_path(ABSOLUTIZE_PATH_EXE, bxl_ctx)
Expand Down Expand Up @@ -183,10 +194,7 @@ def _main(bxl_ctx):
delimiter = "\n",
)

actions = bxl_ctx.bxl_actions().actions
artifact = actions.declare_output(get_mode_config_path(bxl_ctx.cli_args.mode_name))
actions.write(artifact.as_output(), content, allow_args = True)
bxl_ctx.output.print(bxl_ctx.output.ensure(artifact).abs_path())
actions.write(output_artifact.as_output(), content, allow_args = True)

main = bxl_main(
impl = _main,
Expand Down

0 comments on commit e2b9186

Please sign in to comment.