Ticket #8730: HAIKU_HOST_FEATURE.patch

File HAIKU_HOST_FEATURE.patch, 6.4 KB (added by mmadia, 12 years ago)

based off full-host-abstraction.diff

  • configure

    diff --git a/configure b/configure
    index 05f1e06..14e2159 100755
    a b cat << EOF > "$buildOutputDir/libgccObjects"  
    584584HAIKU_GCC_LIBGCC_OBJECTS    ?= ${HAIKU_GCC_LIBGCC_OBJECTS} ;
    585585EOF
    586586
    587 # Generate a boot strap Jamfile in the output directory.
     587# Generate a bootstrap Jamfile in the output directory.
    588588
    589589cat << EOF > $outputDir/Jamfile
    590590# automatically generated Jamfile
    HAIKU_OUTPUT_DIR = ${outputDir} ;  
    595595include [ FDirName \$(HAIKU_TOP) Jamfile ] ;
    596596
    597597EOF
     598
     599
     600
     601# hostFeaturesFile=$outputDir/build/HostFeatures
     602# rm -f "$hostFeaturesFile"
     603# touch "$hostFeaturesFile"
     604# jam -a configure_build
     605#
     606# hostBuildConfigHeader=$outputDir/build/HaikuHostBuildConfig.h
     607# rm -f "$hostBuildConfigHeader"
     608# echo >> "$buildConfigFile"
     609# for feature in `cat $hostFeaturesFile`; do
     610#   echo "#define _HAIKU_HOST_FEATURE_$feature 1" >> "$hostBuildConfigHeader"
     611#   echo "HAIKU_HOST_FEATURE_$feature = 1 ;" >> "$buildConfigFile"
     612# done
     613
     614
     615
     616hostBuildConfigHeader=$outputDir/build/HaikuHostBuildConfig.h
     617cat << EOF > "$hostBuildConfigHeader"
     618/* auto-generated by configure */
     619#ifndef _HAIKU_BUILD_HOST_BUILD_CONFIG_H
     620#define _HAIKU_BUILD_HOST_BUILD_CONFIG_H
     621EOF
     622
     623jam -a configure_build
     624
     625cat << EOF >> "$hostBuildConfigHeader"
     626#endif  /* _HAIKU_BUILD_HOST_BUILD_CONFIG_H */
     627EOF
     628
     629
     630echo >> "$buildConfigFile"
     631cat "$hostBuildConfigHeader" | grep "#define _HAIKU_BUILD_FEATURE_" \
     632    | sed -e 's@#define _\(HAIKU_BUILD_FEATURE_[^[:space:]]*\)[[:space:]]*\(.*\)@\1 = \2 ;@' \
     633    >> "$buildConfigFile"
  • headers/build/HaikuBuild.h

    diff --git a/headers/build/HaikuBuild.h b/headers/build/HaikuBuild.h
    index d8ddfd9..73d6aad 100644
    a b  
    66#define _HAIKU_BUILD_H
    77
    88
    9 //#include <HaikuHostBuildConfig.h>
     9#include <HaikuHostBuildConfig.h>
    1010
    1111
    1212#define _HAIKU_BUILD_STRING(string)
     
    2727// NOTE: #8730 -- _HAIKU_BUILD_DECLARE_CONSTANT is untested.
    2828#ifdef _HAIKU_BUILD_LIBROOT_FUNCTION_WRAPPER
    2929#   define _HAIKU_BUILD_DECLARE_CONSTANT(type, name) \
    30         extern type _haiku_build##name; \
     30        extern type _haiku_build##name;
    3131#else
    3232#   define _HAIKU_BUILD_DECLARE_CONSTANT(type, name) \
    3333        extern type _haiku_build##name; \
  • src/build/Jamfile

    diff --git a/src/build/Jamfile b/src/build/Jamfile
    index 17634b0..3b7aa4c 100644
    a b  
    11SubDir HAIKU_TOP src build ;
    22
     3SubInclude HAIKU_TOP src build configure ;
    34SubInclude HAIKU_TOP src build libbe ;
    45SubInclude HAIKU_TOP src build libhaikucompat ;
    56SubInclude HAIKU_TOP src build libpackage ;
  • new file src/build/configure/Jamfile

    diff --git a/src/build/configure/Jamfile b/src/build/configure/Jamfile
    new file mode 100644
    index 0000000..3745873
    - +  
     1SubDir HAIKU_TOP src build configure ;
     2
     3HAIKU_BUILD_HOST_FEATURES = <build!configure>HostFeatures ;
     4MakeLocate $(HAIKU_BUILD_HOST_FEATURES) : $(HAIKU_BUILD_OUTPUT_DIR) ;
     5
     6HAIKU_BUILD_CONFIG_HEADER = <build!configure>HaikuHostBuildConfig.h ;
     7MakeLocate $(HAIKU_BUILD_CONFIG_HEADER) : $(HAIKU_BUILD_OUTPUT_DIR) ;
     8
     9local configureTargets ;
     10
     11rule ConfigureCheckExists feature : fileTarget
     12{
     13    local target = $(fileTarget:G=build!configure!test) ;
     14
     15    FEATURE on $(target) = $(feature) ;
     16    NotFile $(target) ;
     17    Depends $(target) : $(HAIKU_BUILD_CONFIG_HEADER) $(fileTarget) ;
     18
     19    ConfigureCheckExists1 $(target)
     20        : $(HAIKU_BUILD_CONFIG_HEADER) $(fileTarget) ;
     21
     22    configureTargets += $(target) ;
     23}
     24
     25
     26actions ConfigureCheckExists1
     27{
     28    if [ -f "$(2[2-])" ]; then
     29        echo "#define _HAIKU_BUILD_FEATURE_$(FEATURE) 1" >> $(2[1])
     30#       echo $(FEATURE) >> $(2[1])
     31    fi
     32}
     33
     34
     35rule ConfigureTestCompile feature : sources : libraries
     36{
     37    local executable = <build!configure>test_$(feature) ;
     38
     39    BuildPlatformMain $(executable) : $(sources) : $(libraries) ;
     40    ConfigureCheckExists $(feature) : $(executable) ;
     41}
     42
     43
     44rule ConfigureRunProgram name : sources : libraries
     45{
     46    local program = $(name:G=build!configure) ;
     47    local target = $(name:G=build!configure!test) ;
     48
     49    BuildPlatformMain $(program) : $(sources) : $(libraries) ;
     50
     51    ConfigureRunProgram1 ;
     52
     53    NotFile $(target) ;
     54    Depends $(target) : $(HAIKU_BUILD_CONFIG_HEADER) $(program) ;
     55
     56    ConfigureRunProgram1 $(target) : $(HAIKU_BUILD_CONFIG_HEADER) $(program) ;
     57
     58    configureTargets += $(target) ;
     59}
     60
     61
     62actions ConfigureRunProgram1
     63{
     64    $(2[2-]) >> $(2[1])
     65}
     66
     67
     68ConfigureRunProgram test_int_types : test_int_types.cpp ;
     69
     70
     71Depends configure_build : $(configureTargets) ;
     72NotFile configure_build ;
  • new file src/build/configure/test_int_types.cpp

    diff --git a/src/build/configure/test_int_types.cpp b/src/build/configure/test_int_types.cpp
    new file mode 100644
    index 0000000..6937c2b
    - +  
     1/*
     2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
     3 * Distributed under the terms of the MIT License.
     4 */
     5
     6
     7#include <inttypes.h>
     8#include <stdio.h>
     9
     10
     11template<typename Type>
     12struct TypeInfo {
     13    static const char* const TypeName();
     14    static const char* const Prefix();
     15};
     16
     17
     18#define DEFINE_TYPE_INFO_TEMPLATE(type, prefix) \
     19    template<>                                  \
     20    struct TypeInfo<type> {                     \
     21        static const char* const TypeName()     \
     22        {                                       \
     23            return #type;                       \
     24        }                                       \
     25        static const char* const Prefix()       \
     26        {                                       \
     27            return prefix;                      \
     28        }                                       \
     29    };
     30
     31#define DEFINE_TYPE_INFO_TEMPLATE_SIGNED_AND_UNSIGNED(type, prefix) \
     32    DEFINE_TYPE_INFO_TEMPLATE(type, prefix)                         \
     33    DEFINE_TYPE_INFO_TEMPLATE(unsigned type, prefix)
     34
     35
     36DEFINE_TYPE_INFO_TEMPLATE_SIGNED_AND_UNSIGNED(char, "")
     37DEFINE_TYPE_INFO_TEMPLATE(signed char, "")
     38DEFINE_TYPE_INFO_TEMPLATE_SIGNED_AND_UNSIGNED(short, "")
     39DEFINE_TYPE_INFO_TEMPLATE_SIGNED_AND_UNSIGNED(int, "")
     40DEFINE_TYPE_INFO_TEMPLATE_SIGNED_AND_UNSIGNED(long, "l")
     41DEFINE_TYPE_INFO_TEMPLATE_SIGNED_AND_UNSIGNED(long long, "ll")
     42
     43
     44template<typename Type>
     45struct PrintTypeInfo {
     46    static void Print(const char* name)
     47    {
     48        printf("#define _HAIKU_BUILD_FEATURE_%s %s\n", name,
     49            TypeInfo<Type>::TypeName());
     50        printf("#define _HAIKU_BUILD_FEATURE_FORMAT_PREFIX_%s \"%s\"\n", name,
     51            TypeInfo<Type>::Prefix());
     52    }
     53};
     54
     55
     56#define PRINT_TYPE_INFO(type)   PrintTypeInfo<type##_t>::Print(#type)
     57
     58#define PRINT_TYPE_INFO_SIGNED_AND_UNSIGNED(type)   \
     59    PRINT_TYPE_INFO(type);                          \
     60    PRINT_TYPE_INFO(u##type)
     61
     62
     63int
     64main()
     65{
     66    PRINT_TYPE_INFO_SIGNED_AND_UNSIGNED(int8);
     67    PRINT_TYPE_INFO_SIGNED_AND_UNSIGNED(int16);
     68    PRINT_TYPE_INFO_SIGNED_AND_UNSIGNED(int32);
     69    PRINT_TYPE_INFO_SIGNED_AND_UNSIGNED(int64);
     70    return 0;
     71}