-
-
Notifications
You must be signed in to change notification settings - Fork 670
Support asconfig.json in addition to CLI arguments #1230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This reminds me that #1134 is somewhat related in that it proposes an Another nice touch might be to allow the contents of |
EDIT: I will try to keep this updated with the latest iteration as per suggestions. type EnableFeatures = "sign-extension" | "bulk-memory" | "simd" | "threads" | "reference-types";
type DisableFeatures = "mutable-globals";
type TrapMode = "js" | "clamp" | "allow";
type BinaryenPasses = "AlignmentLowering" |
"asyncify" |
"avoid-reinterprets" |
"coalesce-locals" |
"coalesce-locals-with-learning" |
"code-folding" |
"code-pushing" |
"const-hoisting" |
"dae" |
"dae-optimizing" |
"data-flow-opts" |
"dead-code-elimination" |
"directize" |
"dward-dump" |
"duplicate-import-elimination" |
"duplicate-function-elimination" |
"emit-target-features" |
"extract-function" |
"flatten" |
"func-cast-emulation" |
"full-printer" |
"function-metrics" |
"generate-stack-ir" |
"i64-to-i32-Lowering" |
"inline-main" |
"inlining" |
"inlining-optimizing" |
"legalize-js-interface" |
"legalize-js-interface-minimally" |
"limit-segments" |
"local-cse" |
"log-execution" |
"instrument-locals" |
"instrument-memory" |
"loop-invariant-code-motion" |
"memory-packing" |
"merge-blocks" |
"merge-locals" |
"minified-printer" |
"minify-imports" |
"minify-imports-and-exports" |
"minify-imports-and-exports-and-modules" |
"metrics" |
"name-list" |
"no-rxit-runtime" |
"optimize-added-constants" |
"optimize-added-constants-propagate" |
"optimize-instructions" |
"optimize-stack-ir" |
"pick-load-signs" |
"mod-asyncify-always-only-unwind" |
"mod-asyncify-never-unwind" |
"post-assemblyscript" |
"post-assemblyscript-finalize" |
"post-emscripten" |
"precompute" |
"precompute-propagate" |
"printer" |
"print-call-graph" |
"print-features" |
"print-function-map" |
"print-stack-ir" |
"relooper-jump-threading" |
"remove-non-js-ops" |
"remove-imports" |
"remove-memory" |
"remove-unused-brs" |
"remove-unused-module-elements" |
"remove-unused-non-function-module-elements" |
"remove-unused-names" |
"reorder-functions" |
"reorder-locals" |
"re-reloop" |
"redundant-set-elimination" |
"round-trip" |
"safeHeap" |
"simplify-locals" |
"simplify-globals" |
"simplify-globals-optimizing" |
"simplify-locals-no-nesting" |
"simplify-locals-no-tee" |
"simplify-locals-no-structure" |
"simplify-locals-no-tee-no-structure" |
"strip-debug" |
"strip-dwarf" |
"strip-producers" |
"strip-target-features" |
"souperify" |
"souperify-single-use" |
"spill-pointers" |
"ssaify" |
"ssaify-no-merge" |
"trap-mode-c" |
"trap-mo" |
"untee" |
"vacuum";
interface ASConfig {
options?: {
optimizeLevel?: 0 | 1 | 2 | 3;
shrinkLevel?: 0 | 1 | 2 | "s" | "z";
converge?: boolean;
noAssert?: boolean;
runtime?: "full" | "half" | "stub" | "none";
debug?: boolean;
importMemory?: boolean;
sharedMemory?: boolean;
importTable?: boolean;
exportTable?: boolean;
explicitStart?: boolean;
enable?: EnableFeatures[];
disable?: DisableFeatures[];
use?: {
[key: string]: string | number;
};
memoryBase?: number;
tableBase?: number;
validate?: boolean;
trapMode?: TrapMode;
runPasses?: BinaryenPasses[];
baseDir?: string;
noUnsafe?: boolean;
noEmit?: boolean;
measure?: boolean;
pedantic?: boolean;
lib?: string[];
path?: string[];
traceResolution?: boolean;
printrtti: boolean;
};
output?: {
outFile?: string;
binaryFile: string;
textFile?: string;
asmjsFile?: string;
idlFile?: string;
tsdFile?: string;
sourceMap?: boolean | string;
};
entry?: string[];
} We can use this as a starting point. I went through the CLI help and generated an asconfig.json shape. Any suggestions? |
Nice! A few comments:
|
See edit, switched to
Got it. Will change it.
All of these were copied from the idea of what the tsconfig does, but we have entry points, so instead I replaced them with an Perhaps there is no need for asconfig extension. |
Have been brainstorming with @jtenner on Slack, and this was the latest we came up with: Let every project have an {
"compilerOptions": {
...
}
} The configuration can extend another configuration using the {
"extends": "./path/to/other/asconfig.json"
} Now, while one doesn't typically have the need for multiple builds in TypeScript, it is fairly common to build two variants in AssemblyScript. To make this easier and reduce the amount of files one has to deal with, extending this with multiple targets seems convenient: {
"compilerOptions": {
// common options used by all targets
},
"targets": {
"release": {
// additional release options
},
"debug": {
// additional debug options
}
}
} This feature would be optional, in that if the On the command line, one would either specify just the config file via {
"extends": "./path/to/asconfig.json"
} or, if targets is present, {
"extends": "./path/to/asconfig.json:release"
} If targets is present and the former is used, so a default target is executed, a warning on the console should read "No target specified for './path/to/asconfig.json': Defaulting to 'release'.". Thoughts? The obvious alternative would be to omit the |
Specifying the first "key" as the target is undefined behavior in js. Object keys are not garunteed to be ordered. Suggesting to use an Array instead, and always use the first one. |
Typescript currently allows the extend to use node package resolution. |
Also it would be nice to have nested projects so that multiple binaries can be generated. This is particularly of interest to Near with projects with multiple smart contracts. |
@dcodeIO I am suggesting this: {
"options": {},
"targets": [
{
"name": "release",
"options": { ... }
}
]
} You cannot default to the "first" one, if it's only object keys. Can we resolve this first before I start work? |
Hmm, with that, we could even do something fancy like: {
"targets": [
{
"name": "release",
"extends": "assemblyscript/presets:release",
"options": { ... }
},
{
"name": "debug",
"extends": "assemblyscript/presets:debug",
"options": { ... }
}
]
} but raises the question whether we still need top-level |
Again. Why is it so inconvenient or wrong to just have single asconfig files per target?
|
My thinking there is that one typically has two builds per project, like one debug and one release. Without
where it seems just too easy to overlook something due to having to switch through the files, instead of having a clear view on all the options at once. Then there is
which is impossible to do (in a single command) without |
Right. I'm arguing for simplicity and leaving the complexity for end users. I am now proposing a recursive configuration algorithm and exactly two cli options with defaults specified below.
Steps:
|
I'm sorry this is taking so long. Encapsulating this algorithm feels quite complicated. 😅 |
@jtenner, I am the author of the I think this newer approach looks promising, but may become easier if we can join our efforts. Allow me to add a little bit of context, and see whether you think my proposal makes sense. After discovering some rather silly limitations of the current Instead of managing packages, this tool is the main interface between the dev and the compiler. When you run
While The key is: those settings are their own abstraction. How they work -- what options they pass to the compiler -- should be allowed to change between toolchain versions. The compiler can change its flags, but so long as asbuild changes to match, developers will get what they expect. Manually adding compiler flags directly may be necessary, so that should be possible, but awkward. Intentionally so. Most of the time, the dev should not be thinking at that level. To conclude, I think having a single I don't think this affects much of what you have described so far, except perhaps to put more knowledge about the compiler into asbuild, rather than the configuration itself. My prototype was an MVP, and there is a lot more it could/should do. You seem to have a better grasp of things, so any suggestions or info you have to improve it would help. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I am taking a break from open source development for a while, and I don't want this issue to die, because it's important to AssemblyScript. I have a few more thoughts before I leave this issue up for grabs:
|
@jtenner Do we need keep opened this issue? |
No. I think our needs are covered. |
In an attempt to standardize the way the vscode language server works, we should probably adopt a configuration file definition.
Please file suggestions and discussion on this topic here.
I plan on starting work on this tomorrow in a pull request.
The text was updated successfully, but these errors were encountered: