@ -38,12 +38,8 @@
@@ -38,12 +38,8 @@
# u t i l i t y f u n c t i o n s
#
# * p x 4 _ p a r s e _ f u n c t i o n _ a r g s
# * p x 4 _ a d d _ g i t _ s u b m o d u l e
# * p x 4 _ p r e p e n d _ s t r i n g
# * p x 4 _ j o i n
# * p x 4 _ a d d _ m o d u l e
# * p x 4 _ g e n e r a t e _ m e s s a g e s
# * p x 4 _ a d d _ u p l o a d
# * p x 4 _ a d d _ c o m m o n _ f l a g s
# * p x 4 _ a d d _ o p t i m i z a t i o n _ f l a g s _ f o r _ t a r g e t
# * p x 4 _ a d d _ e x e c u t a b l e
@ -116,81 +112,6 @@ function(px4_parse_function_args)
@@ -116,81 +112,6 @@ function(px4_parse_function_args)
endforeach ( )
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ a d d _ g i t _ s u b m o d u l e
#
# T h i s f u n c t i o n a d d a g i t s u b m o d u l e t a r g e t .
#
# U s a g e :
# px4_add_git_submodule ( TARGET <target> PATH <path> )
#
# I n p u t :
# P A T H : g i t s u b m o d u l e p a t h
#
# O u t p u t :
# T A R G E T : g i t t a r g e t
#
# E x a m p l e :
# px4_add_git_submodule ( TARGET git_nuttx PATH "NuttX" )
#
function ( px4_add_git_submodule )
px4_parse_function_args (
N A M E p x 4 _ a d d _ g i t _ s u b m o d u l e
O N E _ V A L U E T A R G E T P A T H
R E Q U I R E D T A R G E T P A T H
A R G N $ { A R G N } )
string ( REPLACE "/" "_" NAME ${ PATH } )
add_custom_command ( OUTPUT ${ PX4_BINARY_DIR } /git_init_ ${ NAME } .stamp
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ S O U R C E _ D I R }
C O M M A N D t o u c h $ { P X 4 _ B I N A R Y _ D I R } / g i t _ i n i t _ $ { N A M E } . s t a m p
D E P E N D S $ { P X 4 _ S O U R C E _ D I R } / . g i t m o d u l e s
)
add_custom_target ( ${ TARGET }
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ S O U R C E _ D I R }
# t o d o : N o t h a v e 2 l i s t o f s u b m o d u l e s one ( see the end of Tools/check_submodules.sh and Firmware/CMakeLists.txt )
# u s i n g t h e l i s t o f s u b m o d u l e s f r o m t h e C M a k e f i l e t o d r i v e t h e t e s t
# C O M M A N D T o o l s / c h e c k _ s u b m o d u l e s . s h $ { P A T H }
D E P E N D S $ { P X 4 _ B I N A R Y _ D I R } / g i t _ i n i t _ $ { N A M E } . s t a m p
)
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ p r e p e n d _ s t r i n g
#
# T h i s f u n c t i o n p r e p e n d s a s t r i n g t o a l i s t
#
# U s a g e :
# px4_prepend_string ( OUT <output-list> STR <string> LIST <list> )
#
# I n p u t :
# S T R : s t r i n g t o p r e p e n d
# L I S T : l i s t t o p r e p e n d t o
#
# O u t p u t :
# $ { O U T } : p r e p e n d e d l i s t
#
# E x a m p l e :
# px4_prepend_string ( OUT test_str STR "path/to/" LIST src/file1.cpp src/file2.cpp )
# t e s t _ s t r w o u l d t h e n b e :
# p a t h / t o / s r c / f i l e 1 . c p p
# p a t h / t o / s r c / f i l e 2 . c p p
#
function ( px4_prepend_string )
px4_parse_function_args (
N A M E p x 4 _ p r e p e n d _ s t r i n g
O N E _ V A L U E O U T S T R
M U L T I _ V A L U E L I S T
R E Q U I R E D O U T S T R L I S T
A R G N $ { A R G N } )
set ( ${ OUT } )
foreach ( file ${ LIST } )
list ( APPEND ${ OUT } ${ STR } ${ file } )
endforeach ( )
set ( ${ OUT } ${ ${OUT } } PARENT_SCOPE )
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ j o i n
@ -248,7 +169,7 @@ endfunction()
@@ -248,7 +169,7 @@ endfunction()
# S T A C K : d e p r e c a t e d u s e s t a c k m a i n i n s t e a d
# S T A C K _ M A I N : s i z e o f s t a c k f o r m a i n f u n c t i o n
# S T A C K _ M A X : m a x i m u m s t a c k s i z e o f a n y f r a m e
# C O M P I L E _ F L A G S : c o m p i l e f l a g s
# C O M P I L E _ F L A G S : c o m p i l e f l a g s
# L I N K _ F L A G S : l i n k f l a g s
# S R C S : s o u r c e f i l e s
# I N C L U D E S : i n c l u d e d i r e c t o r i e s
@ -277,7 +198,7 @@ function(px4_add_module)
@@ -277,7 +198,7 @@ function(px4_add_module)
R E Q U I R E D M O D U L E
A R G N $ { A R G N } )
if ( EXTERNAL )
if ( EXTERNAL )
px4_mangle_name ( "${EXTERNAL_MODULES_LOCATION}/src/${MODULE}" MODULE )
endif ( )
@ -352,260 +273,6 @@ function(px4_add_module)
@@ -352,260 +273,6 @@ function(px4_add_module)
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ g e n e r a t e _ m e s s a g e s
#
# T h i s f u n c t i o n g e n e r a t e s s o u r c e c o d e f r o m R O S m s g d e f i n i t i o n s .
#
# U s a g e :
# px4_generate_messages ( TARGET <target> MSGS <msg-files> )
#
# I n p u t :
# M S G _ F I L E S : t h e R O S m s g s t o g e n e r a t e f i l e s f r o m
# O S : t h e o p e r a t i n g s y s t e m s e l e c t e d
# D E P E N D S : d e p e n d e n c i e s
#
# O u t p u t :
# T A R G E T : t h e m e s s a g e g e n e r a t i o n t a r g e t
#
# E x a m p l e :
# px4_generate_messages ( TARGET <target>
# M S G _ F I L E S < f i l e s > O S < o p e r a t i n g - s y s t e m >
# [ D E P E N D S < d e p e n d e n c i e s > ]
# )
#
function ( px4_generate_messages )
px4_parse_function_args (
N A M E p x 4 _ g e n e r a t e _ m e s s a g e s
O P T I O N S V E R B O S E
O N E _ V A L U E O S T A R G E T
M U L T I _ V A L U E M S G _ F I L E S D E P E N D S I N C L U D E S
R E Q U I R E D M S G _ F I L E S O S T A R G E T
A R G N $ { A R G N } )
if ( "${config_nuttx_config}" STREQUAL "bootloader" )
else ( )
set ( QUIET )
if ( NOT VERBOSE )
set ( QUIET "-q" )
endif ( )
# h e a d e r s
set ( msg_out_path ${ PX4_BINARY_DIR } /src/modules/uORB/topics )
set ( msg_list )
foreach ( msg_file ${ MSG_FILES } )
get_filename_component ( msg ${ msg_file } NAME_WE )
list ( APPEND msg_list ${ msg } )
endforeach ( )
set ( msg_files_out )
foreach ( msg ${ msg_list } )
list ( APPEND msg_files_out ${ msg_out_path } / ${ msg } .h )
endforeach ( )
add_custom_command ( OUTPUT ${ msg_files_out }
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E }
T o o l s / p x _ g e n e r a t e _ u o r b _ t o p i c _ f i l e s . p y
- - h e a d e r s
$ { Q U I E T }
- f $ { M S G _ F I L E S }
- i $ { I N C L U D E S }
- o $ { m s g _ o u t _ p a t h }
- e m s g / t e m p l a t e s / u o r b
- t $ { P X 4 _ B I N A R Y _ D I R } / t o p i c s _ t e m p o r a r y _ h e a d e r
D E P E N D S $ { D E P E N D S } $ { M S G _ F I L E S }
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ S O U R C E _ D I R }
C O M M E N T " G e n e r a t i n g u O R B t o p i c h e a d e r s "
V E R B A T I M
)
# ! s o u r c e s
set ( msg_source_out_path ${ PX4_BINARY_DIR } /topics_sources )
set ( msg_source_files_out ${ msg_source_out_path } /uORBTopics.cpp )
foreach ( msg ${ msg_list } )
list ( APPEND msg_source_files_out ${ msg_source_out_path } / ${ msg } .cpp )
endforeach ( )
add_custom_command ( OUTPUT ${ msg_source_files_out }
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E }
T o o l s / p x _ g e n e r a t e _ u o r b _ t o p i c _ f i l e s . p y
- - s o u r c e s
$ { Q U I E T }
- f $ { M S G _ F I L E S }
- i $ { I N C L U D E S }
- o $ { m s g _ s o u r c e _ o u t _ p a t h }
- e m s g / t e m p l a t e s / u o r b
- t $ { P X 4 _ B I N A R Y _ D I R } / t o p i c s _ t e m p o r a r y _ s o u r c e s
D E P E N D S $ { D E P E N D S } $ { M S G _ F I L E S }
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ S O U R C E _ D I R }
C O M M E N T " G e n e r a t i n g u O R B t o p i c s o u r c e s "
V E R B A T I M
)
set_source_files_properties ( ${ msg_source_files_out } PROPERTIES GENERATED TRUE )
# m u l t i m e s s a g e s f o r t a r g e t O S
set ( msg_multi_out_path
$ { P X 4 _ B I N A R Y _ D I R } / s r c / p l a t f o r m s / $ { O S } / p x 4 _ m e s s a g e s )
set ( msg_multi_files_out )
foreach ( msg ${ msg_list } )
list ( APPEND msg_multi_files_out ${ msg_multi_out_path } /px4_ ${ msg } .h )
endforeach ( )
add_custom_command ( OUTPUT ${ msg_multi_files_out }
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E }
T o o l s / p x _ g e n e r a t e _ u o r b _ t o p i c _ f i l e s . p y
- - h e a d e r s
$ { Q U I E T }
- f $ { M S G _ F I L E S }
- i $ { I N C L U D E S }
- o $ { m s g _ m u l t i _ o u t _ p a t h }
- e m s g / t e m p l a t e s / p x 4 / u o r b
- t $ { P X 4 _ B I N A R Y _ D I R } / m u l t i _ t o p i c s _ t e m p o r a r y / $ { O S }
- p " p x 4 _ "
D E P E N D S $ { D E P E N D S } $ { M S G _ F I L E S }
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ S O U R C E _ D I R }
C O M M E N T " G e n e r a t i n g u O R B t o p i c m u l t i h e a d e r s f o r $ { O S } "
V E R B A T I M
)
px4_add_library ( ${ TARGET }
$ { m s g _ s o u r c e _ f i l e s _ o u t }
$ { m s g _ m u l t i _ f i l e s _ o u t }
$ { m s g _ f i l e s _ o u t }
)
endif ( )
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ a d d _ u p l o a d
#
# T h i s f u n c t i o n g e n e r a t e s s o u r c e c o d e f r o m R O S m s g d e f i n i t i o n s .
#
# U s a g e :
# px4_add_upload ( OUT <target> BUNDLE <file.px4> )
#
# I n p u t :
# B U N D L E : t h e f i r m w a r e . p x 4 f i l e
# O S : t h e o p e r a t i n g s y s t e m
# B O A R D : t h e b o a r d
#
# O u t p u t :
# O U T : t h e f i r m w a r e t a r g e t
#
# E x a m p l e :
# px4_add_upload ( OUT upload
# B U N D L E m a i n . p x 4
# )
#
function ( px4_add_upload )
px4_parse_function_args (
N A M E p x 4 _ a d d _ u p l o a d
O N E _ V A L U E O S B O A R D O U T B U N D L E
R E Q U I R E D O S B O A R D O U T B U N D L E
A R G N $ { A R G N } )
set ( serial_ports )
if ( ${ CMAKE_HOST_SYSTEM_NAME } STREQUAL "Linux" )
list ( APPEND serial_ports
/ d e v / s e r i a l / b y - i d / * _ P X 4 _ *
/ d e v / s e r i a l / b y - i d / u s b - 3 D _ R o b o t i c s *
/ d e v / s e r i a l / b y - i d / u s b - T h e _ A u t o p i l o t *
/ d e v / s e r i a l / b y - i d / u s b - B i t c r a z e *
/ d e v / s e r i a l / b y - i d / p c i - 3 D _ R o b o t i c s *
/ d e v / s e r i a l / b y - i d / p c i - B i t c r a z e *
/ d e v / s e r i a l / b y - i d / u s b - G u m s t i x *
)
elseif ( ${ CMAKE_HOST_SYSTEM_NAME } STREQUAL "Darwin" )
list ( APPEND serial_ports
/ d e v / t t y . u s b m o d e m P X * , / d e v / t t y . u s b m o d e m *
)
elseif ( ${ CMAKE_HOST_SYSTEM_NAME } STREQUAL "Windows" )
foreach ( port RANGE 32 0 )
list ( APPEND serial_ports
" C O M $ { p o r t } " )
endforeach ( )
endif ( )
px4_join ( OUT serial_ports LIST "${serial_ports}" GLUE "," )
add_custom_target ( ${ OUT }
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E }
$ { P X 4 _ S O U R C E _ D I R } / T o o l s / p x _ u p l o a d e r . p y - - p o r t $ { s e r i a l _ p o r t s } $ { B U N D L E }
D E P E N D S $ { B U N D L E }
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ B I N A R Y _ D I R }
C O M M E N T " u p l o a d i n g $ { B U N D L E } "
V E R B A T I M
U S E S _ T E R M I N A L
)
endfunction ( )
function ( px4_add_adb_push )
px4_parse_function_args (
N A M E p x 4 _ a d d _ u p l o a d
O N E _ V A L U E O S B O A R D O U T D E S T
M U L T I _ V A L U E F I L E S D E P E N D S
R E Q U I R E D O S B O A R D O U T F I L E S D E P E N D S D E S T
A R G N $ { A R G N } )
add_custom_target ( ${ OUT }
C O M M A N D $ { P X 4 _ S O U R C E _ D I R } / T o o l s / a d b _ u p l o a d . s h $ { F I L E S } $ { D E S T }
D E P E N D S $ { D E P E N D S }
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ B I N A R Y _ D I R }
C O M M E N T " u p l o a d i n g $ { B U N D L E } "
V E R B A T I M
U S E S _ T E R M I N A L
)
endfunction ( )
function ( px4_add_adb_push_to_bebop )
px4_parse_function_args (
N A M E p x 4 _ a d d _ u p l o a d _ t o _ b e b o p
O N E _ V A L U E O S B O A R D O U T D E S T
M U L T I _ V A L U E F I L E S D E P E N D S
R E Q U I R E D O S B O A R D O U T F I L E S D E P E N D S D E S T
A R G N $ { A R G N } )
add_custom_target ( ${ OUT }
C O M M A N D $ { P X 4 _ S O U R C E _ D I R } / T o o l s / a d b _ u p l o a d _ t o _ b e b o p . s h $ { F I L E S } $ { D E S T }
D E P E N D S $ { D E P E N D S }
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ B I N A R Y _ D I R }
C O M M E N T " u p l o a d i n g $ { B U N D L E } "
V E R B A T I M
U S E S _ T E R M I N A L
)
endfunction ( )
function ( px4_add_scp_push )
px4_parse_function_args (
N A M E p x 4 _ a d d _ u p l o a d
O N E _ V A L U E O S B O A R D O U T D E S T
M U L T I _ V A L U E F I L E S D E P E N D S
R E Q U I R E D O S B O A R D O U T F I L E S D E P E N D S D E S T
A R G N $ { A R G N } )
add_custom_target ( ${ OUT }
C O M M A N D $ { P X 4 _ S O U R C E _ D I R } / T o o l s / s c p _ u p l o a d . s h $ { F I L E S } $ { D E S T }
D E P E N D S $ { D E P E N D S }
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ B I N A R Y _ D I R }
C O M M E N T " u p l o a d i n g $ { B U N D L E } "
V E R B A T I M
U S E S _ T E R M I N A L
)
endfunction ( )
function ( px4_add_upload_aero )
px4_parse_function_args (
N A M E p x 4 _ a d d _ u p l o a d _ a e r o
O N E _ V A L U E O S B O A R D O U T B U N D L E
R E Q U I R E D O S B O A R D O U T B U N D L E
A R G N $ { A R G N } )
add_custom_target ( ${ OUT }
C O M M A N D $ { P X 4 _ S O U R C E _ D I R } / T o o l s / a e r o _ u p l o a d . s h $ { B U N D L E }
D E P E N D S $ { B U N D L E }
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ B I N A R Y _ D I R }
C O M M E N T " u p l o a d i n g $ { B U N D L E } "
V E R B A T I M
U S E S _ T E R M I N A L
)
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ a d d _ c o m m o n _ f l a g s
@ -657,27 +324,21 @@ function(px4_add_common_flags)
@@ -657,27 +324,21 @@ function(px4_add_common_flags)
set ( warnings
- W a l l
- W a r r a y - b o u n d s
- W e r r o r
- W e x t r a
- W n o - s i g n - c o m p a r e
- W s h a d o w
- W f a t a l - e r r o r s
- W f l o a t - e q u a l
- W p o i n t e r - a r i t h
- W f o r m a t - s e c u r i t y
- W i n i t - s e l f
- W m i s s i n g - d e c l a r a t i o n s
- W p o i n t e r - a r i t h
- W s h a d o w
- W u n i n i t i a l i z e d
- W u n u s e d - v a r i a b l e
- W n o - s i g n - c o m p a r e
- W n o - u n u s e d - p a r a m e t e r
- W e r r o r = f o r m a t - s e c u r i t y
- W e r r o r = a r r a y - b o u n d s
- W f a t a l - e r r o r s
- W e r r o r = u n u s e d - v a r i a b l e
- W e r r o r = r e o r d e r
- W e r r o r = u n i n i t i a l i z e d
- W e r r o r = i n i t - s e l f
# - W c a s t - q u a l - g e n e r a t e s s p u r i o u s n o r e t u r n a t t r i b u t e w a r n i n g s ,
# t r y a g a i n l a t e r
# - W c o n v e r s i o n - w o u l d b e n i c e , b u t t o o m a n y " r i s k y - b u t - s a f e "
# c o n v e r s i o n s i n t h e c o d e
# - W c a s t - a l i g n - w o u l d h e l p c a t c h b a d c a s t s i n s o m e c a s e s ,
# b u t g e n e r a t e s t o o m a n y f a l s e p o s i t i v e s
)
if ( ${ CMAKE_C_COMPILER_ID } MATCHES ".*Clang.*" )
@ -693,111 +354,25 @@ function(px4_add_common_flags)
@@ -693,111 +354,25 @@ function(px4_add_common_flags)
endif ( )
else ( )
list ( APPEND warnings
- W e r r o r = u n u s e d - b u t - s e t - v a r i a b l e
- W u n u s e d - b u t - s e t - v a r i a b l e
- W f o r m a t = 1
# - W l o g i c a l - o p # v e r y v e r b o s e d u e t o e i g e n
- W d o u b l e - p r o m o t i o n
- W e r r o r = d o u b l e - p r o m o t i o n
)
endif ( )
# o p t i m i z a t i o n f l a g s a n d santiziers ( ASAN, TSAN, UBSAN )
if ( $ENV{ PX4_ASAN } MATCHES "1" )
message ( STATUS "address sanitizer enabled" )
# e n v i r o n m e n t v a r i a b l e s
# A S A N _ O P T I O N S = d e t e c t _ s t a c k _ u s e _ a f t e r _ r e t u r n = 1
# A S A N _ O P T I O N S = c h e c k _ i n i t i a l i z a t i o n _ o r d e r = 1
set ( max_optimization -O1 )
# D o n o t u s e optimization_flags ( without _ ) a s t h a t i s a l r e a d y u s e d .
set ( _optimization_flags
- f n o - s t r i c t - a l i a s i n g
- f n o - o m i t - f r a m e - p o i n t e r
- f u n s a f e - m a t h - o p t i m i z a t i o n s
- f f u n c t i o n - s e c t i o n s
- f d a t a - s e c t i o n s
- g 3 - f s a n i t i z e = a d d r e s s
# - f s a n i t i z e - a d d r e s s - u s e - a f t e r - s c o p e
)
elseif ( $ENV{ PX4_TSAN } MATCHES "1" )
message ( STATUS "thread sanitizer enabled" )
# n e e d s s o m e o p t i m i z a t i o n f o r u s a b l e p e r f o r m a n c e
set ( max_optimization -O1 )
# D o n o t u s e optimization_flags ( without _ ) a s t h a t i s a l r e a d y u s e d .
set ( _optimization_flags
- f n o - s t r i c t - a l i a s i n g
- f n o - o m i t - f r a m e - p o i n t e r
- f u n s a f e - m a t h - o p t i m i z a t i o n s
- f f u n c t i o n - s e c t i o n s
- f d a t a - s e c t i o n s
- g 3 - f s a n i t i z e = t h r e a d
)
elseif ( $ENV{ PX4_UBSAN } MATCHES "1" )
message ( STATUS "undefined behaviour sanitizer enabled" )
set ( max_optimization -O2 )
# D o n o t u s e optimization_flags ( without _ ) a s t h a t i s a l r e a d y u s e d .
set ( _optimization_flags
- f n o - s t r i c t - a l i a s i n g
- f n o - o m i t - f r a m e - p o i n t e r
- f u n s a f e - m a t h - o p t i m i z a t i o n s
- f f u n c t i o n - s e c t i o n s
- f d a t a - s e c t i o n s
- g 3
# - f s a n i t i z e = a l i g n m e n t
- f s a n i t i z e = b o o l
- f s a n i t i z e = b o u n d s
- f s a n i t i z e = e n u m
# - f s a n i t i z e = f l o a t - c a s t - o v e r f l o w
- f s a n i t i z e = f l o a t - d i v i d e - b y - z e r o
# - f s a n i t i z e = f u n c t i o n
- f s a n i t i z e = i n t e g e r - d i v i d e - b y - z e r o
- f s a n i t i z e = n o n n u l l - a t t r i b u t e
- f s a n i t i z e = n u l l
- f s a n i t i z e = o b j e c t - s i z e
- f s a n i t i z e = r e t u r n
- f s a n i t i z e = r e t u r n s - n o n n u l l - a t t r i b u t e
- f s a n i t i z e = s h i f t
- f s a n i t i z e = s i g n e d - i n t e g e r - o v e r f l o w
- f s a n i t i z e = u n r e a c h a b l e
# - f s a n i t i z e = u n s i g n e d - i n t e g e r - o v e r f l o w
- f s a n i t i z e = v l a - b o u n d
- f s a n i t i z e = v p t r
)
else ( )
if ( "${OS}" STREQUAL "nuttx" )
set ( max_optimization -Os )
elseif ( ${ BOARD } STREQUAL "bebop" )
set ( max_optimization -Os )
else ( )
set ( max_optimization -O2 )
endif ( )
if ( "${OS}" STREQUAL "qurt" )
set ( PIC_FLAG -fPIC )
endif ( )
set ( _optimization_flags
- f n o - s t r i c t - a l i a s i n g
- f o m i t - f r a m e - p o i n t e r
- f u n s a f e - m a t h - o p t i m i z a t i o n s
- f f u n c t i o n - s e c t i o n s
- f d a t a - s e c t i o n s
$ { P I C _ F L A G }
)
if ( "${OS}" STREQUAL "qurt" )
set ( PIC_FLAG -fPIC )
endif ( )
# c o d e c o v e r a g e
if ( $ENV{ PX4_CODE_COVERAGE } MATCHES "1" )
# set ( max_optimization -O0 )
endif ( )
set ( _optimization_flags
- f n o - s t r i c t - a l i a s i n g
- f o m i t - f r a m e - p o i n t e r
- f u n s a f e - m a t h - o p t i m i z a t i o n s
- f f u n c t i o n - s e c t i o n s
- f d a t a - s e c t i o n s
$ { P I C _ F L A G }
)
set ( c_warnings
- W b a d - f u n c t i o n - c a s t
@ -814,6 +389,7 @@ function(px4_add_common_flags)
@@ -814,6 +389,7 @@ function(px4_add_common_flags)
set ( cxx_warnings
- W n o - m i s s i n g - f i e l d - i n i t i a l i z e r s
- W r e o r d e r
)
set ( cxx_compile_flags
@ -875,7 +451,6 @@ function(px4_add_common_flags)
@@ -875,7 +451,6 @@ function(px4_add_common_flags)
)
set ( added_optimization_flags
$ { m a x _ o p t i m i z a t i o n }
$ { _ o p t i m i z a t i o n _ f l a g s }
)
@ -883,34 +458,26 @@ function(px4_add_common_flags)
@@ -883,34 +458,26 @@ function(px4_add_common_flags)
$ { P X 4 _ B I N A R Y _ D I R }
$ { P X 4 _ B I N A R Y _ D I R } / s r c
$ { P X 4 _ B I N A R Y _ D I R } / s r c / m o d u l e s
$ { P X 4 _ B I N A R Y _ D I R } / s r c / m o d u l e s / p x 4 _ m e s s a g e s
$ { P X 4 _ S O U R C E _ D I R } / m a v l i n k / i n c l u d e / m a v l i n k
$ { P X 4 _ S O U R C E _ D I R } / s r c
$ { P X 4 _ S O U R C E _ D I R } / s r c / d r i v e r s / b o a r d s / $ { B O A R D }
$ { P X 4 _ S O U R C E _ D I R } / s r c / i n c l u d e
$ { P X 4 _ S O U R C E _ D I R } / s r c / l i b
$ { P X 4 _ S O U R C E _ D I R } / s r c / l i b / D r i v e r F r a m e w o r k / f r a m e w o r k / i n c l u d e
$ { P X 4 _ S O U R C E _ D I R } / s r c / l i b / m a t r i x
$ { P X 4 _ S O U R C E _ D I R } / s r c / m o d u l e s
$ { P X 4 _ S O U R C E _ D I R } / s r c / p l a t f o r m s
)
list ( APPEND added_include_dirs
s r c / l i b / m a t r i x
)
set ( added_link_dirs ) # n o n e u s e d c u r r e n t l y
set ( added_exe_linker_flags )
string ( TOUPPER ${ BOARD } board_upper )
string ( REPLACE "-" "_" board_config ${ board_upper } )
set ( added_target_definitions )
if ( NOT ${ target_definitions } )
px4_prepend_string ( OUT added_target_definitions STR "-D" LIST ${ target_definitions } )
endif ( )
set ( added_definitions
- D C O N F I G _ A R C H _ B O A R D _ $ { b o a r d _ c o n f i g }
- D _ _ S T D C _ F O R M A T _ M A C R O S
$ { a d d e d _ t a r g e t _ d e f i n i t i o n s }
)
if ( NOT ( APPLE AND ( ${ CMAKE_C_COMPILER_ID } MATCHES ".*Clang.*" ) ) )
@ -921,20 +488,6 @@ function(px4_add_common_flags)
@@ -921,20 +488,6 @@ function(px4_add_common_flags)
)
endif ( )
# c o d e c o v e r a g e
if ( $ENV{ PX4_CODE_COVERAGE } MATCHES "1" )
message ( STATUS "Code coverage build flags enabled" )
list ( APPEND added_cxx_flags
- f p r o f i l e - a r c s - f t e s t - c o v e r a g e - - c o v e r a g e - g 3 - O 0 - f n o - e l i d e - c o n s t r u c t o r s - W n o - i n v a l i d - o f f s e t o f - f n o - d e f a u l t - i n l i n e - f n o - i n l i n e
)
list ( APPEND added_c_flags
- f p r o f i l e - a r c s - f t e s t - c o v e r a g e - - c o v e r a g e - g 3 - O 0 - f n o - d e f a u l t - i n l i n e - f n o - i n l i n e
)
list ( APPEND added_exe_linker_flags
- f t e s t - c o v e r a g e - - c o v e r a g e - l g c o v
)
endif ( )
# o u t p u t
foreach ( var ${ inout_vars } )
string ( TOLOWER ${ var } lower_var )
@ -969,280 +522,6 @@ function(px4_mangle_name dirname newname)
@@ -969,280 +522,6 @@ function(px4_mangle_name dirname newname)
set ( ${ newname } ${ tmp } PARENT_SCOPE )
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ c r e a t e _ g i t _ h a s h _ h e a d e r
#
# C r e a t e a h e a d e r f i l e c o n t a i n i n g t h e g i t h a s h o f t h e c u r r e n t t r e e
#
# U s a g e :
# px4_create_git_hash_header ( )
#
# E x a m p l e :
# px4_create_git_hash_header ( )
#
function ( px4_create_git_hash_header )
px4_parse_function_args (
N A M E p x 4 _ c r e a t e _ g i t _ h a s h _ h e a d e r
A R G N $ { A R G N } )
set ( px4_git_ver_header ${ PX4_BINARY_DIR } /build_git_version.h )
# c h e c k i f p x 4 s o u r c e i s a g i t r e p o
if ( EXISTS ${ PX4_SOURCE_DIR } /.git )
if ( IS_DIRECTORY ${ PX4_SOURCE_DIR } /.git )
# s t a n d a r d g i t r e p o
set ( git_dir_path ${ PX4_SOURCE_DIR } /.git )
else ( )
# g i t s u b m o d u l e
file ( READ ${ PX4_SOURCE_DIR } /.git git_dir_path )
string ( STRIP ${ git_dir_path } git_dir_path )
string ( REPLACE "gitdir: " "" git_dir_path ${ git_dir_path } )
get_filename_component ( git_dir_path ${ git_dir_path } ABSOLUTE )
endif ( )
else ( )
message ( FATAL_ERROR "is not a git repository" )
endif ( )
if ( NOT IS_DIRECTORY "${git_dir_path}" )
message ( FATAL_ERROR "${git_dir_path} is not a directory" )
endif ( )
set ( deps
$ { P X 4 _ S O U R C E _ D I R } / T o o l s / p x _ u p d a t e _ g i t _ h e a d e r . p y
$ { g i t _ d i r _ p a t h } / i n d e x
$ { g i t _ d i r _ p a t h } / H E A D )
add_custom_command (
O U T P U T $ { p x 4 _ g i t _ v e r _ h e a d e r }
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } $ { P X 4 _ S O U R C E _ D I R } / T o o l s / p x _ u p d a t e _ g i t _ h e a d e r . p y $ { p x 4 _ g i t _ v e r _ h e a d e r } > $ { P X 4 _ B I N A R Y _ D I R } / g i t _ h e a d e r . l o g
D E P E N D S $ { d e p s }
W O R K I N G _ D I R E C T O R Y $ { P X 4 _ S O U R C E _ D I R }
C O M M E N T " G e n e r a t i n g g i t h a s h h e a d e r "
)
set_source_files_properties ( ${ px4_git_ver_header } PROPERTIES GENERATED TRUE )
add_custom_target ( ver_gen ALL DEPENDS ${ px4_git_ver_header } )
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ g e n e r a t e _ p a r a m e t e r s _ x m l
#
# G e n e r a t e s a p a r a m e t e r s . x m l f i l e .
#
# U s a g e :
# px4_generate_parameters_xml ( OUT <param-xml_file> )
#
# I n p u t :
# B O A R D : t h e b o a r d
# M O D U L E S : a l i s t o f p x 4 m o d u l e s u s e d t o l i m i t s c o p e o f t h e p a r a m a t e r s
# O V E R R I D E S : A j s o n d i c t w i t h p a r a m n a m e s a s k e y s a n d p a r a m d e f a u l t
# o v e r r i d e s a s v a l u e s
#
# O u t p u t :
# O U T : t h e g e n e r a t e d x m l f i l e
#
# E x a m p l e :
# px4_generate_parameters_xml ( OUT parameters.xml )
#
function ( px4_generate_parameters_xml )
px4_parse_function_args (
N A M E p x 4 _ g e n e r a t e _ p a r a m e t e r s _ x m l
O N E _ V A L U E O U T B O A R D O V E R R I D E S
M U L T I _ V A L U E M O D U L E S
R E Q U I R E D M O D U L E S O U T B O A R D
A R G N $ { A R G N } )
set ( path ${ PX4_SOURCE_DIR } /src )
file ( GLOB_RECURSE param_src_files
$ { P X 4 _ S O U R C E _ D I R } / s r c / * p a r a m s . c
)
if ( NOT OVERRIDES )
set ( OVERRIDES "{}" )
endif ( )
# g e t f u l l p a t h f o r e a c h m o d u l e
set ( module_list )
if ( DISABLE_PARAMS_MODULE_SCOPING )
set ( module_list ${ path } )
else ( )
foreach ( module ${ MODULES } )
list ( APPEND module_list ${ PX4_SOURCE_DIR } /src/ ${ module } )
endforeach ( )
endif ( )
add_custom_command ( OUTPUT ${ OUT }
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } $ { P X 4 _ S O U R C E _ D I R } / T o o l s / p x _ p r o c e s s _ p a r a m s . p y
- s $ { m o d u l e _ l i s t } $ { E X T E R N A L _ M O D U L E S _ L O C A T I O N }
- - b o a r d C O N F I G _ A R C H _ $ { B O A R D } - - x m l - - i n j e c t - x m l
- - o v e r r i d e s $ { O V E R R I D E S }
D E P E N D S $ { p a r a m _ s r c _ f i l e s } $ { P X 4 _ S O U R C E _ D I R } / T o o l s / p x _ p r o c e s s _ p a r a m s . p y
$ { P X 4 _ S O U R C E _ D I R } / T o o l s / p x _ g e n e r a t e _ p a r a m s . p y
)
set ( ${ OUT } ${ ${OUT } } PARENT_SCOPE )
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ g e n e r a t e _ p a r a m e t e r s _ s o u r c e
#
# G e n e r a t e s a s o u r c e f i l e w i t h a l l p a r a m e t e r s .
#
# U s a g e :
# px4_generate_parameters_source ( OUT <list-source-files> XML <param-xml-file> MODULES px4 module list )
#
# I n p u t :
# X M L : t h e p a r a m e t e r s . x m l f i l e
# M O D U L E S : a l i s t o f p x 4 m o d u l e s u s e d t o l i m i t s c o p e o f t h e p a r a m a t e r s
# D E P S : t a r g e t d e p e n d e n c i e s
#
# O u t p u t :
# O U T : t h e g e n e r a t e d s o u r c e f i l e s
#
# E x a m p l e :
# px4_generate_parameters_source ( OUT param_files XML parameters.xml MODULES lib/controllib modules/ekf2 )
#
function ( px4_generate_parameters_source )
px4_parse_function_args (
N A M E p x 4 _ g e n e r a t e _ p a r a m e t e r s _ s o u r c e
O N E _ V A L U E O U T X M L D E P S
M U L T I _ V A L U E M O D U L E S
R E Q U I R E D M O D U L E S O U T X M L
A R G N $ { A R G N } )
set ( generated_files
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / p x 4 _ p a r a m e t e r s . h
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / p x 4 _ p a r a m e t e r s . c )
set_source_files_properties ( ${ generated_files }
P R O P E R T I E S G E N E R A T E D T R U E )
if ( DISABLE_PARAMS_MODULE_SCOPING )
add_custom_command ( OUTPUT ${ generated_files }
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } $ { P X 4 _ S O U R C E _ D I R } / T o o l s / p x _ g e n e r a t e _ p a r a m s . p y
- - x m l $ { X M L } - - d e s t $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
D E P E N D S $ { X M L } $ { D E P S }
)
else ( )
px4_join ( OUT module_list LIST ${ MODULES } GLUE "," )
add_custom_command ( OUTPUT ${ generated_files }
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } $ { P X 4 _ S O U R C E _ D I R } / T o o l s / p x _ g e n e r a t e _ p a r a m s . p y
- - x m l $ { X M L } - - m o d u l e s $ { m o d u l e _ l i s t } - - d e s t $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
D E P E N D S $ { X M L } $ { D E P S }
)
endif ( )
set ( ${ OUT } ${ generated_files } PARENT_SCOPE )
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ g e n e r a t e _ a i r f r a m e s _ x m l
#
# G e n e r a t e s a i r f r a m e s . x m l
#
# U s a g e :
# px4_generate_airframes_xml ( OUT <airframe-xml-file> )
#
# I n p u t :
# X M L : t h e a i r f r a m e s . x m l f i l e
# B O A R D : t h e b o a r d
#
# O u t p u t :
# O U T : t h e g e n e r a t e d s o u r c e f i l e s
#
# E x a m p l e :
# px4_generate_airframes_xml ( OUT airframes.xml )
#
function ( px4_generate_airframes_xml )
px4_parse_function_args (
N A M E p x 4 _ g e n e r a t e _ a i r f r a m e s _ x m l
O N E _ V A L U E O U T B O A R D
R E Q U I R E D O U T B O A R D
A R G N $ { A R G N } )
set ( process_airframes ${ PX4_SOURCE_DIR } /Tools/px_process_airframes.py )
add_custom_command ( OUTPUT ${ OUT }
C O M M A N D $ { P Y T H O N _ E X E C U T A B L E } $ { p r o c e s s _ a i r f r a m e s }
- a $ { P X 4 _ S O U R C E _ D I R } / R O M F S / $ { c o n f i g _ r o m f s _ r o o t } / i n i t . d
- - b o a r d C O N F I G _ A R C H _ B O A R D _ $ { B O A R D } - - x m l
)
set ( ${ OUT } ${ ${OUT } } PARENT_SCOPE )
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ c o p y _ t r a c k e d
#
# C o p y f i l e s t o a d i r e c t o r y a n d k e e p t r a c k o f d e p e n d e n c i e s .
#
# U s a g e :
# px4_copy_tracked ( OUT <dest-files> FILES <in-files> DIR <dir-name> )
#
# I n p u t :
# F I L E S : t h e s o u r c e f i l e s
# D E S T : t h e d i r e c t o r y t o c o p y f i l e s t o
# R E L A T I V E : r e l a t i v e d i r e c t o r y f o r s o u r c e f i l e s
#
# O u t p u t :
# O U T : t h e c o p i e d f i l e s
#
# E x a m p l e :
# px4_copy_tracked ( OUT copied_files FILES src_files DEST path RELATIVE path_rel )
#
function ( px4_copy_tracked )
px4_parse_function_args (
N A M E p x 4 _ c o p y _ t r a c k e d
O N E _ V A L U E D E S T O U T R E L A T I V E
M U L T I _ V A L U E F I L E S
R E Q U I R E D D E S T O U T F I L E S
A R G N $ { A R G N } )
set ( files )
# b e f o r e b u i l d , m a k e s u r e d e s t d i r e c t o r y e x i s t s
execute_process (
C O M M A N D c m a k e - E m a k e _ d i r e c t o r y $ { D E S T } )
# c r e a t e r u l e t o c o p y e a c h f i l e a n d s e t d e p e n d e n c y a s s o u r c e f i l e
set ( _files_out )
foreach ( _file ${ FILES } )
if ( RELATIVE )
file ( RELATIVE_PATH _file_path ${ RELATIVE } ${ _file } )
else ( )
set ( _file_path ${ _file } )
endif ( )
set ( _dest_file ${ DEST } / ${ _file_path } )
# message ( STATUS "copy ${_file} -> ${_dest_file}" )
add_custom_command ( OUTPUT ${ _dest_file }
C O M M A N D c m a k e - E c o p y $ { _ f i l e } $ { _ d e s t _ f i l e }
D E P E N D S $ { _ f i l e } )
list ( APPEND _files_out ${ _dest_file } )
endforeach ( )
set ( ${ OUT } ${ _files_out } PARENT_SCOPE )
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ s h a r e _ s u b d i r e c t o r y
#
# T h i s f u n c t i o n s i m p l i f e s s h a r i n g a s u b d i r e c t o r y
#
# U s a g e :
# px4_share_subdirectory ( RELDIR <relative path> ARGS <args> )
#
# I n p u t :
# R E L D I R : T h e r e l i t i v e p a t h t o s h a r e .
# A R G S : A n y o p t i o n a l a r g u m e n t s t o p a s s t o a d d _ s u b d i r e c t o r y
#
# O u t p u t :
# : N o n e
#
# E x a m p l e :
# px4_share_subdirectory ( RELDIR ../uavcan/libuavcan ARGS EXCLUDE_FROM_ALL )
#
function ( px4_share_subdirectory )
px4_parse_function_args (
N A M E p x 4 _ s h a r e _ s u b d i r e c t o r y
O N E _ V A L U E O U T R E L D I R
M U L T I _ V A L U E A R G S
R E Q U I R E D R E L D I R
A R G N $ { A R G N } )
add_subdirectory ( ${ RELDIR } ${ RELDIR } / ${ RELDIR } ${ ARGS } )
endfunction ( )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
#
# p x 4 _ s t r i p _ o p t i m i z a t i o n