mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 18:27:05 +08:00
Build: properly read -j argument
The previous check for the -j argument was not actually working. Therefore, the build always used 4 cores, unless when building with ninja when presumably the ninja default was used.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015 - 2019 PX4 Development Team. All rights reserved.
|
# Copyright (c) 2015 - 2020 PX4 Development Team. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -69,7 +69,13 @@ space := $(subst ,, )
|
|||||||
# by cmake in the subdirectory
|
# by cmake in the subdirectory
|
||||||
FIRST_ARG := $(firstword $(MAKECMDGOALS))
|
FIRST_ARG := $(firstword $(MAKECMDGOALS))
|
||||||
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
||||||
j ?= 4
|
|
||||||
|
# Get -j or --jobs argument as suggested in:
|
||||||
|
# https://stackoverflow.com/a/33616144/8548472
|
||||||
|
MAKE_PID := $(shell echo $$PPID)
|
||||||
|
j := $(shell ps T | sed -n 's/.*$(MAKE_PID).*$(MAKE).* \(-j\|--jobs\) *\([0-9][0-9]*\).*/\2/p')
|
||||||
|
# Default to 4
|
||||||
|
j := $(or $(j),4)
|
||||||
|
|
||||||
NINJA_BIN := ninja
|
NINJA_BIN := ninja
|
||||||
ifndef NO_NINJA_BUILD
|
ifndef NO_NINJA_BUILD
|
||||||
|
|||||||
Reference in New Issue
Block a user