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

Feature/more examples #3599

Merged
merged 9 commits into from
Apr 21, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "tests"]
path = tests
url = https://github.com/TrueBlocks/trueblocks-tests
[submodule "examples"]
path = examples
url = https://github.com/TrueBlocks/trueblocks-examples
1 change: 1 addition & 0 deletions examples
Submodule examples added at 853aab
5 changes: 5 additions & 0 deletions scripts/build_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

cd examples
go build -o ../bin/examples/example1 example1/main.go
# go build -o ../bin/examples/example2 example2/main.go
2 changes: 1 addition & 1 deletion sdk/go/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module "github.com/TrueBlocks/trueblocks-core/v0/sdk"
module github.com/TrueBlocks/trueblocks-core/v0/sdk

// Go Version
go 1.22
38 changes: 22 additions & 16 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,34 @@ set(BIN_TEST_DIR ${BIN_CMDS_DIR}/test)
set(CMAKE_INSTALL_PREFIX "/usr/local/" CACHE PATH "Default install directory")

# ----------------------------------------------------------------------------------------
function(ADD_GO_INSTALLABLE_PROGRAM NAME MAIN_SRC DEST_DIR)
add_subdirectory(other/install)
add_subdirectory(other/build_assets)

# ----------------------------------------------------------------------------------------
set(REPO_DIR ${CMAKE_SOURCE_DIR}/..)
set(SCRIPTS_DIR ${REPO_DIR}/scripts)

add_custom_target(lint COMMAND "golangci-lint" "run" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/apps/chifra")
add_custom_target(generate COMMAND "${BIN_DIR}/goMaker" "" WORKING_DIRECTORY "${REPO_DIR}")
add_custom_target(test-all COMMAND "${BIN_TEST_DIR}/test-all.sh" WORKING_DIRECTORY "${REPO_DIR}/build")
add_custom_target(examples ALL COMMAND ${SCRIPTS_DIR}/build_examples.sh WORKING_DIRECTORY ${REPO_DIR})

# ----------------------------------------------------------------------------------------
function(ADD_GO_INSTALLABLE_PROGRAM2 NAME MAIN_SRC DEST_DIR)
get_filename_component(MAIN_SRC_ABS ${MAIN_SRC} ABSOLUTE)
add_custom_target(${NAME})
add_custom_target(${NAME} ALL)
add_custom_command(TARGET ${NAME}
COMMAND go build
-o "${DEST_DIR}/${NAME}"
${CMAKE_GO_FLAGS} ${MAIN_SRC}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS ${MAIN_SRC_ABS} ${MAIN_SRC})
add_custom_target(${NAME}_all ALL DEPENDS ${NAME})
endfunction(ADD_GO_INSTALLABLE_PROGRAM)
endfunction(ADD_GO_INSTALLABLE_PROGRAM2)

# ----------------------------------------------------------------------------------------
# Enable testing
# enable_testing()
add_custom_target(lint COMMAND "golangci-lint" "run" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/apps/chifra")
add_custom_target(generate COMMAND "${BIN_DIR}/goMaker" "" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/..")
add_custom_target(test-all COMMAND "${BIN_TEST_DIR}/test-all.sh" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/../build")
ADD_GO_INSTALLABLE_PROGRAM2(testRunner ${CMAKE_SOURCE_DIR}/dev_tools/testRunner/*.go ${BIN_DIR})
ADD_GO_INSTALLABLE_PROGRAM2(goMaker ${CMAKE_SOURCE_DIR}/dev_tools/goMaker/*.go ${BIN_DIR})
ADD_GO_INSTALLABLE_PROGRAM2(chifra ${CMAKE_SOURCE_DIR}/apps/chifra/*.go ${BIN_DIR})

# ----------------------------------------------------------------------------------------
# Compilation order for the subfolders
add_subdirectory(dev_tools)
add_subdirectory(apps)
add_subdirectory(examples)
add_subdirectory(other)
add_dependencies(testRunner goMaker)
add_dependencies(chifra testRunner)
add_dependencies(examples chifra)
3 changes: 0 additions & 3 deletions src/apps/CMakeLists.txt

This file was deleted.

16 changes: 0 additions & 16 deletions src/apps/chifra/CMakeLists.txt

This file was deleted.

6 changes: 0 additions & 6 deletions src/dev_tools/CMakeLists.txt

This file was deleted.

5 changes: 0 additions & 5 deletions src/dev_tools/goMaker/CMakeLists.txt

This file was deleted.

5 changes: 0 additions & 5 deletions src/dev_tools/testRunner/CMakeLists.txt

This file was deleted.

12 changes: 10 additions & 2 deletions src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
cmake_minimum_required (VERSION 3.5)

project (examples)
function(ADD_GO_INSTALLABLE_PROGRAM NAME MAIN_SRC DEST_DIR)
get_filename_component(MAIN_SRC_ABS ${MAIN_SRC} ABSOLUTE)
add_custom_target(${NAME} ALL)
add_custom_command(TARGET ${NAME}
COMMAND go build
-o "${DEST_DIR}/${NAME}"
${CMAKE_GO_FLAGS} ${MAIN_SRC}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS ${MAIN_SRC_ABS} ${MAIN_SRC})
endfunction(ADD_GO_INSTALLABLE_PROGRAM)

add_subdirectory(simple)
add_subdirectory(findFirst)
# add_subdirectory(txCounter)
add_subdirectory(allContracts)
add_subdirectory(usesSDK)
add_subdirectory(balanceChart)
Expand Down
2 changes: 1 addition & 1 deletion src/examples/balanceChart/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/TrueBlocks/balanceChart
module github.com/TrueBlocks/examples/balanceChart

// Go Version
go 1.22
Expand Down
3 changes: 1 addition & 2 deletions src/examples/balanceChart/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"sort"
"strings"

"github.com/TrueBlocks/examples/balanceChart/charts"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc"
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types"
"github.com/TrueBlocks/trueblocks-core/v0/sdk"
"github.com/bykof/gostradamus"

"github.com/TrueBlocks/balanceChart/charts"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion src/examples/optimism1/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/TrueBlocks/examples
module github.com/TrueBlocks/examples/optimism1

// Go Version
go 1.22
Expand Down
2 changes: 1 addition & 1 deletion src/examples/usesSDK/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/TrueBlocks/usesSDK
module github.com/TrueBlocks/examples/usesSDK

// Go Version
go 1.22
Expand Down
11 changes: 0 additions & 11 deletions src/other/CMakeLists.txt

This file was deleted.

13 changes: 0 additions & 13 deletions src/other/known_abi_gen/README.md

This file was deleted.

46 changes: 0 additions & 46 deletions src/other/known_abi_gen/cmd/root.go

This file was deleted.

31 changes: 0 additions & 31 deletions src/other/known_abi_gen/go.mod.save

This file was deleted.

Loading
Loading