This repository has been archived by the owner on Jul 12, 2021. It is now read-only.
forked from daokoder/dao
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.dao
47 lines (34 loc) · 1.44 KB
/
bundle.dao
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Building system for single executable deployment:
#
# Given example.dao, the following will compile it into bytecodes,
# and bundle the bytecodes with Dao runtime and loaded modules
# into a single executable:
#
# make -f Makefile.daomake macosx OPTIONS="--option-BUNDLE-SCRIPT example"
daovm_bundle = DaoMake::Option( "BUNDLE", "" )
if( daovm_bundle == "" ) return;
bundler = DaoMake::Project( "DaoBundler" )
bundle_main = bundler.AddObjects( { "kernel/daoMain.c" } )
bundle_script = bundler.AddObjects( { daovm_bundle + ".dar.c" } )
bundle_main.AddDefinition( 'DAO_WITH_STATIC_MODULES' )
bundle_script.AddIncludePath( "kernel" )
bundle = bundler.AddExecutable( daovm_bundle, bundle_main, bundle_script )
std.load( "FindDao.dao" )
daovm = DaoMake::FindPackage( "Dao" )
if( daovm != none ) bundle.UseStaticLibrary( daovm, "dao" )
finders = io.read( daovm_bundle + ".dar.finders" )
bundle_finders = finders.split( '\n' )
cmd_dir = DaoMake::SourcePath()
dao_dir = DaoMake::GetEnv( 'DAO_DIR' )
home_dir = DaoMake::GetEnv( 'HOME' )
for( finder in bundle_finders ){
finder = finder.replace( '$(CMD_DIR)/', cmd_dir )
finder = finder.replace( '$(DAO_DIR)/', dao_dir )
finder = finder.replace( '$(HOME)/', home_dir )
fields = finder.split( '\t' )
if( fields.size() < 3 ) skip;
if( DaoMake::IsFile( fields[1] ) ) std.load( fields[1] )
pro = DaoMake::FindPackage( fields[0] )
io.writeln( pro, fields )
if( pro != none ) bundle.UseStaticLibrary( pro )
}