Comments (8)
The way bflat is structured is really no different from how clang, gcc, or other native compilers are structured. They scale to the extent of Linux kernel, Chromium browser, etc. with thousands of files.
bflat build foo.cs bar.cs
produces an executable you can run (same way gcc foo.c
produces an executable). This is for quick consumption with small things.
But you can also do:
bflat build-il foo.cs bar.cs -o:MyAssembly.dll
bflat build program.cs -r:MyAssembly.dll
The first invocation produces an equivalent of a library csproj. The second invocation uses the library to create an executable (equivalent of Exe csproj).
Depending on what you want to achieve, you can also do:
bflat build -c program.cs
This is the same as the -c
argument to clang: it says compile to object file, but don't run the linker. You can then run the linker manually. (You can use bflat build -x program.cs
to have bflat tell you how it invokes the linker so that you know the correct invocation as a starting point.)
from bflat.
bflat build
without specifying the input files will look for any *.cs files in the current directory. If you need more control, you would specify the file names explicitly.
Bflat is just a compiler, not a build system. If the build is more complex, one would drive this from a build system. Makefiles, or even MSBuild targets.
from bflat.
Sure, but if you have anything more than a few files this somewhat becomes unfeasible. Its also not clear how linking etc would work.
One example that I have in mind is for example game modding.
Currently I have to a solution with a project that declares base types for modding, and then a project per mod that uses the types from the base project.
I then compile the mod project, have a small C++ dll that injects the CLR into the game and loads the mods via dynamic assembly loading.
Ideally I'd like to avoid having to load the CLR and compile the mods (including project and nuget deps) to native code and inject them directly. Is that possible with this compiler or is this only usable for 2-3 file projects?
from bflat.
You'd have to change the way you write and structure code but there's genuinely no reason you couldn't do this with 150+ file projects. This is less of a problem for F# since we (culturally) don't rely on that kind of polymorphism as much but there's no actual strict need to write your C# that way.
from bflat.
Can you elaborate how the code should be structured?
Also how to deal with nuget dependency graph?
from bflat.
For your own code you should be able to essentially treat folders as projects using namespaces etc as you do in C# normally. For nuget you'll have to be more careful with what packages/versions you choose. If it becomes intractable there are tools like paket which are allow for more fine grained control and flexibility with package resolution. If my current understanding is correct, you probably won't be able to write your project with the kind of runtime modular approach that you're used to, so you should design with that in mind.
from bflat.
Thanks.
Can library outputs have a dll entrypoint (DllMain)? Not obvious how to declare that from c# or how that gets exposed? Also, not obvious how to export symbols from your dlls as C ABI (I assume thats the usecase for supporting compiling to libraries)
I guess it's a lot of manual work to do that for the whole solution but I'll give it a go see how far I get.
from bflat.
If you have existing project files, you can just drive bflat from MSBuild.
Bflat builds with bflat, but the bflat command line is constructed by MSBuild:
Lines 200 to 216 in 200c770
(Or you can just use the built-in PublishAot
option and skip bflat completely. The main advantage of bflat is in the seamless crosscompilation and ability to use without MSBuild. If you don't need that, just go with the built-in thing).
Can library outputs have a dll entrypoint (DllMain)
DllMain is not directly exposed because running managed code under loader lock would be asking for trouble. You can use [ModuleInitializer]
to sort of get similar semantics.
Also, not obvious how to export symbols from your dlls as C ABI
Did you see the sample?
from bflat.
Related Issues (20)
- `-o` switch will produce executable without extension HOT 2
- Cannot build. Missing jitinterface_x64 HOT 3
- how to compiler multi file HOT 1
- Detected as malware. HOT 1
- Compiler exits with status code 0 even there are errors. Confusing automated platform as a result HOT 2
- Memory management with Zero stdlib? HOT 2
- run in docker HOT 3
- Cannot run Sokol sample on Linux (Ubuntu 22.04 WSL2) HOT 6
- [zerolib] can you give a printf combined with an example of printing string (including Chinese) Thank HOT 4
- [zerolib] Span<T> is readonly
- No auto library specifying HOT 9
- [zerolib x86] Implement Concat, string Assignment issues? HOT 1
- Debugging doesn't work on Linux HOT 3
- Tight inner loop recommended in /src/zerolib doesn't work on Linux (doesn't link 3 SystemNative functions) HOT 4
- Can't reference System.Diagnostics with --stdlib:zero HOT 5
- Which language features not available in the Zero stdlib? HOT 12
- [zerolib] `Console.Write` and some overloads
- [zerolib] `Console.WriteLine` and some overloads
- Please add this method to `ClassConstructionRunner` to make `ReadOnlySpan` returning methods compile HOT 6
- [zerolib] What is the encoding of `string`? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bflat.