mirror of
https://github.com/g012/l65.git
synced 2024-09-27 19:55:29 +00:00
Added build.zig to cross compile
Warning: currently you need to edit ConfigHeader.zig in Zig's std library, and comment "try output.appendSlice(c_generated_line);"
This commit is contained in:
parent
0a65af8621
commit
29f5666b20
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
/build
|
/build
|
||||||
/tmp
|
/tmp
|
||||||
|
/zig-*
|
||||||
*.bin
|
*.bin
|
||||||
*.nes
|
*.nes
|
||||||
*.nes.deb
|
*.nes.deb
|
||||||
|
@ -8,8 +8,8 @@ set(L65_SOURCE_DIR ${PROJECT_SOURCE_DIR})
|
|||||||
set(L65_BINARY_DIR ${PROJECT_BINARY_DIR})
|
set(L65_BINARY_DIR ${PROJECT_BINARY_DIR})
|
||||||
|
|
||||||
set(L65_VERSION_MAJOR "1")
|
set(L65_VERSION_MAJOR "1")
|
||||||
set(L65_VERSION_MINOR "2")
|
set(L65_VERSION_MINOR "3")
|
||||||
set(L65_VERSION_REVISION "2")
|
set(L65_VERSION_REVISION "0")
|
||||||
set(L65_VERSION "${L65_VERSION_MAJOR}.${L65_VERSION_MINOR}.${L65_VERSION_REVISION}")
|
set(L65_VERSION "${L65_VERSION_MAJOR}.${L65_VERSION_MINOR}.${L65_VERSION_REVISION}")
|
||||||
configure_file("${L65_SOURCE_DIR}/l65cfg.lua.in" "${L65_BINARY_DIR}/l65cfg.lua")
|
configure_file("${L65_SOURCE_DIR}/l65cfg.lua.in" "${L65_BINARY_DIR}/l65cfg.lua")
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# l65
|
# l65
|
||||||
[![Build Status](https://travis-ci.org/g012/l65.svg?branch=master)](https://travis-ci.org/g012/l65)
|
|
||||||
|
|
||||||
l65 is a 6502 assembler, operating from within Lua and written in Lua. This means assembler mnemonics become regular Lua statements anywhere in the middle of Lua code.
|
l65 is a 6502 assembler, operating from within Lua and written in Lua. This means assembler mnemonics become regular Lua statements anywhere in the middle of Lua code.
|
||||||
|
l7801 is a µPD7801 assembler, using l65 framework, created and maintained by [@MooZ] (https://github.com/BlockoS).
|
||||||
|
|
||||||
Table of Contents
|
Table of Contents
|
||||||
=================
|
=================
|
||||||
|
120
build.zig
Normal file
120
build.zig
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
const major: u32 = 1;
|
||||||
|
const minor: u32 = 3;
|
||||||
|
const revision: u32 = 0;
|
||||||
|
|
||||||
|
const targets: []const std.Target.Query = &.{
|
||||||
|
.{ .os_tag = .windows, .cpu_arch = .x86_64, .cpu_model = .baseline },
|
||||||
|
.{ .os_tag = .windows, .cpu_arch = .aarch64, .cpu_model = .baseline },
|
||||||
|
.{ .os_tag = .macos, .cpu_arch = .x86_64, .cpu_model = .baseline, .os_version_min = std.zig.CrossTarget.OsVersion{ .semver = .{ .major = 10, .minor = 7, .patch = 0 } } },
|
||||||
|
.{ .os_tag = .macos, .cpu_arch = .aarch64, .cpu_model = .baseline, .os_version_min = std.zig.CrossTarget.OsVersion{ .semver = .{ .major = 11, .minor = 0, .patch = 0 } } },
|
||||||
|
.{ .os_tag = .linux, .cpu_arch = .x86_64, .cpu_model = .baseline, .abi = .musl },
|
||||||
|
.{ .os_tag = .linux, .cpu_arch = .aarch64, .cpu_model = .baseline },
|
||||||
|
};
|
||||||
|
|
||||||
|
fn setupExe(exe: *std.Build.Step.Compile, embed_output: *const std.Build.LazyPath) !void {
|
||||||
|
exe.addCSourceFiles(.{
|
||||||
|
.files = &.{ "lfs.c", "lpeg.c", "main.c" },
|
||||||
|
.flags = &.{},
|
||||||
|
});
|
||||||
|
|
||||||
|
exe.addIncludePath(embed_output.dirname());
|
||||||
|
|
||||||
|
exe.linkLibC();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn build(b: *std.Build) !void {
|
||||||
|
const target = b.standardTargetOptions(.{});
|
||||||
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Embed tool
|
||||||
|
|
||||||
|
const version_storage = struct { var str: [32]u8 = undefined; };
|
||||||
|
const version = try std.fmt.bufPrint(version_storage.str[0..], "{d}.{d}.{d}", .{ major, minor, revision });
|
||||||
|
const l65cfg_lua_in = b.addConfigHeader(
|
||||||
|
.{
|
||||||
|
.style = .{ .cmake = .{ .path = "l65cfg.lua.in" } },
|
||||||
|
.include_path = "l65cfg.lua",
|
||||||
|
},
|
||||||
|
.{
|
||||||
|
.L65_VERSION_MAJOR = major,
|
||||||
|
.L65_VERSION_MINOR = minor,
|
||||||
|
.L65_VERSION_REVISION = revision,
|
||||||
|
.L65_VERSION = version,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
// FIXME current version (0.12-dev) of ConfigHeader adds a C comment on top of file
|
||||||
|
// - comment "try output.appendSlice(c_generated_line);" in ConfigHeader.zig to avoid it
|
||||||
|
|
||||||
|
|
||||||
|
const embed_exe = b.addExecutable(.{
|
||||||
|
.name = "embed",
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
embed_exe.addCSourceFile(.{ .file = .{ .path = "embed.c" }, .flags = &.{ "-std=c99" } });
|
||||||
|
embed_exe.linkLibC();
|
||||||
|
|
||||||
|
const embed = b.addRunArtifact(embed_exe);
|
||||||
|
embed.step.dependOn(&l65cfg_lua_in.step);
|
||||||
|
embed.addArg("-o");
|
||||||
|
const embed_output = embed.addOutputFileArg("scripts.h");
|
||||||
|
embed.addFileArg(l65cfg_lua_in.getOutput());
|
||||||
|
embed.addFileArg(.{ .path = "asm.lua" });
|
||||||
|
embed.addFileArg(.{ .path = "6502.lua" });
|
||||||
|
embed.addFileArg(.{ .path = "dkjson.lua" });
|
||||||
|
embed.addFileArg(.{ .path = "l65.lua" });
|
||||||
|
embed.addFileArg(.{ .path = "re.lua" });
|
||||||
|
embed.addFileArg(.{ .path = "nes.l65" });
|
||||||
|
embed.addFileArg(.{ .path = "pce.l65" });
|
||||||
|
embed.addFileArg(.{ .path = "vcs.l65" });
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Build for current machine
|
||||||
|
|
||||||
|
var exe = b.addExecutable(.{
|
||||||
|
.name = "l65",
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
|
exe.step.dependOn(&embed.step);
|
||||||
|
try setupExe(exe, &embed_output);
|
||||||
|
b.installArtifact(exe);
|
||||||
|
|
||||||
|
const run_cmd = b.addRunArtifact(exe);
|
||||||
|
run_cmd.step.dependOn(b.getInstallStep());
|
||||||
|
if (b.args) |args| {
|
||||||
|
run_cmd.addArgs(args);
|
||||||
|
}
|
||||||
|
const run_step = b.step("run", "Run l65");
|
||||||
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Release binaries
|
||||||
|
|
||||||
|
const release_step = b.step("release", "Generate a release");
|
||||||
|
for (targets) |t| {
|
||||||
|
const rel_exe = b.addExecutable(.{
|
||||||
|
.name = "l65",
|
||||||
|
.target = b.resolveTargetQuery(t),
|
||||||
|
.optimize = .ReleaseSmall,
|
||||||
|
});
|
||||||
|
const target_output = b.addInstallArtifact(rel_exe, .{
|
||||||
|
.dest_dir = .{
|
||||||
|
.override = .{
|
||||||
|
.custom = try t.zigTriple(b.allocator),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
rel_exe.step.dependOn(&embed.step);
|
||||||
|
try setupExe(rel_exe, &embed_output);
|
||||||
|
release_step.dependOn(&target_output.step);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// Build samples as test
|
||||||
|
// TODO
|
||||||
|
}
|
2
lua.h
2
lua.h
@ -20280,7 +20280,7 @@ static void luai_fchecksize (luai_LoadState *S, size_t size, const char *tname)
|
|||||||
#define luai_checksize(S,t) luai_fchecksize(S,sizeof(t),#t)
|
#define luai_checksize(S,t) luai_fchecksize(S,sizeof(t),#t)
|
||||||
|
|
||||||
static void luai_checkHeader (luai_LoadState *S) {
|
static void luai_checkHeader (luai_LoadState *S) {
|
||||||
luai_checkliteral(S, LUA_SIGNATURE + 1, "not a"); /* 1st char already checked */
|
luai_checkliteral(S, (const char*)LUA_SIGNATURE + 1, "not a"); /* 1st char already checked */
|
||||||
if (luai_LoadByte(S) != LUAC_VERSION)
|
if (luai_LoadByte(S) != LUAC_VERSION)
|
||||||
luai_error(S, "version mismatch in");
|
luai_error(S, "version mismatch in");
|
||||||
if (luai_LoadByte(S) != LUAC_FORMAT)
|
if (luai_LoadByte(S) != LUAC_FORMAT)
|
||||||
|
Loading…
Reference in New Issue
Block a user