Skip to content

Commit

Permalink
Change fift path separator for FIFTPATH and -I argument (#1014)
Browse files Browse the repository at this point in the history
* add github action for macOS 14 (arm64, M1)

* add github action (portable) for macOS 14 (arm64, M1)

* rename macOS arm64 output artifact

* Colon cannot be used as a path separator for FIFTPATH or -I argument in fift on Windows when absolute paths are used (e.g. C:\path\lib:C:\path\smartcont).
Suggestion to use @ as a new path separator on Windows.

---------

Co-authored-by: neodiX <neodix42@ton.org>
  • Loading branch information
neodix42 and neodiX authored Jun 7, 2024
1 parent f9b6d21 commit 5186c47
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 6 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build-ton-macos-arm64-shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: MacOS TON build (shared, arm64)

on: [push,workflow_dispatch,workflow_call]

jobs:
build:
runs-on: macos-14

steps:
- name: Check out repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Build TON
run: |
cp assembly/native/build-macos-shared.sh .
chmod +x build-macos-shared.sh
./build-macos-shared.sh -t -a
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-binaries-macos-14
path: artifacts
107 changes: 107 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ jobs:
workflow_conclusion: success
skip_unpack: true

- name: Download Mac arm64 artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: ton-arm64-macos.yml
path: artifacts
workflow_conclusion: success
skip_unpack: true

- name: Download and unzip Mac x86-64 artifacts
uses: dawidd6/action-download-artifact@v2
with:
Expand All @@ -43,6 +51,14 @@ jobs:
workflow_conclusion: success
skip_unpack: false

- name: Download and unzip arm64 artifacts
uses: dawidd6/action-download-artifact@v2
with:
workflow: ton-arm64-macos.yml
path: artifacts
workflow_conclusion: success
skip_unpack: false

- name: Download Windows artifacts
uses: dawidd6/action-download-artifact@v2
with:
Expand Down Expand Up @@ -297,6 +313,97 @@ jobs:
asset_name: tonlib-cli-mac-x86-64
tag: ${{ steps.tag.outputs.TAG }}


# mac arm64

- name: Upload Mac arm64 artifacts
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries.zip
asset_name: ton-mac-arm64.zip
tag: ${{ steps.tag.outputs.TAG }}

- name: Upload Mac arm64 single artifact - fift
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries/fift
asset_name: fift-mac-arm64
tag: ${{ steps.tag.outputs.TAG }}

- name: Upload Mac arm64 single artifact - func
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries/func
asset_name: func-mac-arm64
tag: ${{ steps.tag.outputs.TAG }}

- name: Upload Mac arm64 single artifact - lite-client
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries/lite-client
asset_name: lite-client-mac-arm64
tag: ${{ steps.tag.outputs.TAG }}

- name: Upload Mac arm64 single artifact - rldp-http-proxy
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries/rldp-http-proxy
asset_name: rldp-http-proxy-mac-arm64
tag: ${{ steps.tag.outputs.TAG }}

- name: Upload Mac arm64 single artifact - http-proxy
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries/http-proxy
asset_name: http-proxy-mac-arm64
tag: ${{ steps.tag.outputs.TAG }}

- name: Upload Mac arm64 single artifact - storage-daemon-cli
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries/storage-daemon-cli
asset_name: storage-daemon-cli-mac-arm64
tag: ${{ steps.tag.outputs.TAG }}

- name: Upload Mac arm64 single artifact - storage-daemon
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries/storage-daemon
asset_name: storage-daemon-mac-arm64
tag: ${{ steps.tag.outputs.TAG }}

- name: Upload Mac arm64 single artifact - tonlibjson
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries/libtonlibjson.dylib
asset_name: tonlibjson-mac-arm64.dylib
tag: ${{ steps.tag.outputs.TAG }}

- name: Upload Mac arm64 single artifact - libemulator
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries/libemulator.dylib
asset_name: libemulator-mac-arm64.dylib
tag: ${{ steps.tag.outputs.TAG }}

- name: Upload Mac arm64 single artifact - tonlib-cli
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/ton-arm64-macos-binaries/tonlib-cli
asset_name: tonlib-cli-mac-arm64
tag: ${{ steps.tag.outputs.TAG }}

# linux x86-64

- name: Upload Linux x86-64 artifacts
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/ton-arm64-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: MacOS TON build (portable, arm64)

on: [push,workflow_dispatch,workflow_call]

jobs:
build:
runs-on: macos-14

steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- uses: cachix/install-nix-action@v23
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Build TON
run: |
cp assembly/nix/build-macos-nix.sh .
chmod +x build-macos-nix.sh
./build-macos-nix.sh -t
- name: Simple binaries test
run: |
sudo mv /nix/store /nix/store2
artifacts/validator-engine -V
artifacts/lite-client -V
artifacts/fift -V
artifacts/func -V
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: ton-arm64-macos-binaries
path: artifacts
9 changes: 8 additions & 1 deletion crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,17 @@ if (NOT CMAKE_CROSSCOMPILING OR USE_EMSCRIPTEN)
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_DEST_FIF}
)
set(ARG_DEST_CPP "${ARG_DEST}.cpp")

if (WIN32)
set(ARG_LIB_DIR "fift/lib@smartcont")
else()
set(ARG_LIB_DIR "fift/lib:smartcont")
endif()

add_custom_command(
COMMENT "Generate ${ARG_DEST_CPP}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND fift -Ifift/lib:smartcont -s asm-to-cpp.fif ${ARG_DEST_FIF} ${ARG_DEST_CPP} ${ARG_NAME}
COMMAND fift -I${ARG_LIB_DIR} -s asm-to-cpp.fif ${ARG_DEST_FIF} ${ARG_DEST_CPP} ${ARG_NAME}
MAIN_DEPENDENCY ${ARG_SOURCE}
DEPENDS fift ${ARG_DEST_FIF} smartcont/asm-to-cpp.fif fift/lib/Asm.fif
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_DEST_CPP}
Expand Down
9 changes: 7 additions & 2 deletions crypto/block/create-state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,11 +814,16 @@ void usage(const char* progname) {
void parse_include_path_set(std::string include_path_set, std::vector<std::string>& res) {
td::Parser parser(include_path_set);
while (!parser.empty()) {
auto path = parser.read_till_nofail(':');
#if TD_WINDOWS
auto path_separator = '@';
#else
auto path_separator = ':';
#endif
auto path = parser.read_till_nofail(path_separator);
if (!path.empty()) {
res.push_back(path.str());
}
parser.skip_nofail(':');
parser.skip_nofail(path_separator);
}
}

Expand Down
11 changes: 8 additions & 3 deletions crypto/fift/fift-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void usage(const char* progname) {
<< " [-i] [-n] [-I <source-include-path>] {-L <library-fif-file>} <source-file1-fif> <source-file2-fif> ...\n";
std::cerr << "\t-n\tDo not preload standard preamble file `Fift.fif`\n"
"\t-i\tForce interactive mode even if explicit source file names are indicated\n"
"\t-I<source-search-path>\tSets colon-separated library source include path. If not indicated, "
"\t-I<source-search-path>\tSets colon-separated (unix) or at-separated (windows) library source include path. If not indicated, "
"$FIFTPATH is used instead.\n"
"\t-L<library-fif-file>\tPre-loads a library source file\n"
"\t-d<ton-db-path>\tUse a ton database\n"
Expand All @@ -75,11 +75,16 @@ void usage(const char* progname) {
void parse_include_path_set(std::string include_path_set, std::vector<std::string>& res) {
td::Parser parser(include_path_set);
while (!parser.empty()) {
auto path = parser.read_till_nofail(':');
#if TD_WINDOWS
auto path_separator = '@';
#else
auto path_separator = ':';
#endif
auto path = parser.read_till_nofail(path_separator);
if (!path.empty()) {
res.push_back(path.str());
}
parser.skip_nofail(':');
parser.skip_nofail(path_separator);
}
}

Expand Down

0 comments on commit 5186c47

Please sign in to comment.