@@ -2668,6 +2668,10 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
26682668 . map ( d => ePrjRoot . ToRelativePath ( d . path ) || d . path ) ;
26692669 }
26702670
2671+ // init source args
2672+ const srcOptsObj = < SourceFileOptions > { version : EIDE_FILE_OPTION_VERSION , options : { } } ;
2673+ srcOptsObj . version = EIDE_FILE_OPTION_VERSION ;
2674+
26712675 // init all target
26722676 for ( const eTarget of ePrjInfo . targets ) {
26732677
@@ -2687,108 +2691,48 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
26872691 }
26882692 } ;
26892693
2690- nEideTarget . custom_dep . defineList = eTarget . globalArgs . cMacros ;
2691- nEideTarget . custom_dep . incList = eTarget . globalArgs . cIncDirs ;
2692-
2693- var getRootIncompatibleArgs = ( t : eclipseParser . EclipseProjectTarget ) : string [ ] => {
2694-
2695- const res : string [ ] = [ ] ;
2696-
2697- if ( ! t . incompatibleArgs [ '/' ] ) return res ;
2698- const bArgs : any = t . incompatibleArgs [ '/' ] ;
2699- for ( const key in bArgs ) {
2700- if ( ! isArray ( bArgs [ key ] ) ) continue ;
2701- for ( const arg of bArgs [ key ] ) {
2702- res . push ( arg ) ;
2703- }
2704- }
2705-
2706- return res ;
2707- } ;
2694+ nEideTarget . custom_dep . defineList = eTarget . builldArgs . cMacros ;
2695+ nEideTarget . custom_dep . incList = eTarget . builldArgs . cIncDirs ;
2696+ nEideTarget . custom_dep . libList = eTarget . builldArgs . linkerLibSearchDirs ;
27082697
27092698 // for arm gcc toolchain
27102699 if ( nEideTarget . toolchain == 'GCC' ) {
27112700
2712- var guessArmCpuType = ( t : eclipseParser . EclipseProjectTarget ) : string | undefined => {
2713-
2701+ var guessArmCpuType = ( archName ?: string ) : string | undefined => {
2702+ if ( ! archName )
2703+ return undefined ;
27142704 // @note : this list is trimed, not full
2715- const armCpuTypeList = [
2716- 'Cortex-M0' ,
2717- 'Cortex-M23' ,
2718- 'Cortex-M33' ,
2719- 'Cortex-M3' ,
2720- 'Cortex-M4' ,
2721- 'Cortex-M7'
2722- ] ;
2723-
2724- for ( const arg of getRootIncompatibleArgs ( t ) ) {
2725- const mRes = / ( c o r t e x - m [ \w \+ ] + ) / . exec ( arg ) ;
2726- if ( mRes && mRes . length > 1 ) {
2727- const name = mRes [ 1 ] . toLowerCase ( ) ;
2728- const idx = armCpuTypeList . map ( c => c . toLowerCase ( ) )
2729- . findIndex ( c => name == c || name . startsWith ( c ) ) ;
2730- if ( idx != - 1 ) return armCpuTypeList [ idx ] ;
2731- }
2732- }
2705+ const armCpuTypeMap : any = {
2706+ 'cortex-m0plus' : 'Cortex-M0+' ,
2707+ 'cortex-m0+' : 'Cortex-M0+' ,
2708+ 'cortex-m23' : 'Cortex-M23' ,
2709+ 'cortex-m33' : 'Cortex-M33' ,
2710+ 'cortex-m35p' : 'Cortex-M35P' ,
2711+ 'cortex-m55' : 'Cortex-M55' ,
2712+ 'cortex-m85' : 'Cortex-M85' ,
2713+ 'cortex-m0' : 'Cortex-M0' ,
2714+ 'cortex-m3' : 'Cortex-M3' ,
2715+ 'cortex-m4' : 'Cortex-M4' ,
2716+ 'cortex-m7' : 'Cortex-M7'
2717+ } ;
2718+ return armCpuTypeMap [ archName . toLowerCase ( ) ] ;
27332719 } ;
27342720
27352721 const compilerOpt = < ArmBaseCompileData > nEideTarget . compileConfig ;
2736- compilerOpt . cpuType = guessArmCpuType ( eTarget ) || 'Cortex-M3' ;
2722+ compilerOpt . cpuType = guessArmCpuType ( eTarget . archName ) || 'Cortex-M3' ;
27372723 compilerOpt . floatingPointHardware = ArmCpuUtils . hasFpu ( compilerOpt . cpuType ) ? 'single' : 'none' ;
27382724 compilerOpt . useCustomScatterFile = true ;
2739- compilerOpt . scatterFilePath = '' ;
2740-
2741- getRootIncompatibleArgs ( eTarget ) . forEach ( arg => {
2742- if ( / l i n k e r s c r i p t / i. test ( arg ) ) {
2743- const mRes = / [ ^ = ] + = ( .+ ) $ / . exec ( arg ) ;
2744- if ( mRes && mRes . length > 1 ) {
2745- const p = eclipseParser . formatFilePath ( mRes [ 1 ] . trim ( ) ) ;
2746- if ( / \. l d [ s ] ? $ / i. test ( p ) ) {
2747- compilerOpt . scatterFilePath = p ;
2748- }
2749- }
2750- }
2751- } ) ;
2725+ compilerOpt . scatterFilePath = eTarget . linkerScriptPath || '' ;
27522726 }
2753-
27542727 // for riscv gcc toolchain
27552728 else if ( nEideTarget . toolchain == 'RISCV_GCC' ) {
2756-
27572729 const compilerOpt = < RiscvCompileData > nEideTarget . compileConfig ;
2758-
2759- compilerOpt . linkerScriptPath = '' ;
2760-
2761- getRootIncompatibleArgs ( eTarget ) . forEach ( arg => {
2762- if ( / l i n k e r s c r i p t / i. test ( arg ) ) {
2763- const mRes = / [ ^ = ] + = ( .+ ) $ / . exec ( arg ) ;
2764- if ( mRes && mRes . length > 1 ) {
2765- const p = eclipseParser . formatFilePath ( mRes [ 1 ] . trim ( ) ) ;
2766- if ( / \. l d [ s ] ? $ / i. test ( p ) ) {
2767- compilerOpt . linkerScriptPath = p ;
2768- }
2769- }
2770- }
2771- } ) ;
2730+ compilerOpt . linkerScriptPath = eTarget . linkerScriptPath || '' ;
27722731 }
2773-
27742732 // for any gcc toolchain
27752733 else if ( nEideTarget . toolchain == 'ANY_GCC' ) {
2776-
27772734 const compilerOpt = < AnyGccCompileData > nEideTarget . compileConfig ;
2778-
2779- compilerOpt . linkerScriptPath = '' ;
2780-
2781- getRootIncompatibleArgs ( eTarget ) . forEach ( arg => {
2782- if ( / l i n k e r s c r i p t / i. test ( arg ) ) {
2783- const mRes = / [ ^ = ] + = ( .+ ) $ / . exec ( arg ) ;
2784- if ( mRes && mRes . length > 1 ) {
2785- const p = eclipseParser . formatFilePath ( mRes [ 1 ] . trim ( ) ) ;
2786- if ( / \. l d [ s ] ? $ / i. test ( p ) ) {
2787- compilerOpt . linkerScriptPath = p ;
2788- }
2789- }
2790- }
2791- } ) ;
2735+ compilerOpt . linkerScriptPath = eTarget . linkerScriptPath || '' ;
27922736 }
27932737
27942738 // init compiler args for target
@@ -2797,16 +2741,16 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
27972741 const toolchainDefConf = toolchain . getDefaultConfig ( ) ;
27982742
27992743 // glob
2800- toolchainDefConf . global [ 'misc-control' ] = eTarget . globalArgs . globalArgs . filter ( a => a . trim ( ) != '' ) ;
2744+ toolchainDefConf . global [ 'misc-control' ] = eTarget . builldArgs . globalArgs . filter ( a => a . trim ( ) != '' ) ;
28012745
28022746 // asm
28032747 {
28042748 let flags : string [ ] = [ ] ;
28052749 const asmCfg = toolchainDefConf [ "asm-compiler" ] ;
28062750
28072751 if ( asmCfg [ 'ASM_FLAGS' ] ) flags . push ( asmCfg [ 'ASM_FLAGS' ] ) ;
2808- eTarget . globalArgs . sMacros . forEach ( m => flags . push ( `-D${ m } ` ) ) ;
2809- eTarget . globalArgs . assemblerArgs . forEach ( arg => flags . push ( arg ) ) ;
2752+ eTarget . builldArgs . sMacros . forEach ( m => flags . push ( `-D${ m } ` ) ) ;
2753+ eTarget . builldArgs . assemblerArgs . forEach ( arg => flags . push ( arg ) ) ;
28102754
28112755 flags = flags . filter ( p => p . trim ( ) != '' ) ;
28122756 if ( asmCfg [ 'ASM_FLAGS' ] != undefined ) {
@@ -2822,12 +2766,24 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
28222766 let cxxFlags : string [ ] = [ ] ;
28232767 const ccCfg = toolchainDefConf [ "c/cpp-compiler" ] ;
28242768
2825- if ( ccCfg [ 'C_FLAGS' ] ) flags . push ( ccCfg [ 'C_FLAGS' ] ) ;
2826- if ( ccCfg [ 'CXX_FLAGS' ] ) cxxFlags . push ( ccCfg [ 'CXX_FLAGS' ] ) ;
2827-
2828- eTarget . globalArgs . cCompilerArgs . forEach ( arg => {
2769+ if ( eTarget . builldArgs . optimization )
2770+ ccCfg [ 'optimization' ] = eTarget . builldArgs . optimization ;
2771+ if ( eTarget . builldArgs . cLanguageStd )
2772+ ccCfg [ 'language-c' ] = eTarget . builldArgs . cLanguageStd ;
2773+ if ( eTarget . builldArgs . cppLanguageStd )
2774+ ccCfg [ 'language-cpp' ] = eTarget . builldArgs . cppLanguageStd ;
2775+ if ( eTarget . builldArgs . signedChar )
2776+ ccCfg [ 'signed-char' ] = true ;
2777+
2778+ if ( ccCfg [ 'C_FLAGS' ] )
2779+ flags . push ( ccCfg [ 'C_FLAGS' ] ) ;
2780+ if ( ccCfg [ 'CXX_FLAGS' ] )
2781+ cxxFlags . push ( ccCfg [ 'CXX_FLAGS' ] ) ;
2782+
2783+ eTarget . builldArgs . cCompilerArgs . forEach ( arg => {
28292784 flags . push ( arg ) ;
2830- cxxFlags . push ( arg ) ;
2785+ //TODO not support C++ options now
2786+ //cxxFlags.push(arg);
28312787 } ) ;
28322788
28332789 flags = flags . filter ( p => p . trim ( ) != '' ) ;
@@ -2845,21 +2801,59 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
28452801 if ( ! toolchainDefConf . linker ) toolchainDefConf . linker = { } ;
28462802 const ldCfg = toolchainDefConf . linker ;
28472803
2848- const flags : string [ ] = eTarget . globalArgs . linkerArgs . filter ( a => a . trim ( ) != '' ) ;
2804+ const flags : string [ ] = eTarget . builldArgs . linkerArgs . filter ( a => a . trim ( ) != '' ) ;
28492805 if ( ldCfg [ 'LD_FLAGS' ] != undefined ) {
28502806 ldCfg [ 'LD_FLAGS' ] = flags . join ( ' ' ) ;
2851- const libFlags = eTarget . globalArgs . linkerLibArgs . filter ( a => a . trim ( ) != '' ) ;
2807+ const libFlags = eTarget . builldArgs . linkerLibArgs . filter ( a => a . trim ( ) != '' ) ;
28522808 if ( ldCfg [ 'LIB_FLAGS' ] != undefined ) {
28532809 ldCfg [ 'LIB_FLAGS' ] = libFlags . join ( ' ' ) ;
28542810 }
28552811 } else {
28562812 ldCfg [ 'misc-control' ] = flags . join ( ' ' ) ;
28572813 }
2814+
2815+ // setup link order
2816+ if ( eTarget . objsOrder . length ) {
2817+ const linkOrder : { pattern : string , order : number } [ ] = [ ] ;
2818+ eTarget . objsOrder . forEach ( ( e , idx ) => {
2819+ linkOrder . push ( {
2820+ pattern : e ,
2821+ order : idx
2822+ } ) ;
2823+ } ) ;
2824+ ldCfg [ 'object-order' ] = linkOrder ;
2825+ }
28582826 }
28592827
28602828 nEideTarget . builderOptions [ toolchain . name ] = toolchainDefConf ;
28612829 }
28622830
2831+ // setup source options
2832+ if ( eTarget . sourceArgs ) {
2833+ srcOptsObj . options [ eTarget . name ] = { files : { } } ;
2834+ const srcOptions : any = srcOptsObj . options [ eTarget . name ] . files ;
2835+ const srcFilters = AbstractProject . getSourceFileFilter ( ) ;
2836+ for ( const fpath in eTarget . sourceArgs ) {
2837+ const flags : string [ ] = [ ] ;
2838+ const sourceArgs = eTarget . sourceArgs [ fpath ] ;
2839+ if ( AbstractProject . asmfileFilter . test ( fpath ) ) {
2840+ sourceArgs . sIncDirs . forEach ( arg => flags . push ( `-I${ arg } ` ) ) ;
2841+ sourceArgs . sMacros . forEach ( arg => flags . push ( `-D${ arg } ` ) ) ;
2842+ sourceArgs . assemblerArgs . forEach ( arg => flags . push ( arg ) ) ;
2843+ } else {
2844+ sourceArgs . cIncDirs . forEach ( arg => flags . push ( `-I${ arg } ` ) ) ;
2845+ sourceArgs . cMacros . forEach ( arg => flags . push ( `-D${ arg } ` ) ) ;
2846+ sourceArgs . cCompilerArgs . forEach ( arg => flags . push ( arg ) ) ;
2847+ }
2848+ if ( flags . length > 0 ) {
2849+ if ( srcFilters . some ( r => r . test ( fpath ) ) )
2850+ srcOptions [ fpath ] = ArrayDelRepetition ( flags ) . join ( ' ' ) ;
2851+ else
2852+ srcOptions [ fpath + '/*' ] = ArrayDelRepetition ( flags ) . join ( ' ' ) ;
2853+ }
2854+ }
2855+ }
2856+
28632857 nPrjConfig . targets [ eTarget . name ] = nEideTarget ;
28642858 }
28652859
@@ -2880,62 +2874,9 @@ class ProjectDataProvider implements vscode.TreeDataProvider<ProjTreeItem>, vsco
28802874
28812875 // save all config
28822876 basePrj . prjConfig . Save ( ) ;
2883-
2884- // show warning
2885-
2886- var getAllKeys = ( obj : any ) : string [ ] => {
2887- if ( typeof obj != 'object' ) return [ ] ;
2888- const keys : string [ ] = [ ] ;
2889- for ( const key in obj ) keys . push ( key ) ;
2890- return keys ;
2891- } ;
2892-
2893- if ( getAllKeys ( ePrjInfo . envs ) . length > 0 ||
2894- ePrjInfo . targets . some ( t => getAllKeys ( t . incompatibleArgs ) . length > 0 ) ) {
2895-
2896- let warnLines = [
2897- `!!! ${ WARNING } !!!` ,
2898- '' ,
2899- view_str$prompt$eclipse_imp_warning ,
2900- '' ,
2901- '---' ,
2902- ''
2903- ] ;
2904-
2905- if ( getAllKeys ( ePrjInfo . envs ) . length > 0 ) {
2906- warnLines . push (
2907- `##### Eclipse Project Environment Variables #####` ,
2908- `` ,
2909- yaml . stringify ( { 'Envs' : ePrjInfo . envs } ) ,
2910- ``
2911- ) ;
2912- }
2913-
2914- warnLines . push (
2915- `##### Configurations For All Targets #####` ,
2916- ``
2917- ) ;
2918-
2919- ePrjInfo . targets . forEach ( target => {
2920- warnLines . push (
2921- `//` ,
2922- `///// Target: '${ target . name } ' /////` ,
2923- `//` ,
2924- '' ,
2925- yaml . stringify ( { 'Incompatible Args' : target . incompatibleArgs } ) ,
2926- ''
2927- ) ;
2928- } ) ;
2929-
2930- const f = File . fromArray ( [ ePrjRoot . path , `eclipse.${ AbstractProject . importerWarningBaseName } ` ] ) ;
2931- f . Write ( warnLines . join ( os . EOL ) ) ;
2932- const doc = await vscode . workspace . openTextDocument ( vscode . Uri . parse ( f . ToUri ( ) ) ) ;
2933-
2934- vscode . window . showTextDocument ( doc , {
2935- preview : false ,
2936- selection : doc . lineAt ( 0 ) . range ,
2937- } ) ;
2938- }
2877+ // save src options
2878+ const optFile = File . fromArray ( [ basePrj . rootFolder . path , AbstractProject . EIDE_DIR , `files.options.yml` ] ) ;
2879+ optFile . Write ( view_str$prompt$filesOptionsComment + yaml . stringify ( srcOptsObj , { indent : 4 } ) ) ;
29392880
29402881 // switch project
29412882 const selection = await vscode . window . showInformationMessage (
0 commit comments