Skip to content

Commit a698763

Browse files
committed
v.builder: support downloading the FreeBSD cross compilation files on first use
1 parent 302916c commit a698763

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

vlib/v/builder/cc.v

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,22 @@ fn (mut b Builder) ensure_linuxroot_exists(sysroot string) {
781781
}
782782
}
783783

784+
fn (mut b Builder) ensure_freebsdroot_exists(sysroot string) {
785+
crossrepo_url := 'https://github.com/spytheman/freebsd_base13.2'
786+
sysroot_git_config_path := os.join_path(sysroot, '.git', 'config')
787+
if os.is_dir(sysroot) && !os.exists(sysroot_git_config_path) {
788+
// remove existing obsolete unarchived .zip file content
789+
os.rmdir_all(sysroot) or {}
790+
}
791+
if !os.is_dir(sysroot) {
792+
println('Downloading files for FreeBSD cross compilation (~458MB) ...')
793+
os.system('git clone ${crossrepo_url} ${sysroot}')
794+
if !os.exists(sysroot_git_config_path) {
795+
verror('Failed to clone `${crossrepo_url}` to `${sysroot}`')
796+
}
797+
}
798+
}
799+
784800
fn (mut b Builder) cc_linux_cross() {
785801
b.setup_ccompiler_options(b.pref.ccompiler)
786802
b.build_thirdparty_obj_files()
@@ -857,10 +873,8 @@ fn (mut b Builder) cc_freebsd_cross() {
857873
if !os.exists(parent_dir) {
858874
os.mkdir(parent_dir) or { panic(err) }
859875
}
860-
// Download from:
861-
// http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/13.2-RELEASE/base.txz
862-
sysroot := '/tmp/base13.2' // os.join_path(os.vmodules_dir(), 'freebsdroot')
863-
// b.ensure_linuxroot_exists(sysroot)
876+
sysroot := os.join_path(os.vmodules_dir(), 'freebsdroot')
877+
b.ensure_freebsdroot_exists(sysroot)
864878
obj_file := b.out_name_c + '.o'
865879
cflags := b.get_os_cflags()
866880
defines, others, libs := cflags.defines_others_libs()

0 commit comments

Comments
 (0)