diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-8-build.yml similarity index 96% rename from .github/workflows/linux-ci.yml rename to .github/workflows/linux-8-build.yml index cb9f84c..26eed32 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-8-build.yml @@ -1,4 +1,4 @@ -name: Linux CI +name: Linux TCL8 build on: push: diff --git a/.github/workflows/mac-ci.yml b/.github/workflows/mac-8-build.yml similarity index 50% rename from .github/workflows/mac-ci.yml rename to .github/workflows/mac-8-build.yml index 02cde94..0ca7f07 100644 --- a/.github/workflows/mac-ci.yml +++ b/.github/workflows/mac-8-build.yml @@ -16,14 +16,14 @@ jobs: - name: Install dependencies run: | brew update - brew install tcl-tk || true - sudo mkdir -p /usr/local - sudo ln -sf /usr/local/opt/tcl-tk/include/tcl-tk /usr/local/include/tcl8.6 - sudo install /usr/local/opt/tcl-tk/lib/libtcl* /usr/local/lib - sudo ln -sf /usr/local/opt/tcl-tk/bin/tclsh8.6 /usr/local/bin/tclsh - sudo ln -sf /usr/local/opt/tcl-tk/bin/tclsh8.6 /usr/local/bin/tclsh8.6 + brew reinstall tcl-tk@8 - name: make - run: make + run: | + PREFIX=/opt/homebrew/opt/tcl-tk@8 + export LDFLAGS="-L$PREFIX/lib" + export CPPFLAGS="-I$PREFIX/include" + export TCL_ROOT=$PREFIX + make - name: install run: sudo make install - name: make test diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ad5c84..191d4a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ include(cmake/version.cmake) load_git_properties(cpptcl ${CMAKE_BINARY_DIR}/generated) set(CPPTCL_VERSION 2.2.8) +cmake_policy(SET CMP0074 NEW) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to Release as none was specified.") @@ -13,8 +14,6 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) endif() message(INFO " cmake build type ${CMAKE_BUILD_TYPE}") -set(TCLSH_VERSION_STRING, "8.6") - # Determine if cpptcl is built as a subproject (using add_subdirectory) # or if it is the master project. set(CPPTCL_MASTER_PROJECT OFF) @@ -38,17 +37,9 @@ endif() include (CTest) -set(TCL_VERSION_MAJOR "8" CACHE STRING "TCL Major version") -set(TCL_VERSION_MINOR "6" CACHE STRING "TCL Minor version") -set(TCL_TCLSH "tclsh${TCL_VERSION_MAJOR}.${TCL_VERSION_MINOR}") -set(TCL_VER "${TCL_VERSION_MAJOR}.${TCL_VERSION_MINOR}") -set(TCL_VER_BSD "${TCL_VERSION_MAJOR}${TCL_VERSION_MINOR}") - -message(INFO " TCL_VER ${TCL_VER}") - -find_path(TCL_INCLUDE_PATH tcl.h PATHS /usr/local/include/tcl${TCL_VER} /usr/local/include /usr/include/tcl${TCL_VER} /usr/include NO_DEFAULT_PATH) -find_library(TCL_LIBRARY NAMES tcl${TCL_VER} tcl${TCL_VER_BSD} PATHS /usr/local/lib /usr/lib) -find_library(TCL_STUB_LIBRARY NAMES tclstub${TCL_VER} tclstub${TCL_VER_BSD} PATHS /usr/local/lib /usr/lib) +find_package(TCL) +find_package(TclStub) +find_package(Tclsh) message(INFO " Tcl include ${TCL_INCLUDE_PATH}") message(INFO " Tcl library ${TCL_LIBRARY}") diff --git a/COMMONmakefile b/COMMONmakefile index 3074936..a3e102e 100644 --- a/COMMONmakefile +++ b/COMMONmakefile @@ -3,7 +3,7 @@ CPPTCL_LIBRARY = build/libcpptcl.so all: $(CPPTCL_LIBRARY) build/Makefile: CMakeLists.txt - (mkdir -p build; cd build; cmake -DTCL_VERSION_MINOR:STRING=$${TCL_VERSION_MINOR:-6} ..) + (mkdir -p build; cd build; cmake ..) debug: CMakeLists.txt (mkdir -p build; cd build; cmake -DCMAKE_BUILD_TYPE=Debug ..) @@ -15,7 +15,7 @@ install: all (cd build; make install) test: build/Makefile - (cd build; ctest) + (cd build; ctest --output-on-failure) examples: build/Makefile (cd build; make examples) diff --git a/cpptcl.cc b/cpptcl.cc index e7a7aeb..1a04d9e 100644 --- a/cpptcl.cc +++ b/cpptcl.cc @@ -654,7 +654,7 @@ interpreter::interpreter(Tcl_Interp *interp, bool owner) { interp_ = interp; owner_ = owner; if (!defaultInterpreter) { - if (Tcl_InitStubs(interp, "8.6", 0) == NULL) { + if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { throw tcl_error("Failed to initialize stubs"); } // Make a copy diff --git a/cpptcl/cpptcl.h b/cpptcl/cpptcl.h index 40318dd..d610887 100644 --- a/cpptcl/cpptcl.h +++ b/cpptcl/cpptcl.h @@ -523,7 +523,7 @@ inline std::ostream & operator<<(std::ostream &os, const object& obj) #define CPPTCL_MODULE(name, i) \ void name##_cpptcl_Init(Tcl::interpreter &i); \ extern "C" int name##_Init(Tcl_Interp *interp) { \ - Tcl_InitStubs(interp, "8.3", 0); \ + Tcl_InitStubs(interp, "8.6-", 0); \ Tcl::interpreter i(interp, false); \ name##_cpptcl_Init(i); \ return TCL_OK; \ diff --git a/examples/example2.cc b/examples/example2.cc index 6d48986..685506e 100644 --- a/examples/example2.cc +++ b/examples/example2.cc @@ -12,7 +12,7 @@ using namespace Tcl; void hello() { cout << "Hello C++/Tcl!" << endl; } int main() { - Tcl_Interp * interp = Tcl_CreateInterpWithStubs("8.6", 0); + Tcl_Interp * interp = Tcl_CreateInterpWithStubs("8.6-", 0); interpreter i(interp, true); i.def("hello", hello); diff --git a/examples/example6.cc b/examples/example6.cc index 6a5c545..3792fa4 100644 --- a/examples/example6.cc +++ b/examples/example6.cc @@ -8,7 +8,7 @@ using namespace std; using namespace Tcl; int main() { - Tcl_Interp * interp = Tcl_CreateInterpWithStubs("8.6", 0); + Tcl_Interp * interp = Tcl_CreateInterpWithStubs("8.6-", 0); interpreter i(interp, true); int numbers[] = {5, 7, 1, 6, 3, 9, 7}; diff --git a/test/test1.cc b/test/test1.cc index d848398..9796fdf 100644 --- a/test/test1.cc +++ b/test/test1.cc @@ -26,7 +26,9 @@ int fun5(char const *s) { return std::string(s).size(); } void test1() { Tcl_Interp * interp = Tcl_CreateInterp(); interpreter i(interp, true); +#if (TCL_MAJOR_VERSION < 9) i.make_safe(); +#endif std::string s = i.eval("return \"ala ma kota\""); assert(s == "ala ma kota");