From cb4faaf2d3fa269b4e2a29ac9eea0914d30e0e60 Mon Sep 17 00:00:00 2001 From: Oleg Puchinin Date: Fri, 5 Sep 2008 11:19:22 +0700 Subject: [PATCH] + rmake ruby script --- gclib2/build.sh | 5 -- gclib2/cmake_install.cmake | 53 --------------------- gclib2/modules/Core/elist.cxx | 8 +++- gclib2/modules/Net/FTP/FTP.cxx | 4 +- gclib2/rmake | 27 +++++++++++ silentbob/CMakeLists.txt | 12 ++--- silentbob/CMakeLists_linux.txt | 1 + silentbob/compile.rb | 99 --------------------------------------- silentbob/plugins/plugin_ruby.cxx | 5 ++ silentbob/rmake | 53 +++++++++++++++++++++ 10 files changed, 101 insertions(+), 166 deletions(-) delete mode 100755 gclib2/build.sh delete mode 100644 gclib2/cmake_install.cmake create mode 100755 gclib2/rmake delete mode 100755 silentbob/compile.rb create mode 100755 silentbob/rmake diff --git a/gclib2/build.sh b/gclib2/build.sh deleted file mode 100755 index 78394f6..0000000 --- a/gclib2/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -v - -cmake . -make - diff --git a/gclib2/cmake_install.cmake b/gclib2/cmake_install.cmake deleted file mode 100644 index 595fb9b..0000000 --- a/gclib2/cmake_install.cmake +++ /dev/null @@ -1,53 +0,0 @@ -# Install script for directory: /GIT/gclib2 - -# Set the install prefix -IF(NOT DEFINED CMAKE_INSTALL_PREFIX) - SET(CMAKE_INSTALL_PREFIX "/usr/local") -ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX) -STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") - -# Set the install configuration name. -IF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) - IF(BUILD_TYPE) - STRING(REGEX REPLACE "^[^A-Za-z0-9_]+" "" - CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") - ELSE(BUILD_TYPE) - SET(CMAKE_INSTALL_CONFIG_NAME "") - ENDIF(BUILD_TYPE) - MESSAGE(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") -ENDIF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) - -# Set the component getting installed. -IF(NOT CMAKE_INSTALL_COMPONENT) - IF(COMPONENT) - MESSAGE(STATUS "Install component: \"${COMPONENT}\"") - SET(CMAKE_INSTALL_COMPONENT "${COMPONENT}") - ELSE(COMPONENT) - SET(CMAKE_INSTALL_COMPONENT) - ENDIF(COMPONENT) -ENDIF(NOT CMAKE_INSTALL_COMPONENT) - -# Install shared libraries without execute permission? -IF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) - SET(CMAKE_INSTALL_SO_NO_EXE "0") -ENDIF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) - -IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" MATCHES "^(Unspecified)$") - FILE(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE SHARED_LIBRARY FILES "/GIT/gclib2/libgclib2.so") - IF(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libgclib2.so") - IF(CMAKE_INSTALL_DO_STRIP) - EXECUTE_PROCESS(COMMAND "/usr/bin/strip" "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libgclib2.so") - ENDIF(CMAKE_INSTALL_DO_STRIP) - ENDIF(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/libgclib2.so") -ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" MATCHES "^(Unspecified)$") - -IF(CMAKE_INSTALL_COMPONENT) - SET(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") -ELSE(CMAKE_INSTALL_COMPONENT) - SET(CMAKE_INSTALL_MANIFEST "install_manifest.txt") -ENDIF(CMAKE_INSTALL_COMPONENT) - -FILE(WRITE "/GIT/gclib2/${CMAKE_INSTALL_MANIFEST}" "") -FOREACH(file ${CMAKE_INSTALL_MANIFEST_FILES}) - FILE(APPEND "/GIT/gclib2/${CMAKE_INSTALL_MANIFEST}" "${file}\n") -ENDFOREACH(file) diff --git a/gclib2/modules/Core/elist.cxx b/gclib2/modules/Core/elist.cxx index 68c5f3c..12c3957 100644 --- a/gclib2/modules/Core/elist.cxx +++ b/gclib2/modules/Core/elist.cxx @@ -249,10 +249,12 @@ Array * EList::toArray () List & EList::operator = (List & l) { + char * one; + while (first ()) rm (); - for (char * one = l.first (); one = l.get (); l.next ()) + for (one = (char *) l.first (); one = (char *) l.get (); l.next ()) add (one); return *this; @@ -260,7 +262,9 @@ List & EList::operator = (List & l) List & EList::operator + (List & l) { - for (char * one = l.first (); one = l.get (); l.next ()) + char * one; + + for (one = l.first (); one = l.get (); l.next ()) push (one); return *this; diff --git a/gclib2/modules/Net/FTP/FTP.cxx b/gclib2/modules/Net/FTP/FTP.cxx index c09877c..ed0436e 100644 --- a/gclib2/modules/Net/FTP/FTP.cxx +++ b/gclib2/modules/Net/FTP/FTP.cxx @@ -4,6 +4,8 @@ * */ +#if 0 + #include #include #include @@ -32,7 +34,6 @@ List * FTP::waitReply () { List * Ret; char * S; - int i = 0; while (true) { Ret = recvStrings (); @@ -142,4 +143,5 @@ char * FTP::syst () { } +#endif diff --git a/gclib2/rmake b/gclib2/rmake new file mode 100755 index 0000000..e3bb6bd --- /dev/null +++ b/gclib2/rmake @@ -0,0 +1,27 @@ +#!/usr/bin/ruby + +require "ruby_build.rb" + +class Main < RubyBuild + + def initialize(project_name) + super project_name + + files = `find modules -name "*.cxx"` + files = files.split("\n") + @debug_env[:include] = "-Iinclude -Igclib/include" + @release_env[:include] = "-Iinclude -Igclib/include" + + build_shared("libgclib2.so", files) + end + + def install + end + + def uninstall + end + +end + +m = Main.new "gclib2" + diff --git a/silentbob/CMakeLists.txt b/silentbob/CMakeLists.txt index fd6b746..9e0e5f2 100644 --- a/silentbob/CMakeLists.txt +++ b/silentbob/CMakeLists.txt @@ -47,15 +47,15 @@ add_executable (silent_bob src/callTags.cxx add_dependencies (silent_bob sblib) + # Unneeded -#add_library (plugin_aap SHARED plugins/plugin_aap.cxx) -#add_library (plugin_compile SHARED plugins/plugin_compile.cxx) -#add_library (plugin_foreach SHARED plugins/plugin_foreach.cxx) -#add_library (plugin_make SHARED plugins/plugin_make.cxx) -#add_library (plugin_scons SHARED plugins/plugin_scons.cxx) +add_library (plugin_aap SHARED plugins/plugin_aap.cxx) +add_library (plugin_compile SHARED plugins/plugin_compile.cxx) +add_library (plugin_foreach SHARED plugins/plugin_foreach.cxx) +add_library (plugin_make SHARED plugins/plugin_make.cxx) +add_library (plugin_scons SHARED plugins/plugin_scons.cxx) #add_library (plugin_test SHARED plugins/plugin_test.cxx) -# default add_library (plugin_cache SHARED plugins/plugin_cache.cxx) add_library (plugin_editor SHARED plugins/plugin_editor.cxx) add_library (plugin_grep SHARED plugins/plugin_grep.cxx) diff --git a/silentbob/CMakeLists_linux.txt b/silentbob/CMakeLists_linux.txt index dd59fed..1bd3256 100644 --- a/silentbob/CMakeLists_linux.txt +++ b/silentbob/CMakeLists_linux.txt @@ -63,6 +63,7 @@ add_library (plugin_perl SHARED plugins/plugin_perl.cxx) add_library (plugin_perlpackages SHARED plugins/plugin_perlpackages.cxx) add_library (plugin_python SHARED plugins/plugin_python.cxx) add_library (plugin_ruby SHARED plugins/plugin_ruby.cxx) +add_library (plugin_ruby_newclass SHARED plugins/plugin_ruby_newclass.cxx) install (TARGETS sblib silent_bob RUNTIME DESTINATION bin LIBRARY DESTINATION lib ) diff --git a/silentbob/compile.rb b/silentbob/compile.rb deleted file mode 100755 index 5073a50..0000000 --- a/silentbob/compile.rb +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/ruby - -class Build - -def initialize - @debug = "no" - @release = "no" - - init_dirs - argv - - if @debug == "yes" or @release == "yes" - build_gclib - build_silentbob - end - -end - -def compile_files(files, shared = "") - files.each { |file| - name, ext = file.split(".", 2) - compiler = "g++" if ext == "cxx" - compiler = "gcc" if ext == "c" - - path = name.split("/") - resname = path.last - - name = "#{name}.#{ext}" - puts "\tCXX #{resname}" if ext == "cxx" - puts "\tCC #{resname}" if ext == "c" - - dbg = "#{compiler} -Iinclude -Igclib/include/ #{shared} -O3 -c -o debug/#{resname}.o #{name}" - release = "#{compiler} -Iinclude -Igclib/include/ #{shared} -g3 -Wall -c -o release/#{resname}.o #{name}" - system dbg if @debug == "yes" - system release if @release == "yes" - } -end - -def init_dirs - Dir.mkdir("debug") unless File.exists?("./debug") - Dir.mkdir("release") unless File.exists?("./release") -end - -def clean - system "rm debug/*.o" if @debug == "yes" - system "rm release/*.o" if @release == "yes" -end - -def clean_all - system "rm -fr debug*" - system "rm -fr release" - exit 0 -end - -def build_gclib - puts "Build libgclib.so ... " - files = Dir["sblib/*.cxx"] + Dir["gclib/src/*.cxx"] - files << "gclib/src/gclib_c.c" - - compile_files(files, "-fPIC -DPIC") - cmd_d = "g++ debug/*.o --shared -o debug/libgclib.so" - cmd_r = "g++ release/*.o --shared -o release/libgclib.so" - puts "\tLD libgclib.so" - system cmd_d if @debug == "yes" - system cmd_r if @release == "yes" - clean -end - -def build_silentbob - files = Dir["src/*.cxx"] - puts "Build silent_bob" - - compile_files(files) - cmd_d = "g++ debug/*.o -o debug/silent_bob -Ldebug -ldl -lgclib" - cmd_r = "g++ release/*.o -o release/silent_bob -Lrelease -ldl -lgclib" - puts "\tLD silent_bob" - system cmd_d if @debug == "yes" - system cmd_r if @release == "yes" - clean - -end - -def argv - ARGV.each { |arg| - if arg == "all" - @debug = "yes" - @release = "yes" - end - - @debug = "yes" if arg == "debug" - @release = "yes" if arg == "release" - clean_all if arg == "clean" - } -end - -end # class Build - -b = Build.new - diff --git a/silentbob/plugins/plugin_ruby.cxx b/silentbob/plugins/plugin_ruby.cxx index 9825b88..656b0e3 100644 --- a/silentbob/plugins/plugin_ruby.cxx +++ b/silentbob/plugins/plugin_ruby.cxx @@ -52,9 +52,14 @@ char ruby_opt2 (DArray * d_opts, int * pos) bool ruby_scan_line (const char *S) { + char * ptr; if (! S) return false; + ptr = strchr (S, '#'); + if (ptr) + *ptr = '\0'; + if (strstr (S, "class ") || strstr (S, "module ") || strstr (S, "def ")) diff --git a/silentbob/rmake b/silentbob/rmake new file mode 100755 index 0000000..6bc3761 --- /dev/null +++ b/silentbob/rmake @@ -0,0 +1,53 @@ +#!/usr/bin/ruby +# +# +# To change this template, choose Tools | Templates +# and open the template in the editor. + +require "ruby_build.rb" + +class Main < RubyBuild + + def initialize(package_name) + super package_name + + @debug_env[:ldflags] = "-L./ -ldl" + @release_env[:ldflags] = "-L./ -ldl" + @debug_env[:include] = "-Iinclude -Igclib/include" + @release_env[:include] = "-Iinclude -Igclib/include" + build_sblib + + @debug_env[:ldflags] = "-L./ -ldl -lsblib" + @release_env[:ldflags] = "-L./ -ldl -lsblib" + build_silentbob + + end + + def fetch + @url = "http://op.oaoontk.ru/silentbob.tar.bz2" + super + end + + def build_sblib + files = Dir["sblib/*.cxx"] + Dir["gclib/src/*.cxx"] + files << "gclib/src/gclib_c.c" + build_shared("libsblib.so", files) + end + + def build_silentbob + files = Dir["src/*.cxx"] + build_binary("silent_bob", files) + end + + def install + system ("./install.sh") + end + + def uninstall + system ("./uninstall.sh") + end + +end + +m = Main.new "SilentBob" + -- 2.11.4.GIT