Skip to content

Commit eb46bd0

Browse files
committed
- allow user defined ar params for libs generator
- move libs.makefile path
1 parent e65deee commit eb46bd0

3 files changed

Lines changed: 29 additions & 10 deletions

File tree

res/data/template.libs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
#
1111
##########################################################################################
1212

13+
# -----------
14+
# Config
15+
# -----------
16+
# $AR_PATH: '/Your/AR/Executable/Path'
17+
# $AR_CMD : '-rcv ${out} ${in}'
18+
1319
## ----------------------------
1420
## examples
1521
## This examples will generate 2 libs after build done,

src/CodeBuilder.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,20 +481,22 @@ export abstract class CodeBuilder {
481481
this.preHandleOptions(builderOptions.options);
482482

483483
// gen libs.makefile
484-
const mkfile = File.fromArray([this.project.ToAbsolutePath(outDir), 'libs.makefile']);
485-
const mk_txt = this.project.genLibsMakefileContent(mkfile.name);
486-
if (mk_txt) {
484+
const mkfile_dir = new File(this.project.ToAbsolutePath(outDir + '/.lib'));
485+
const mkfile_path = `${mkfile_dir.name}/Makefile`;
486+
const mkfile_cont = this.project.genLibsMakefileContent(mkfile_path);
487+
if (mkfile_cont) {
487488
try {
488-
mkfile.Write(mk_txt);
489+
if (!mkfile_dir.IsDir()) mkfile_dir.CreateDir(true);
490+
fs.writeFileSync(`${this.project.ToAbsolutePath(outDir)}/${mkfile_path}`, mkfile_cont);
489491
let command: any = {
490-
name: 'make libs',
491-
command: `make --directory=./${outDir} --makefile=./${mkfile.name} all`
492+
name: 'make libraries',
493+
command: `make --directory=./${outDir} --makefile=./${mkfile_path} all`
492494
};
493495
if (builderOptions.options.afterBuildTasks == undefined)
494496
builderOptions.options.afterBuildTasks = [];
495497
builderOptions.options.afterBuildTasks = [command].concat(builderOptions.options.afterBuildTasks);
496498
} catch (error) {
497-
GlobalEvent.emit('msg', newMessage('Warning', `Generating '${mkfile.name}' failed !`));
499+
GlobalEvent.emit('msg', newMessage('Warning', `Generating '${mkfile_path}' failed !`));
498500
GlobalEvent.emit('globalLog', ExceptionToMessage(error, 'Error'));
499501
}
500502
}

src/EIDEProject.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,10 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
18271827
return optFile;
18281828
}
18291829

1830-
genLibsMakefileContent(makefileName: string): string | undefined {
1830+
/**
1831+
* @param makefile_repath a path relative from build output dir, like: '.lib/Makefile'
1832+
*/
1833+
genLibsMakefileContent(makefile_repath: string): string | undefined {
18311834

18321835
const fcfg = this.getLibsGeneratorCfgFile(true);
18331836
if (!fcfg.IsFile())
@@ -1906,6 +1909,9 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
19061909

19071910
for (const name in cfg) {
19081911

1912+
if (name.startsWith('$'))
1913+
continue; // skip internal vars
1914+
19091915
let exprs: string[] = cfg[name];
19101916
if (!Array.isArray(exprs)) continue;
19111917

@@ -1931,6 +1937,11 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
19311937
}
19321938
}
19331939

1940+
if (cfg['$AR_PATH'])
1941+
AR_PATH = File.ToUnixPath(this.toAbsolutePath(cfg['$AR_PATH']));
1942+
if (cfg['$AR_CMD'])
1943+
AR_PARAMS = cfg['$AR_CMD'];
1944+
19341945
// --------------------------
19351946
// - gen makefile
19361947
// --------------------------
@@ -1945,7 +1956,7 @@ export abstract class AbstractProject implements CustomConfigurationProvider, Pr
19451956
.replace('${out}', outname);
19461957
let rule_tmp = `# ${libname}
19471958
lib${libname}_OBJS += ${objs.join(AR_OBJ_SEP)}
1948-
lib${libname}: $(lib${libname}_OBJS) ${makefileName}
1959+
lib${libname}: $(lib${libname}_OBJS) ${makefile_repath}
19491960
\t@echo -e $(COLOR_BLUE)-------------------------$(COLOR_END)
19501961
\t@echo -e $(COLOR_BLUE)AR "${outname}"$(COLOR_END)
19511962
\t@echo -e $(COLOR_BLUE)-------------------------$(COLOR_END)
@@ -1990,7 +2001,7 @@ $(OUT_DIR):
19902001

19912002
mk_tmp = mk_tmp
19922003
.replace('<LIB_TARGETS>', lib_rules.join('\n'))
1993-
.replace('<LIB_OUT_DIR>', '.lib');
2004+
.replace('<LIB_OUT_DIR>', NodePath.dirname(makefile_repath));
19942005

19952006
return mk_tmp;
19962007
}

0 commit comments

Comments
 (0)