Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(fmt): replace fmt with std format #191

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:

build-macos:
name: Build macOS
runs-on: macos-latest
runs-on: macos-13
strategy:
fail-fast: false
matrix:
Expand All @@ -86,6 +86,16 @@ jobs:
fetch-depth: 0
lfs: false

- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Install LLVM
run: brew install llvm

- name: Add LLVM to PATH
run: |
echo "/usr/local/opt/llvm/bin" >> $GITHUB_PATH

- name: Add premake5 to PATH
uses: abel0b/[email protected]
with:
Expand Down Expand Up @@ -119,7 +129,7 @@ jobs:
- release
arch:
- x64
- arm64
# - arm64
steps:
- name: Check out files
uses: actions/checkout@v4
Expand All @@ -128,11 +138,15 @@ jobs:
fetch-depth: 0
lfs: false

- name: Install dependencies (arm64)
if: matrix.arch == 'arm64'
- name: Install LLVM
run: |
sudo apt-get update
sudo apt-get install crossbuild-essential-arm64 -y
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17

# - name: Install dependencies (arm64)
# if: matrix.arch == 'arm64'
# run: sudo apt-get install crossbuild-essential-arm64 -y

- name: Add premake5 to PATH
uses: abel0b/[email protected]
Expand All @@ -150,8 +164,8 @@ jobs:
pushd build
make config=${{matrix.config}}_${{matrix.arch}} -j$(nproc)
env:
CC: clang
CXX: clang++
CC: clang-17
CXX: clang++-17

- name: Upload ${{matrix.arch}} ${{matrix.config}} binaries
uses: actions/[email protected]
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
path = deps/zlib
url = https://github.com/madler/zlib
branch = master
[submodule "deps/fmt"]
path = deps/fmt
url = https://github.com/fmtlib/fmt
[submodule "deps/cxxopts"]
path = deps/cxxopts
url = https://github.com/jarro2783/cxxopts.git
1 change: 0 additions & 1 deletion deps/fmt
Submodule fmt deleted from 67c0c0
31 changes: 0 additions & 31 deletions deps/fmt.lua

This file was deleted.

26 changes: 13 additions & 13 deletions deps/zlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ function zlib:project()
language "C"
warnings "off"

if os.istarget("linux") or os.istarget("macosx") then
defines {
"HAVE_UNISTD_H"
}
elseif os.istarget("windows") then
defines {
"_CRT_SECURE_NO_WARNINGS",
"_CRT_NONSTDC_NO_DEPRECATE",
"_CRT_SECURE_NO_DEPRECATE",
}
end

self:include()

files
{
files {
path.join(zlib.base, "*.h"),
path.join(zlib.base, "*.c")
}

defines
{
"_CRT_SECURE_NO_WARNINGS",
"_CRT_NONSTDC_NO_DEPRECATE",
"_CRT_SECURE_NO_DEPRECATE",
}

if os.istarget("darwin") then
defines "HAVE_UNISTD_H"
end
end

table.insert(dependencies, zlib)
8 changes: 4 additions & 4 deletions gen/arc/parser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,13 @@ stmt_for
stmt_foreach
: FOREACH LPAREN expr_identifier IN expr RPAREN stmt
{
auto array = expr_identifier::make(@$, fmt::format("_a{}", ++index));
auto key = expr_identifier::make(@$, fmt::format("_k{}", ++index));
auto array = expr_identifier::make(@$, std::format("_a{}", ++index));
auto key = expr_identifier::make(@$, std::format("_k{}", ++index));
$$ = stmt_foreach::make(@$, std::move($5), std::move($3), std::move(array), std::move(key), std::move($7), false);
}
| FOREACH LPAREN expr_identifier COMMA expr_identifier IN expr RPAREN stmt
{
auto array = expr_identifier::make(@$, fmt::format("_a{}", ++index));
auto array = expr_identifier::make(@$, std::format("_a{}", ++index));
$$ = stmt_foreach::make(@$, std::move($7), std::move($5), std::move(array), std::move($3), std::move($9), true);
}
;
Expand Down Expand Up @@ -1161,7 +1161,7 @@ auto map_token(context const* ctx_, token& tok) -> parser::symbol_type
}
}

throw error(fmt::format("unmapped token! {}", (u8)tok.type));
throw error(std::format("unmapped token! {}", (u8)tok.type));
}

auto ARClex(context const* ctx_, preprocessor& ppr) -> parser::symbol_type
Expand Down
14 changes: 7 additions & 7 deletions gen/gsc/parser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ decl_constant
: expr_identifier ASSIGN expr SEMICOLON
{
ppr.ban_header(@$); $$ = decl_constant::make(@$, std::move($1), std::move($3));
printf("%s" , fmt::format("{}: constants deprecated, use #define instead\n", @$.print()).data());
printf("%s" , std::format("{}: constants deprecated, use #define instead\n", @$.print()).data());
}
;

Expand Down Expand Up @@ -496,14 +496,14 @@ stmt_for
stmt_foreach
: FOREACH LPAREN expr_identifier IN expr RPAREN stmt
{
auto array = expr_identifier::make(@$, fmt::format("_temp_{}", ++index));
auto key = expr_identifier::make(@$, fmt::format("_temp_{}", ++index));
auto array = expr_identifier::make(@$, std::format("_temp_{}", ++index));
auto key = expr_identifier::make(@$, std::format("_temp_{}", ++index));
$$ = stmt_foreach::make(@$, std::move($5), std::move($3), expr_empty::make(@$), std::move(array), std::move(key), std::move($7), false);
}
| FOREACH LPAREN expr_identifier COMMA expr_identifier IN expr RPAREN stmt
{
auto array = expr_identifier::make(@$, fmt::format("_temp_{}", ++index));
expr::ptr key = (ctx_->props() & props::foreach) ? expr_identifier::make(@$, fmt::format("_temp_{}", ++index)) : std::move($3);
auto array = expr_identifier::make(@$, std::format("_temp_{}", ++index));
expr::ptr key = (ctx_->props() & props::foreach) ? expr_identifier::make(@$, std::format("_temp_{}", ++index)) : std::move($3);
$$ = stmt_foreach::make(@$, std::move($7), std::move($5), (ctx_->props() & props::foreach) ? std::move($3) : (expr::ptr)expr_empty::make(@$), std::move(array), std::move(key), std::move($9), true);
}
;
Expand Down Expand Up @@ -821,7 +821,7 @@ expr_tuple
: LBRACKET expr_tuple_arguments RBRACKET
{
$$ = std::move($2);
$$->as<expr_tuple>().temp = expr_identifier::make($$->loc(), fmt::format("_temp_{}", ++index));
$$->as<expr_tuple>().temp = expr_identifier::make($$->loc(), std::format("_temp_{}", ++index));
}
;

Expand Down Expand Up @@ -1088,7 +1088,7 @@ auto map_token(context const* ctx_, token& tok) -> parser::symbol_type
}
}

throw error(fmt::format("unmapped token! {}", (u8)tok.type));
throw error(std::format("unmapped token! {}", (u8)tok.type));
}

auto GSClex(context const* ctx_, preprocessor& ppr) -> parser::symbol_type
Expand Down
4 changes: 2 additions & 2 deletions include/xsk/arc/common/location.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ class location

auto print() const -> std::string
{
return fmt::format("{}:{}:{}", *begin.filename, begin.line, begin.column);
return std::format("{}:{}:{}", *begin.filename, begin.line, begin.column);
}

auto label() const -> std::string
{
return fmt::format("loc_{:X}", begin.line);
return std::format("loc_{:X}", begin.line);
}
};

Expand Down
4 changes: 2 additions & 2 deletions include/xsk/gsc/common/location.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ class location

auto print() const -> std::string
{
return fmt::format("{}:{}:{}", *begin.filename, begin.line, begin.column);
return std::format("{}:{}:{}", *begin.filename, begin.line, begin.column);
}

auto label() const -> std::string
{
return fmt::format("loc_{:X}", begin.line);
return std::format("loc_{:X}", begin.line);
}
};

Expand Down
8 changes: 1 addition & 7 deletions include/xsk/stdinc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <array>
#include <deque>
#include <filesystem>
#include <format>
#include <fstream>
#include <functional>
#include <iostream>
Expand All @@ -31,13 +32,6 @@
#include <vector>
#include <version>

#ifdef __cpp_lib_format
#include <format>
namespace fmt = std;
#else
#include <fmt/core.h>
#endif

#ifdef _WINDOWS_
#undef ERROR
#undef IN
Expand Down
30 changes: 9 additions & 21 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ workspace "gsc-tool"

configurations { "debug", "release" }

if os.istarget("linux") or os.istarget("darwin") then
if os.istarget("linux") or os.istarget("macosx") then
platforms { "x64", "arm64" }
else
platforms { "x86", "x64", "arm64" }
Expand Down Expand Up @@ -119,23 +119,18 @@ workspace "gsc-tool"
staticruntime "On"
warnings "Extra"

filter { "system:linux", "system:macosx" }
buildoptions "-pthread"
linkoptions "-pthread"
filter "system:linux"
linkoptions "-fuse-ld=lld"
filter {}

if os.istarget("linux") then
filter { "platforms:arm64" }
buildoptions "--target=arm64-linux-gnu"
linkoptions "--target=arm64-linux-gnu"
filter {}

linkoptions "-fuse-ld=lld"
end
filter { "system:linux", "platforms:arm64" }
buildoptions "--target=arm64-linux-gnu"
linkoptions "--target=arm64-linux-gnu"
filter {}

filter { "system:macosx", "platforms:arm64" }
buildoptions "-arch arm64"
linkoptions "-arch arm64"
buildoptions "-arch arm64"
linkoptions "-arch arm64"
filter {}

filter "configurations:release"
Expand Down Expand Up @@ -178,7 +173,6 @@ project "xsk-tool"
}

cxxopts:link()
fmt:link()
zlib:link()

project "xsk-utils"
Expand All @@ -195,7 +189,6 @@ project "xsk-utils"
"./include",
}

fmt:include()
zlib:include()

project "xsk-arc"
Expand All @@ -212,8 +205,6 @@ project "xsk-arc"
"./include",
}

fmt:include()

project "xsk-gsc"
kind "StaticLib"
language "C++"
Expand All @@ -228,8 +219,5 @@ project "xsk-gsc"
"./include",
}

fmt:include()

group "Dependencies"
zlib:project()
fmt:project()
10 changes: 5 additions & 5 deletions src/arc/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ auto assembler::assemble_instruction(instruction const& inst) -> void
assemble_end_switch(inst);
break;
default:
throw asm_error(fmt::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
throw asm_error(std::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
}
}

Expand Down Expand Up @@ -533,7 +533,7 @@ auto assembler::assemble_end_switch(instruction const& inst) -> void
}
else
{
throw asm_error(fmt::format("invalid switch case {}", inst.data[1 + (3 * i)]));
throw asm_error(std::format("invalid switch case {}", inst.data[1 + (3 * i)]));
}
}
}
Expand Down Expand Up @@ -846,7 +846,7 @@ auto assembler::align_instruction(instruction& inst) -> void
break;
}
default:
throw asm_error(fmt::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
throw asm_error(std::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
}
}

Expand All @@ -860,7 +860,7 @@ auto assembler::resolve_label(std::string const& name) -> i32
}
}

throw asm_error(fmt::format("couldn't resolve label address of {}", name));
throw asm_error(std::format("couldn't resolve label address of {}", name));
}

auto assembler::resolve_string(std::string const& name) -> u16
Expand All @@ -872,7 +872,7 @@ auto assembler::resolve_string(std::string const& name) -> u16
return itr->second;
}

throw asm_error(fmt::format("couldn't resolve string address of {}", name));
throw asm_error(std::format("couldn't resolve string address of {}", name));
}

void assembler::add_stringref(std::string const& str, string_type type, u32 ref)
Expand Down
Loading
Loading