Skip to content

Commit

Permalink
#432 Fix nested dependencies between (nocorto) packages
Browse files Browse the repository at this point in the history
Also added a verbose option to the build system which makes it easier
to debug build issues.
  • Loading branch information
SanderMertens committed Jan 19, 2016
1 parent 23af99e commit 5d70cfa
Show file tree
Hide file tree
Showing 11 changed files with 1,457 additions and 176 deletions.
23 changes: 16 additions & 7 deletions build/artefact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

CHDIR_SET ||= false

if not defined? VERBOSE then
if ENV['verbose'] == "true" then
VERBOSE ||= true
else
VERBOSE ||= false
end
end

if !CHDIR_SET then
Dir.chdir(File.dirname(Rake.application.rakefile))
end
Expand Down Expand Up @@ -132,7 +140,7 @@ def corto_replace(str)
# Task that collects all artefacts from the build and store them in a 'pack'
# folder, where they can be tarred for redistribution.
task :collect do
verbose(false)
verbose(VERBOSE)
artefact = "#{TARGETDIR}/#{ARTEFACT}"
target = ENV['HOME'] + "/.corto/pack" + artefact["#{ENV['CORTO_TARGET']}".length..artefact.length]
sh "mkdir -p " + target.split("/")[0...-1].join("/")
Expand All @@ -146,14 +154,14 @@ def corto_replace(str)

# Rule to automatically create components.txt
file ".corto/components.txt" do
verbose(false)
verbose(VERBOSE)
sh "mkdir -p .corto"
sh "touch .corto/components.txt"
end

# Rule to automatically create packages.txt
file ".corto/packages.txt" do
verbose(false)
verbose(VERBOSE)
sh "mkdir -p .corto"
sh "touch .corto/packages.txt"
end
Expand All @@ -162,7 +170,7 @@ def corto_replace(str)

# Build artefact
file "#{TARGETDIR}/#{ARTEFACT}" => OBJECTS do
verbose(false)
verbose(VERBOSE)
sh "mkdir -p #{TARGETDIR}"

# Create list of files that are going to be linked with. Abstract away from the
Expand Down Expand Up @@ -193,7 +201,8 @@ def corto_replace(str)
else
result = `corto locate #{i} --lib`[0...-1]
if $?.exitstatus != 0 then
p result
print "\033[1;31m[ dependency #{i} could not be located ]\033[0;49m\n"
print "\033[1;31m #{result} \033[0;49m\n"
abort "\033[1;31m[ build failed ]\033[0;49m"
end
result
Expand Down Expand Up @@ -265,7 +274,7 @@ def corto_replace(str)

# Run test for project
task :test do
verbose(false)
verbose(VERBOSE)
begin
sh "corto test"
rescue
Expand Down Expand Up @@ -310,7 +319,7 @@ def corto_replace(str)

# Utility for building a sourcefile
def build_source(source, target, echo)
verbose(false)
verbose(VERBOSE)
flags = ""
cc = ""

Expand Down
10 changes: 9 additions & 1 deletion build/component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
require "#{ENV['CORTO_BUILD']}/version"

if not defined? VERBOSE then
if ENV['verbose'] == "true" then
VERBOSE ||= true
else
VERBOSE ||= false
end
end

if not defined? TARGET then
raise "library: TARGET not specified\n"
end
Expand Down Expand Up @@ -37,7 +45,7 @@
GENERATED_HEADERS ||= ["include/_interface.h"]

file ".corto/_load.c" => [".corto/packages.txt", ".corto/components.txt"] do
verbose(false)
verbose(VERBOSE)
if generate then
sh "mkdir -p .corto"
command = "corto pp --name #{TARGET} -g c_project --attr h=include --attr component=true"
Expand Down
12 changes: 10 additions & 2 deletions build/library.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
require "#{ENV['CORTO_BUILD']}/version"
require 'rake/clean'

if not defined? VERBOSE then
if ENV['verbose'] == "true" then
VERBOSE ||= true
else
VERBOSE ||= false
end
end

if not defined? TARGET then
raise "library: TARGET not specified\n"
end
Expand Down Expand Up @@ -37,7 +45,7 @@
"#{ENV['CORTO_HOME']}/include/corto/#{VERSION}/libraries"

task :prebuild do
verbose(false)
verbose(VERBOSE)
if File.exists?("include") and Dir.glob("include/**/*").length != 0 then
includePath = "#{ENV['CORTO_TARGET']}/include/corto/#{VERSION}/#{TARGETPATH}"

Expand Down Expand Up @@ -82,7 +90,7 @@
end

task :collect do
verbose(false)
verbose(VERBOSE)
if File.exists?("include") then
includePath = "#{ENV['HOME']}/.corto/pack/include/corto/#{VERSION}/#{TARGETPATH}"
sh "mkdir -p #{includePath}"
Expand Down
33 changes: 23 additions & 10 deletions build/package.rb
Original file line number Diff line number Diff line change
@@ -1,43 +1,56 @@
require 'rake/clean'

if not defined? VERBOSE then
if ENV['verbose'] == "true" then
VERBOSE ||= true
else
VERBOSE ||= false
end
end

LOCAL ||= false
INCLUDE ||= []
PACKAGE_FWSLASH = PACKAGE.gsub("::", "/")

if LOCAL == true then
TARGETPATH = "./.corto"
TARGETDIR = TARGETPATH
INCLUDE << "include"
else
PACKAGEDIR = "packages/" + PACKAGE.gsub("::", "/")
PACKAGEDIR = "packages/" + PACKAGE_FWSLASH
TARGETPATH = PACKAGEDIR
end

TARGET = PACKAGE.split("::").last
TARGET = PACKAGE_FWSLASH.split("/").last

PP_PRELOAD ||= []
GENERATED_SOURCES ||= []
DEFINE ||= []
CFLAGS ||= []

DEFINE << "BUILDING_" + PACKAGE.gsub("::", "_").upcase
CFLAGS << "-fvisibility=hidden"
DEFINE << "BUILDING_" + PACKAGE_FWSLASH.gsub("/", "_").upcase

# If this is not a corto package, expose all symbols by default
if not defined? NOCORTO then
CFLAGS << "-fvisibility=hidden"
end

PREFIX ||= TARGET
NAME ||= PACKAGE.split("::").last
NAME ||= PACKAGE_FWSLASH.split("/").last

CHDIR_SET = true
Dir.chdir(File.dirname(Rake.application.rakefile))

GENFILE = Rake::FileList["#{NAME}.{cx,idl,xml}"][0]

file ".corto/packages.txt" do
verbose(false)
verbose(VERBOSE)
sh "mkdir -p .corto"
sh "touch .corto/packages.txt"
end

file ".corto/components.txt" do
verbose(false)
verbose(VERBOSE)
sh "mkdir -p .corto"
sh "touch .corto/components.txt"
end
Expand All @@ -56,7 +69,7 @@
"include/_interface.h"

file "include/_type.h" => [GENFILE, ".corto/packages.txt", ".corto/components.txt"] do
verbose(false)
verbose(VERBOSE)
preload = PP_PRELOAD.join(" ")
sh "mkdir -p .corto"
sh "touch .corto/_wrapper.c"
Expand Down Expand Up @@ -86,10 +99,10 @@
end

task :doc do
verbose(false)
verbose(VERBOSE)
if `corto locate corto::md` != "corto: package 'corto::md' not found\n" then
if File.exists? "#{NAME}.md" and not LOCAL then
command = "corto pp #{NAME}.md --scope #{PACKAGE} -g html"
command = "corto pp #{NAME}.md --scope #{PACKAGE_FWSLASH} -g html"
begin
sh command
rescue
Expand Down
2 changes: 1 addition & 1 deletion packages/corto/src/corto.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct corto_exitHandler {

#define VERSION_MAJOR "0"
#define VERSION_MINOR "2"
#define VERSION_PATCH "10"
#define VERSION_PATCH "11"
#define VERSION_SUFFIX "alpha"

#ifdef VERSION_SUFFIX
Expand Down
5 changes: 4 additions & 1 deletion packages/corto/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,14 @@ static corto_dl corto_loadValidLibrary(corto_string fileName) {
build = (corto_string ___ (*)(void))corto_dlProc(result, "corto_getBuild");

/* Validate version */
if (!build || strcmp(build(), corto_getBuild())) {
if (build && strcmp(build(), corto_getBuild())) {
/* Library is linked with different Corto version */
goto error;
}

/* If no build function is available, the library is not linked with
* Corto, and probably represents a --nocorto package */

return result;
error:
if (result) corto_dlClose(result);
Expand Down
131 changes: 131 additions & 0 deletions packages/corto/test/include/test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/* test.h
*
* This file contains generated code. Do not modify!
*/

#ifndef TEST_H
#define TEST_H

#include "corto/corto.h"
#include "_type.h"
#include "_api.h"
#include "_meta.h"
#include "_interface.h"

#ifdef __cplusplus
extern "C" {
#endif


TEST_EXPORT corto_void _test_functionToResolve(corto_int32 a, corto_int32 b);
#define test_functionToResolve(a, b) _test_functionToResolve(a, b)

TEST_EXPORT corto_void _test_ol_any__test_Color(test_Color a);
#define test_ol_any__test_Color(a) _test_ol_any__test_Color(a)

TEST_EXPORT corto_void _test_ol_any_bool(corto_bool a);
#define test_ol_any_bool(a) _test_ol_any_bool(a)

TEST_EXPORT corto_void _test_ol_any_char(corto_char a);
#define test_ol_any_char(a) _test_ol_any_char(a)

TEST_EXPORT corto_void _test_ol_any_float32(corto_float32 a);
#define test_ol_any_float32(a) _test_ol_any_float32(a)

TEST_EXPORT corto_void _test_ol_any_int32(corto_int32 a);
#define test_ol_any_int32(a) _test_ol_any_int32(a)

TEST_EXPORT corto_void _test_ol_any_object(corto_object a);
#define test_ol_any_object(a) _test_ol_any_object(a)

TEST_EXPORT corto_void _test_ol_any_string(corto_string a);
#define test_ol_any_string(a) _test_ol_any_string(a)

TEST_EXPORT corto_void _test_ol_bool(corto_bool a);
#define test_ol_bool(a) _test_ol_bool(a)

TEST_EXPORT corto_void _test_ol_inherit__test_Animal(test_Animal a);
#define test_ol_inherit__test_Animal(a) _test_ol_inherit__test_Animal(test_Animal(a))

TEST_EXPORT corto_void _test_ol_inherit__test_Dog(test_Dog a);
#define test_ol_inherit__test_Dog(a) _test_ol_inherit__test_Dog(test_Dog(a))

TEST_EXPORT corto_void _test_ol_int(corto_int32 a);
#define test_ol_int(a) _test_ol_int(a)

TEST_EXPORT corto_void _test_ol_null_bool(corto_bool a);
#define test_ol_null_bool(a) _test_ol_null_bool(a)

TEST_EXPORT corto_void _test_ol_null_object(corto_object a);
#define test_ol_null_object(a) _test_ol_null_object(a)

TEST_EXPORT corto_void _test_ol_null_string(corto_string a);
#define test_ol_null_string(a) _test_ol_null_string(a)

TEST_EXPORT corto_void _test_ol_num_float64(corto_float64 a);
#define test_ol_num_float64(a) _test_ol_num_float64(a)

TEST_EXPORT corto_void _test_ol_num_int32(corto_int32 a);
#define test_ol_num_int32(a) _test_ol_num_int32(a)

TEST_EXPORT corto_void _test_ol_object(corto_object a);
#define test_ol_object(a) _test_ol_object(a)

TEST_EXPORT corto_void _test_ol_string(corto_string a);
#define test_ol_string(a) _test_ol_string(a)

TEST_EXPORT corto_void _test_ol_uint(corto_int32 a);
#define test_ol_uint(a) _test_ol_uint(a)

TEST_EXPORT corto_void _test_ol_wildcard_float32_string(corto_float32 a, corto_string b);
#define test_ol_wildcard_float32_string(a, b) _test_ol_wildcard_float32_string(a, b)

TEST_EXPORT corto_void _test_ol_wildcard_int32_string(corto_int32 a, corto_string b);
#define test_ol_wildcard_int32_string(a, b) _test_ol_wildcard_int32_string(a, b)
#include "Animal.h"
#include "AnonymousTest.h"
#include "Args.h"
#include "Bar.h"
#include "Cat.h"
#include "CompositeCollection.h"
#include "DeclaredParent.h"
#include "DefinedParent.h"
#include "Dog.h"
#include "Env.h"
#include "Event.h"
#include "EventTest.h"
#include "Foo.h"
#include "FooReplicator.h"
#include "Fullname.h"
#include "GoldenRetriever.h"
#include "JsonReplicator.h"
#include "Line.h"
#include "ListReplicator.h"
#include "MethodForwardTest.h"
#include "MethodResolver.h"
#include "MethodTester.h"
#include "MethodTesterInherit.h"
#include "ObjectMgmt.h"
#include "Overload.h"
#include "Ownership.h"
#include "Point.h"
#include "Point3D.h"
#include "PrimitiveCollection.h"
#include "Project.h"
#include "RelativeName.h"
#include "ReplicatorRequest.h"
#include "Resolver.h"
#include "Select.h"
#include "SelectContentType.h"
#include "StringDeserializer.h"
#include "StringReplicator.h"
#include "StringSerializer.h"
#include "VoidParent.h"
#include "corto/test/test.h"
#include "corto/test/test.h"

#ifdef __cplusplus
}
#endif
#endif

Loading

0 comments on commit 5d70cfa

Please sign in to comment.