Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add parallel flag into build options #173

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ def __init__(self):
'--search-prefix', dest='search_prefix', type=str,
help='search prefix to pass to CMake'
)

'''Option to control resource usage when running on a Raspberry Pi'''
self.parser.add_argument(
'--parallel', dest='parallel', type=int,
help='Control the number of parallel build processes or threads'
)

'''Agent only'''
self.parser.add_argument(
Expand Down Expand Up @@ -422,6 +428,7 @@ def __init__(self, script_args):
self.static_analysis = self.script_args.static_analysis
self.build_for_snap = self.script_args.build_for_snap
self.search_prefix = self.script_args.search_prefix
self.parallel = self.script_args.parallel

@property
def platform(self):
Expand Down Expand Up @@ -462,6 +469,13 @@ def run(self):
def package(self):
subprocess.call(['/bin/bash', '-c', 'cd {} && cpack .'.format(self.build_path)])

@property
def build_options(self):
build_options_linux = super().build_options
if (self.parallel):
build_options_linux += ['--parallel', str(self.parallel)]
return build_options_linux

class WindowsBuildRunner(BuildRunnerBase):
"""Windows BuildRunner class."""

Expand Down
2 changes: 1 addition & 1 deletion sdk-cpp/tests/test_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const std::chrono::seconds g_largeFileWaitTime = 5min;
#if defined(DO_INTERFACE_REST)

#ifdef DO_BUILD_FOR_SNAP
const std::string g_docsSvcName = "deliveryoptimization-client.agent";
const std::string g_docsSvcName = "deliveryoptimization-agent.agent";
#else
const std::string g_docsSvcName = "deliveryoptimization-agent.service";
#endif
Expand Down
6 changes: 3 additions & 3 deletions snapcraft-options/connect-snaps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
set -e

# Plug agent snap into sdk-tests snap downloads slot
sudo snap connect deliveryoptimization-client:deviceupdate-agent-downloads deliveryoptimization-sdk-tests:downloads-folder
sudo snap connect deliveryoptimization-agent:deviceupdate-agent-downloads deliveryoptimization-sdk-tests:downloads-folder

# Plug sdk-tests snap into agent's run and config slots
sudo snap connect deliveryoptimization-sdk-tests:do-port-numbers deliveryoptimization-client:do-port-numbers
sudo snap connect deliveryoptimization-sdk-tests:do-configs deliveryoptimization-client:do-configs
sudo snap connect deliveryoptimization-sdk-tests:do-port-numbers deliveryoptimization-agent:do-port-numbers
sudo snap connect deliveryoptimization-sdk-tests:do-configs deliveryoptimization-agent:do-configs
10 changes: 5 additions & 5 deletions snapcraft-options/snapcraft-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ description: |
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

architectures:
- build-on: [amd64, arm64]
run-on: [amd64, armhf, arm64]

#####
#
# Keywords
Expand Down Expand Up @@ -39,7 +35,11 @@ parts:
plugin: python
source: .
override-build: |
python3 ./build/build.py --project agent --build-for-snap
if grep -q "Raspberry Pi" /proc/cpuinfo; then
python3 ./build/build.py --project agent --build-for-snap --parallel 1
else
python3 ./build/build.py --project agent --build-for-snap
fi
mkdir -p ../install/bin
cp /tmp/build-deliveryoptimization-agent/linux-debug/client-lite/deliveryoptimization-agent ../install/bin/deliveryoptimization-agent

Expand Down
10 changes: 5 additions & 5 deletions snapcraft-options/snapcraft-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ description: |
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

architectures:
- build-on: [amd64, arm64]
run-on: [amd64, armhf, arm64]

#####
#
# Keywords
Expand Down Expand Up @@ -39,7 +35,11 @@ parts:
plugin: python
source: .
override-build: |
python3 ./build/build.py --project sdk --build-for-snap
if grep -q "Raspberry Pi" /proc/cpuinfo; then
python3 ./build/build.py --project sdk --build-for-snap --parallel 1
else
python3 ./build/build.py --project sdk --build-for-snap
fi
mkdir -p ../install/bin
mkdir -p ../install/lib
cp /tmp/build-deliveryoptimization-sdk/linux-debug/sdk-cpp/tests/deliveryoptimization-sdk-tests ../install/bin/deliveryoptimization-sdk-tests
Expand Down