@@ -26,7 +26,7 @@ export async function worldgen({
26
26
27
27
const systems = ( await resolveSystems ( { rootDir, config } ) )
28
28
// TODO: move to codegen option or generate "system manifest" and codegen from that
29
- . filter ( ( system ) => system . deploy . registerWorldFunctions )
29
+ . filter ( ( system ) => system . deploy . registerWorldFunctions || config . codegen . generateSystemLibraries )
30
30
. map ( ( system ) => {
31
31
const interfaceName = `I${ system . label } ` ;
32
32
const libraryName = `${ system . label } Lib` ;
@@ -61,12 +61,14 @@ export async function worldgen({
61
61
62
62
const outputPath = path . join ( worldgenOutDir , config . codegen . worldInterfaceName + ".sol" ) ;
63
63
64
- const worldImports = systems . map (
65
- ( system ) : ImportDatum => ( {
66
- symbol : system . interfaceName ,
67
- path : "./" + path . relative ( path . dirname ( outputPath ) , system . interfacePath ) ,
68
- } ) ,
69
- ) ;
64
+ const worldImports = systems
65
+ . filter ( ( system ) => system . deploy . registerWorldFunctions )
66
+ . map (
67
+ ( system ) : ImportDatum => ( {
68
+ symbol : system . interfaceName ,
69
+ path : "./" + path . relative ( path . dirname ( outputPath ) , system . interfacePath ) ,
70
+ } ) ,
71
+ ) ;
70
72
71
73
const storeImportPath = config . codegen . storeImportPath . startsWith ( "." )
72
74
? "./" + path . relative ( path . dirname ( outputPath ) , path . join ( rootDir , config . codegen . storeImportPath ) )
@@ -80,24 +82,27 @@ export async function worldgen({
80
82
const source = await fs . readFile ( path . join ( rootDir , system . sourcePath ) , "utf8" ) ;
81
83
// get external functions from a contract
82
84
const { functions, errors, symbolImports } = contractToInterface ( source , system . label ) ;
83
- const interfaceImports = symbolImports . map (
84
- ( { symbol, path : importPath } ) : ImportDatum => ( {
85
- symbol,
86
- path : importPath . startsWith ( "." )
87
- ? "./" + path . relative ( worldgenOutDir , path . join ( rootDir , path . dirname ( system . sourcePath ) , importPath ) )
88
- : importPath ,
89
- } ) ,
90
- ) ;
91
85
92
- const systemInterface = renderSystemInterface ( {
93
- name : system . interfaceName ,
94
- functionPrefix : system . namespace === "" ? "" : `${ system . namespace } __` ,
95
- functions,
96
- errors,
97
- imports : interfaceImports ,
98
- } ) ;
99
- // write to file
100
- await formatAndWriteSolidity ( systemInterface , system . interfacePath , "Generated system interface" ) ;
86
+ if ( system . deploy . registerWorldFunctions ) {
87
+ const interfaceImports = symbolImports . map (
88
+ ( { symbol, path : importPath } ) : ImportDatum => ( {
89
+ symbol,
90
+ path : importPath . startsWith ( "." )
91
+ ? "./" + path . relative ( worldgenOutDir , path . join ( rootDir , path . dirname ( system . sourcePath ) , importPath ) )
92
+ : importPath ,
93
+ } ) ,
94
+ ) ;
95
+
96
+ const systemInterface = renderSystemInterface ( {
97
+ name : system . interfaceName ,
98
+ functionPrefix : system . namespace === "" ? "" : `${ system . namespace } __` ,
99
+ functions,
100
+ errors,
101
+ imports : interfaceImports ,
102
+ } ) ;
103
+ // write to file
104
+ await formatAndWriteSolidity ( systemInterface , system . interfacePath , "Generated system interface" ) ;
105
+ }
101
106
102
107
if ( config . codegen . generateSystemLibraries ) {
103
108
const systemImport = {
0 commit comments