clibgen 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5ba08a83c21b795e510bc7d8b3d14bdf33fe51b28f35a5d1b6a8d39894616ff2
4
+ data.tar.gz: 1c949644f850588a4d6248ca59cb3a81dfb4ce0711185c6ff29479c218ae31e8
5
+ SHA512:
6
+ metadata.gz: a3bdd537dc7171645de820a421c9d42e9fe37faaef6de5571772fce30df5869a5b60b2686125a5e7043856166dc85b75e840ae008405149b68f3d7a0912b83a4
7
+ data.tar.gz: 8c596734c27c910391c68fa549ba790e93e739c843d5d7da8247f8587684862210db4555e0578abc088f2b743cf0ad285e17e7310243339406aa0cc831b99d23
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.0
7
+ before_install: gem install bundler -v 1.16.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in libgen.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Libgen
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/libgen`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'libgen'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install libgen
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/libgen.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/.DS_Store ADDED
Binary file
data/bin/libgen ADDED
@@ -0,0 +1,4 @@
1
+ #!
2
+ require 'libgen'
3
+ Libgen::gen
4
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,49 @@
1
+ LOCAL_PATH := $(call my-dir)
2
+ include $(CLEAR_VARS)
3
+
4
+ LOCAL_CFLAGS :=
5
+
6
+ LOCAL_MODULE := libpng
7
+ LOCAL_SRC_FILES :=\
8
+ adler32.c \
9
+ compress.c \
10
+ crc32.c \
11
+ deflate.c \
12
+ example.c \
13
+ gzclose.c \
14
+ gzlib.c \
15
+ gzread.c \
16
+ gzwrite.c \
17
+ infback.c \
18
+ inffast.c \
19
+ inflate.c \
20
+ inftrees.c \
21
+ png.c \
22
+ pngerror.c \
23
+ pngget.c \
24
+ pngmem.c \
25
+ pngpread.c \
26
+ pngread.c \
27
+ pngrio.c \
28
+ pngrtran.c \
29
+ pngrutil.c \
30
+ pngset.c \
31
+ pngtest.c \
32
+ pngtrans.c \
33
+ pngwio.c \
34
+ pngwrite.c \
35
+ pngwtran.c \
36
+ pngwutil.c \
37
+ trees.c \
38
+ uncompr.c \
39
+ zutil.c \
40
+ arm/filter_neon_intrinsics.c \
41
+ arm/palette_neon_intrinsics.c \
42
+ arm/arm_init.c
43
+
44
+ #LOCAL_SHARED_LIBRARIES := -lz
45
+ LOCAL_EXPORT_LDLIBS := -lz
46
+ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.
47
+
48
+ # include $(BUILD_SHARED_LIBRARY)
49
+ include $(BUILD_STATIC_LIBRARY)
@@ -0,0 +1,38 @@
1
+ root_path=$1
2
+ ndk_path=$2
3
+ asset_path=$3
4
+ tmp_path=$root_path/tmp
5
+ to_ndk_path=$tmp_path/android-ndk
6
+
7
+ if [ ! -e $tmp_path ]
8
+ then
9
+ mkdir $tmp_path
10
+ fi
11
+ cp -r -n $ndk_path $tmp_path
12
+
13
+ if [ ! -e $tmp_path/ndk ]
14
+ then
15
+ cd $to_ndk_path/build/tools
16
+ ./make_standalone_toolchain.py --arch arm --api 21 --stl libc++ --install-dir $tmp_path/ndk
17
+ fi
18
+
19
+ echo "---------build libde265---------"
20
+
21
+ cd $tmp_path
22
+ if [ ! -e ./libheif ]
23
+ then
24
+ git clone https://github.com/strukturag/libde265 -q
25
+ fi
26
+
27
+ out_dir=$root_path/out/libde265
28
+
29
+ cd libde265
30
+ export CC=$tmp_path/ndk/bin/clang
31
+ export CXX=$tmp_path/ndk/bin/clang++
32
+ export CFLAGS="-fPIE"
33
+ export LDFLAGS="-fPIE"
34
+ export PATH=$PATH:$tmp_path/ndk/bin
35
+ sh ./autogen.sh
36
+ ./configure --prefix=$out_dir --enable-shared=no --host=arm-linux-androideabi --disable-arm --disable-sse --disable-sherlock265
37
+ make -j8 && make install
38
+
@@ -0,0 +1,39 @@
1
+ root_path=$1
2
+ ndk_path=$2
3
+ asset_path=$3
4
+ tmp_path=$root_path/tmp
5
+ to_ndk_path=$tmp_path/android-ndk
6
+
7
+ if [ ! -e $tmp_path ]
8
+ then
9
+ mkdir $tmp_path
10
+ fi
11
+ cp -r -n $ndk_path $tmp_path
12
+
13
+ if [ ! -e $tmp_path/ndk ]
14
+ then
15
+ cd $to_ndk_path/build/tools
16
+ ./make_standalone_toolchain.py --arch arm --api 21 --stl libc++ --install-dir $tmp_path/ndk
17
+ fi
18
+
19
+ echo "---------build libheif---------"
20
+
21
+ cd $tmp_path
22
+ if [ ! -e ./libheif ]
23
+ then
24
+ git clone https://github.com/strukturag/libheif -q
25
+ fi
26
+
27
+ cd libheif
28
+ sh ./autogen.sh
29
+
30
+ export CC=$tmp_path/ndk/bin/arm-linux-androideabi-clang
31
+ export CXX=$tmp_path/ndk/bin/arm-linux-androideabi-clang++
32
+ export CFLAGS="-fPIE -Wno-tautological-constant-compare"
33
+ export CXXFLAGS="-fPIE -Wno-tautological-constant-compare"
34
+ export LDFLAGS="-fPIE -pie"
35
+ export PKG_CONFIG_PATH=$root_path/out/x265/lib/pkgconfig:$root_path/out/libde265/lib/pkgconfig:$root_path/out/libpng/lib/pkgconfig
36
+ export PATH=$PATH:$tmp_path/ndk/bin
37
+
38
+ out_dir=$root_path/out/libheif
39
+ ./configure --prefix=$out_dir --host=arm-linux-androideabi
@@ -0,0 +1,76 @@
1
+ root_path=$1
2
+ ndk_path=$2
3
+ asset_path=$3
4
+ tmp_path=$root_path/tmp
5
+
6
+ if [ ! -e $tmp_path ]
7
+ then
8
+ mkdir $tmp_path
9
+ fi
10
+
11
+ export PATH=${PATH}:$ndk_path
12
+
13
+ cd $tmp_path
14
+ if [ ! -e ./libpng ]
15
+ then
16
+ git clone https://github.com/glennrp/libpng.git -q
17
+ fi
18
+
19
+ if [ ! -e ./libpng-android ]
20
+ then
21
+ git clone https://github.com/julienr/libpng-android.git -q
22
+ fi
23
+
24
+ if [ ! -e ./zlib ]
25
+ then
26
+ git clone https://github.com/madler/zlib.git -q
27
+ fi
28
+
29
+ cd $tmp_path/libpng-android/jni
30
+
31
+
32
+ cd $tmp_path/libpng
33
+
34
+ for filename in * ;
35
+ do
36
+ if [[ $filename = *.h ]] || [[ $filename = *.c ]] || [[ $filename = "arm" ]];
37
+ then
38
+ if [ -d ./$filename ]
39
+ then
40
+ cp -f -r $tmp_path/libpng/$filename $tmp_path/libpng-android/jni/
41
+ else
42
+ cp -f $tmp_path/libpng/$filename $tmp_path/libpng-android/jni/$filename
43
+ fi
44
+
45
+ fi
46
+ done
47
+
48
+ cd $tmp_path/zlib
49
+
50
+ for filename in * ;
51
+ do
52
+ if [[ $filename = *.h ]] || [[ $filename = *.c ]];
53
+ then
54
+ cp -f $tmp_path/zlib/$filename $tmp_path/libpng-android/jni/$filename
55
+ fi
56
+ done
57
+
58
+ cd $tmp_path/libpng-android/jni
59
+
60
+ android_content=`cat Application.mk`
61
+ if [[ ! $android_content == *"APP_PLATFORM"* ]]
62
+ then
63
+ echo 'APP_PLATFORM := android-16' >> Application.mk
64
+ fi
65
+ cp -r $asset_path/Android.mk $tmp_path/libpng-android/jni/Android.mk
66
+
67
+
68
+ cd $tmp_path/libpng-android
69
+ ./build.sh
70
+
71
+ out_dir=$root_path/out/libpng
72
+ if [ ! -e $out_dir ]
73
+ then
74
+ mkdir -p $out_dir
75
+ fi
76
+ cp -f -r $tmp_path/libpng-android/obj $out_dir
data/lib/asset/x256.sh ADDED
@@ -0,0 +1,32 @@
1
+ root_path=$1
2
+ ndk_path=$2
3
+ asset_path=$3
4
+ tmp_path=$root_path/tmp
5
+ to_ndk_path=$tmp_path/android-ndk
6
+
7
+ if [ ! -e $tmp_path ]
8
+ then
9
+ mkdir $tmp_path
10
+ fi
11
+ cp -r -n $ndk_path $tmp_path
12
+
13
+ if [ ! -e $tmp_path/ndk ]
14
+ then
15
+ cd $to_ndk_path/build/tools
16
+ ./make_standalone_toolchain.py --arch arm --api 21 --stl libc++ --install-dir $tmp_path/ndk
17
+ fi
18
+
19
+ echo "---------build x265-----------"
20
+ cd $tmp_path
21
+ git clone https://github.com/videolan/x265 -q
22
+
23
+ out_dir=$root_path/out/x256
24
+
25
+ cd $tmp_path/x265/build
26
+ mkdir -p arm-android && cd arm-android
27
+ cmake -DCROSS_COMPILE_ARM=1 -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=armv7l \
28
+ -DCMAKE_C_COMPILER=/tmp/ndk/bin/arm-linux-androideabi-clang -DCMAKE_CXX_COMPILER=/tmp/ndk/bin/arm-linux-androideabi-clang++ \
29
+ -DCMAKE_FIND_ROOT_PATH=/tmp/ndk/sysroot -DENABLE_ASSEMBLY=OFF -DENABLE_CLI=OFF \
30
+ -DENABLE_PIC=ON -DENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=$out_dir -DCMAKE_C_FLAGS="" \
31
+ -G "Unix Makefiles" ../../source
32
+ make -j8 && make install
data/lib/libgen/gen.rb ADDED
@@ -0,0 +1,83 @@
1
+ require 'optparse'
2
+ require 'pathname'
3
+ require "colorize"
4
+
5
+ module Gen
6
+
7
+ def self.root
8
+ File.dirname __dir__
9
+ end
10
+
11
+ def self.tmp_dir
12
+ "/tmp/libgen"
13
+ end
14
+
15
+ def self.asset_path
16
+ root + "/asset"
17
+ end
18
+
19
+ def self.libgen_path
20
+ root + "/libgen"
21
+ end
22
+
23
+ def self.run
24
+ options = {}
25
+ OptionParser.new do |opts|
26
+ opts.banner = "Usage: 编译C/C++库为提供安卓/ios所用"
27
+
28
+ opts.on("-o", "--out folder", "输入目录") do |v|
29
+ options[:out] = v
30
+ end
31
+
32
+ opts.on("-n", "--ndk folder","ndk所在的目录") do |v|
33
+ options[:ndk] = v
34
+ end
35
+
36
+ opts.on("-l", "--lib lib",Array,"库名称,例如:libpng、x256、libde265、libheif ...") do |v|
37
+ options[:lib] = v
38
+ end
39
+
40
+ end.parse!
41
+
42
+ out_dir = options[:out]
43
+ ndk_dir = options[:ndk]
44
+ lib_type = options[:lib]
45
+
46
+ if file_exist? tmp_dir
47
+ `rm -rf #{tmp_dir}`
48
+ `mkdir #{tmp_dir}`
49
+ end
50
+
51
+ if !(file_exist?(out_dir) && file_exist?(ndk_dir))
52
+ puts "指定的目录不存在:#{path}".colorize(:red)
53
+ return
54
+ end
55
+
56
+ lib_type.each do |lib|
57
+ buildlib out_dir, ndk_dir, lib
58
+ end
59
+
60
+ if lib_type.length == 0
61
+ puts "请指定 -t,可选为 [libpng、x256、libde265、libheif]"
62
+ end
63
+
64
+ `cp -r -f "#{tmp_dir}/out" "#{out_dir}"`
65
+ puts "任务完成,请查看目标目录".colorize(:green)
66
+ `open #{out_dir}`
67
+ end
68
+
69
+ def self.buildlib(out_dir, ndk_dir, lib)
70
+ puts "开始编译#{lib},请耐心等待...".colorize(:green)
71
+ sh_path = asset_path + "/#{lib}.sh"
72
+ `sh "#{sh_path}" "#{tmp_dir}" "#{ndk_dir}" "#{asset_path}"`
73
+ end
74
+
75
+ def self.empty?(val)
76
+ val && !val.empty?
77
+ end
78
+
79
+ def self.file_exist?(path)
80
+ File.exist?(path)
81
+ end
82
+
83
+ end
@@ -0,0 +1,3 @@
1
+ module Libgen
2
+ VERSION = "0.1.0"
3
+ end
data/lib/libgen.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "libgen/version"
2
+ require "libgen/gen"
3
+
4
+ module Libgen
5
+ def self.gen
6
+ Gen::run
7
+ end
8
+ end
data/libgen.gemspec ADDED
@@ -0,0 +1,37 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "libgen/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "clibgen"
8
+ spec.version = Libgen::VERSION
9
+ spec.authors = ["kaich"]
10
+ spec.email = ["chengkai1853@163.com"]
11
+
12
+ spec.summary = %q{为对应平台编译C/C++库}
13
+ spec.description = %q{为对应平台编译C/C++库, Android编译为.so}
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib", "bin"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.16"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "minitest", "~> 5.0"
36
+ spec.add_runtime_dependency 'colorize' , '~> 0.7'
37
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clibgen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kaich
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-07-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ description: 为对应平台编译C/C++库, Android编译为.so
70
+ email:
71
+ - chengkai1853@163.com
72
+ executables:
73
+ - ".DS_Store"
74
+ - libgen
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".DS_Store"
79
+ - ".gitignore"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/.DS_Store
86
+ - bin/libgen
87
+ - lib/asset/Android.mk
88
+ - lib/asset/libde265.sh
89
+ - lib/asset/libheif.sh
90
+ - lib/asset/libpng.sh
91
+ - lib/asset/x256.sh
92
+ - lib/libgen.rb
93
+ - lib/libgen/gen.rb
94
+ - lib/libgen/version.rb
95
+ - libgen.gemspec
96
+ homepage:
97
+ licenses:
98
+ - MIT
99
+ metadata:
100
+ allowed_push_host: https://rubygems.org
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ - bin
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 3.0.3
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: 为对应平台编译C/C++库
121
+ test_files: []