shithub: h264bsd

Download patch

ref: 655ad776b30599f052f6c686ec30fb117cb18473
parent: 634babeda4a9397bbb73c51b237e48a53ea00b03
author: Sam Leitch <[email protected]>
date: Wed Jan 30 19:46:44 EST 2019

Travis ci (#14)

* Added travis-ci files

* Switch posix to gnu99 standard

* Moved CI complexity into Rakefile

* Added build status graphic to README.md

--- /dev/null
+++ b/.travis.yml
@@ -1,0 +1,34 @@
+matrix:
+  include:
+    - language: c
+      compiler:
+        - clang
+        - gcc
+      dist: trusty
+      script:
+        - rake ci_build_posix
+    - language: node_js
+      node_js:
+        - node
+      sudo: required
+      services:
+        - docker
+      before_install:
+        - docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:latest bash
+        - docker exec -it emscripten apt-get update
+        - docker exec -it emscripten apt-get -y install rake
+        - docker exec -it emscripten npm install uglify-js -g
+      script:
+        - docker exec -it -e PATH=${PATH}:/emsdk_portable/node/bin emscripten rake ci_build_js
+    - language: node_js
+      node_js:
+        - node
+      sudo: required
+      services:
+        - docker
+      before_install:
+        - docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:latest bash
+        - docker exec -it emscripten apt-get update
+        - docker exec -it emscripten apt-get -y install rake
+      script:
+        - docker exec -it emscripten rake ci_build_wasm
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# h264bsd
+# h264bsd [![Build Status](https://travis-ci.org/oneam/h264bsd.svg?branch=master)](https://travis-ci.org/oneam/h264bsd)
 
 This is a software-based library that was extracted from the Android project with the intention of being used elsewhere.
 
--- /dev/null
+++ b/Rakefile
@@ -1,0 +1,35 @@
+task :js do
+    Dir.chdir("js") do
+        sh "rake"
+    end
+end
+
+task :wasm do
+    Dir.chdir("wasm") do
+        sh "rake"
+    end
+end
+
+task :posix do
+    Dir.chdir("posix") do
+        sh "rake"
+    end
+end
+
+task :ci_build_js do
+    Dir.chdir("js") do
+        sh "rake clean build test"
+    end
+end
+
+task :ci_build_wasm do
+    Dir.chdir("wasm") do
+        sh "rake clean build test"
+    end
+end
+
+task :ci_build_posix do
+    Dir.chdir("posix") do
+        sh "rake clean static_lib test"
+    end
+end
--- a/js/Rakefile
+++ b/js/Rakefile
@@ -3,12 +3,8 @@
 EMCC_FLAGS = ENV["EMCC_FLAGS"] || "-O0 -g4 -D_ASSERT_USED -D_ERROR_PRINT --memory-init-file 0 -s TOTAL_MEMORY=67108864 -s WASM=0" if ENV["DEBUG"]
 EMCC_FLAGS = ENV["EMCC_FLAGS"] || "-O3 -D_ERROR_PRINT --memory-init-file 0 -s TOTAL_MEMORY=67108864 -s WASM=0" unless ENV["DEBUG"]
 
-rule '.o' => ['.c'] do |t|
-  sh "emcc #{t.source} -c #{EMCC_FLAGS} -o #{t.name}"
-end
+c_files = FileList["../src/*.c"]
 
-o_files = FileList["../src/*.c"].gsub(/c$/, 'o')
-
 exported_functions = [
 	"_malloc",
 	"_free",
@@ -32,8 +28,8 @@
 
 EXPORT_FLAGS = "-s LINKABLE=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='#{JSON.generate(exported_runtime_methods)}' -s EXPORTED_FUNCTIONS='#{JSON.generate(exported_functions)}'"
 
-file "h264bsd_asm.js" => o_files do                                     
-	sh "emcc #{o_files.join(' ')} #{EMCC_FLAGS} #{EXPORT_FLAGS} -o h264bsd_asm.js"
+file "h264bsd_asm.js" do                                     
+	sh "emcc #{c_files.join(' ')} #{EMCC_FLAGS} #{EXPORT_FLAGS} -o h264bsd_asm.js"
 end
 
 directory "min"
@@ -69,7 +65,6 @@
 task :compress => ["min/h264bsd_full.min.js", "min/h264bsd_canvas.min.js", "min/h264bsd_worker.min.js"]
 
 task :clean do
-	o_files.each{|o| FileUtils.rm_f(o)}
 	FileUtils.rm_f("h264bsd_asm.js")
 	FileUtils.rm_rf("min")
 end
@@ -86,4 +81,10 @@
 	WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.pwd).start
 end
 
-task :default => [:setup, :compress]
+task :build => [:setup, :compress]
+
+task :test do
+	sh "node test_node.js"
+end
+
+task :default => [:build]
--- a/posix/Rakefile
+++ b/posix/Rakefile
@@ -2,9 +2,9 @@
 AR = "ar"
 
 if ENV["DEBUG"]
-  CC_FLAGS = ENV["CC_FLAGS"] || "-O0 -g4 -D_ASSERT_USED -D_ERROR_PRINT"
+  CC_FLAGS = ENV["CC_FLAGS"] || "-std=gnu99 -O0 -g4 -D_ASSERT_USED -D_ERROR_PRINT"
 else
-  CC_FLAGS = ENV["CC_FLAGS"] || "-O3 -D_ERROR_PRINT"
+  CC_FLAGS = ENV["CC_FLAGS"] || "-std=gnu99 -O3 -D_ERROR_PRINT"
 end
 
 static_lib = "lib/libh264bsd.a"
--- a/wasm/Rakefile
+++ b/wasm/Rakefile
@@ -49,4 +49,10 @@
 	WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.pwd).start
 end
 
-task :default => [:setup, 'h264bsd_wasm.js']
+task :build => [:setup, 'h264bsd_wasm.js']
+
+task :test do
+	sh "node test_node.js"
+end
+
+task :default => [:build]