AdeptLanguage / Adept

The Adept Programming Language
GNU General Public License v3.0
120 stars 8 forks source link

Support "response files" #292

Closed ghost closed 7 months ago

ghost commented 7 months ago

On some systems (such as older UNIX systems and certain Windows variants) command-lines have relatively limited lengths. Windows compilers therefore support "response files". These files are mentioned on the command-line (using the "@file") syntax. The compiler reads these files and inserts the contents into argv, thereby working around the command-line length limits.

https://stackoverflow.com/questions/61799140/is-it-possible-to-put-a-bunch-of-wno-gcc-flags-into-a-file-and-reference-th

IsaacShelton commented 7 months ago

Command line arguments can already be specified via pragma options "ARGUMENTS GO HERE" as well as argument-specific directives pragma project_name "output_filename" for example, so I'm not sure if it would be necessary to add another way to specify them when you can already do it from within the language.

And if you want different configurations, you can just have multiple root files, each which import main.adept e.g.

release.adept

pragma project_name "my_app_release"
pragma optimization aggressive

import "main.adept"

debug.adept

pragma project_name "my_app_debug"
pragma optimization less

import "main.adept"

And then compile like normal

adept release.adept

or

adept debug.adept
ghost commented 7 months ago

What I care most is the -I, -L, and -l flags. How could they be used within pragma options?

ghost commented 7 months ago

What if each source file has their own pragma options? After being included all together, which pragma options would be used?

ghost commented 7 months ago

The -I, -L, and -l flags are dynamic. They should be set on the command line, not on the source file.

IsaacShelton commented 7 months ago

1.

You can specify additional command line arguments inside of pragma options like this:

pragma options '-Lvendor -lfirst -lsecond -lthird -I"~/common_adept_files/" -O3'

https://github.com/AdeptLanguage/Adept/wiki/pragma-options


2.

pragma options passes additional command line options to the compiler.

So if pragma options is in multiple files, all of them will be added, in the order that they are first imported.


3.

If you want to use them as command line, then you can already do that right?

If you absolutely need to store them in a file, then you can do something like the following no?

my_build.adept

pragma options '-Lvendor -lfirst -lsecond -lthird'
pragma options '-I"~/common_adept_files/" -O3'
import "main.adept"

main.adept

import basics

func main {
    print("Hello World")
}

adept my_build.adept

And if you want to specify additional options on top of a custom build, you can still add arguments on the command line like normal as well:

adept my_build.adept -Lalso_look_at_these_libs

The order of the arguments goes:

So having a my_custom_build.adept -like file is effectively the same as using @file (they just end in .adept and are more powerful)