@@ -85,8 +85,8 @@ const outPathOption = new Option(
8585const defineOption = new Option (
8686 "-D,--define <entry...>" ,
8787 "Define cache variables passed when configuring projects" ,
88- ) . argParser < Record < string , string | CmakeTypedDefinition > > (
89- ( input , previous = { } ) => {
88+ )
89+ . argParser < Array < Record < string , string > > > ( ( input , previous = [ ] ) => {
9090 // TODO: Implement splitting of value using a regular expression (using named groups) for the format <var>[:<type>]=<value>
9191 // and return an object keyed by variable name with the string value as value or alternatively an array of [value, type]
9292 const match = input . match (
@@ -98,9 +98,9 @@ const defineOption = new Option(
9898 ) ;
9999 }
100100 const { name, type, value } = match . groups ;
101- return { ...previous , [ name ] : type ? { value , type } : value } ;
102- } ,
103- ) ;
101+ return [ ...previous , { [ type ? name : ` ${ name } : ${ type } ` ] : value } ] ;
102+ } )
103+ . default ( [ ] ) ;
104104
105105const targetOption = new Option (
106106 "--target <target...>" ,
@@ -302,13 +302,13 @@ async function configureProject<T extends string>(
302302 weakNodeApiLinkage && isSupportedTriplet ( triplet )
303303 ? getWeakNodeApiVariables ( triplet )
304304 : // TODO: Make this a part of the platform definition
305- { } ;
305+ [ ] ;
306306
307- const definitions = {
307+ const definitions = [
308308 ...nodeApiDefinitions ,
309309 ...options . define ,
310- CMAKE_LIBRARY_OUTPUT_DIRECTORY : outputPath ,
311- } ;
310+ { CMAKE_LIBRARY_OUTPUT_DIRECTORY : outputPath } ,
311+ ] ;
312312
313313 await spawn (
314314 "cmake" ,
@@ -352,18 +352,13 @@ async function buildProject<T extends string>(
352352 ) ;
353353}
354354
355- type CmakeTypedDefinition = { value : string ; type : string } ;
356-
357- function toDefineArguments (
358- declarations : Record < string , string | CmakeTypedDefinition > ,
359- ) {
360- return Object . entries ( declarations ) . flatMap ( ( [ key , definition ] ) => {
361- if ( typeof definition === "string" ) {
362- return [ "-D" , `${ key } =${ definition } ` ] ;
363- } else {
364- return [ "-D" , `${ key } :${ definition . type } =${ definition . value } ` ] ;
365- }
366- } ) ;
355+ function toDefineArguments ( declarations : Array < Record < string , string > > ) {
356+ return declarations . flatMap ( ( values ) =>
357+ Object . entries ( values ) . flatMap ( ( [ key , definition ] ) => [
358+ "-D" ,
359+ `${ key } =${ definition } ` ,
360+ ] ) ,
361+ ) ;
367362}
368363
369364export { program } ;
0 commit comments