Skip to content

Commit

Permalink
Fix last minute bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
AMythicDev committed May 27, 2024
1 parent 0c5d5bb commit 7b13c0f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
4 changes: 4 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ pub fn build(b: *std.Build) !void {
common.link_libc = true;
}

const strip = if (optimize == std.builtin.OptimizeMode.ReleaseSafe) true else null;

const zigvm = b.addExecutable(.{
.name = "zigvm",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.strip = strip,
});
const zig = b.addExecutable(.{
.name = "zig",
.root_source_file = b.path("src/zig//main.zig"),
.target = target,
.optimize = optimize,
.strip = strip,
});

zigvm.root_module.addImport("common", common);
Expand Down
15 changes: 4 additions & 11 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,16 @@ OS=$(uname -s | awk '{print tolower($0)}')
ARCH=$(uname -m | awk '{print tolower($0)}')

curl -L https://github.com/AMythicDev/zigvm/releases/download/v0.1.0/zigvm-0.1.0-${ARCH}-${OS}.zip > /tmp/zigvm.zip
unzip /tmp/zigvm.zip

mv zigvm-0.1.0-${ARCH}-${OS}/zigvm $ZIGVM_ROOT_DIR/bin/
mv zigvm-0.1.0-${ARCH}-${OS}/zig $ZIGVM_ROOT_DIR/bin/

chmod 755 $ZIGVM_ROOT_DIR/bin/zigvm
chmod 755 $ZIGVM_ROOT_DIR/bin/zig
unzip /tmp/zigvm.zip -d $ZIGVM_ROOT_DIR/bin/

echo "Installing zig stable"
$ZIGVM_ROOT_DIR/bin/zigvm install stable
echo "Setting default version to stable"
$ZIGVM_ROOT_DIR/bin/zigvm override default stable


DEFAULT_SHELL=$(getent passwd arijit | awk -F: '{ print($NF) } ' | awk -F/ '{ print ($NF) }')

case DEFAULT_SHELL in
case $DEFAULT_SHELL in
"bash")
echo 'export PATH=$PATH:'$ZIGVM_ROOT_DIR/bin >> $HOME/.bashrc
;;
Expand All @@ -44,9 +37,9 @@ case DEFAULT_SHELL in
*)
echo "Cannot write to shell rc file. Unknown shell" 1>&2;
echo "You need to manually add {$ZIGVM_ROOT_DIR}/bin to ensure zigvm can be called from anywhere."
;;
esac

echo 'export PATH=$PATH:'$ZIGVM_ROOT_DIR/bin/ >> $HOME/.profile

echo "\033[0;33;1mzigvm installed successfully"
echo "Please restart your terminal for changes to take effect."
echo -e "\033[0;33;1mzigvm installed successfully\nPlease restart your terminal for changes to take effect.\033[0m"
7 changes: 4 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ fn install_release(alloc: Allocator, client: *Client, releases: json.Value, rel:
var try_tarball_file = cp.download_dir.openFile(tarball_dw_filename, .{});

if (try_tarball_file == File.OpenError.FileNotFound) {
var tarball = try cp.download_dir.createFile(tarball_dw_filename, .{});
defer tarball.close();
var tarball = try cp.download_dir.createFile(tarball_dw_filename, .{ .read = true });

var tarball_writer = std.io.bufferedWriter(tarball.writer());
try download_tarball(
Expand All @@ -97,13 +96,15 @@ fn install_release(alloc: Allocator, client: *Client, releases: json.Value, rel:
&tarball_writer,
tarball_size,
);
try_tarball_file = cp.download_dir.createFile(tarball_dw_filename, .{});
try_tarball_file = tarball;
try tarball.seekTo(0);
} else {
std.log.info("Found already existing tarball, using that", .{});
}

const tarball_file = try try_tarball_file;
defer tarball_file.close();

var tarball_reader = std.io.bufferedReader(tarball_file.reader());
const hash_matched = try utils.check_hash(target.object.get("shasum").?.string[0..64], tarball_reader.reader());

Expand Down
3 changes: 2 additions & 1 deletion z.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def make_release():
print(f"Building for {target}")
target_dir = "zigvm-" + VERSION + "-" + target
subprocess.run(["zig", "build", "install", "--prefix", "releases/",
"--prefix-exe-dir", target_dir, "--release=safe"])
"--prefix-exe-dir", target_dir, "--release=safe",
f"-Dtarget={target}"])
shutil.make_archive("releases/" + target_dir,
"zip", "releases/" + target_dir)

Expand Down

0 comments on commit 7b13c0f

Please sign in to comment.