1cdf0e10cSrcweir#!/usr/bin/gawk -f 2*5b501c92SAndrew Rist# ************************************************************* 3*5b501c92SAndrew Rist# 4*5b501c92SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 5*5b501c92SAndrew Rist# or more contributor license agreements. See the NOTICE file 6*5b501c92SAndrew Rist# distributed with this work for additional information 7*5b501c92SAndrew Rist# regarding copyright ownership. The ASF licenses this file 8*5b501c92SAndrew Rist# to you under the Apache License, Version 2.0 (the 9*5b501c92SAndrew Rist# "License"); you may not use this file except in compliance 10*5b501c92SAndrew Rist# with the License. You may obtain a copy of the License at 11*5b501c92SAndrew Rist# 12*5b501c92SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 13*5b501c92SAndrew Rist# 14*5b501c92SAndrew Rist# Unless required by applicable law or agreed to in writing, 15*5b501c92SAndrew Rist# software distributed under the License is distributed on an 16*5b501c92SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17*5b501c92SAndrew Rist# KIND, either express or implied. See the License for the 18*5b501c92SAndrew Rist# specific language governing permissions and limitations 19*5b501c92SAndrew Rist# under the License. 20*5b501c92SAndrew Rist# 21*5b501c92SAndrew Rist# ************************************************************* 22cdf0e10cSrcweir# Usage: gawk -f linkermapfile-check.awk *.map *.xml 23cdf0e10cSrcweir# Order of *.map *.xml is important, otherwise all symbols are reported to be 24cdf0e10cSrcweir# missing. 25cdf0e10cSrcweir# Checks if all symbols of all locale data are present in the symbol scoping 26cdf0e10cSrcweir# linker mapfiles. Any output indicates a missing symbol, ../localedata.cxx is 27cdf0e10cSrcweir# grep'ed to indicate the library to which mapfile the symbol should be added. 28cdf0e10cSrcweir# Author: Eike Rathke <er@openoffice.org> 29cdf0e10cSrcweir 30cdf0e10cSrcweirBEGIN { 31cdf0e10cSrcweir bAnyMissing = 0 32cdf0e10cSrcweir file = "" 33cdf0e10cSrcweir nMap = 0 34cdf0e10cSrcweir nMaps = 0 35cdf0e10cSrcweir nPublics = 0 36cdf0e10cSrcweir sPublic[nPublics++] = "getAllCalendars_" 37cdf0e10cSrcweir sPublic[nPublics++] = "getAllCurrencies_" 38cdf0e10cSrcweir sPublic[nPublics++] = "getAllFormats0_" 39cdf0e10cSrcweir bOptional[nPublics] = 1 # getAllFormats1 most times not present 40cdf0e10cSrcweir sPublic[nPublics++] = "getAllFormats1_" 41cdf0e10cSrcweir sPublic[nPublics++] = "getBreakIteratorRules_" 42cdf0e10cSrcweir sPublic[nPublics++] = "getCollationOptions_" 43cdf0e10cSrcweir sPublic[nPublics++] = "getCollatorImplementation_" 44cdf0e10cSrcweir sPublic[nPublics++] = "getContinuousNumberingLevels_" 45cdf0e10cSrcweir sPublic[nPublics++] = "getForbiddenCharacters_" 46cdf0e10cSrcweir sPublic[nPublics++] = "getLCInfo_" 47cdf0e10cSrcweir sPublic[nPublics++] = "getLocaleItem_" 48cdf0e10cSrcweir sPublic[nPublics++] = "getOutlineNumberingLevels_" 49cdf0e10cSrcweir sPublic[nPublics++] = "getReservedWords_" 50cdf0e10cSrcweir sPublic[nPublics++] = "getSearchOptions_" 51cdf0e10cSrcweir sPublic[nPublics++] = "getTransliterations_" 52cdf0e10cSrcweir sPublic[nPublics++] = "getIndexAlgorithm_" 53cdf0e10cSrcweir sPublic[nPublics++] = "getUnicodeScripts_" 54cdf0e10cSrcweir sPublic[nPublics++] = "getFollowPageWords_" 55cdf0e10cSrcweir} 56cdf0e10cSrcweir 57cdf0e10cSrcweirfile != FILENAME { 58cdf0e10cSrcweir file = FILENAME 59cdf0e10cSrcweir if ( file ~ /\.map$/ ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir sMapFile[nMaps] = file 62cdf0e10cSrcweir nMap = nMaps 63cdf0e10cSrcweir ++nMaps 64cdf0e10cSrcweir } 65cdf0e10cSrcweir else if ( file ~ /\.xml$/ ) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir bOut = 0 68cdf0e10cSrcweir n = split( file, arr, /[:\\\/.]/ ) 69cdf0e10cSrcweir locale = arr[n-1] 70cdf0e10cSrcweir for ( i=0; i<nPublics; ++i ) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir symbol = sPublic[i] locale ";" 73cdf0e10cSrcweir bFound = 0 74cdf0e10cSrcweir for ( j=0; j<nMaps && !bFound; ++j ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir if ( sSymbol[j,symbol] ) 77cdf0e10cSrcweir bFound = 1 78cdf0e10cSrcweir } 79cdf0e10cSrcweir if ( !bFound && bOptional[i] ) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir print symbol " not present but optional" 82cdf0e10cSrcweir bFound = 1 83cdf0e10cSrcweir } 84cdf0e10cSrcweir if ( !bFound ) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir if ( !bOut ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir search = "\"" locale "\"" 89cdf0e10cSrcweir while ( !bOut && (getline <"../localedata.cxx") > 0 ) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir if ( $0 ~ search ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir bOut = 1 94cdf0e10cSrcweir print "../localedata.cxx says this should go into: " $0 95cdf0e10cSrcweir } 96cdf0e10cSrcweir } 97cdf0e10cSrcweir close( "../localedata.cxx" ) 98cdf0e10cSrcweir if ( !bOut ) 99cdf0e10cSrcweir print "../localedata.cxx doesn't indicate to which lib this belongs to:" 100cdf0e10cSrcweir bOut = 1 101cdf0e10cSrcweir } 102cdf0e10cSrcweir print symbol 103cdf0e10cSrcweir } 104cdf0e10cSrcweir } 105cdf0e10cSrcweir if ( bOut) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir printf("\n") 108cdf0e10cSrcweir bAnyMissing = 1 109cdf0e10cSrcweir } 110cdf0e10cSrcweir nextfile 111cdf0e10cSrcweir } 112cdf0e10cSrcweir else 113cdf0e10cSrcweir nextfile 114cdf0e10cSrcweir} 115cdf0e10cSrcweir 116cdf0e10cSrcweir# only reached if .map file encountered, read in symbols 117cdf0e10cSrcweir{ 118cdf0e10cSrcweir if ( $1 ~ /;$/ ) 119cdf0e10cSrcweir sSymbol[nMap,$1] = 1 120cdf0e10cSrcweir} 121cdf0e10cSrcweir 122cdf0e10cSrcweirEND { 123cdf0e10cSrcweir if ( !bAnyMissing ) 124cdf0e10cSrcweir print "All good." >>"/dev/stderr" 125cdf0e10cSrcweir} 126