Skip to content

Commit

Permalink
Merge pull request #1726 from actonlang/build-ng
Browse files Browse the repository at this point in the history
Build ng
  • Loading branch information
plajjan authored Mar 13, 2024
2 parents e5ea847 + 30a0f71 commit 33ea0a7
Show file tree
Hide file tree
Showing 17 changed files with 521 additions and 177 deletions.
37 changes: 13 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ DEPS_DIRS += dist/deps/libxml2
DEPS_DIRS += dist/deps/libyyjson
DEPS_DIRS += dist/deps/libsnappy_c

# TODO: depend on include file rather than lib directory and remove lib files from distribution?
DEPS += dist/depsout/lib/libactongc.a
DEPS += dist/depsout/lib/libargp.a
DEPS += dist/depsout/lib/libbsdnt.a
Expand Down Expand Up @@ -358,16 +359,9 @@ builder/builder: builder/build.zig backend/build.zig base/build.zig $(ZIG_DEP) $
(echo 'const root = @import("build.zig");'; tail -n +2 dist/zig/lib/build_runner.zig | sed -e 's/@dependencies/dependencies.zig/') > builder/build_runner.zig
cd builder && $(ZIG) build-exe build_runner.zig -femit-bin=builder $(ZIG_ARCH_ARG)

.PHONY: base/out/rel/lib/libActon.a base/out/dev/lib/libActon.a
base/out/rel/lib/libActon.a: $(ACTONC) $(DEPS)
cd base && ../dist/bin/actonc build --auto-stub $(CPEDANTIC)

base/out/dev/lib/libActon.a: $(ACTONC) $(DEPS)
cd base && ../dist/bin/actonc build --auto-stub --dev $(CPEDANTIC)

base/out/types/__builtin__.ty: $(ACTONC)
cd base && ../dist/bin/actonc src/__builtin__.act

.PHONY: base/out/types/__builtin__.ty
base/out/types/__builtin__.ty: $(ACTONC) $(DEPS)
cd base && ../dist/bin/actonc build --auto-stub --only-act $(CPEDANTIC)

# top level targets

Expand Down Expand Up @@ -408,10 +402,9 @@ test-rts:
test-rts-db:
$(MAKE) -C test

# TODO: remove setting PATH below, acton cli should find actonc relative to itself
test-stdlib: dist/bin/acton
cd compiler && stack test --ta '-p "stdlib"'
cd test/stdlib_tests && PATH=$$PATH:$(TD)/dist/bin $(ACTON) test
cd test/stdlib_tests && $(ACTON) test


.PHONY: clean clean-all clean-base
Expand All @@ -425,12 +418,11 @@ clean-all: clean clean-compiler

clean-base:
rm -rf base/build-cache base/out builder/build_runner* builder/builder* builder/zig-cache builder/zig-out
rm -rf $(OFILES) builtin/__builtin__.h builtin/__builtin__.c builtin/ty/out stdlib/out/

bin/acton: cli/out/rel/bin/acton
bin/acton: cli/out/bin/acton
cp -a $< $@

cli/out/rel/bin/acton: distribution1
cli/out/bin/acton: distribution1
cd cli && $(ACTC) build $(ACTONC_TARGET)

# == DIST ==
Expand All @@ -444,9 +436,10 @@ dist/backend%: backend/%

# We depend on libActon.a because the base/out directory will be populated as a
# result of building it, and we want to copy those files!
dist/base: base dist/lib/dev/libActon.a
@mkdir -p $@
cp -r base/Acton.toml base/builtin base/out base/rts base/src base/stdlib dist/base/
dist/base: base dist/base/out/types/__builtin__.ty
@mkdir -p $@ $@/out
cp -r base/Acton.toml base/builtin base/rts base/src base/stdlib dist/base/
cp -r base/out/types dist/base/out/

dist/bin/acton: bin/acton
@mkdir -p $(dir $@)
Expand Down Expand Up @@ -488,11 +481,7 @@ dist/rts/%: base/rts/%
@mkdir -p $(dir $@)
cp $< $@

dist/lib/dev/libActon.a: base/out/dev/lib/libActon.a
@mkdir -p $(dir $@)
cp $< $@

dist/lib/rel/libActon.a: base/out/rel/lib/libActon.a
dist/base/out/types/__builtin__.ty: base/out/types/__builtin__.ty
@mkdir -p $(dir $@)
cp $< $@

Expand All @@ -518,7 +507,7 @@ else
endif

.PHONY: distribution1 distribution clean-distribution
distribution1: dist/base $(DIST_BACKEND_FILES) $(DEPSA) dist/lib/dev/libActon.a dist/lib/rel/libActon.a dist/builder $(DIST_INC) $(DIST_BINS) $(DIST_HFILES) $(DIST_ZIG)
distribution1: dist/base $(DIST_BACKEND_FILES) $(DEPSA) dist/builder $(DIST_INC) $(DIST_BINS) $(DIST_HFILES) $(DIST_ZIG)
$(MAKE) $(DIST_DEPS)

distribution: dist/bin/acton
Expand Down
4 changes: 0 additions & 4 deletions base/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,9 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const cpedantic = b.option(bool, "cpedantic", "") orelse false;
const use_db = b.option(bool, "db", "") orelse false;
const use_prebuilt = b.option(bool, "use_prebuilt", "") orelse false;
const syspath = b.option([]const u8, "syspath", "") orelse "";
const syspath_libreldev = b.option([]const u8, "syspath_libreldev", "") orelse "";
const libactondeps = b.option([]const u8, "libactondeps", "") orelse "";
const libactongc = b.option([]const u8, "libactongc", "") orelse "";
_ = use_prebuilt;
_ = libactongc;
_ = libactondeps;

Expand All @@ -71,7 +68,6 @@ pub fn build(b: *std.Build) void {
const syspath_include = joinPath(b.allocator, syspath, "depsout/include");

print("Acton Base Builder\nBuilding in {s}\n", .{buildroot_path});
_ = syspath_libreldev;

var iter_dir = b.build_root.handle.openDir(
"out/types/",
Expand Down
135 changes: 134 additions & 1 deletion base/src/file.act
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,151 @@ class WriteFileCap():
def __init__(self, cap: FileCap):
pass

class FileStat(value):
name: str
dev: u64
mode: u64
nlink: u64
uid: u64
gid: u64
rdev: u64
ino: u64
size: u64
blksize: u64
blocks: u64
flags: u64
gen: u64
atime: float
mtime: float
ctime: float
birthtime: float

def __init__(self, name: str, dev: u64, mode: u64, nlink: u64, uid: u64, gid: u64, rdev: u64, ino: u64, size: u64, blksize: u64, blocks: u64, flags: u64, gen: u64, atime: float, mtime: float, ctime: float, birthtime: float):
self.name = name
self.dev = dev
self.mode = mode
self.nlink = nlink
self.uid = uid
self.gid = gid
self.rdev = rdev
self.ino = ino
self.size = size
self.blksize = blksize
self.blocks = blocks
self.flags = flags
self.gen = gen
self.atime = atime
self.mtime = mtime
self.ctime = ctime
self.birthtime = birthtime

def is_dir(self) -> bool:
"""Return True if the file is a directory"""
NotImplemented

def is_file(self) -> bool:
"""Return True if the file is a regular file"""
NotImplemented

def is_symlink(self) -> bool:
"""Return True if the file is a symbolic link"""
NotImplemented

def is_block_device(self) -> bool:
"""Return True if the file is a block device"""
NotImplemented

def is_char_device(self) -> bool:
"""Return True if the file is a character device"""
NotImplemented

def is_fifo(self) -> bool:
"""Return True if the file is a FIFO"""
NotImplemented

def is_socket(self) -> bool:
"""Return True if the file is a socket"""
NotImplemented

# TODO: refactor into a read-only version and one for writing!?
actor FS(cap: FileCap):
"""File system operations """

proc def _pin_affinity() -> None:
NotImplemented
_pin_affinity()

action def exepath() -> str:
"""Get the path to the executable"""
NotImplemented

action def homedir() -> str:
"""Get the home directory"""
NotImplemented

action def mkdir(filename: str):
"""Make a directory"""
pass
NotImplemented

action def listdir(path: str) -> list[str]:
"""List directory contents"""
NotImplemented

action def lstat(filename: str) -> FileStat:
"""Get file status without following symlinks"""
NotImplemented

action def remove(filename: str) -> None:
"""Remove a file"""
NotImplemented

action def rmdir(dirname: str) -> None:
"""Remove a directory"""
NotImplemented

action def rmtree(d: str) -> None:
"""Recursively remove a directory tree"""
try:
for entry in listdir(d):
try:
s = lstat(d + "/" + entry)
if s.is_dir():
rmtree(d + "/" + entry)
rmdir(d + "/" + entry)
else:
remove(d + "/" + entry)
except RuntimeError:
# probably a symlink or permission denied
pass
except RuntimeError:
# dir doesn't exist
pass

action def stat(filename: str) -> FileStat:
"""Get file status"""
NotImplemented

action def walk(d: str, follow_symlinks: bool=False) -> list[FileStat]:
"""Recursively walk a directory tree"""
# TODO: this should be a generator
res = []
try:
for entry in listdir(d):
try:
if follow_symlinks:
s = stat(d + "/" + entry)
else:
s = lstat(d + "/" + entry)
res.append(s)
if s.is_dir():
res.extend(walk(d + "/" + entry))
except RuntimeError:
# probably a symlink or permission denied
pass
except RuntimeError:
# dir doesn't exist
pass
return res

actor ReadFile(cap: ReadFileCap, filename: str):
"""Read a file
Expand Down
Loading

0 comments on commit 33ea0a7

Please sign in to comment.