kore-doc

The kore documentation found under https://docs.kore.io/
Commits | Files | Refs | README | git clone https://git.kore.io/kore-doc.git

building.md (2053B)



      1 # Build framework
      2 
      3 Kore provides a flexible way of building your applications through the **conf/build.conf** file.
      4 
      5 This file contains build flavors that dictate CFLAGS and LDFLAGS.
      6 
      7 Flavors can be switched using the **flavor** command:
      8 
      9 ```
     10 $ kodev flavor osx
     11 changed build flavor to: osx
     12 $
     13 ```
     14 
     15 ### Sources
     16 
     17 Kore will automatically build any source files found under the **src** directory in your application.
     18 
     19 ### Assets
     20 
     21 By default the build tool will automatically convert files found under **assets** into C files and compile them into your code allowing you to access these directly.
     22 
     23 Each asset gets its own page handler as well that can be easily added to the configuration, reducing the work you have to do to configure static assets.
     24 Additionally the assets also get an ETag that is automatically included in the response and Kore will honor if-none-match for these assets and send
     25 a 304 if they were not modified.
     26 
     27 The example below configures / to serve the static asset index.html.
     28 
     29 ```
     30 domain * {
     31 	route / {
     32 		handler asset_serve_index_html
     33 	}
     34 }
     35 ```
     36 
     37 You may specify media types for these static assets in **conf/build.conf**.
     38 
     39 ```
     40 mime_add=jpg:image/jpeg
     41 mime_add=css:text/css; charset=utf-8
     42 mime_add=html:text/html; charset=utf-8
     43 ```
     44 
     45 ### Single binaries
     46 
     47 Kore will normally produce a single dynamic library \(DSO\) file that contains your application logic. This DSO file is then loaded at run-time by the main Kore binary as instructed by your configuration file.
     48 
     49 If DSO's are not your cup-o-tea you can opt for building a single binary instead. This requires you to update your **conf/build.conf** file and add the following settings globally:
     50 
     51 ```
     52 single_binary = yes
     53 kore_source = /path/to/kore/source/
     54 kore_flavor = <flavors..>
     55 ```
     56 
     57 This will cause _kodev build_ to build the original Kore source code and link your application logic directly into it. It will also add in the configuration file and of course any assets that are under the **assets** directory. The result is a single dynamically linked binary that can be run.
     58