Skip to content

Commit

Permalink
fix: add maxcpucount argument
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Sep 16, 2023
1 parent 54e631e commit 2ddd11b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 5 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ inputs:
required: false
default: ''
description: 'Overwrite the detected dotnet target framework used for the plugin build (default: "")'
max-cpu-count:
required: false
default: '1'
description: 'Maximum number of processors to use during build (default: "1")'
verbosity:
required: false
default: 'debug'
Expand Down Expand Up @@ -70,7 +74,7 @@ runs:
PLUGIN_VERSION=""
fi
artifact="$(python3 ${{ github.action_path }}/jprm/__init__.py --verbosity=${{ inputs.verbosity }} plugin build ${{ inputs.path }} -o ${{ inputs.output }} ${PLUGIN_VERSION} --dotnet-configuration ${{ inputs.dotnet-config }} ${DOTNET_FRAMEWORK})"
artifact="$(python3 ${{ github.action_path }}/jprm/__init__.py --verbosity=${{ inputs.verbosity }} plugin build ${{ inputs.path }} -o ${{ inputs.output }} ${PLUGIN_VERSION} --dotnet-configuration ${{ inputs.dotnet-config }} --max-cpu-count ${{ inputs.max-cpu-count }} ${DOTNET_FRAMEWORK})"
echo "Artifact: ${artifact}"
echo "artifact=${artifact}" >> $GITHUB_OUTPUT
Expand Down
16 changes: 12 additions & 4 deletions jprm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ def pop(self, k, d=KeyError):
####################


def build_plugin(path, output=None, build_cfg=None, version=None, dotnet_config='Release', dotnet_framework=None):
def build_plugin(path, output=None, build_cfg=None, version=None, dotnet_config='Release', dotnet_framework=None,
max_cpu_count='1'):
if build_cfg is None:
build_cfg = get_config(path)

Expand All @@ -332,6 +333,7 @@ def build_plugin(path, output=None, build_cfg=None, version=None, dotnet_config=
'dotnet_config': dotnet_config,
'dotnet_framework': dotnet_framework,
'output': output,
'max_cpu_count': max_cpu_count,
'version': version,
}

Expand Down Expand Up @@ -373,7 +375,7 @@ def build_plugin(path, output=None, build_cfg=None, version=None, dotnet_config=

build_command = "dotnet publish --nologo --no-restore" \
" --configuration={dotnet_config} --framework={dotnet_framework}" \
" -p:PublishDir={output} -p:Version={version}"
f" -p:PublishDir={output} -p:Version={version} /maxcpucount:{max_cpu_count}"

stdout, stderr, retcode = run_os_command(build_command.format(**params), cwd=path)
if retcode:
Expand Down Expand Up @@ -806,9 +808,15 @@ def cli_plugin():
default=None,
help='Dotnet framework ({})'.format(DEFAULT_FRAMEWORK),
)
def cli_plugin_build(path, output, dotnet_configuration, dotnet_framework, version):
@click.option('--max-cpu-count',
default='1',
required=False,
help='Maximum number of processors to use during build',
)
def cli_plugin_build(path, output, dotnet_configuration, dotnet_framework, max_cpu_count, version):
with tempfile.TemporaryDirectory() as bintemp:
build_plugin(path, output=bintemp, dotnet_config=dotnet_configuration, dotnet_framework=dotnet_framework, version=version)
build_plugin(path, output=bintemp, dotnet_config=dotnet_configuration, dotnet_framework=dotnet_framework,
version=version, max_cpu_count=max_cpu_count)
filename = package_plugin(path, version=version, binary_path=bintemp, output=output)
click.echo(filename)

Expand Down

0 comments on commit 2ddd11b

Please sign in to comment.